github.com/MetalBlockchain/metalgo@v1.11.9/network/handler_test.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package network
     5  
     6  import (
     7  	"github.com/MetalBlockchain/metalgo/ids"
     8  	"github.com/MetalBlockchain/metalgo/snow/networking/router"
     9  	"github.com/MetalBlockchain/metalgo/version"
    10  )
    11  
    12  var _ router.ExternalHandler = (*testHandler)(nil)
    13  
    14  type testHandler struct {
    15  	router.InboundHandler
    16  	ConnectedF    func(nodeID ids.NodeID, nodeVersion *version.Application, subnetID ids.ID)
    17  	DisconnectedF func(nodeID ids.NodeID)
    18  }
    19  
    20  func (h *testHandler) Connected(id ids.NodeID, nodeVersion *version.Application, subnetID ids.ID) {
    21  	if h.ConnectedF != nil {
    22  		h.ConnectedF(id, nodeVersion, subnetID)
    23  	}
    24  }
    25  
    26  func (h *testHandler) Disconnected(id ids.NodeID) {
    27  	if h.DisconnectedF != nil {
    28  		h.DisconnectedF(id)
    29  	}
    30  }