witnet-rust
witnet-rust copied to clipboard
feat: allow keeping an index of utxos in memory
Fix #2173
This PR adds a new option in witnet.toml storage.utxos_in_memory
that defaults to false
. When enabled, the node will keep a map of address to list of UTXOs in memory, which allows to implement fast getBalance
and getUtxoInfo
methods. With this option enabled a call to getBalance
takes around 5ms, while the same call with this option disabled may take up to 5000ms. The expected memory usage in mainnet is around 500 MB.
Seems to work just fine 👍 Would appreciate feedback from @drcpu-github, who I suspect that will be the main user for this feature for the time being!
I'll try and have a look by integrating it in the test version of my explorer.
@tmpolaczyk I have been testing this branch in the test version of my explorer and it works like a charm! I don't really notice any slowdown in either address lookups in the explorer or the building of the list of all accounts with a non-zero balance.
Merged in as 2d497aad9e3c8fb27d431378ffa4917c351f5603