Documentation ¶
Index ¶
- func MakeSigChainTransaction(wallet vault.Wallet, sigChain []byte) (*transaction.Transaction, error)
- func NewBacktrackSigChainMessage(sigChainElems []*pb.SigChainElem, prevSignature []byte) (*pb.UnsignedMessage, error)
- func NewGetBlockHeadersMessage(startHeight, endHeight uint32) (*pb.UnsignedMessage, error)
- func NewGetBlockHeadersReply(headers []*block.Header) (*pb.UnsignedMessage, error)
- func NewGetBlocksMessage(startHeight, endHeight uint32) (*pb.UnsignedMessage, error)
- func NewGetBlocksReply(blocks []*block.Block) (*pb.UnsignedMessage, error)
- func NewIHaveSignatureChainTransactionMessage(height uint32, sigHash []byte) (*pb.UnsignedMessage, error)
- func NewRelayMessage(srcIdentifier string, srcPubkey, destID, payload, blockHash, signature []byte, ...) (*pb.UnsignedMessage, error)
- func NewRequestSignatureChainTransactionMessage(sigHash []byte) (*pb.UnsignedMessage, error)
- func NewRequestSignatureChainTransactionReply(transaction *transaction.Transaction) (*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) FindSuccessorAddrs(key []byte, numSucc int) ([]string, error)
- func (localNode *LocalNode) FindWsAddr(key []byte) (string, []byte, []byte, error)
- func (localNode *LocalNode) GetChordInfo() *ChordInfo
- func (nm *LocalNode) GetConnectionCnt() uint
- func (localNode *LocalNode) GetGossipNeighbors(filter func(*RemoteNode) bool) []*RemoteNode
- 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) GetProposalSubmitted() uint32
- func (localNode *LocalNode) GetRelayMessageCount() uint64
- func (localNode *LocalNode) GetSyncState() pb.SyncState
- func (localNode *LocalNode) GetTxnPool() *pool.TxnPool
- func (localNode *LocalNode) GetVotingNeighbors(filter func(*RemoteNode) bool) []*RemoteNode
- func (localNode *LocalNode) GetWsAddr() string
- func (localNode *LocalNode) IncrementProposalSubmitted()
- func (localNode *LocalNode) IncrementRelayMessageCount()
- func (localNode *LocalNode) MarshalJSON() ([]byte, error)
- func (localNode *LocalNode) ResetSyncing()
- func (localNode *LocalNode) SendRelayMessage(srcAddr, destAddr string, payload, signature, blockHash []byte, ...) error
- func (localNode *LocalNode) SerializeMessage(unsignedMsg *pb.UnsignedMessage, sign bool) ([]byte, error)
- func (localNode *LocalNode) SetMinVerifiableHeight(height uint32)
- func (localNode *LocalNode) SetSyncState(s pb.SyncState) bool
- func (localNode *LocalNode) Start() error
- func (localNode *LocalNode) StartSyncing(stopHash common.Uint256, stopHeight uint32, neighbors []*RemoteNode) (bool, error)
- type MessageHandler
- type Node
- func (n *Node) GetChordID() []byte
- func (n *Node) GetHostname() string
- func (n *Node) GetID() string
- func (n *Node) GetMinVerifiableHeight() uint32
- func (n *Node) GetPubKey() *crypto.PubKey
- func (n *Node) GetSyncState() pb.SyncState
- func (n *Node) MarshalJSON() ([]byte, error)
- func (n *Node) SetMinVerifiableHeight(height uint32)
- func (n *Node) SetSyncState(s pb.SyncState) bool
- type RelayService
- type RemoteMessage
- type RemoteNode
- func (remoteNode *RemoteNode) CloseConn()
- func (remoteNode *RemoteNode) GetBlockHeaders(startHeight, endHeight uint32) ([]*block.Header, error)
- func (remoteNode *RemoteNode) GetBlocks(startHeight, endHeight uint32) ([]*block.Block, error)
- func (remoteNode *RemoteNode) GetHeight() uint32
- func (remoteNode *RemoteNode) GetLastUpdateTime() time.Time
- 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)
- func (remoteNode *RemoteNode) SetLastUpdateTime(lastUpdateTime time.Time)
- func (remoteNode *RemoteNode) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeSigChainTransaction ¶
func MakeSigChainTransaction(wallet vault.Wallet, sigChain []byte) (*transaction.Transaction, error)
func NewBacktrackSigChainMessage ¶
func NewBacktrackSigChainMessage(sigChainElems []*pb.SigChainElem, prevSignature []byte) (*pb.UnsignedMessage, error)
NewBacktrackSigChainMessage creates a BACKTRACK_SIGNATURE_CHAIN message
func NewGetBlockHeadersMessage ¶
func NewGetBlockHeadersMessage(startHeight, endHeight uint32) (*pb.UnsignedMessage, error)
NewGetBlockHeadersMessage creates a GET_BLOCK_HEADERS message
func NewGetBlockHeadersReply ¶
func NewGetBlockHeadersReply(headers []*block.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 []*block.Block) (*pb.UnsignedMessage, error)
NewGetBlocksReply creates a GET_BLOCKS_REPLY message in respond to GET_BLOCKS message
func NewIHaveSignatureChainTransactionMessage ¶
func NewIHaveSignatureChainTransactionMessage(height uint32, sigHash []byte) (*pb.UnsignedMessage, error)
NewIHaveSignatureChainTransactionMessage creates a I_HAVE_SIGNATURE_CHAIN_TRANSACTION message
func NewRelayMessage ¶
func NewRelayMessage(srcIdentifier string, srcPubkey, destID, payload, blockHash, signature []byte, maxHoldingSeconds uint32) (*pb.UnsignedMessage, error)
NewRelayMessage creates a RELAY message
func NewRequestSignatureChainTransactionMessage ¶
func NewRequestSignatureChainTransactionMessage(sigHash []byte) (*pb.UnsignedMessage, error)
NewRequestSignatureChainTransactionMessage creates a REQUEST_SIGNATURE_CHAIN_TRANSACTION message
func NewRequestSignatureChainTransactionReply ¶
func NewRequestSignatureChainTransactionReply(transaction *transaction.Transaction) (*pb.UnsignedMessage, error)
NewRequestSignatureChainTransactionReply creates a REQUEST_SIGNATURE_CHAIN_TRANSACTION_REPLY 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) FindSuccessorAddrs ¶
func (*LocalNode) FindWsAddr ¶
func (*LocalNode) GetChordInfo ¶
func (*LocalNode) GetConnectionCnt ¶
func (nm *LocalNode) GetConnectionCnt() uint
func (*LocalNode) GetGossipNeighbors ¶
func (localNode *LocalNode) GetGossipNeighbors(filter func(*RemoteNode) bool) []*RemoteNode
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) GetProposalSubmitted ¶
func (*LocalNode) GetRelayMessageCount ¶
func (*LocalNode) GetSyncState ¶
func (*LocalNode) GetTxnPool ¶
func (*LocalNode) GetVotingNeighbors ¶
func (localNode *LocalNode) GetVotingNeighbors(filter func(*RemoteNode) bool) []*RemoteNode
func (*LocalNode) IncrementProposalSubmitted ¶
func (localNode *LocalNode) IncrementProposalSubmitted()
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) SetMinVerifiableHeight ¶
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) GetMinVerifiableHeight ¶
func (*Node) GetSyncState ¶
func (*Node) MarshalJSON ¶
func (*Node) SetMinVerifiableHeight ¶
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) ([]*block.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) ([]*block.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) GetLastUpdateTime ¶
func (remoteNode *RemoteNode) GetLastUpdateTime() time.Time
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)
func (*RemoteNode) SetLastUpdateTime ¶
func (remoteNode *RemoteNode) SetLastUpdateTime(lastUpdateTime time.Time)
func (*RemoteNode) String ¶
func (remoteNode *RemoteNode) String() string