Skip to content

Commit b8746de

Browse files
authored
Embed noop handler for all unhandled messages (#2288)
1 parent 86201ae commit b8746de

File tree

1 file changed

+8
-42
lines changed

1 file changed

+8
-42
lines changed

vms/platformvm/block/builder/network.go

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package builder
88
import (
99
"context"
1010
"fmt"
11-
"time"
1211

1312
"go.uber.org/zap"
1413

@@ -20,11 +19,9 @@ import (
2019
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
2120
)
2221

23-
const (
24-
// We allow [recentCacheSize] to be fairly large because we only store hashes
25-
// in the cache, not entire transactions.
26-
recentCacheSize = 512
27-
)
22+
// We allow [recentCacheSize] to be fairly large because we only store hashes
23+
// in the cache, not entire transactions.
24+
const recentCacheSize = 512
2825

2926
var _ Network = (*network)(nil)
3027

@@ -36,6 +33,9 @@ type Network interface {
3633
}
3734

3835
type network struct {
36+
// We embed a noop handler for all unhandled messages
37+
common.AppHandler
38+
3939
ctx *snow.Context
4040
blkBuilder *builder
4141

@@ -50,49 +50,15 @@ func NewNetwork(
5050
appSender common.AppSender,
5151
) Network {
5252
return &network{
53+
AppHandler: common.NewNoOpAppHandler(ctx.Log),
54+
5355
ctx: ctx,
5456
blkBuilder: blkBuilder,
5557
appSender: appSender,
5658
recentTxs: &cache.LRU[ids.ID, struct{}]{Size: recentCacheSize},
5759
}
5860
}
5961

60-
func (*network) CrossChainAppRequestFailed(context.Context, ids.ID, uint32) error {
61-
// This VM currently only supports gossiping of txs, so there are no
62-
// requests.
63-
return nil
64-
}
65-
66-
func (*network) CrossChainAppRequest(context.Context, ids.ID, uint32, time.Time, []byte) error {
67-
// This VM currently only supports gossiping of txs, so there are no
68-
// requests.
69-
return nil
70-
}
71-
72-
func (*network) CrossChainAppResponse(context.Context, ids.ID, uint32, []byte) error {
73-
// This VM currently only supports gossiping of txs, so there are no
74-
// requests.
75-
return nil
76-
}
77-
78-
func (*network) AppRequestFailed(context.Context, ids.NodeID, uint32) error {
79-
// This VM currently only supports gossiping of txs, so there are no
80-
// requests.
81-
return nil
82-
}
83-
84-
func (*network) AppRequest(context.Context, ids.NodeID, uint32, time.Time, []byte) error {
85-
// This VM currently only supports gossiping of txs, so there are no
86-
// requests.
87-
return nil
88-
}
89-
90-
func (*network) AppResponse(context.Context, ids.NodeID, uint32, []byte) error {
91-
// This VM currently only supports gossiping of txs, so there are no
92-
// requests.
93-
return nil
94-
}
95-
9662
func (n *network) AppGossip(_ context.Context, nodeID ids.NodeID, msgBytes []byte) error {
9763
n.ctx.Log.Debug("called AppGossip message handler",
9864
zap.Stringer("nodeID", nodeID),

0 commit comments

Comments
 (0)