Skip to content

Commit

Permalink
Add NoOpHandler implementation to SDK (#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-kim authored Aug 23, 2023
1 parent a3c4649 commit 1a58888
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions network/p2p/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/ava-labs/avalanchego/utils/logging"
)

var _ Handler = (*NoOpHandler)(nil)

// Handler is the server-side logic for virtual machine application protocols.
type Handler interface {
// AppGossip is called when handling an AppGossip message.
Expand Down Expand Up @@ -42,6 +44,20 @@ type Handler interface {
) ([]byte, error)
}

type NoOpHandler struct{}

func (NoOpHandler) AppGossip(context.Context, ids.NodeID, []byte) error {
return nil
}

func (NoOpHandler) AppRequest(context.Context, ids.NodeID, time.Time, []byte) ([]byte, error) {
return nil, nil
}

func (NoOpHandler) CrossChainAppRequest(context.Context, ids.ID, time.Time, []byte) ([]byte, error) {
return nil, nil
}

// responder automatically sends the response for a given request
type responder struct {
handlerID uint64
Expand Down

0 comments on commit 1a58888

Please # to comment.