-
Notifications
You must be signed in to change notification settings - Fork 199
/
blockNotifierHandlerStub.go
40 lines (33 loc) · 1.19 KB
/
blockNotifierHandlerStub.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
package mock
import (
"github.com/ElrondNetwork/elrond-go-core/data"
)
// BlockNotifierHandlerStub -
type BlockNotifierHandlerStub struct {
CallHandlersCalled func(shardID uint32, headers []data.HeaderHandler, headersHashes [][]byte)
RegisterHandlerCalled func(handler func(shardID uint32, headers []data.HeaderHandler, headersHashes [][]byte))
GetNumRegisteredHandlersCalled func() int
}
// CallHandlers -
func (bnhs *BlockNotifierHandlerStub) CallHandlers(shardID uint32, headers []data.HeaderHandler, headersHashes [][]byte) {
if bnhs.CallHandlersCalled != nil {
bnhs.CallHandlersCalled(shardID, headers, headersHashes)
}
}
// RegisterHandler -
func (bnhs *BlockNotifierHandlerStub) RegisterHandler(handler func(shardID uint32, headers []data.HeaderHandler, headersHashes [][]byte)) {
if bnhs.RegisterHandlerCalled != nil {
bnhs.RegisterHandlerCalled(handler)
}
}
// GetNumRegisteredHandlers -
func (bnhs *BlockNotifierHandlerStub) GetNumRegisteredHandlers() int {
if bnhs.GetNumRegisteredHandlersCalled != nil {
return bnhs.GetNumRegisteredHandlersCalled()
}
return 0
}
// IsInterfaceNil -
func (bnhs *BlockNotifierHandlerStub) IsInterfaceNil() bool {
return bnhs == nil
}