Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Aug 1, 2024
1 parent 8164620 commit 4dc24a6
Showing 1 changed file with 42 additions and 45 deletions.
87 changes: 42 additions & 45 deletions cmd/soroban-cli/src/commands/snapshot/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,54 +245,51 @@ impl Cmd {
if seen.contains(&key) {
continue;
}
if let Some(val) = val {
let keep = match &val.data {
LedgerEntryData::Account(e) => {
current.account_ids.contains(&e.account_id.to_string())
}
LedgerEntryData::Trustline(e) => {
current.account_ids.contains(&e.account_id.to_string())
}
LedgerEntryData::ContractData(e) => {
let keep = current.contract_ids.contains(&e.contract.to_string());
// If a contract instance references
// contract executable stored in another
// ledger entry, add that ledger entry to
// the filter so that Wasm for any filtered
// contract is collected too in the second pass.
if keep && e.key == ScVal::LedgerKeyContractInstance {
if let ScVal::ContractInstance(ScContractInstance {
executable: ContractExecutable::Wasm(Hash(hash)),
..
}) = e.val
{
next.wasm_hashes.push(hash);
println!("ℹ️ Adding wasm {} to search", hex::encode(hash));
}
let Some(val) = val else { continue };
let keep = match &val.data {
LedgerEntryData::Account(e) => {
current.account_ids.contains(&e.account_id.to_string())
}
LedgerEntryData::Trustline(e) => {
current.account_ids.contains(&e.account_id.to_string())
}
LedgerEntryData::ContractData(e) => {
let keep = current.contract_ids.contains(&e.contract.to_string());
// If a contract instance references
// contract executable stored in another
// ledger entry, add that ledger entry to
// the filter so that Wasm for any filtered
// contract is collected too in the second pass.
if keep && e.key == ScVal::LedgerKeyContractInstance {
if let ScVal::ContractInstance(ScContractInstance {
executable: ContractExecutable::Wasm(Hash(hash)),
..
}) = e.val
{
next.wasm_hashes.push(hash);
println!("ℹ️ Adding wasm {} to search", hex::encode(hash));
}
keep
}
LedgerEntryData::ContractCode(e) => {
current.wasm_hashes.contains(&e.hash.0)
}
LedgerEntryData::Offer(_)
| LedgerEntryData::Data(_)
| LedgerEntryData::ClaimableBalance(_)
| LedgerEntryData::LiquidityPool(_)
| LedgerEntryData::ConfigSetting(_)
| LedgerEntryData::Ttl(_) => false,
};
seen.insert(key.clone());
if keep {
// Store the found ledger entry in the snapshot with
// a max u32 expiry.
// TODO: Change the expiry to come from the
// corresponding TTL ledger entry.
snapshot
.ledger_entries
.push((Box::new(key), (Box::new(val), Some(u32::MAX))));
count_saved += 1;
keep
}
LedgerEntryData::ContractCode(e) => current.wasm_hashes.contains(&e.hash.0),
LedgerEntryData::Offer(_)
| LedgerEntryData::Data(_)
| LedgerEntryData::ClaimableBalance(_)
| LedgerEntryData::LiquidityPool(_)
| LedgerEntryData::ConfigSetting(_)
| LedgerEntryData::Ttl(_) => false,
};
seen.insert(key.clone());
if keep {
// Store the found ledger entry in the snapshot with
// a max u32 expiry.
// TODO: Change the expiry to come from the
// corresponding TTL ledger entry.
snapshot
.ledger_entries
.push((Box::new(key), (Box::new(val), Some(u32::MAX))));
count_saved += 1;
}
}
if count_saved > 0 {
Expand Down

0 comments on commit 4dc24a6

Please sign in to comment.