github.com/MetalBlockchain/metalgo@v1.11.9/snow/networking/router/inbound_handler.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package router 5 6 import ( 7 "context" 8 9 "github.com/MetalBlockchain/metalgo/ids" 10 "github.com/MetalBlockchain/metalgo/message" 11 "github.com/MetalBlockchain/metalgo/version" 12 ) 13 14 var _ InboundHandler = InboundHandlerFunc(nil) 15 16 // InboundHandler handles inbound messages 17 type InboundHandler interface { 18 HandleInbound(context.Context, message.InboundMessage) 19 } 20 21 // The ExternalRouterFunc type is an adapter to allow the use of ordinary 22 // functions as ExternalRouters. If f is a function with the appropriate 23 // signature, ExternalRouterFunc(f) is an ExternalRouter that calls f. 24 type InboundHandlerFunc func(context.Context, message.InboundMessage) 25 26 func (f InboundHandlerFunc) HandleInbound(ctx context.Context, msg message.InboundMessage) { 27 f(ctx, msg) 28 } 29 30 // ExternalHandler handles messages from external parties 31 type ExternalHandler interface { 32 InboundHandler 33 34 Connected(nodeID ids.NodeID, nodeVersion *version.Application, subnetID ids.ID) 35 Disconnected(nodeID ids.NodeID) 36 }