@@ -69,45 +69,61 @@ PopulateLedgerCacheWork::doWork()
69
69
mBucketToProcessIndex );
70
70
return advance ();
71
71
}
72
-
73
- auto contractEntryRange = bucket->getContractEntryRange ();
74
72
auto ledgerStateCache = mApp .getLedgerManager ().getLedgerStateCache ();
75
- if (ledgerStateCache && contractEntryRange )
73
+ if (! ledgerStateCache)
76
74
{
77
- auto cache = ledgerStateCache.value ();
78
- auto [lowerBound, upperBound] = *contractEntryRange;
79
- for (LiveBucketInputIterator iter (bucket);
80
- iter && iter.pos () < upperBound; ++iter)
75
+ CLOG_DEBUG (Ledger, " LedgerStateCache is not enabled" );
76
+ return State::WORK_FAILURE;
77
+ }
78
+
79
+ auto cache = ledgerStateCache.value ();
80
+ std::streamoff upperBound = 0 ;
81
+ std::streamoff lowerBound = std::numeric_limits<std::streamoff>::max ();
82
+ if (cache->getMode () == LedgerStateCache::Mode::SOROBAN_ONLY)
83
+ {
84
+ // Update the bounds to only iterate over soroban state.
85
+ auto contractEntryRange = bucket->getContractEntryRange ();
86
+ if (contractEntryRange)
81
87
{
82
- if (iter.pos () < lowerBound)
83
- {
84
- iter.seek (lowerBound);
85
- }
86
- BucketEntry const & entry = *iter;
87
- if (entry.type () == LIVEENTRY || entry.type () == INITENTRY)
88
+ lowerBound = std::get<0 >(*contractEntryRange);
89
+ upperBound = std::get<1 >(*contractEntryRange);
90
+ }
91
+ }
92
+
93
+ for (LiveBucketInputIterator iter (bucket); iter && iter.pos () < upperBound; ++iter)
94
+ {
95
+ if (iter.pos () < lowerBound)
96
+ {
97
+ iter.seek (lowerBound);
98
+ }
99
+ BucketEntry const & entry = *iter;
100
+ if (entry.type () == LIVEENTRY || entry.type () == INITENTRY)
101
+ {
102
+ auto const & e = entry.liveEntry ();
103
+ auto const & k = LedgerEntryKey (e);
104
+ if (!cache->supportedKeyType (k.type ()))
88
105
{
89
- auto const & e = entry.liveEntry ();
90
- auto const & k = LedgerEntryKey (e);
91
- // If the key is not in the dead keys set and not already in the
92
- // cache, add it.
93
- if (mDeadKeys .find (k) == mDeadKeys .end () && !cache->getEntry (k))
94
- {
95
- cache->addEntry (e);
96
- }
106
+ continue ;
97
107
}
98
- else if (entry.type () == DEADENTRY)
108
+ // If the key is not in the dead keys set and not already in the
109
+ // cache, add it.
110
+ if (mDeadKeys .find (k) == mDeadKeys .end () && !cache->getEntry (k))
99
111
{
100
- if (!cache->getEntry (entry.deadEntry ()))
101
- {
102
- mDeadKeys .insert (entry.deadEntry ());
103
- }
112
+ cache->addEntry (e);
104
113
}
105
- else
114
+ }
115
+ else if (entry.type () == DEADENTRY)
116
+ {
117
+ if (!cache->getEntry (entry.deadEntry ()))
106
118
{
107
- releaseAssert (false );
108
- continue ;
119
+ mDeadKeys .insert (entry.deadEntry ());
109
120
}
110
121
}
122
+ else
123
+ {
124
+ releaseAssert (false );
125
+ continue ;
126
+ }
111
127
}
112
128
return advance ();
113
129
}
0 commit comments