-
Notifications
You must be signed in to change notification settings - Fork 157
/
ilocalnode.go
73 lines (61 loc) · 2.26 KB
/
ilocalnode.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// interface of local node
package node
import (
"github.com/nknorg/nkn/v2/chain/pool"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/transaction"
"github.com/nknorg/nnet"
nnetnode "github.com/nknorg/nnet/node"
)
type IChordInfo interface{}
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{})
ComputeSharedKey(remotePublicKey []byte) (*[SharedKeySize]byte, error)
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
}