-
Notifications
You must be signed in to change notification settings - Fork 0
/
shardCoordinatorStub.go
49 lines (42 loc) · 1.41 KB
/
shardCoordinatorStub.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
package mock
// ShardCoordinatorStub -
type ShardCoordinatorStub struct {
NumberOfShardsCalled func() uint32
ComputeIdCalled func(address []byte) uint32
SelfIdCalled func() uint32
SameShardCalled func(firstAddress, secondAddress []byte) bool
CommunicationIdentifierCalled func(destShardID uint32) string
}
// NumberOfShards -
func (coordinator *ShardCoordinatorStub) NumberOfShards() uint32 {
if coordinator.NumberOfShardsCalled != nil {
return coordinator.NumberOfShardsCalled()
}
return 1
}
// ComputeId -
func (coordinator *ShardCoordinatorStub) ComputeId(address []byte) uint32 {
if coordinator.ComputeIdCalled != nil {
return coordinator.ComputeIdCalled(address)
}
return 0
}
// SelfId -
func (coordinator *ShardCoordinatorStub) SelfId() uint32 {
if coordinator.SelfIdCalled != nil {
return coordinator.SelfIdCalled()
}
return 0
}
// SameShard -
func (coordinator *ShardCoordinatorStub) SameShard(firstAddress, secondAddress []byte) bool {
return coordinator.SameShardCalled(firstAddress, secondAddress)
}
// CommunicationIdentifier -
func (coordinator *ShardCoordinatorStub) CommunicationIdentifier(destShardID uint32) string {
return coordinator.CommunicationIdentifierCalled(destShardID)
}
// IsInterfaceNil returns true if there is no value under the interface
func (coordinator *ShardCoordinatorStub) IsInterfaceNil() bool {
return coordinator == nil
}