-
Notifications
You must be signed in to change notification settings - Fork 114
fix:support-classic-accounts-trustlines #1746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ use stellar_xdr::curr::{ | |
| LedgerKeyClaimableBalance, LedgerKeyConfigSetting, LedgerKeyContractCode, | ||
| LedgerKeyContractData, LedgerKeyData, LedgerKeyLiquidityPool, LedgerKeyOffer, | ||
| LedgerKeyTrustLine, LedgerKeyTtl, Limited, Limits, ReadXdr, ScAddress, ScContractInstance, | ||
| ScVal, | ||
| ScVal, TrustLineAsset, | ||
| }; | ||
| use tokio::fs::OpenOptions; | ||
| use tokio::io::BufReader; | ||
|
|
@@ -289,7 +289,14 @@ impl Cmd { | |
| } | ||
| let keep = match &key { | ||
| LedgerKey::Account(k) => current.account_ids.contains(&k.account_id), | ||
| LedgerKey::Trustline(k) => current.account_ids.contains(&k.account_id), | ||
| LedgerKey::Trustline(k) => { | ||
| current.account_ids.contains(&k.account_id) || | ||
| current.account_ids.iter().any(|id| match &k.asset { | ||
| TrustLineAsset::CreditAlphanum4(a4) => a4.issuer == *id, | ||
| TrustLineAsset::CreditAlphanum12(a12) => a12.issuer == *id, | ||
|
Comment on lines
-292
to
+296
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pulling in every trustline for an asset unfortunately doesn't scale well with the current implementation of snapshots, which was why I left it out. If you pass in the address for a very popular asset, the file becomes huge and unusable. For assets with much less trust lines though I can see this being very useful so maybe we should add it. I think this use case will be better served by the following issue that hopefully we can implement in the near future: Thoguhts @fnando ? |
||
| _ => false, // Ignore non-credit assets | ||
| }) | ||
| }, | ||
| LedgerKey::ContractData(k) => current.contract_ids.contains(&k.contract), | ||
| LedgerKey::ContractCode(e) => current.wasm_hashes.contains(&e.hash), | ||
| _ => false, | ||
|
|
@@ -299,7 +306,7 @@ impl Cmd { | |
| } | ||
| seen.insert(key.clone()); | ||
| let Some(val) = val else { continue }; | ||
| match &val.data { | ||
| let should_save = match &val.data { | ||
| LedgerEntryData::ContractData(e) => { | ||
| // If a contract instance references contract | ||
| // executable stored in another ledger entry, add | ||
|
|
@@ -319,7 +326,7 @@ impl Cmd { | |
| hex::encode(hash) | ||
| )); | ||
| } | ||
| } | ||
| } | ||
| ScVal::ContractInstance(ScContractInstance { | ||
| executable: ContractExecutable::StellarAsset, | ||
| storage: Some(storage), | ||
|
|
@@ -333,24 +340,25 @@ impl Cmd { | |
| Asset::CreditAlphanum4(a4) => Some(a4.issuer), | ||
| Asset::CreditAlphanum12(a12) => Some(a12.issuer), | ||
| } { | ||
| print.infoln(format!( | ||
| "Adding asset issuer {issuer} to search" | ||
| )); | ||
| print.infoln(format!("Adding asset issuer {issuer} to search")); | ||
| next.account_ids.insert(issuer); | ||
| } | ||
| } | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
| keep | ||
| true | ||
| } | ||
| _ => false, | ||
| LedgerEntryData::ContractCode(_) => true, | ||
| _ => false | ||
| }; | ||
| snapshot | ||
| .ledger_entries | ||
| .push((Box::new(key), (Box::new(val), Some(u32::MAX)))); | ||
| count_saved += 1; | ||
| if should_save { | ||
| snapshot | ||
| .ledger_entries | ||
| .push((Box::new(key), (Box::new(val), Some(u32::MAX)))); | ||
| count_saved += 1; | ||
| } | ||
| } | ||
| if count_saved > 0 { | ||
| print.infoln(format!("Found {count_saved} entries")); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting the complex trustline filtering logic (lines 292-298) into a helper function to improve readability and maintainability.