-
Notifications
You must be signed in to change notification settings - Fork 199
/
poolsHolderStub.go
110 lines (88 loc) · 2.74 KB
/
poolsHolderStub.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package testscommon
import (
"github.com/ElrondNetwork/elrond-go/dataRetriever"
"github.com/ElrondNetwork/elrond-go/storage"
)
// PoolsHolderStub -
type PoolsHolderStub struct {
HeadersCalled func() dataRetriever.HeadersPool
TransactionsCalled func() dataRetriever.ShardedDataCacherNotifier
UnsignedTransactionsCalled func() dataRetriever.ShardedDataCacherNotifier
RewardTransactionsCalled func() dataRetriever.ShardedDataCacherNotifier
MiniBlocksCalled func() storage.Cacher
MetaBlocksCalled func() storage.Cacher
CurrBlockTxsCalled func() dataRetriever.TransactionCacher
TrieNodesCalled func() storage.Cacher
PeerChangesBlocksCalled func() storage.Cacher
}
// NewPoolsHolderStub -
func NewPoolsHolderStub() *PoolsHolderStub {
return &PoolsHolderStub{}
}
// Headers -
func (holder *PoolsHolderStub) Headers() dataRetriever.HeadersPool {
if holder.HeadersCalled != nil {
return holder.HeadersCalled()
}
return nil
}
// Transactions -
func (holder *PoolsHolderStub) Transactions() dataRetriever.ShardedDataCacherNotifier {
if holder.TransactionsCalled != nil {
return holder.TransactionsCalled()
}
return NewShardedDataStub()
}
// UnsignedTransactions -
func (holder *PoolsHolderStub) UnsignedTransactions() dataRetriever.ShardedDataCacherNotifier {
if holder.UnsignedTransactionsCalled != nil {
return holder.UnsignedTransactionsCalled()
}
return NewShardedDataStub()
}
// RewardTransactions -
func (holder *PoolsHolderStub) RewardTransactions() dataRetriever.ShardedDataCacherNotifier {
if holder.RewardTransactionsCalled != nil {
return holder.RewardTransactionsCalled()
}
return NewShardedDataStub()
}
// MiniBlocks -
func (holder *PoolsHolderStub) MiniBlocks() storage.Cacher {
if holder.MiniBlocksCalled != nil {
return holder.MiniBlocksCalled()
}
return NewCacherStub()
}
// MetaBlocks -
func (holder *PoolsHolderStub) MetaBlocks() storage.Cacher {
if holder.MetaBlocksCalled != nil {
return holder.MetaBlocksCalled()
}
return NewCacherStub()
}
// CurrentBlockTxs -
func (holder *PoolsHolderStub) CurrentBlockTxs() dataRetriever.TransactionCacher {
if holder.CurrBlockTxsCalled != nil {
return holder.CurrBlockTxsCalled()
}
return nil
}
// TrieNodes -
func (holder *PoolsHolderStub) TrieNodes() storage.Cacher {
if holder.TrieNodesCalled != nil {
return holder.TrieNodesCalled()
}
return NewCacherStub()
}
// PeerChangesBlocks -
func (holder *PoolsHolderStub) PeerChangesBlocks() storage.Cacher {
if holder.PeerChangesBlocksCalled != nil {
return holder.PeerChangesBlocksCalled()
}
return NewCacherStub()
}
// IsInterfaceNil returns true if there is no value under the interface
func (holder *PoolsHolderStub) IsInterfaceNil() bool {
return holder == nil
}