Documentation
¶
Index ¶
- Constants
- Variables
- func ToIPDesc(addr salticidae.NetAddr) (utils.IPDesc, error)
- type AddrCert
- func (ac *AddrCert) Add(ip salticidae.NetAddr, id ids.ShortID)
- func (ac *AddrCert) Conns() ([]utils.IPDesc, []ids.ShortID)
- func (ac *AddrCert) ContainsID(id ids.ShortID) bool
- func (ac *AddrCert) ContainsIP(ip salticidae.NetAddr) bool
- func (ac *AddrCert) GetID(ip salticidae.NetAddr) (ids.ShortID, bool)
- func (ac *AddrCert) GetIP(id ids.ShortID) (salticidae.NetAddr, bool)
- func (ac *AddrCert) IDs() ids.ShortSet
- func (ac *AddrCert) IPs() []salticidae.NetAddr
- func (ac *AddrCert) Len() int
- func (ac *AddrCert) Peers() []utils.IPDesc
- func (ac *AddrCert) RawConns() ([]salticidae.NetAddr, []ids.ShortID)
- func (ac *AddrCert) Remove(ip salticidae.NetAddr, id ids.ShortID)
- func (ac *AddrCert) RemoveID(id ids.ShortID)
- func (ac *AddrCert) RemoveIP(ip salticidae.NetAddr)
- 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, myVersion string) (Msg, error)
- type Codec
- type Connections
- type Field
- type Handshake
- func (nm *Handshake) AwaitConnections(awaiting *networking.AwaitingConnections)
- func (nm *Handshake) Connections() Connections
- func (nm *Handshake) Initialize(log logging.Logger, vdrs validators.Set, myAddr salticidae.NetAddr, ...)
- func (nm *Handshake) SendGetVersion(addr salticidae.NetAddr)
- func (nm *Handshake) SendPeerList(addrs ...salticidae.NetAddr) error
- func (nm *Handshake) SendVersion(addr salticidae.NetAddr) 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 )
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, 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 AddrCert ¶
type AddrCert struct {
// contains filtered or unexported fields
}
AddrCert implements the Connections interface
func (*AddrCert) Add ¶
func (ac *AddrCert) Add(ip salticidae.NetAddr, id ids.ShortID)
Add Assumes that addr is garbage collected normally
func (*AddrCert) ContainsID ¶
ContainsID returns true if the id is contained in the connection pool
func (*AddrCert) ContainsIP ¶
func (ac *AddrCert) ContainsIP(ip salticidae.NetAddr) bool
ContainsIP returns true if the ip is contained in the connection pool
func (*AddrCert) IPs ¶
func (ac *AddrCert) IPs() []salticidae.NetAddr
IPs returns the full list of ips contained in this connection pool. This can be useful for gossiping a node's connections through the network.
func (*AddrCert) RawConns ¶
func (ac *AddrCert) RawConns() ([]salticidae.NetAddr, []ids.ShortID)
RawConns return the set of connections in this connection pool.
func (*AddrCert) Remove ¶
func (ac *AddrCert) Remove(ip salticidae.NetAddr, id ids.ShortID)
Remove ensures that no connection will have any mapping containing [ip] or [id].
func (*AddrCert) RemoveIP ¶
func (ac *AddrCert) RemoveIP(ip salticidae.NetAddr)
RemoveIP ensures that no connection will have a mapping containing [ip]
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
func (Codec) Parse ¶
func (Codec) Parse(op salticidae.Opcode, ds salticidae.DataStream) (Msg, error)
Parse attempts to convert a byte stream into a message.
type Connections ¶
type Connections interface {
Add(salticidae.NetAddr, ids.ShortID)
GetIP(ids.ShortID) (salticidae.NetAddr, bool)
GetID(salticidae.NetAddr) (ids.ShortID, bool)
ContainsIP(salticidae.NetAddr) bool
ContainsID(ids.ShortID) bool
Remove(salticidae.NetAddr, ids.ShortID)
RemoveIP(salticidae.NetAddr)
RemoveID(ids.ShortID)
Peers() []utils.IPDesc
IPs() []salticidae.NetAddr
IDs() ids.ShortSet
Conns() ([]utils.IPDesc, []ids.ShortID)
RawConns() ([]salticidae.NetAddr, []ids.ShortID)
Len() int
}
Connections provides an interface for what a group of connections will support.
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 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(addr salticidae.NetAddr)
SendGetVersion to the requested peer
func (*Handshake) SendPeerList ¶
func (nm *Handshake) SendPeerList(addrs ...salticidae.NetAddr) error
SendPeerList to the requested peer
func (*Handshake) SendVersion ¶
func (nm *Handshake) SendVersion(addr salticidae.NetAddr) error
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.