@@ -69,45 +69,62 @@ 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;
94
+ ++iter)
95
+ {
96
+ if (iter.pos () < lowerBound)
97
+ {
98
+ iter.seek (lowerBound);
99
+ }
100
+ BucketEntry const & entry = *iter;
101
+ if (entry.type () == LIVEENTRY || entry.type () == INITENTRY)
102
+ {
103
+ auto const & e = entry.liveEntry ();
104
+ auto const & k = LedgerEntryKey (e);
105
+ if (!cache->supportedKeyType (k.type ()))
88
106
{
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
- }
107
+ continue ;
97
108
}
98
- else if (entry.type () == DEADENTRY)
109
+ // If the key is not in the dead keys set and not already in the
110
+ // cache, add it.
111
+ if (mDeadKeys .find (k) == mDeadKeys .end () && !cache->getEntry (k))
99
112
{
100
- if (!cache->getEntry (entry.deadEntry ()))
101
- {
102
- mDeadKeys .insert (entry.deadEntry ());
103
- }
113
+ cache->addEntry (e);
104
114
}
105
- else
115
+ }
116
+ else if (entry.type () == DEADENTRY)
117
+ {
118
+ if (!cache->getEntry (entry.deadEntry ()))
106
119
{
107
- releaseAssert (false );
108
- continue ;
120
+ mDeadKeys .insert (entry.deadEntry ());
109
121
}
110
122
}
123
+ else
124
+ {
125
+ releaseAssert (false );
126
+ continue ;
127
+ }
111
128
}
112
129
return advance ();
113
130
}
0 commit comments