fix: return error in relay publish if exceeding max-msg-size (#939)

This commit is contained in:
Prem Chaitanya Prathi 2023-12-01 06:53:28 +05:30 committed by GitHub
parent ac1a699171
commit 6bd85a1dc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -43,7 +43,7 @@ func NewMetricsServer(address string, port int, log *zap.Logger) *Server {
// Start executes the HTTP server in the background.
func (p *Server) Start() {
p.log.Info("server stopped ", zap.Error(p.server.ListenAndServe()))
p.log.Info("server started ", zap.Error(p.server.ListenAndServe()))
}
// Stop shuts down the prometheus server

View File

@ -289,6 +289,10 @@ func (w *WakuRelay) Publish(ctx context.Context, message *pb.WakuMessage, opts .
return nil, err
}
if len(out) > pubsub.DefaultMaxMessageSize {
return nil, errors.New("message size exceeds gossipsub max message size")
}
err = pubSubTopic.Publish(ctx, out)
if err != nil {
return nil, err