properly set the max message size with salticidae

This commit is contained in:
StephenButtolph 2020-03-12 12:11:45 -04:00
parent c827c914d6
commit 683e10af3e
2 changed files with 6 additions and 3 deletions

View File

@ -50,6 +50,7 @@ const (
defaultChannelSize = 1
externalRequestTimeout = 2 * time.Second
internalRequestTimeout = 250 * time.Millisecond
maxMessageSize = 1 << 25
)
// MainNode is the reference for node callbacks
@ -61,7 +62,7 @@ type Node struct {
LogFactory logging.Factory
HTTPLog logging.Logger
// This node's unique ID used when communicationg with other nodes
// This node's unique ID used when communicating with other nodes
// (in consensus, for example)
ID ids.ShortID
@ -145,6 +146,7 @@ func (n *Node) initNetlib() error {
peerConfig := salticidae.NewPeerNetworkConfig()
if n.Config.EnableStaking {
msgConfig := peerConfig.AsMsgNetworkConfig()
msgConfig.MaxMsgSize(maxMessageSize)
msgConfig.EnableTLS(true)
msgConfig.TLSKeyFile(n.Config.StakingKeyFile)
msgConfig.TLSCertFile(n.Config.StakingCertFile)
@ -163,6 +165,7 @@ func (n *Node) initNetlib() error {
if n.Config.ThroughputServerEnabled {
// Create the client network
msgConfig := salticidae.NewMsgNetworkConfig()
msgConfig.MaxMsgSize(maxMessageSize)
n.ClientNet = salticidae.NewMsgNetwork(n.EC, msgConfig, &err)
if code := err.GetCode(); code != 0 {
return errors.New(salticidae.StrError(code))

View File

@ -25,8 +25,8 @@ const (
)
const (
defaultMaxSize = 1 << 19 // default max size, in bytes, of something being marshalled by Marshal()
defaultMaxSliceLength = 1 << 19 // default max length of a slice being marshalled by Marshal()
defaultMaxSize = 1 << 18 // default max size, in bytes, of something being marshalled by Marshal()
defaultMaxSliceLength = 1 << 18 // default max length of a slice being marshalled by Marshal()
)
// ErrBadCodec is returned when one tries to perform an operation