github.com/ConsenSys/Quorum@v20.10.0+incompatible/consensus/protocol.go (about)

     1  // Quorum
     2  package consensus
     3  
     4  import (
     5  	"github.com/ethereum/go-ethereum/common"
     6  	"github.com/ethereum/go-ethereum/core/types"
     7  )
     8  
     9  // Constants to match up protocol versions and messages
    10  // istanbul/99 was added to accommodate new eth/64 handshake status data with fork id
    11  // this is for backward compatibility which allows a mixed old/new istanbul node network
    12  // istanbul/64 will continue using old status data as eth/63
    13  const (
    14  	eth63      = 63
    15  	eth64      = 64
    16  	Istanbul64 = 64
    17  	Istanbul99 = 99
    18  )
    19  
    20  var (
    21  	IstanbulProtocol = Protocol{
    22  		Name:     "istanbul",
    23  		Versions: []uint{Istanbul99, Istanbul64},
    24  		Lengths:  map[uint]uint64{Istanbul99: 18, Istanbul64: 18},
    25  	}
    26  
    27  	CliqueProtocol = Protocol{
    28  		Name:     "eth",
    29  		Versions: []uint{eth64, eth63},
    30  		Lengths:  map[uint]uint64{eth64: 17, eth63: 17},
    31  	}
    32  
    33  	// Default: Keep up-to-date with eth/protocol.go
    34  	EthProtocol = Protocol{
    35  		Name:     "eth",
    36  		Versions: []uint{eth64, eth63},
    37  		Lengths:  map[uint]uint64{eth64: 17, eth63: 17},
    38  	}
    39  
    40  	NorewardsProtocol = Protocol{
    41  		Name:     "Norewards",
    42  		Versions: []uint{0},
    43  		Lengths:  map[uint]uint64{0: 0},
    44  	}
    45  )
    46  
    47  // Protocol defines the protocol of the consensus
    48  type Protocol struct {
    49  	// Official short name of the protocol used during capability negotiation.
    50  	Name string
    51  	// Supported versions of the eth protocol (first is primary).
    52  	Versions []uint
    53  	// Number of implemented message corresponding to different protocol versions.
    54  	Lengths map[uint]uint64
    55  }
    56  
    57  // Broadcaster defines the interface to enqueue blocks to fetcher and find peer
    58  type Broadcaster interface {
    59  	// Enqueue add a block into fetcher queue
    60  	Enqueue(id string, block *types.Block)
    61  	// FindPeers retrives peers by addresses
    62  	FindPeers(map[common.Address]bool) map[common.Address]Peer
    63  }
    64  
    65  // Peer defines the interface to communicate with peer
    66  type Peer interface {
    67  	// Send sends the message to this peer
    68  	Send(msgcode uint64, data interface{}) error
    69  }