Skip to content

feat(zcoin): impl tx_history support for WASM target#2077

Merged
shamardy merged 16 commits intodevfrom
zcoin_tx_history
Mar 29, 2024
Merged

feat(zcoin): impl tx_history support for WASM target#2077
shamardy merged 16 commits intodevfrom
zcoin_tx_history

Conversation

@borngraced
Copy link
Copy Markdown

@borngraced borngraced commented Mar 4, 2024

fixes: #2072

Screenshot 2024-03-18 at 05 06 48

@borngraced borngraced self-assigned this Mar 4, 2024
@borngraced borngraced linked an issue Mar 19, 2024 that may be closed by this pull request
@shamardy shamardy requested a review from mariocynicys March 22, 2024 22:01
Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you for the PR! First review iteration!

Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question, LGTM otherwise :)

Comment on lines +61 to +98
// Fetch transactions
let txs = tx_table
.cursor_builder()
.only("ticker", z.ticker())?
.offset(offset as u32)
.limit(limit)
.reverse()
.open_cursor("ticker")
.await?
.collect()
.await?;

// Fetch received notes
let rn_table = db_transaction.table::<WalletDbReceivedNotesTable>().await?;
let received_notes = rn_table
.cursor_builder()
.only("ticker", z.ticker())?
.open_cursor("ticker")
.await?
.collect()
.await?;

// Fetch blocks
let blocks_table = db_transaction.table::<WalletDbBlocksTable>().await?;
let blocks = blocks_table
.cursor_builder()
.only("ticker", z.ticker())?
.open_cursor("ticker")
.await?
.collect()
.await?;

// Process transactions and construct tx_details
let mut tx_details = vec![];
for (tx_id, tx) in txs {
if let Some((_, WalletDbBlocksTable { height, time, .. })) = blocks
.iter()
.find(|(_, block)| tx.block.map(|b| b == block.height).unwrap_or_default())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: idb doesn't have a join construct like sql?
will such a join ever be expensive?

Copy link
Copy Markdown
Author

@borngraced borngraced Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately indexeddb doesn't offer such abstraction most things are done manually with indexeddb 😄 but with indexes they're fast

@shamardy shamardy merged commit 8a0e195 into dev Mar 29, 2024
@shamardy shamardy deleted the zcoin_tx_history branch March 29, 2024 13:59
dimxy pushed a commit to dimxy/komodo-defi-framework that referenced this pull request Mar 30, 2024
* dev:
  feat(zcoin): balance event streaming (GLEECBTC#2076)
  feat(zcoin): tx_history support for WASM target (GLEECBTC#2077)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

implement z_coin tx_history for WASM target

3 participants