Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pubsub Maxmessagesize config #40

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type (
PrivateNetworkPSK string `yaml:"privateNetworkPSK"`
GroupID string `yaml:"groupID"`
MaxPeer int `yaml:"maxPeer"`
MaxMessageSize int `yaml:"maxMessageSize"`
BlacklistTolerance int `yaml:"blacklistTolerance"`
}

Expand Down Expand Up @@ -106,6 +107,7 @@ var (
ProtocolID: "/iotex",
GroupID: "iotex",
MaxPeer: 30,
MaxMessageSize: 12582912, // 12MB
BlacklistTolerance: 3,
}

Expand Down Expand Up @@ -250,6 +252,14 @@ func WithMaxPeer(num uint32) Option {
}
}

// WithMaxMessageSize config MaxMessageSize option.
func WithMaxMessageSize(size int) Option {
return func(cfg *Config) error {
cfg.MaxMessageSize = size
return nil
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's an option.


// Host is the main struct that represents a host that communicating with the rest of the P2P networks
type Host struct {
host core.Host
Expand Down Expand Up @@ -381,7 +391,7 @@ func NewHost(ctx context.Context, options ...Option) (*Host, error) {
if err != nil {
return nil, err
}
ps, err := newPubSub(ctx, host, pubsub.WithBlacklist(blacklist))
ps, err := newPubSub(ctx, host, pubsub.WithBlacklist(blacklist), pubsub.WithMaxMessageSize(cfg.MaxMessageSize))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the change that fix the issue (> 1M byte block) last night?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,after updating config, the 1000tps test passed

if err != nil {
return nil, err
}
Expand Down
Loading