-
Notifications
You must be signed in to change notification settings - Fork 211
/
interface.go
45 lines (36 loc) · 1.16 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
package beacon
import (
"context"
"time"
"github.com/spacemeshos/go-spacemesh/beacon/weakcoin"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/p2p"
)
//go:generate mockgen -typed -package=beacon -destination=./mocks.go -source=./interface.go
type coin interface {
StartEpoch(context.Context, types.EpochID)
StartRound(context.Context, types.RoundID, []weakcoin.Participant)
FinishRound(context.Context)
Get(context.Context, types.EpochID, types.RoundID) (bool, error)
FinishEpoch(context.Context, types.EpochID)
HandleProposal(context.Context, p2p.Peer, []byte) error
}
type eligibilityChecker interface {
PassThreshold(types.VrfSignature) bool
PassStrictThreshold(types.VrfSignature) bool
}
type layerClock interface {
LayerToTime(types.LayerID) time.Time
CurrentLayer() types.LayerID
AwaitLayer(types.LayerID) <-chan struct{}
}
type vrfSigner interface {
Sign(msg []byte) types.VrfSignature
NodeID() types.NodeID
}
type vrfVerifier interface {
Verify(nodeID types.NodeID, msg []byte, sig types.VrfSignature) bool
}
type nonceFetcher interface {
VRFNonce(types.NodeID, types.EpochID) (types.VRFPostIndex, error)
}