Before this PR there was a single table called transaction_metadata that stored tx metadata.
With this PR, we are adding two more tables
transaction_metadata_cache - this table contains changes that need to be synced with platform.
transaction_metadata_platform - this table is synced with Platform
in theory transaction_metadata = latest(transaction_metadata_platform + transaction_metadata_cache).
In other words, the current state of the metadata that is displayed to the user is equal to the data stored on platform plus the data not yet pushed to platform.
Example:
For transaction A, there is no memo
User sets a memo "Alice Pizza Party" for transaction A.
transaction_metadata is updated with this change.
An entry is also added to transaction_metadata_cache which indicates that the memo on transaction A has changed.
After a period of time (currently 15 seconds) or before Reset Wallet, all records (including transaction A) in transaction_metadata_cache are combined into a single list and published to Platform. transaction_metadata_cache is emptied.
Shortly after 5), the app detects that there is a new information published on Platform and this will be added to the transaction_metadata_platform table.
Restoration of a Wallet
Sync headers
Sync masternode lists
Sync Platform data (identity, username, contacts, profiles and tx_metadata). Tx Metadata is stored in the transaction_metadata_platform table. No transactions have been found.
Sync blockchain and transactions.
As each transaction is found, we search in transaction_metadata_platform for the latest data on a transaction. Then an entry with that information is added to transaction_metadata. For transaction A, it will find "Alice Pizza Party" as the memo.
After blockchain sync is complete, transaction_metadata should be the same as it was before the Reset Wallet action.
Refactoring
PlatformRepo has been split into PlatformRepo and PlatformSyncService and PlatformBroadcastService
PlatformRepo can still be further refactored to separate out identity/username creation, etc in other stories.
Before this PR there was a single table called
transaction_metadata
that stored tx metadata.With this PR, we are adding two more tables
in theory
transaction_metadata = latest(transaction_metadata_platform + transaction_metadata_cache)
.In other words, the current state of the metadata that is displayed to the user is equal to the data stored on platform plus the data not yet pushed to platform.
Example:
transaction_metadata
is updated with this change.transaction_metadata_cache
which indicates that the memo on transaction A has changed.transaction_metadata_cache
are combined into a single list and published to Platform.transaction_metadata_cache
is emptied.transaction_metadata_platform
table.Restoration of a Wallet
transaction_metadata_platform
table. No transactions have been found.transaction_metadata_platform
for the latest data on a transaction. Then an entry with that information is added totransaction_metadata
. For transaction A, it will find "Alice Pizza Party" as the memo.transaction_metadata
should be the same as it was before the Reset Wallet action.Refactoring
PlatformRepo
has been split intoPlatformRepo
andPlatformSyncService
andPlatformBroadcastService
PlatformRepo
can still be further refactored to separate out identity/username creation, etc in other stories.Issue being fixed or feature implemented
Related PR's and Dependencies
1042
https://github.com/dashevo/android-dpp/pull/35 https://github.com/dashevo/android-dashpay/pull/67
Screenshots / Videos
How Has This Been Tested?
Checklist: