lnode

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const NumNbrToSyncRandAddr = 1

Number of random neighbors to sync rand addr

View Source
const NumNbrToSyncTxnPool = 1

Number of random neighbors to sync txn pool

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, hash []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 NewGetStateMessage

func NewGetStateMessage(hashes []common.Uint256) (*pb.UnsignedMessage, error)

NewGetStateMessage creates a GET_STATES message

func NewGetStatesReply

func NewGetStatesReply(nodes [][]byte) (*pb.UnsignedMessage, error)

NewGetStatesReply creates a GET_STATES_REPLY message in respond to GET_STATES message

func NewIHaveSignatureChainTransactionMessage

func NewIHaveSignatureChainTransactionMessage(height uint32, sigHash []byte) (*pb.UnsignedMessage, error)

NewIHaveSignatureChainTransactionMessage creates a I_HAVE_SIGNATURE_CHAIN_TRANSACTION message

func NewPinSigChainMessage

func NewPinSigChainMessage(hash []byte) (*pb.UnsignedMessage, error)

NewPinSigChainMessage creates a PIN_SIGNATURE_CHAIN message

func NewRelayMessage

func NewRelayMessage(srcIdentifier string, srcPubkey, destID, payload, blockHash, lastHash []byte, maxHoldingSeconds uint32) (*pb.UnsignedMessage, error)

NewRelayMessage creates a RELAY message

func NewReqAddrNonceMessage

func NewReqAddrNonceMessage() (*pb.UnsignedMessage, error)

build a REQ_ADDR_NONCE request message

func NewReqSyncAddrTxnMessage

func NewReqSyncAddrTxnMessage(addr []byte, nonce uint64) (*pb.UnsignedMessage, error)

build REQ_SYNC_ADDR_TXN request message This message includse my txn pool's txn address and maximum nonce.

func NewReqSyncTxnPoolMessage

func NewReqSyncTxnPoolMessage(tp *pool.TxnPool) (*pb.UnsignedMessage, error)

build REQ_SYNC_TXN_POOL request message. This message includse my txn pool's txn address and maximum nonce.

func NewReqTxnPoolHashMessage

func NewReqTxnPoolHashMessage() (*pb.UnsignedMessage, error)

build a REQ_TXN_POOL_HASH request 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 NewRplAddrNonceMessage

func NewRplAddrNonceMessage(tp *pool.TxnPool) (*pb.UnsignedMessage, error)

build RPL_ADDR_NONCE reply message reply with rand address my txn pool's with this address' nonce.

func NewRplSyncAddrTxnMessage

func NewRplSyncAddrTxnMessage(reqMsg *pb.AddrNonce, tp *pool.TxnPool) (*pb.UnsignedMessage, error)

build RPL_SYNC_ADDR_TXN message. reply transactions which are needed to sync to the requestor.

func NewRplSyncTxnPoolMessage

func NewRplSyncTxnPoolMessage(reqMsg *pb.RequestSyncTxnPool, tp *pool.TxnPool) (*pb.UnsignedMessage, error)

build RPL_SYNC_TXN_POOL message. reply transactions which are needed to sync to the requestor.

func NewRplTxnPoolHashMessage

func NewRplTxnPoolHashMessage(tp *pool.TxnPool) (*pb.UnsignedMessage, error)

build RPL_TXN_POOL_HASH reply message, reply with my txn pool's hash and txn count.

func NewTransactionsMessage

func NewTransactionsMessage(transactions []*transaction.Transaction) (*pb.UnsignedMessage, error)

NewTransactionsMessage creates a TRANSACTIONS message

func ShouldRejectAddr

func ShouldRejectAddr(localAddr, remoteAddr string) bool

ShouldRejectAddr returns if remoteAddr should be rejected by localAddr

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 struct {
	// contains filtered or unexported fields
}

func (*ChordRemoteNodeInfo) MarshalJSON

func (crn *ChordRemoteNodeInfo) MarshalJSON() ([]byte, error)

type LocalNode

type LocalNode struct {
	*node.Node

	*pool.TxnPool // transaction pool of local node

	*node.MessageHandlerStore
	// contains filtered or unexported fields
}

func NewLocalNode

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

func (*LocalNode) BroadcastTransaction

func (localNode *LocalNode) BroadcastTransaction(txn *transaction.Transaction) error

BroadcastTransaction broadcast a transaction to the network using TRANSACTIONS message

func (*LocalNode) CheckIDChange

func (localNode *LocalNode) CheckIDChange(v interface{})

func (*LocalNode) ComputeSharedKey

func (localNode *LocalNode) ComputeSharedKey(remotePublicKey []byte) (*[node.SharedKeySize]byte, error)

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, string, []byte, []byte, error)

func (*LocalNode) FindWssAddr

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

func (*LocalNode) GetChordInfo

func (localNode *LocalNode) GetChordInfo() node.IChordInfo

func (LocalNode) GetConnectionCnt

func (nm LocalNode) GetConnectionCnt() uint

func (*LocalNode) GetGossipNeighbors

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

func (*LocalNode) GetHeight

func (localNode *LocalNode) GetHeight() uint32

func (*LocalNode) GetNeighborBlockHeaders

func (localNode *LocalNode) GetNeighborBlockHeaders(remoteNode *node.RemoteNode, startHeight, endHeight uint32) ([]*block.Header, error)

GetBlockHeaders requests a range of consecutive block headers from a neighbor using GET_BLOCK_HEADERS message

func (*LocalNode) GetNeighborBlocks

func (localNode *LocalNode) GetNeighborBlocks(remoteNode *node.RemoteNode, startHeight, endHeight uint32) ([]*block.Block, error)

GetBlocks requests a range of consecutive blocks from a neighbor using GET_BLOCKS message

func (*LocalNode) GetNeighborByNNetNode

func (localNode *LocalNode) GetNeighborByNNetNode(nnetRemoteNode *nnetnode.RemoteNode) *node.RemoteNode

func (LocalNode) GetNeighborHeights

func (nm LocalNode) GetNeighborHeights() ([]uint32, uint)

func (*LocalNode) GetNeighborInfo

func (localNode *LocalNode) GetNeighborInfo() []*node.RemoteNode

func (LocalNode) GetNeighborNode

func (nm LocalNode) GetNeighborNode(id string) *node.RemoteNode

func (*LocalNode) GetNeighborStates

func (localNode *LocalNode) GetNeighborStates(remoteNode *node.RemoteNode, hashes []common.Uint256) ([][]byte, error)

func (LocalNode) GetNeighbors

func (nm LocalNode) GetNeighbors(filter func(*node.RemoteNode) bool) []*node.RemoteNode

func (*LocalNode) GetNeighborsMajorityStateRootByHeight

func (localNode *LocalNode) GetNeighborsMajorityStateRootByHeight(height uint32, neighbors []*node.RemoteNode) common.Uint256

func (*LocalNode) GetNnet

func (localNode *LocalNode) GetNnet() *nnet.NNet

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(*node.RemoteNode) bool) []*node.RemoteNode

func (*LocalNode) GetWsAddr

func (localNode *LocalNode) GetWsAddr() string

func (*LocalNode) GetWssAddr

func (localNode *LocalNode) GetWssAddr() 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) NewSignatureChainObjectionMessage

func (localNode *LocalNode) NewSignatureChainObjectionMessage(height uint32, sigHash []byte) (*pb.UnsignedMessage, error)

NewSignatureChainObjectionMessage creates a SIGNATURE_CHAIN_OBJECTION message

func (LocalNode) RemoveNeighborNode

func (nm LocalNode) RemoveNeighborNode(id string)

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

func (localNode *LocalNode) StartFastSyncing(syncRootHash common.Uint256, peers []*node.RemoteNode) error

StartFastSyncing quickly download the headers, full sync only at the chain

func (*LocalNode) StartSyncRandAddrTxn

func (localNode *LocalNode) StartSyncRandAddrTxn()

func (*LocalNode) StartSyncTxnPool

func (localNode *LocalNode) StartSyncTxnPool()

func (*LocalNode) StartSyncing

func (localNode *LocalNode) StartSyncing(syncStopHash common.Uint256, syncStopHeight uint32, neighbors []*node.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

func (*LocalNode) SyncRandAddrTxn

func (localNode *LocalNode) SyncRandAddrTxn()

sync rand addr process

func (*LocalNode) SyncTxnPool

func (localNode *LocalNode) SyncTxnPool()

sync txn pool process

func (*LocalNode) VerifySigChain

func (localNode *LocalNode) VerifySigChain(sc *pb.SigChain, height uint32) error

func (*LocalNode) VerifySigChainObjection

func (localNode *LocalNode) VerifySigChainObjection(sc *pb.SigChain, reporterID []byte, height uint32) (int, error)

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

Jump to

Keyboard shortcuts

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