-
Notifications
You must be signed in to change notification settings - Fork 197
/
blockSizeThrottlerStub.go
51 lines (43 loc) · 1.16 KB
/
blockSizeThrottlerStub.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
package mock
import (
"github.com/ElrondNetwork/elrond-go-core/core"
)
// BlockSizeThrottlerStub -
type BlockSizeThrottlerStub struct {
GetCurrentMaxSizeCalled func() uint32
AddCalled func(round uint64, size uint32)
SucceedCalled func(round uint64)
ComputeCurrentMaxSizeCalled func()
}
// GetCurrentMaxSize -
func (bsts *BlockSizeThrottlerStub) GetCurrentMaxSize() uint32 {
if bsts.GetCurrentMaxSizeCalled != nil {
return bsts.GetCurrentMaxSizeCalled()
}
return uint32(core.MegabyteSize * 90 / 100)
}
// Add -
func (bsts *BlockSizeThrottlerStub) Add(round uint64, size uint32) {
if bsts.AddCalled != nil {
bsts.AddCalled(round, size)
return
}
}
// Succeed -
func (bsts *BlockSizeThrottlerStub) Succeed(round uint64) {
if bsts.SucceedCalled != nil {
bsts.SucceedCalled(round)
return
}
}
// ComputeCurrentMaxSize -
func (bsts *BlockSizeThrottlerStub) ComputeCurrentMaxSize() {
if bsts.ComputeCurrentMaxSizeCalled != nil {
bsts.ComputeCurrentMaxSizeCalled()
return
}
}
// IsInterfaceNil returns true if there is no value under the interface
func (bsts *BlockSizeThrottlerStub) IsInterfaceNil() bool {
return bsts == nil
}