Merge pull request #9 from StephenButtolph/msg-size

properly set the max message size with salticidae
This commit is contained in:
Stephen Buttolph 2020-03-13 17:32:36 -04:00 committed by GitHub
commit 7404200a0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -45,6 +45,10 @@ import (
"github.com/ava-labs/gecko/vms/timestampvm"
)
const (
maxMessageSize = 1 << 25 // maximum size of a message sent with salticidae
)
// MainNode is the reference for node callbacks
var MainNode = Node{}
@ -54,7 +58,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
@ -138,6 +142,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)
@ -156,6 +161,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