Documentation ¶
Index ¶
- Constants
- func NewGetBlockHeadersMessage(startHeight, endHeight uint32) (*pb.UnsignedMessage, error)
- func NewGetBlockHeadersReply(headers []*ledger.Header) (*pb.UnsignedMessage, error)
- func NewGetBlocksMessage(startHeight, endHeight uint32) (*pb.UnsignedMessage, error)
- func NewGetBlocksReply(blocks []*ledger.Block) (*pb.UnsignedMessage, error)
- func NewHashCache() *hashCache
- func NewRelayMessage(srcAddr string, destID, payload []byte, sigChain *por.SigChain, ...) (*pb.UnsignedMessage, error)
- func NewTransactionsMessage(transactions []*transaction.Transaction) (*pb.UnsignedMessage, error)
- type ChordInfo
- type ChordRemoteNodeInfo
- type LocalNode
- func (handlerStore LocalNode) AddMessageHandler(messageType pb.MessageType, handler MessageHandler)
- func (nm *LocalNode) AddNbrNode(remoteNode *RemoteNode) error
- func (localNode *LocalNode) BroadcastTransaction(txn *transaction.Transaction) error
- func (nm *LocalNode) DelNbrNode(id string)
- func (hc LocalNode) ExistHash(hash common.Uint256) bool
- func (localNode *LocalNode) FindHttpProxyAddr(key []byte) (string, error)
- func (localNode *LocalNode) FindSuccessorAddrs(key []byte, numSucc int) ([]string, error)
- func (localNode *LocalNode) FindWsAddr(key []byte) (string, error)
- func (localNode *LocalNode) GetChordInfo() *ChordInfo
- func (nm *LocalNode) GetConnectionCnt() uint
- func (eq *LocalNode) GetEvent(eventName string) *events.Event
- func (localNode *LocalNode) GetHeight() uint32
- func (handlerStore LocalNode) GetMessageHandlers(messageType pb.MessageType) []MessageHandler
- func (nm *LocalNode) GetNbrNode(id string) *RemoteNode
- func (nm *LocalNode) GetNeighborHeights() ([]uint32, uint)
- func (localNode *LocalNode) GetNeighborInfo() []*RemoteNode
- func (nm *LocalNode) GetNeighbors(filter func(*RemoteNode) bool) []*RemoteNode
- func (localNode *LocalNode) GetRelayMessageCount() uint64
- func (localNode *LocalNode) GetTxnPool() *pool.TxnPool
- func (localNode *LocalNode) GetWsAddr() string
- func (localNode *LocalNode) IncrementRelayMessageCount()
- func (localNode *LocalNode) MarshalJSON() ([]byte, error)
- func (localNode *LocalNode) ResetSyncing()
- func (localNode *LocalNode) SendRelayMessage(srcAddr, destAddr string, payload, signature []byte, maxHoldingSeconds uint32) error
- func (localNode *LocalNode) SerializeMessage(unsignedMsg *pb.UnsignedMessage, sign bool) ([]byte, error)
- func (localNode *LocalNode) SetSyncState(s pb.SyncState)
- func (localNode *LocalNode) Start() error
- func (localNode *LocalNode) StartSyncing(stopHash common.Uint256, stopHeight uint32, neighbors []*RemoteNode) (bool, error)
- type MessageHandler
- type Node
- type RelayService
- type RemoteMessage
- type RemoteNode
- func (remoteNode *RemoteNode) CloseConn()
- func (remoteNode *RemoteNode) GetBlockHeaders(startHeight, endHeight uint32) ([]*ledger.Header, error)
- func (remoteNode *RemoteNode) GetBlocks(startHeight, endHeight uint32) ([]*ledger.Block, error)
- func (remoteNode *RemoteNode) GetHeight() uint32
- func (remoteNode *RemoteNode) MarshalJSON() ([]byte, error)
- func (remoteNode *RemoteNode) SendBytesAsync(buf []byte) error
- func (remoteNode *RemoteNode) SendBytesReply(replyToID, buf []byte) error
- func (remoteNode *RemoteNode) SendBytesSync(buf []byte) ([]byte, error)
- func (remoteNode *RemoteNode) SendBytesSyncWithTimeout(buf []byte, replyTimeout time.Duration) ([]byte, error)
- func (remoteNode *RemoteNode) SetHeight(height uint32)
Constants ¶
const ( HashCacheExpiration = 3600 * time.Second HashCacheCleanupInterval = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func NewGetBlockHeadersMessage ¶
func NewGetBlockHeadersMessage(startHeight, endHeight uint32) (*pb.UnsignedMessage, error)
NewGetBlockHeadersMessage creates a GET_BLOCK_HEADERS message
func NewGetBlockHeadersReply ¶
func NewGetBlockHeadersReply(headers []*ledger.Header) (*pb.UnsignedMessage, error)
NewGetBlockHeadersReply creates a GET_BLOCK_HEADERS_REPLY message in respond to GET_BLOCK_HEADERS message
func NewGetBlocksMessage ¶
func NewGetBlocksMessage(startHeight, endHeight uint32) (*pb.UnsignedMessage, error)
NewGetBlocksMessage creates a GET_BLOCKS message
func NewGetBlocksReply ¶
func NewGetBlocksReply(blocks []*ledger.Block) (*pb.UnsignedMessage, error)
NewGetBlocksReply creates a GET_BLOCKS_REPLY message in respond to GET_BLOCKS message
func NewHashCache ¶
func NewHashCache() *hashCache
func NewRelayMessage ¶
func NewRelayMessage(srcAddr string, destID, payload []byte, sigChain *por.SigChain, maxHoldingSeconds uint32) (*pb.UnsignedMessage, error)
NewRelayMessage creates a RELAY message
func NewTransactionsMessage ¶
func NewTransactionsMessage(transactions []*transaction.Transaction) (*pb.UnsignedMessage, error)
NewTransactionsMessage creates a TRANSACTIONS message
Types ¶
type ChordInfo ¶
type ChordInfo struct { LocalNode *LocalNode `json:"localNode"` Successors []*ChordRemoteNodeInfo `json:"successors"` Predecessors []*ChordRemoteNodeInfo `json:"predecessors"` FingerTable map[int][]*ChordRemoteNodeInfo `json:"fingerTable"` }
type ChordRemoteNodeInfo ¶
type ChordRemoteNodeInfo nnetnode.RemoteNode
func (*ChordRemoteNodeInfo) MarshalJSON ¶
func (rn *ChordRemoteNodeInfo) MarshalJSON() ([]byte, error)
type LocalNode ¶
type LocalNode struct { *Node *pool.TxnPool // transaction pool of local node sync.RWMutex // contains filtered or unexported fields }
func (LocalNode) AddMessageHandler ¶
func (handlerStore LocalNode) AddMessageHandler(messageType pb.MessageType, handler MessageHandler)
AddMessageHandler adds a message handler to a message type
func (*LocalNode) AddNbrNode ¶
func (nm *LocalNode) AddNbrNode(remoteNode *RemoteNode) error
func (*LocalNode) BroadcastTransaction ¶
func (localNode *LocalNode) BroadcastTransaction(txn *transaction.Transaction) error
BroadcastTransaction broadcast a transaction to the network using TRANSACTIONS message
func (*LocalNode) DelNbrNode ¶
func (nm *LocalNode) DelNbrNode(id string)
func (*LocalNode) FindHttpProxyAddr ¶
func (*LocalNode) FindSuccessorAddrs ¶
func (*LocalNode) GetChordInfo ¶
func (*LocalNode) GetConnectionCnt ¶
func (nm *LocalNode) GetConnectionCnt() uint
func (LocalNode) GetMessageHandlers ¶
func (handlerStore LocalNode) GetMessageHandlers(messageType pb.MessageType) []MessageHandler
GetMessageHandlers gets all handlers of a message type
func (*LocalNode) GetNbrNode ¶
func (nm *LocalNode) GetNbrNode(id string) *RemoteNode
func (*LocalNode) GetNeighborHeights ¶
func (*LocalNode) GetNeighborInfo ¶
func (localNode *LocalNode) GetNeighborInfo() []*RemoteNode
func (*LocalNode) GetNeighbors ¶
func (nm *LocalNode) GetNeighbors(filter func(*RemoteNode) bool) []*RemoteNode
func (*LocalNode) GetRelayMessageCount ¶
func (*LocalNode) GetTxnPool ¶
func (*LocalNode) IncrementRelayMessageCount ¶
func (localNode *LocalNode) IncrementRelayMessageCount()
func (*LocalNode) MarshalJSON ¶
func (*LocalNode) ResetSyncing ¶
func (localNode *LocalNode) ResetSyncing()
ResetSyncing resets syncOnce and allows for future block syncing
func (*LocalNode) SendRelayMessage ¶
func (*LocalNode) SerializeMessage ¶
func (*LocalNode) SetSyncState ¶
func (*LocalNode) StartSyncing ¶
func (localNode *LocalNode) StartSyncing(stopHash common.Uint256, stopHeight uint32, neighbors []*RemoteNode) (bool, error)
StartSyncing starts block syncing from current local ledger until it gets to block height stopHeight with block hash stopHash from given neighbors
type MessageHandler ¶
type MessageHandler func(msg *RemoteMessage) (reply []byte, shouldCallNext bool, err error)
MessageHandler handles a message and returns reply, if it should be passed through to other message handler and error
type Node ¶
type Node struct { *nnetpb.Node *pb.NodeData sync.RWMutex // contains filtered or unexported fields }
func (*Node) GetChordID ¶
func (*Node) GetHostname ¶
func (*Node) GetSyncState ¶
func (*Node) MarshalJSON ¶
func (*Node) SetSyncState ¶
type RelayService ¶
func NewRelayService ¶
func NewRelayService(wallet vault.Wallet, localNode *LocalNode) *RelayService
func (*RelayService) Start ¶
func (rs *RelayService) Start() error
type RemoteMessage ¶
RemoteMessage is the message received from remote nodes
type RemoteNode ¶
func NewRemoteNode ¶
func NewRemoteNode(localNode *LocalNode, nnetNode *nnetnode.RemoteNode) (*RemoteNode, error)
func (*RemoteNode) CloseConn ¶
func (remoteNode *RemoteNode) CloseConn()
func (*RemoteNode) GetBlockHeaders ¶
func (remoteNode *RemoteNode) GetBlockHeaders(startHeight, endHeight uint32) ([]*ledger.Header, error)
GetBlockHeaders requests a range of consecutive block headers from a neighbor using GET_BLOCK_HEADERS message
func (*RemoteNode) GetBlocks ¶
func (remoteNode *RemoteNode) GetBlocks(startHeight, endHeight uint32) ([]*ledger.Block, error)
GetBlocks requests a range of consecutive blocks from a neighbor using GET_BLOCKS message
func (*RemoteNode) GetHeight ¶
func (remoteNode *RemoteNode) GetHeight() uint32
func (*RemoteNode) MarshalJSON ¶
func (remoteNode *RemoteNode) MarshalJSON() ([]byte, error)
func (*RemoteNode) SendBytesAsync ¶
func (remoteNode *RemoteNode) SendBytesAsync(buf []byte) error
func (*RemoteNode) SendBytesReply ¶
func (remoteNode *RemoteNode) SendBytesReply(replyToID, buf []byte) error
func (*RemoteNode) SendBytesSync ¶
func (remoteNode *RemoteNode) SendBytesSync(buf []byte) ([]byte, error)
func (*RemoteNode) SendBytesSyncWithTimeout ¶
func (*RemoteNode) SetHeight ¶
func (remoteNode *RemoteNode) SetHeight(height uint32)