-
Notifications
You must be signed in to change notification settings - Fork 199
/
interface.go
70 lines (61 loc) · 2.37 KB
/
interface.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
package heartbeat
import (
"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/data"
"github.com/ElrondNetwork/elrond-go-crypto"
"github.com/ElrondNetwork/elrond-go/common"
"github.com/ElrondNetwork/elrond-go/sharding/nodesCoordinator"
"github.com/ElrondNetwork/elrond-go/state"
)
// P2PMessenger defines a subset of the p2p.Messenger interface
type P2PMessenger interface {
Broadcast(topic string, buff []byte)
ID() core.PeerID
Sign(payload []byte) ([]byte, error)
ConnectedPeersOnTopic(topic string) []core.PeerID
IsInterfaceNil() bool
}
// PeerTypeProviderHandler defines what a component which computes the type of a peer should do
type PeerTypeProviderHandler interface {
ComputeForPubKey(pubKey []byte) (common.PeerType, uint32, error)
GetAllPeerTypeInfos() []*state.PeerTypeInfo
IsInterfaceNil() bool
}
// HardforkTrigger defines the behavior of a hardfork trigger
type HardforkTrigger interface {
TriggerReceived(payload []byte, data []byte, pkBytes []byte) (bool, error)
RecordedTriggerMessage() ([]byte, bool)
NotifyTriggerReceivedV2() <-chan struct{}
CreateData() []byte
IsInterfaceNil() bool
}
// CurrentBlockProvider can provide the current block that the node was able to commit
type CurrentBlockProvider interface {
GetCurrentBlockHeader() data.HeaderHandler
SetCurrentBlockHeaderAndRootHash(bh data.HeaderHandler, rootHash []byte) error
IsInterfaceNil() bool
}
// NodeRedundancyHandler defines the interface responsible for the redundancy management of the node
type NodeRedundancyHandler interface {
IsRedundancyNode() bool
IsMainMachineActive() bool
ObserverPrivateKey() crypto.PrivateKey
IsInterfaceNil() bool
}
// NodesCoordinator defines the behavior of a struct able to do validator selection
type NodesCoordinator interface {
GetAllEligibleValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error)
GetAllWaitingValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error)
GetValidatorWithPublicKey(publicKey []byte) (validator nodesCoordinator.Validator, shardId uint32, err error)
IsInterfaceNil() bool
}
// PeerShardMapper saves the shard for a peer ID
type PeerShardMapper interface {
PutPeerIdShardId(pid core.PeerID, shardID uint32)
IsInterfaceNil() bool
}
// TrieSyncStatisticsProvider is able to provide trie sync statistics
type TrieSyncStatisticsProvider interface {
NumProcessed() int
IsInterfaceNil() bool
}