Skip to content

Commit 6f3e622

Browse files
committed
Refactor metadata extraction.
1 parent faa544c commit 6f3e622

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

  • cmd/soroban-cli/src/commands/snapshot

cmd/soroban-cli/src/commands/snapshot/create.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,40 +309,47 @@ impl Cmd {
309309
continue;
310310
}
311311
};
312+
312313
if seen.contains(&key) {
313314
continue;
314315
}
315316

316-
// Extract TTL settings from StateArchival config entries before filtering
317-
let Some(val) = val else { continue };
318-
if let LedgerEntryData::ConfigSetting(ConfigSettingEntry::StateArchival(
319-
state_archival,
320-
)) = &val.data
321-
{
322-
snapshot.min_persistent_entry_ttl = state_archival.min_persistent_ttl;
323-
snapshot.min_temp_entry_ttl = state_archival.min_temporary_ttl;
324-
snapshot.max_entry_ttl = state_archival.max_entry_ttl;
325-
}
326-
327317
let keep = match &key {
328318
LedgerKey::Account(k) => current.account_ids.contains(&k.account_id),
329319
LedgerKey::Trustline(k) => current.account_ids.contains(&k.account_id),
330320
LedgerKey::ContractData(k) => current.contract_ids.contains(&k.contract),
331321
LedgerKey::ContractCode(e) => current.wasm_hashes.contains(&e.hash),
322+
LedgerKey::ConfigSetting(_) => true,
332323
_ => false,
333324
};
325+
334326
if !keep {
335327
continue;
336328
}
329+
337330
seen.insert(key.clone());
331+
332+
let Some(val) = val else {
333+
continue;
334+
};
335+
338336
match &val.data {
337+
LedgerEntryData::ConfigSetting(ConfigSettingEntry::StateArchival(
338+
state_archival,
339+
)) => {
340+
snapshot.min_persistent_entry_ttl = state_archival.min_persistent_ttl;
341+
snapshot.min_temp_entry_ttl = state_archival.min_temporary_ttl;
342+
snapshot.max_entry_ttl = state_archival.max_entry_ttl;
343+
false
344+
}
345+
339346
LedgerEntryData::ContractData(e) => {
340347
// If a contract instance references contract
341348
// executable stored in another ledger entry, add
342349
// that ledger entry to the filter so that Wasm for
343350
// any filtered contract is collected too in the
344351
// second pass.
345-
if keep && e.key == ScVal::LedgerKeyContractInstance {
352+
if e.key == ScVal::LedgerKeyContractInstance {
346353
match &e.val {
347354
ScVal::ContractInstance(ScContractInstance {
348355
executable: ContractExecutable::Wasm(hash),

0 commit comments

Comments
 (0)