Documentation ¶
Overview ¶
interface of local node
ln: abbr. of local node
Index ¶
- Constants
- Variables
- func DecryptMessage(message []byte, sharedKey *[SharedKeySize]byte) ([]byte, bool, error)
- func EncryptMessage(message []byte, sharedKey *[SharedKeySize]byte) []byte
- type IChordInfo
- type ILocalNode
- type MessageHandler
- type MessageHandlerStore
- 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() []byte
- 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 RemoteMessage
- type RemoteNode
- func (remoteNode *RemoteNode) CloseConn()
- func (remoteNode *RemoteNode) DecryptMessage(message []byte) ([]byte, bool, error)
- func (remoteNode *RemoteNode) EncryptMessage(message []byte) []byte
- func (remoteNode *RemoteNode) GetHeight() uint32
- func (remoteNode *RemoteNode) GetLastUpdateTime() time.Time
- func (remoteNode *RemoteNode) IsStopped() bool
- 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 ¶
View Source
const (
)for encryption
Variables ¶
View Source
var EmptyNonce [nonceSize]byte
Functions ¶
func DecryptMessage ¶ added in v2.2.0
func EncryptMessage ¶ added in v2.2.0
func EncryptMessage(message []byte, sharedKey *[SharedKeySize]byte) []byte
Types ¶
type IChordInfo ¶ added in v2.2.0
type IChordInfo interface{}
type ILocalNode ¶ added in v2.2.0
type ILocalNode interface { // info GetNeighborInfo() []*RemoteNode GetChordInfo() IChordInfo // node GetMinVerifiableHeight() uint32 GetChordID() []byte // handler AddMessageHandler(messageType pb.MessageType, handler MessageHandler) SerializeMessage(unsignedMsg *pb.UnsignedMessage, sign bool) ([]byte, error) // localNode MarshalJSON() ([]byte, error) Start() error GetProposalSubmitted() uint32 IncrementProposalSubmitted() GetRelayMessageCount() uint64 IncrementRelayMessageCount() GetTxnPool() *pool.TxnPool GetHeight() uint32 SetSyncState(s pb.SyncState) bool GetSyncState() pb.SyncState SetMinVerifiableHeight(height uint32) GetWsAddr() string GetWssAddr() string FindSuccessorAddrs(key []byte, numSucc int) ([]string, error) FindWsAddr(key []byte) (string, string, []byte, []byte, error) FindWssAddr(key []byte) (string, string, []byte, []byte, error) CheckIDChange(v interface{}) GetNnet() *nnet.NNet // neighbor GetNeighborByNNetNode(nnetRemoteNode *nnetnode.RemoteNode) *RemoteNode GetGossipNeighbors(filter func(*RemoteNode) bool) []*RemoteNode GetVotingNeighbors(filter func(*RemoteNode) bool) []*RemoteNode VerifySigChain(sc *pb.SigChain, height uint32) error VerifySigChainObjection(sc *pb.SigChain, reporterID []byte, height uint32) (int, error) GetNeighborNode(id string) *RemoteNode RemoveNeighborNode(id string) // relay SendRelayMessage(srcAddr, destAddr string, payload, signature, blockHash []byte, nonce, maxHoldingSeconds uint32) error NewSignatureChainObjectionMessage(height uint32, sigHash []byte) (*pb.UnsignedMessage, error) StartSyncing(syncStopHash common.Uint256, syncStopHeight uint32, neighbors []*RemoteNode) (bool, error) ResetSyncing() BroadcastTransaction(txn *transaction.Transaction) error // neighborNodes GetConnectionCnt() uint GetNeighbors(filter func(*RemoteNode) bool) []*RemoteNode // txnpool AppendTxnPool(txn *transaction.Transaction) error }
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 MessageHandlerStore ¶ added in v2.2.0
type MessageHandlerStore map[pb.MessageType][]MessageHandler
messageHandlerStore is the map from message type to message handler
func NewMessageHandlerStore ¶ added in v2.2.0
func NewMessageHandlerStore() *MessageHandlerStore
func (MessageHandlerStore) AddMessageHandler ¶ added in v2.2.0
func (handlerStore MessageHandlerStore) AddMessageHandler(messageType pb.MessageType, handler MessageHandler)
AddMessageHandler adds a message handler to a message type
func (MessageHandlerStore) GetMessageHandlers ¶ added in v2.2.0
func (handlerStore MessageHandlerStore) GetMessageHandlers(messageType pb.MessageType) []MessageHandler
GetMessageHandlers gets all handlers of a message type
type Node ¶
type Node struct { *nnetpb.Node *pb.NodeData StartTime time.Time 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 RemoteMessage ¶
RemoteMessage is the message received from remote nodes
type RemoteNode ¶
type RemoteNode struct { *Node NnetNode *nnetnode.RemoteNode sync.RWMutex // contains filtered or unexported fields }
func NewRemoteNode ¶
func NewRemoteNode(localNode ILocalNode, nnetNode *nnetnode.RemoteNode) (*RemoteNode, error)
func (*RemoteNode) CloseConn ¶
func (remoteNode *RemoteNode) CloseConn()
func (*RemoteNode) DecryptMessage ¶ added in v2.2.0
func (remoteNode *RemoteNode) DecryptMessage(message []byte) ([]byte, bool, error)
func (*RemoteNode) EncryptMessage ¶ added in v2.2.0
func (remoteNode *RemoteNode) EncryptMessage(message []byte) []byte
func (*RemoteNode) GetHeight ¶
func (remoteNode *RemoteNode) GetHeight() uint32
func (*RemoteNode) GetLastUpdateTime ¶
func (remoteNode *RemoteNode) GetLastUpdateTime() time.Time
func (*RemoteNode) IsStopped ¶ added in v2.1.7
func (remoteNode *RemoteNode) IsStopped() bool
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
Click to show internal directories.
Click to hide internal directories.