Documentation ¶
Index ¶
- func FakeClient(host string) grpc.DialOption
- func IDsToWire(ids []hash.Peer) *api.PeerIDs
- func PeersHeightsDiff(all, excepts map[string]uint64) (res map[string]uint64)
- func WireToIDs(w *api.PeerIDs) []hash.Peer
- type Config
- type Consensus
- type Node
- func (n *Node) AddBuiltInPeers(hosts ...string)
- func (n *Node) AddExternalTxn(tx []byte)
- func (n *Node) AddInternalTxn(tx inter.InternalTransaction) (hash.Transaction, error)
- func (n *Node) AsPeer() *Peer
- func (n *Node) AskPeerInfo(host string, id *hash.Peer)
- func (n *Node) CheckPeerIsKnown(host string, id *hash.Peer)
- func (cc *Node) Clean()
- func (n *Node) ConnectFail(p *Peer, err error)
- func (n *Node) ConnectOK(p *Peer)
- func (n *Node) ConnectTo(peer *Peer) (client api.NodeClient, free func(), fail func(error), err error)
- func (pp *Node) Del(e hash.Event)
- func (n *Node) EmitEvent() *inter.Event
- func (n *Node) EventOf(peer hash.Peer, i uint64) *inter.Event
- func (n *Node) FreePeer(p *Peer)
- func (cc *Node) Get(addr string) (*connection, error)
- func (n *Node) GetEvent(ctx context.Context, req *api.EventRequest) (*wire.Event, error)
- func (n *Node) GetID() hash.Peer
- func (n *Node) GetPeerInfo(ctx context.Context, req *api.PeerRequest) (*api.PeerInfo, error)
- func (n *Node) Host() string
- func (n *Node) LastEventOf(peer hash.Peer) *inter.Event
- func (n *Node) NetAddrOf(host string) string
- func (n *Node) NextBuiltInPeer() (host string)
- func (n *Node) NextForGossip() *Peer
- func (n *Node) PeerReadyForReq(host string) bool
- func (n *Node) PeerUnknown(id *hash.Peer) bool
- func (n *Node) PubKey() *common.PublicKey
- func (cc *Node) Release(c *connection, count bool, err error)
- func (pp *Node) Snapshot() []hash.Peer
- func (n *Node) Start()
- func (n *Node) StartDiscovery()
- func (n *Node) StartEventEmission()
- func (n *Node) StartGossip(threads int)
- func (n *Node) StartService()
- func (n *Node) Stop()
- func (n *Node) StopDiscovery()
- func (n *Node) StopEventEmission()
- func (n *Node) StopGossip()
- func (n *Node) StopService()
- func (pp *Node) Sum(e hash.Event) uint64
- func (n *Node) SyncEvents(ctx context.Context, req *api.KnownEvents) (*api.KnownEvents, error)
- type Peer
- type Store
- func (s *Store) BootstrapPeers(peers ...*Peer)
- func (s *Store) Close()
- func (s *Store) GetEvent(h hash.Event) *inter.Event
- func (s *Store) GetEventHash(creator hash.Peer, index uint64) *hash.Event
- func (s *Store) GetPeer(id hash.Peer) *Peer
- func (s *Store) GetPeerHeight(id hash.Peer) uint64
- func (s *Store) GetTopPeers() []hash.Peer
- func (s *Store) GetWireEvent(h hash.Event) *wire.Event
- func (s *Store) GetWirePeer(id hash.Peer) *api.PeerInfo
- func (s *Store) HasEvent(h hash.Event) bool
- func (s *Store) SetEvent(e *inter.Event)
- func (s *Store) SetEventHash(creator hash.Peer, index uint64, hash hash.Event)
- func (s *Store) SetPeer(peer *Peer)
- func (s *Store) SetPeerHeight(id hash.Peer, height uint64)
- func (s *Store) SetTopPeers(ids []hash.Peer)
- func (s *Store) SetWirePeer(id hash.Peer, info *api.PeerInfo)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FakeClient ¶
func FakeClient(host string) grpc.DialOption
FakeClient returns dialer for fake network.
func PeersHeightsDiff ¶
PeersHeightsDiff returns all heights excluding excepts.
Types ¶
type Config ¶
type Config struct { EventParentsCount int // max count of event's parents (includes self-parent) Port int // default service port GossipThreads int // count of gossiping goroutines EmitInterval time.Duration // event emission interval DiscoveryTimeout time.Duration // how often discovery should try to request ConnectTimeout time.Duration // how long dialer will for connection to be established ClientTimeout time.Duration // how long will gRPC client will wait for response TopPeersCount int // peers hot cache size }
Config is a set of nodes params.
type Consensus ¶
type Consensus interface { // PushEvent takes event for processing. PushEvent(hash.Event) // StakeOf returns stake of peer. StakeOf(hash.Peer) uint64 // GetGenesisHash returns hash of genesis poset works with. GetGenesisHash() hash.Hash }
Consensus is a consensus interface.
type Node ¶
Node is a Lachesis node implementation.
func New ¶
func New(host string, key *common.PrivateKey, s *Store, c Consensus, conf *Config, listen network.ListenFunc, opts ...grpc.DialOption) *Node
New creates node. It does not start any process.
func (*Node) AddBuiltInPeers ¶
AddBuiltInPeers sets hosts for futher peer discovery.
func (*Node) AddExternalTxn ¶
AddExternalTxn takes external transaction for new event.
func (*Node) AddInternalTxn ¶
func (n *Node) AddInternalTxn(tx inter.InternalTransaction) (hash.Transaction, error)
AddInternalTxn takes internal transaction for new event.
func (*Node) AskPeerInfo ¶
AskPeerInfo gets peer info (network address, public key, etc).
func (*Node) CheckPeerIsKnown ¶
CheckPeerIsKnown queues peer checking for a late.
func (*Node) ConnectFail ¶
ConnectFail counts unsuccessful connections to peer.
func (*Node) ConnectTo ¶
func (n *Node) ConnectTo(peer *Peer) (client api.NodeClient, free func(), fail func(error), err error)
ConnectTo connects to other node service.
func (*Node) EmitEvent ¶
EmitEvent takes all transactions from buffer builds event, connects it with given amount of parents, sign and put it into the storage. It returns emmited event for test purpose.
func (*Node) GetPeerInfo ¶
GetPeerInfo returns requested peer info.
func (*Node) LastEventOf ¶
LastEventOf returns last event of peer.
func (*Node) NextBuiltInPeer ¶
NextBuiltInPeer returns one of builtin hosts.
func (*Node) NextForGossip ¶
NextForGossip returns the best candidate to gossip with and marks it as busy. You should call FreePeer() to mark candidate as not busy.
func (*Node) PeerReadyForReq ¶
PeerReadyForReq returns false if peer is not ready for request.
func (*Node) PeerUnknown ¶
PeerUnknown returns true if peer should be discovered.
func (*Node) StartDiscovery ¶
func (n *Node) StartDiscovery()
StartDiscovery starts single thread network discovery. If there are no tasks for the discovery of unknown peers, after idle time will try to discover one of builtin peers.
func (*Node) StartEventEmission ¶
func (n *Node) StartEventEmission()
StartEventEmission starts event emission.
func (*Node) StopEventEmission ¶
func (n *Node) StopEventEmission()
StopEventEmission stops event emission.
func (*Node) SyncEvents ¶
func (n *Node) SyncEvents(ctx context.Context, req *api.KnownEvents) (*api.KnownEvents, error)
SyncEvents returns their known event heights excluding heights from request.
type Store ¶
Store is a node persistent storage working over physical key-value database.
func (*Store) BootstrapPeers ¶
BootstrapPeers stores peer list.
func (*Store) GetEventHash ¶
GetEventHash returns stored event hash.
func (*Store) GetPeerHeight ¶
GetPeerHeight returns last event index of peer.
func (*Store) GetTopPeers ¶
GetTopPeers returns peers.top.
func (*Store) GetWireEvent ¶
GetWireEvent returns stored event. Result is a ready gRPC message.
func (*Store) GetWirePeer ¶
GetWirePeer returns stored peer info. Result is a ready gRPC message.
func (*Store) SetEventHash ¶
SetEventHash stores hash.
func (*Store) SetPeerHeight ¶
SetPeerHeight stores last event index of peer.
func (*Store) SetTopPeers ¶
SetTopPeers stores peers.top.