-
Notifications
You must be signed in to change notification settings - Fork 199
/
feeAccumulatorStub.go
66 lines (56 loc) · 2 KB
/
feeAccumulatorStub.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package mock
import (
"math/big"
"github.com/multiversx/mx-chain-core-go/data/scheduled"
)
// FeeAccumulatorStub is a stub which implements TransactionFeeHandler interface
type FeeAccumulatorStub struct {
CreateBlockStartedCalled func(gasAndFees scheduled.GasAndFees)
GetAccumulatedFeesCalled func() *big.Int
GetDeveloperFeesCalled func() *big.Int
ProcessTransactionFeeCalled func(cost *big.Int, devFee *big.Int, hash []byte)
ProcessTransactionFeeRelayedUserTxCalled func(cost *big.Int, devFee *big.Int, userTxHash []byte, originalTxHash []byte)
RevertFeesCalled func(txHashes [][]byte)
}
// RevertFees -
func (f *FeeAccumulatorStub) RevertFees(txHashes [][]byte) {
if f.RevertFeesCalled != nil {
f.RevertFeesCalled(txHashes)
}
}
// CreateBlockStarted -
func (f *FeeAccumulatorStub) CreateBlockStarted(gasAndFees scheduled.GasAndFees) {
if f.CreateBlockStartedCalled != nil {
f.CreateBlockStartedCalled(gasAndFees)
}
}
// GetAccumulatedFees -
func (f *FeeAccumulatorStub) GetAccumulatedFees() *big.Int {
if f.GetAccumulatedFeesCalled != nil {
return f.GetAccumulatedFeesCalled()
}
return big.NewInt(0)
}
// GetDeveloperFees -
func (f *FeeAccumulatorStub) GetDeveloperFees() *big.Int {
if f.GetDeveloperFeesCalled != nil {
return f.GetDeveloperFeesCalled()
}
return big.NewInt(0)
}
// ProcessTransactionFee -
func (f *FeeAccumulatorStub) ProcessTransactionFee(cost *big.Int, devFee *big.Int, txHash []byte) {
if f.ProcessTransactionFeeCalled != nil {
f.ProcessTransactionFeeCalled(cost, devFee, txHash)
}
}
// ProcessTransactionFeeRelayedUserTx -
func (f *FeeAccumulatorStub) ProcessTransactionFeeRelayedUserTx(cost *big.Int, devFee *big.Int, userTxHash []byte, originalTxHash []byte) {
if f.ProcessTransactionFeeRelayedUserTxCalled != nil {
f.ProcessTransactionFeeRelayedUserTxCalled(cost, devFee, userTxHash, originalTxHash)
}
}
// IsInterfaceNil -
func (f *FeeAccumulatorStub) IsInterfaceNil() bool {
return f == nil
}