Description
Describe the enhancement
Currently, there is no way to sync a Wallet
to a specific block (and no further).
One can specify an initial chain tip in a sync request, but there is no way to specify a target chain tip. A sync always ends with the current best tip.
There is no way to disconnect a wallet tip either, so syncing to current best tip and then disconnecting blocks is not possible (#1271, #1655).
It should be possible to either:
- Disconnect blocks from a
Wallet
- Specify a target chain tip in a sync request
Use case
In an application that needs to keep a wallet in sync with some other component that updates on each new tip (eg. a mempool), an initial sync process is quite awkward:
- Load wallet
- Subscribe to
sequence
/rawblock
/hashblock
- Sync wallet
- Sync other component to wallet tip
- Persist wallet
- Ignore tip updates older than wallet tip
- For each new tip, apply block to wallet and other component, and persist wallet
In particular, the requirement to sync a wallet to the current tip before anything else is a constraint on application architecture - it is more complex to perform initial sync concurrently, since a wallet may sync to a different tip than another component. If that other component also does not support disconnecting blocks, one needs to repeatedly attempt to sync each to the same block.
If specifying a target chain tip for sync was possible, an initial sync process could look like
- Load wallet
- Subscribe to
sequence
/rawblock
/hashblock
- Get current best tip
- Sync & persist wallet, sync other component to best tip
- Ignore tip updates older than wallet tip
- For each new tip, apply block to wallet and other component, and persist wallet
If disconnecting blocks was possible, an initial sync process could look like
- Load wallet
- Subscribe to
sequence
/rawblock
/hashblock
- Get current best tip
- Sync wallet, sync other component to best tip
- If wallet tip is behind best tip, connect blocks; If wallet tip is ahead, disconnect blocks
- Persist wallet
- Ignore tip updates older than shared tip
- For each new tip, apply block to wallet and other component, and persist wallet
Metadata
Metadata
Assignees
Type
Projects
Status