github.com/arieschain/arieschain@v0.0.0-20191023063405-37c074544356/consensus/protocol.go (about) 1 // Package consensus implements different Ethereum consensus engines. 2 package consensus 3 4 import ( 5 "github.com/quickchainproject/quickchain/common" 6 "github.com/quickchainproject/quickchain/core/types" 7 ) 8 9 // Constants to match up protocol versions and messages 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 // Protocol defines the protocol of the consensus 24 type Protocol struct { 25 // Official short name of the protocol used during capability negotiation. 26 Name string 27 // Supported versions of the eth protocol (first is primary). 28 Versions []uint 29 // Number of implemented message corresponding to different protocol versions. 30 Lengths []uint64 31 } 32 33 // Broadcaster defines the interface to enqueue blocks to fetcher and find peer 34 type Broadcaster interface { 35 // Enqueue add a block into fetcher queue 36 Enqueue(id string, block *types.Block) 37 // FindPeers retrives peers by addresses 38 FindPeers(map[common.Address]bool) map[common.Address]Peer 39 } 40 41 // Peer defines the interface to communicate with peer 42 type Peer interface { 43 // Send sends the message to this peer 44 Send(msgcode uint64, data interface{}) error 45 }