Skip to content
New issue

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

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

Already on GitHub? # to your account

Add NoOpHandler implementation to SDK #1903

Merged
merged 2 commits into from
Aug 23, 2023
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
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