node

package
v1.1.1-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2019 License: Apache-2.0 Imports: 40 Imported by: 7

Documentation

Index

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 NewLocalNode

func NewLocalNode(wallet vault.Wallet, nn *nnet.NNet) (*LocalNode, error)

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) ExistHash

func (hc LocalNode) ExistHash(hash common.Uint256) bool

func (*LocalNode) FindSuccessorAddrs

func (localNode *LocalNode) FindSuccessorAddrs(key []byte, numSucc int) ([]string, error)

func (*LocalNode) FindWsAddr

func (localNode *LocalNode) FindWsAddr(key []byte) (string, []byte, []byte, error)

func (*LocalNode) GetChordInfo

func (localNode *LocalNode) GetChordInfo() *ChordInfo

func (*LocalNode) GetConnectionCnt

func (nm *LocalNode) GetConnectionCnt() uint

func (*LocalNode) GetGossipNeighbors

func (localNode *LocalNode) GetGossipNeighbors(filter func(*RemoteNode) bool) []*RemoteNode

func (*LocalNode) GetHeight

func (localNode *LocalNode) GetHeight() uint32

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 (nm *LocalNode) GetNeighborHeights() ([]uint32, uint)

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 *LocalNode) GetProposalSubmitted() uint32

func (*LocalNode) GetRelayMessageCount

func (localNode *LocalNode) GetRelayMessageCount() uint64

func (*LocalNode) GetSyncState

func (localNode *LocalNode) GetSyncState() pb.SyncState

func (*LocalNode) GetTxnPool

func (localNode *LocalNode) GetTxnPool() *pool.TxnPool

func (*LocalNode) GetVotingNeighbors

func (localNode *LocalNode) GetVotingNeighbors(filter func(*RemoteNode) bool) []*RemoteNode

func (*LocalNode) GetWsAddr

func (localNode *LocalNode) GetWsAddr() string

func (*LocalNode) IncrementProposalSubmitted

func (localNode *LocalNode) IncrementProposalSubmitted()

func (*LocalNode) IncrementRelayMessageCount

func (localNode *LocalNode) IncrementRelayMessageCount()

func (*LocalNode) MarshalJSON

func (localNode *LocalNode) MarshalJSON() ([]byte, error)

func (*LocalNode) ResetSyncing

func (localNode *LocalNode) ResetSyncing()

ResetSyncing resets syncOnce and allows for future block syncing

func (*LocalNode) SendRelayMessage

func (localNode *LocalNode) SendRelayMessage(srcAddr, destAddr string, payload, signature, blockHash []byte, nonce, maxHoldingSeconds uint32) error

func (*LocalNode) SerializeMessage

func (localNode *LocalNode) SerializeMessage(unsignedMsg *pb.UnsignedMessage, sign bool) ([]byte, error)

func (*LocalNode) SetMinVerifiableHeight

func (localNode *LocalNode) SetMinVerifiableHeight(height uint32)

func (*LocalNode) SetSyncState

func (localNode *LocalNode) SetSyncState(s pb.SyncState) bool

func (*LocalNode) Start

func (localNode *LocalNode) Start() error

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 NewNode

func NewNode(nnetNode *nnetpb.Node, nodeData *pb.NodeData) (*Node, error)

func (*Node) GetChordID

func (n *Node) GetChordID() []byte

func (*Node) GetHostname

func (n *Node) GetHostname() string

func (*Node) GetID

func (n *Node) GetID() string

func (*Node) GetMinVerifiableHeight

func (n *Node) GetMinVerifiableHeight() uint32

func (*Node) GetPubKey

func (n *Node) GetPubKey() *crypto.PubKey

func (*Node) GetSyncState

func (n *Node) GetSyncState() pb.SyncState

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

func (*Node) SetMinVerifiableHeight

func (n *Node) SetMinVerifiableHeight(height uint32)

func (*Node) SetSyncState

func (n *Node) SetSyncState(s pb.SyncState) bool

type RelayService

type RelayService struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewRelayService

func NewRelayService(wallet vault.Wallet, localNode *LocalNode) *RelayService

func (*RelayService) Start

func (rs *RelayService) Start() error

type RemoteMessage

type RemoteMessage struct {
	Sender  *Node
	Message []byte
}

RemoteMessage is the message received from remote nodes

type RemoteNode

type RemoteNode struct {
	*Node

	sync.RWMutex
	// contains filtered or unexported fields
}

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 *RemoteNode) SendBytesSyncWithTimeout(buf []byte, replyTimeout time.Duration) ([]byte, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL