Skip to content

Commit

Permalink
Remove dupe storage item if we get one back, to be compatible with Sm…
Browse files Browse the repository at this point in the history
…oldot + legacy RPCs (#1534)

* Remove dupe storage item if we get one back, to be compatibel with Smoldot + legacy RPCs

* remove commented-out code
  • Loading branch information
jsdw authored Apr 15, 2024
1 parent 652b9bc commit 9765ad0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions subxt/src/backend/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,17 @@ impl<T: Config> Stream for StorageFetchDescendantKeysStream<T> {
};

match keys {
Ok(keys) => {
Ok(mut keys) => {
if this.pagination_start_key.is_some()
&& keys.first() == this.pagination_start_key.as_ref()
{
// Currently, Smoldot returns the "start key" as the first key in the input
// (see https://github.com/smol-dot/smoldot/issues/1692), whereas Substrate doesn't.
// We don't expect the start key to be returned either (since it was the last key of prev
// iteration), so remove it if we see it. This `remove()` method isn't very efficient but
// this will be a non issue with the RPC V2 APIs or if Smoldot aligns with Substrate anyway.
keys.remove(0);
}
if keys.is_empty() {
// No keys left; we're done!
this.done = true;
Expand All @@ -428,7 +438,7 @@ impl<T: Config> Stream for StorageFetchDescendantKeysStream<T> {
let key = this.key.clone();
let at = this.at;
let storage_page_size = this.storage_page_size;
let pagination_start_key = this.pagination_start_key.take();
let pagination_start_key = this.pagination_start_key.clone();
let keys_fut = async move {
methods
.state_get_keys_paged(
Expand Down

0 comments on commit 9765ad0

Please sign in to comment.