Page MenuHomePhabricator

[Cashtab] Refactoring wallet state - disccusion
AbandonedPublic

Authored by hungsam on Dec 1 2021, 23:01.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Summary

Currently, we have the following data stored in the wallet state

  • balances
  • hydratedUtxoDetails
  • parsedTxHistory
  • slpBalancesAndUtxos
  • tokens
  • utxos

To maintain a single source of truth, we should drop “utxos”, “hydratedUtxoDetails”,
“tokens”, and maybe even “balances” from the wallet state.
Those data is already in or can be derived from “slpBalancesAndUtxos”.
This would make to code clearer and easier to understand.

We should consider converting each property (nonSlpUtxos, slpUtxos, tokens)
of slpBalancesAndUtxos from Array to Object (with the key being tx_hash + tx_pos).
This would give us quick direct access to each tx if we need to.
While looping through them still cost the same in term of performance.
Checking to see if an utxo is new would simply involve accessing
slpBalancesAndUtxos.nonSlpUtxos[utxo.tx_hash + utxo.tx_pos] and
slpBalancesAndUtxos.slpUtxos[utxo.tx_hash + utxo.tx_pos]

Test Plan

Nothing to test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
refactor-wallet-state (branched from master)
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 17502
Build 34830: Build Diffcashtab-tests
Build 34829: arc lint + arc unit

Event Timeline

Owners added a reviewer: Restricted Owners Package.Dec 1 2021, 23:01
hungsam requested review of this revision.Dec 1 2021, 23:02
bytesofman requested changes to this revision.Dec 2 2021, 00:04

Hey -- this is a good idea. Please create this as a task on the Cashtab work board that describes the scope as you've outlined it above, and then abandon this diff.

This revision now requires changes to proceed.Dec 2 2021, 00:04