github.com/MetalBlockchain/metalgo@v1.11.9/snow/networking/router/router.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 "time" 9 10 "github.com/prometheus/client_golang/prometheus" 11 12 "github.com/MetalBlockchain/metalgo/api/health" 13 "github.com/MetalBlockchain/metalgo/ids" 14 "github.com/MetalBlockchain/metalgo/message" 15 "github.com/MetalBlockchain/metalgo/proto/pb/p2p" 16 "github.com/MetalBlockchain/metalgo/snow/networking/benchlist" 17 "github.com/MetalBlockchain/metalgo/snow/networking/handler" 18 "github.com/MetalBlockchain/metalgo/snow/networking/timeout" 19 "github.com/MetalBlockchain/metalgo/utils/logging" 20 "github.com/MetalBlockchain/metalgo/utils/set" 21 ) 22 23 // Router routes consensus messages to the Handler of the consensus 24 // engine that the messages are intended for 25 type Router interface { 26 ExternalHandler 27 InternalHandler 28 29 Initialize( 30 nodeID ids.NodeID, 31 log logging.Logger, 32 timeouts timeout.Manager, 33 shutdownTimeout time.Duration, 34 criticalChains set.Set[ids.ID], 35 sybilProtectionEnabled bool, 36 trackedSubnets set.Set[ids.ID], 37 onFatal func(exitCode int), 38 healthConfig HealthConfig, 39 reg prometheus.Registerer, 40 ) error 41 Shutdown(context.Context) 42 AddChain(ctx context.Context, chain handler.Handler) 43 health.Checker 44 } 45 46 // InternalHandler deals with messages internal to this node 47 type InternalHandler interface { 48 benchlist.Benchable 49 50 RegisterRequest( 51 ctx context.Context, 52 nodeID ids.NodeID, 53 sourceChainID ids.ID, 54 destinationChainID ids.ID, 55 requestID uint32, 56 op message.Op, 57 failedMsg message.InboundMessage, 58 engineType p2p.EngineType, 59 ) 60 }