Documentation ¶
Overview ¶
Package node provides a node implementation that can participate in the Nano network.
Index ¶
- Variables
- func Sync(syncer Syncer, p *proto.Proto, peer *Peer) error
- type BulkPullBlocksPusher
- type BulkPullBlocksSyncer
- type BulkPullBlocksSyncerFunc
- type BulkPullPusher
- type BulkPullSyncer
- type BulkPullSyncerFunc
- type FrontierPusher
- type FrontierSyncer
- type FrontierSyncerFunc
- type Node
- type Options
- type Peer
- type PeerList
- func (l *PeerList) Add(addr *net.UDPAddr) (*Peer, error)
- func (l *PeerList) Full() bool
- func (l *PeerList) Get(addr *net.UDPAddr) *Peer
- func (l *PeerList) Len() int
- func (l *PeerList) Peers() []*Peer
- func (l *PeerList) Pick() ([]*Peer, error)
- func (l *PeerList) Random() (*Peer, error)
- func (l *PeerList) Remove(peer *Peer)
- type Pusher
- type Syncer
Constants ¶
This section is empty.
Variables ¶
var ( ErrMaxPeers = errors.New("max amount of peers reached") ErrPeerExists = errors.New("this peer already exists in the list") )
var ( DefaultOptions = Options{ Network: proto.NetworkLive, Address: ":7075", EnableIPv6: false, EnableVoting: true, MaxPeers: 15, } )
Functions ¶
Types ¶
type BulkPullBlocksPusher ¶
type BulkPullBlocksPusher struct { }
type BulkPullBlocksSyncer ¶
type BulkPullBlocksSyncer struct {
// contains filtered or unexported fields
}
func NewBulkPullBlocksSyncer ¶
func NewBulkPullBlocksSyncer(cb BulkPullBlocksSyncerFunc) *BulkPullBlocksSyncer
func (*BulkPullBlocksSyncer) Flush ¶
func (s *BulkPullBlocksSyncer) Flush()
Flush implements the Syncer interface.
type BulkPullPusher ¶
type BulkPullPusher struct { }
type BulkPullSyncer ¶
type BulkPullSyncer struct {
// contains filtered or unexported fields
}
func NewBulkPullSyncer ¶
func NewBulkPullSyncer(cb BulkPullSyncerFunc, frontiers map[nano.Address]block.Hash) *BulkPullSyncer
func (*BulkPullSyncer) Flush ¶
func (s *BulkPullSyncer) Flush()
Flush implements the Syncer interface.
type BulkPullSyncerFunc ¶
type FrontierPusher ¶
type FrontierPusher struct { }
type FrontierSyncer ¶
type FrontierSyncer struct {
// contains filtered or unexported fields
}
func NewFrontierSyncer ¶
func NewFrontierSyncer(cb FrontierSyncerFunc) *FrontierSyncer
func (*FrontierSyncer) Flush ¶
func (s *FrontierSyncer) Flush()
Flush implements the Syncer interface.
type FrontierSyncerFunc ¶
type Peer ¶
Peer represents a Nano peer.
func (*Peer) Dead ¶
Dead reports whether this peer should be considered dead and be removed from the peer list.
func (*Peer) Ping ¶
Ping will call the given function if the peer needs to be pinged. If fn returns nil, the last ping time is reset.
type PeerList ¶
type PeerList struct {
// contains filtered or unexported fields
}
PeerList represents a list of peers.
func NewPeerList ¶
NewPeerList creates a new peer list with the given maximum capacity.
func (*PeerList) Add ¶
Add creates a new peer instance with the given address, adds it to the internal peer list and returns it.
func (*PeerList) Full ¶
Full reports whether the internal peer list has reached its maximum capacity.
func (*PeerList) Get ¶
Get retrieves a peer with the given address. If no such peer exists, nil is returned.
func (*PeerList) Pick ¶
Pick returns 8 random peers from the internal peer list. This function is usually used to populate a KeepAlivePacket.
type Syncer ¶
type Syncer interface { // Flush flushes all items in the cache through the registered callback. Flush() // ReadNext reads the next packet from the given reader, parses it and adds // the item to the cache. ReadNext(r io.Reader) (done bool, err error) // WriteNext writes the next packet to the given reader. If no packets need // to be sent, 'done' is set to true. WriteNext(p *proto.Proto, w io.Writer) (done bool, err error) }