4
4
5
5
#include " lrucache.h"
6
6
7
- LRUCache::LRUCache ()
7
+ PrecomputeLRUCache::PrecomputeLRUCache ()
8
8
{
9
9
Clear ();
10
10
}
11
11
12
- void LRUCache ::Clear ()
12
+ void PrecomputeLRUCache ::Clear ()
13
13
{
14
14
cache_list.clear ();
15
15
mapCacheLocation.clear ();
16
16
mapDirtyWitnessData.clear ();
17
17
}
18
18
19
- void LRUCache ::AddNew (const uint256& hash, CoinWitnessCacheData& data)
19
+ void PrecomputeLRUCache ::AddNew (const uint256& hash, CoinWitnessCacheData& data)
20
20
{
21
21
cache_list.push_front (std::make_pair (hash, data));
22
22
mapCacheLocation.insert (make_pair (hash, cache_list.begin ()));
@@ -25,29 +25,29 @@ void LRUCache::AddNew(const uint256& hash, CoinWitnessCacheData& data)
25
25
mapDirtyWitnessData.erase (hash);
26
26
}
27
27
28
- int LRUCache ::Size () const
28
+ int PrecomputeLRUCache ::Size () const
29
29
{
30
30
return mapCacheLocation.size ();
31
31
}
32
32
33
- int LRUCache ::DirtyCacheSize () const
33
+ int PrecomputeLRUCache ::DirtyCacheSize () const
34
34
{
35
35
return mapDirtyWitnessData.size ();
36
36
}
37
37
38
- bool LRUCache ::Contains (const uint256& hash) const
38
+ bool PrecomputeLRUCache ::Contains (const uint256& hash) const
39
39
{
40
40
return mapCacheLocation.count (hash) > 0 || mapDirtyWitnessData.count (hash) > 0 ;
41
41
}
42
42
43
- void LRUCache ::MoveDirtyToLRU (const uint256& hash)
43
+ void PrecomputeLRUCache ::MoveDirtyToLRU (const uint256& hash)
44
44
{
45
45
auto data = CoinWitnessData (mapDirtyWitnessData.at (hash));
46
46
auto cachedata = CoinWitnessCacheData (&data);
47
47
AddNew (hash, cachedata);
48
48
}
49
49
50
- void LRUCache ::MoveLastToDirtyIfFull ()
50
+ void PrecomputeLRUCache ::MoveLastToDirtyIfFull ()
51
51
{
52
52
if (mapCacheLocation.size () > PRECOMPUTE_LRU_CACHE_SIZE) {
53
53
auto last_it = cache_list.end (); last_it --;
@@ -58,7 +58,7 @@ void LRUCache::MoveLastToDirtyIfFull()
58
58
}
59
59
}
60
60
61
- CoinWitnessData LRUCache ::GetWitnessData (const uint256& hash)
61
+ CoinWitnessData PrecomputeLRUCache ::GetWitnessData (const uint256& hash)
62
62
{
63
63
if (mapDirtyWitnessData.count (hash)) {
64
64
MoveDirtyToLRU (hash);
@@ -74,7 +74,7 @@ CoinWitnessData LRUCache::GetWitnessData(const uint256& hash)
74
74
return CoinWitnessData ();
75
75
}
76
76
77
- void LRUCache ::Remove (const uint256& hash)
77
+ void PrecomputeLRUCache ::Remove (const uint256& hash)
78
78
{
79
79
auto it = mapCacheLocation.find (hash);
80
80
if (it != mapCacheLocation.end ()) {
@@ -84,7 +84,7 @@ void LRUCache::Remove(const uint256& hash)
84
84
mapDirtyWitnessData.erase (hash);
85
85
}
86
86
87
- void LRUCache ::AddToCache (const uint256& hash, CoinWitnessCacheData& serialData)
87
+ void PrecomputeLRUCache ::AddToCache (const uint256& hash, CoinWitnessCacheData& serialData)
88
88
{
89
89
// If the LRU cache already has a entry for it, update the entry and move it to the front of the list
90
90
auto it = mapCacheLocation.find (hash);
@@ -100,7 +100,7 @@ void LRUCache::AddToCache(const uint256& hash, CoinWitnessCacheData& serialData)
100
100
MoveLastToDirtyIfFull ();
101
101
}
102
102
103
- void LRUCache ::FlushToDisk (CPrecomputeDB* pprecomputeDB)
103
+ void PrecomputeLRUCache ::FlushToDisk (CPrecomputeDB* pprecomputeDB)
104
104
{
105
105
// Save all cache data that was dirty back into the database
106
106
for (auto item : mapDirtyWitnessData) {
0 commit comments