Documentation ¶
Index ¶
- Constants
- Variables
- func ToIPDesc(addr salticidae.NetAddr) (utils.IPDesc, error)
- type Builder
- func (m Builder) Accepted(chainID ids.ID, requestID uint32, containerIDs ids.Set) (Msg, error)
- func (m Builder) AcceptedFrontier(chainID ids.ID, requestID uint32, containerIDs ids.Set) (Msg, error)
- func (m Builder) Chits(chainID ids.ID, requestID uint32, containerIDs ids.Set) (Msg, error)
- func (m Builder) Data(b []byte) (Msg, error)
- func (m Builder) DecidedTx(txID ids.ID, status choices.Status) (Msg, error)
- func (m Builder) Get(chainID ids.ID, requestID uint32, containerID ids.ID) (Msg, error)
- func (m Builder) GetAccepted(chainID ids.ID, requestID uint32, containerIDs ids.Set) (Msg, error)
- func (m Builder) GetAcceptedFrontier(chainID ids.ID, requestID uint32) (Msg, error)
- func (m Builder) GetPeerList() (Msg, error)
- func (m Builder) GetVersion() (Msg, error)
- func (m Builder) IssueTx(chainID ids.ID, tx []byte) (Msg, error)
- func (m Builder) PeerList(ipDescs []utils.IPDesc) (Msg, error)
- func (m Builder) Ping() (Msg, error)
- func (m Builder) Pong() (Msg, error)
- func (m Builder) PullQuery(chainID ids.ID, requestID uint32, containerID ids.ID) (Msg, error)
- func (m Builder) PushQuery(chainID ids.ID, requestID uint32, containerID ids.ID, container []byte) (Msg, error)
- func (m Builder) Put(chainID ids.ID, requestID uint32, containerID ids.ID, container []byte) (Msg, error)
- func (m Builder) Version(networkID uint32, myTime uint64, ip utils.IPDesc, myVersion string) (Msg, error)
- type Codec
- type Connections
- type Field
- type Handshake
- func (nm *Handshake) AwaitConnections(awaiting *networking.AwaitingConnections)
- func (nm *Handshake) Connect(addr salticidae.NetAddr)
- func (nm *Handshake) Connections() Connections
- func (nm *Handshake) Initialize(log logging.Logger, vdrs validators.Set, myAddr salticidae.NetAddr, ...)
- func (nm *Handshake) SendGetVersion(peer salticidae.PeerID)
- func (nm *Handshake) SendPeerList(peers ...salticidae.PeerID) error
- func (nm *Handshake) SendVersion(peer salticidae.PeerID) error
- func (nm *Handshake) Shutdown()
- type Msg
- type Voting
- func (s *Voting) Accept(chainID, containerID ids.ID, container []byte) error
- func (s *Voting) Accepted(validatorID ids.ShortID, chainID ids.ID, requestID uint32, ...)
- func (s *Voting) AcceptedFrontier(validatorID ids.ShortID, chainID ids.ID, requestID uint32, ...)
- func (s *Voting) Chits(validatorID ids.ShortID, chainID ids.ID, requestID uint32, votes ids.Set)
- func (s *Voting) Get(validatorID ids.ShortID, chainID ids.ID, requestID uint32, containerID ids.ID)
- func (s *Voting) GetAccepted(validatorIDs ids.ShortSet, chainID ids.ID, requestID uint32, ...)
- func (s *Voting) GetAcceptedFrontier(validatorIDs ids.ShortSet, chainID ids.ID, requestID uint32)
- func (s *Voting) Initialize(log logging.Logger, vdrs validators.Set, peerNet salticidae.PeerNetwork, ...)
- func (s *Voting) PullQuery(validatorIDs ids.ShortSet, chainID ids.ID, requestID uint32, ...)
- func (s *Voting) PushQuery(validatorIDs ids.ShortSet, chainID ids.ID, requestID uint32, ...)
- func (s *Voting) Put(validatorID ids.ShortID, chainID ids.ID, requestID uint32, containerID ids.ID, ...)
- func (s *Voting) Shutdown()
Constants ¶
const ( // Handshake: GetVersion salticidae.Opcode = iota Version GetPeerList PeerList // Bootstrapping: GetAcceptedFrontier AcceptedFrontier GetAccepted Accepted // Consensus: Get Put PushQuery PullQuery Chits // Pinging: Ping Pong // Arbitrary data message: Data // Throughput test: IssueTx DecidedTx )
Public commands that may be sent between stakers
const ( // CurrentVersion this avalanche instance is executing. CurrentVersion = "avalanche/0.0.1" // MaxClockDifference allowed between connected nodes. MaxClockDifference = time.Minute // PeerListGossipSpacing is the amount of time to wait between pushing this // node's peer list to other nodes. PeerListGossipSpacing = time.Minute // PeerListGossipSize is the number of peers to gossip each period. PeerListGossipSize = 100 // PeerListStakerGossipFraction calculates the fraction of stakers that are // gossiped to. If set to 1, then only stakers will be gossiped to. PeerListStakerGossipFraction = 2 // GetVersionTimeout is the amount of time to wait before sending a // getVersion message to a partially connected peer GetVersionTimeout = 2 * time.Second // ReconnectTimeout is the amount of time to wait to reconnect to a staker // before giving up ReconnectTimeout = 10 * time.Minute )
Variables ¶
var (
HandshakeNet = Handshake{}
)
Manager is the struct that will be accessed on event calls
var ( Messages = map[salticidae.Opcode][]Field{ GetVersion: []Field{}, Version: []Field{NetworkID, MyTime, IP, VersionStr}, GetPeerList: []Field{}, PeerList: []Field{Peers}, GetAcceptedFrontier: []Field{ChainID, RequestID}, AcceptedFrontier: []Field{ChainID, RequestID, ContainerIDs}, GetAccepted: []Field{ChainID, RequestID, ContainerIDs}, Accepted: []Field{ChainID, RequestID, ContainerIDs}, Get: []Field{ChainID, RequestID, ContainerID}, Put: []Field{ChainID, RequestID, ContainerID, ContainerBytes}, PushQuery: []Field{ChainID, RequestID, ContainerID, ContainerBytes}, PullQuery: []Field{ChainID, RequestID, ContainerID}, Chits: []Field{ChainID, RequestID, ContainerIDs}, Ping: []Field{}, Pong: []Field{}, Data: []Field{Bytes}, IssueTx: []Field{ChainID, Tx}, DecidedTx: []Field{TxID, Status}, } )
Defines the messages that can be sent/received with this network
var ( // VotingNet implements the SenderExternal interface. VotingNet = Voting{} )
Functions ¶
Types ¶
type Builder ¶
type Builder struct{ Codec }
Builder extends a Codec to build messages safely
func (Builder) AcceptedFrontier ¶
func (m Builder) AcceptedFrontier(chainID ids.ID, requestID uint32, containerIDs ids.Set) (Msg, error)
AcceptedFrontier message
func (Builder) GetAccepted ¶
GetAccepted message
func (Builder) GetAcceptedFrontier ¶
GetAcceptedFrontier message
func (Builder) PushQuery ¶
func (m Builder) PushQuery(chainID ids.ID, requestID uint32, containerID ids.ID, container []byte) (Msg, error)
PushQuery message
type Codec ¶
type Codec struct{}
Codec defines the serialization and deserialization of network messages
type Connections ¶
type Connections interface { Add(salticidae.PeerID, ids.ShortID, utils.IPDesc) GetPeerID(ids.ShortID) (salticidae.PeerID, bool) GetID(salticidae.PeerID) (ids.ShortID, bool) ContainsPeerID(salticidae.PeerID) bool ContainsID(ids.ShortID) bool ContainsIP(utils.IPDesc) bool Remove(salticidae.PeerID, ids.ShortID) RemovePeerID(salticidae.PeerID) RemoveID(ids.ShortID) PeerIDs() []salticidae.PeerID IDs() ids.ShortSet IPs() []utils.IPDesc Conns() ([]salticidae.PeerID, []ids.ShortID, []utils.IPDesc) Len() int }
Connections provides an interface for what a group of connections will support.
func NewConnections ¶
func NewConnections() Connections
NewConnections returns a new and empty connections object
type Field ¶
type Field uint32
Field that may be packed into a message
const ( VersionStr Field = iota // Used in handshake NetworkID // Used in handshake MyTime // Used in handshake IP // Used in handshake Peers // Used in handshake ChainID // Used for dispatching RequestID // Used for all messages ContainerID // Used for querying ContainerBytes // Used for gossiping ContainerIDs // Used for querying Bytes // Used as arbitrary data TxID // Used for throughput tests Tx // Used for throughput tests Status // Used for throughput tests )
Fields that may be packed. These values are not sent over the wire.
type Handshake ¶
type Handshake struct {
// contains filtered or unexported fields
}
Handshake handles the authentication of new peers. Only valid stakers will appear connected.
func (*Handshake) AwaitConnections ¶
func (nm *Handshake) AwaitConnections(awaiting *networking.AwaitingConnections)
AwaitConnections ...
func (*Handshake) Connections ¶
func (nm *Handshake) Connections() Connections
Connections returns the object that tracks the nodes that are currently connected to this node.
func (*Handshake) Initialize ¶
func (nm *Handshake) Initialize( log logging.Logger, vdrs validators.Set, myAddr salticidae.NetAddr, myID ids.ShortID, peerNet salticidae.PeerNetwork, registerer prometheus.Registerer, enableStaking bool, networkID uint32, )
Initialize to the c networking library. This should only be done once during node setup.
func (*Handshake) SendGetVersion ¶
func (nm *Handshake) SendGetVersion(peer salticidae.PeerID)
SendGetVersion to the requested peer
func (*Handshake) SendPeerList ¶
SendPeerList to the requested peer
func (*Handshake) SendVersion ¶
SendVersion to the requested peer
type Msg ¶
type Msg interface { Op() salticidae.Opcode Get(Field) interface{} DataStream() salticidae.DataStream }
Msg represents a set of fields that can be serialized into a byte stream
type Voting ¶
type Voting struct {
// contains filtered or unexported fields
}
Voting implements the SenderExternal interface with a c++ library.
func (*Voting) Accepted ¶
func (s *Voting) Accepted(validatorID ids.ShortID, chainID ids.ID, requestID uint32, containerIDs ids.Set)
Accepted implements the Sender interface.
func (*Voting) AcceptedFrontier ¶
func (s *Voting) AcceptedFrontier(validatorID ids.ShortID, chainID ids.ID, requestID uint32, containerIDs ids.Set)
AcceptedFrontier implements the Sender interface.
func (*Voting) GetAccepted ¶
func (s *Voting) GetAccepted(validatorIDs ids.ShortSet, chainID ids.ID, requestID uint32, containerIDs ids.Set)
GetAccepted implements the Sender interface.
func (*Voting) GetAcceptedFrontier ¶
GetAcceptedFrontier implements the Sender interface.
func (*Voting) Initialize ¶
func (s *Voting) Initialize(log logging.Logger, vdrs validators.Set, peerNet salticidae.PeerNetwork, conns Connections, router router.Router, registerer prometheus.Registerer)
Initialize to the c networking library. Should only be called once ever.
func (*Voting) PullQuery ¶
func (s *Voting) PullQuery(validatorIDs ids.ShortSet, chainID ids.ID, requestID uint32, containerID ids.ID)
PullQuery implements the Sender interface.
func (*Voting) PushQuery ¶
func (s *Voting) PushQuery(validatorIDs ids.ShortSet, chainID ids.ID, requestID uint32, containerID ids.ID, container []byte)
PushQuery implements the Sender interface.