github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/chain/consensus/protocol.go (about) 1 package consensus 2 3 import ( 4 "math/big" 5 6 "github.com/neatio-net/neatio/chain/core/types" 7 "github.com/neatio-net/neatio/utilities/common" 8 ) 9 10 const ( 11 Eth62 = 62 12 Eth63 = 63 13 ) 14 15 var ( 16 EthProtocol = Protocol{ 17 Name: "eth", 18 Versions: []uint{Eth62, Eth63}, 19 Lengths: []uint64{17, 8}, 20 } 21 ) 22 23 type Protocol struct { 24 Name string 25 26 Versions []uint 27 28 Lengths []uint64 29 } 30 31 type Broadcaster interface { 32 Enqueue(id string, block *types.Block) 33 34 FindPeers(map[common.Address]bool) map[common.Address]Peer 35 36 BroadcastBlock(block *types.Block, propagate bool) 37 38 BroadcastMessage(msgcode uint64, data interface{}) 39 40 TryFixBadPreimages() 41 } 42 43 type Peer interface { 44 Send(msgcode uint64, data interface{}) error 45 46 SendNewBlock(block *types.Block, td *big.Int) error 47 48 GetPeerState() PeerState 49 50 GetKey() string 51 52 GetConsensusKey() string 53 54 SetPeerState(ps PeerState) 55 } 56 57 type PeerState interface { 58 GetHeight() uint64 59 Disconnect() 60 }