-
Notifications
You must be signed in to change notification settings - Fork 199
/
epochNotifierStub.go
46 lines (39 loc) · 1.09 KB
/
epochNotifierStub.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
package mock
import (
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-core/data"
vmcommon "github.com/ElrondNetwork/elrond-vm-common"
)
// EpochNotifierStub -
type EpochNotifierStub struct {
CheckEpochCalled func(header data.HeaderHandler)
CurrentEpochCalled func() uint32
RegisterNotifyHandlerCalled func(handler vmcommon.EpochSubscriberHandler)
}
// CheckEpoch -
func (ens *EpochNotifierStub) CheckEpoch(header data.HeaderHandler) {
if ens.CheckEpochCalled != nil {
ens.CheckEpochCalled(header)
}
}
// RegisterNotifyHandler -
func (ens *EpochNotifierStub) RegisterNotifyHandler(handler vmcommon.EpochSubscriberHandler) {
if ens.RegisterNotifyHandlerCalled != nil {
ens.RegisterNotifyHandlerCalled(handler)
} else {
if !check.IfNil(handler) {
handler.EpochConfirmed(0, 0)
}
}
}
// CurrentEpoch -
func (ens *EpochNotifierStub) CurrentEpoch() uint32 {
if ens.CurrentEpochCalled != nil {
return ens.CurrentEpochCalled()
}
return 0
}
// IsInterfaceNil -
func (ens *EpochNotifierStub) IsInterfaceNil() bool {
return ens == nil
}