-
Notifications
You must be signed in to change notification settings - Fork 199
/
poolsHolderMock.go
96 lines (81 loc) · 3.3 KB
/
poolsHolderMock.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
package mock
import (
"github.com/ElrondNetwork/elrond-go/data/typeConverters/uint64ByteSlice"
"github.com/ElrondNetwork/elrond-go/dataRetriever"
"github.com/ElrondNetwork/elrond-go/dataRetriever/dataPool"
"github.com/ElrondNetwork/elrond-go/dataRetriever/shardedData"
"github.com/ElrondNetwork/elrond-go/storage"
"github.com/ElrondNetwork/elrond-go/storage/storageUnit"
)
type PoolsHolderMock struct {
transactions dataRetriever.ShardedDataCacherNotifier
unsignedTransactions dataRetriever.ShardedDataCacherNotifier
rewardTransactions dataRetriever.ShardedDataCacherNotifier
headers storage.Cacher
metaBlocks storage.Cacher
hdrNonces dataRetriever.Uint64SyncMapCacher
miniBlocks storage.Cacher
peerChangesBlocks storage.Cacher
metaHdrNonces dataRetriever.Uint64SyncMapCacher
}
func NewPoolsHolderMock() *PoolsHolderMock {
phf := &PoolsHolderMock{}
phf.transactions, _ = shardedData.NewShardedData(storageUnit.CacheConfig{Size: 10000, Type: storageUnit.LRUCache})
phf.unsignedTransactions, _ = shardedData.NewShardedData(storageUnit.CacheConfig{Size: 10000, Type: storageUnit.LRUCache})
phf.rewardTransactions, _ = shardedData.NewShardedData(storageUnit.CacheConfig{Size: 100, Type: storageUnit.LRUCache})
phf.headers, _ = storageUnit.NewCache(storageUnit.LRUCache, 10000, 1)
phf.metaBlocks, _ = storageUnit.NewCache(storageUnit.LRUCache, 10000, 1)
cacheHdrNonces, _ := storageUnit.NewCache(storageUnit.LRUCache, 10000, 1)
phf.hdrNonces, _ = dataPool.NewNonceSyncMapCacher(
cacheHdrNonces,
uint64ByteSlice.NewBigEndianConverter(),
)
cacheMetaHdrNonces, _ := storageUnit.NewCache(storageUnit.LRUCache, 10000, 1)
phf.metaHdrNonces, _ = dataPool.NewNonceSyncMapCacher(
cacheMetaHdrNonces,
uint64ByteSlice.NewBigEndianConverter(),
)
phf.miniBlocks, _ = storageUnit.NewCache(storageUnit.LRUCache, 10000, 1)
phf.peerChangesBlocks, _ = storageUnit.NewCache(storageUnit.LRUCache, 10000, 1)
return phf
}
func (phm *PoolsHolderMock) Transactions() dataRetriever.ShardedDataCacherNotifier {
return phm.transactions
}
func (phm *PoolsHolderMock) UnsignedTransactions() dataRetriever.ShardedDataCacherNotifier {
return phm.unsignedTransactions
}
func (phm *PoolsHolderMock) RewardTransactions() dataRetriever.ShardedDataCacherNotifier {
return phm.rewardTransactions
}
func (phm *PoolsHolderMock) Headers() storage.Cacher {
return phm.headers
}
func (phm *PoolsHolderMock) HeadersNonces() dataRetriever.Uint64SyncMapCacher {
return phm.hdrNonces
}
func (phm *PoolsHolderMock) MiniBlocks() storage.Cacher {
return phm.miniBlocks
}
func (phm *PoolsHolderMock) PeerChangesBlocks() storage.Cacher {
return phm.peerChangesBlocks
}
func (phm *PoolsHolderMock) MetaBlocks() storage.Cacher {
return phm.metaBlocks
}
func (phm *PoolsHolderMock) MetaHeadersNonces() dataRetriever.Uint64SyncMapCacher {
return phm.metaHdrNonces
}
func (phm *PoolsHolderMock) SetTransactions(transactions dataRetriever.ShardedDataCacherNotifier) {
phm.transactions = transactions
}
func (phm *PoolsHolderMock) SetUnsignedTransactions(scrs dataRetriever.ShardedDataCacherNotifier) {
phm.unsignedTransactions = scrs
}
// IsInterfaceNil returns true if there is no value under the interface
func (phf *PoolsHolderMock) IsInterfaceNil() bool {
if phf == nil {
return true
}
return false
}