Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Change data persitence #8

Open
ManfredKarrer opened this issue Apr 27, 2018 · 0 comments
Open

Change data persitence #8

ManfredKarrer opened this issue Apr 27, 2018 · 0 comments

Comments

@ManfredKarrer
Copy link
Contributor

ManfredKarrer commented Apr 27, 2018

We use at the moment one protobuffer file which gets persisted to disk (PersistableNetworkPayloadMap) for storing data which arrived from the P2P network and are from payload type PersistableNetworkPayload.
There are 2 use cases for those data: Account age witness and trade statistics.
Both are persisted in an append-only style as there is no use case for removing that data. This allows us to only use the hash of the payload as key in a map. For removal of the data we would need to support a signature and store a public key with the data which increases the data size quite a lot (specially for account age witness data we want to keep it as small as possible).

We will have new use cases from the DAO: Proposals and BlindVotes which are essential data for constructing the vote result need to be persisted as well.
We could use a custom data structure inside the DAO domain but then we would need to re-implement already existing features from the p2p network like the delta handling for requests.
At the moment the 2 payload types (account age witness and trade statistics) are stored in the same data structure/file (PersistableNetworkPayloadMap).
For the DAO we would like to have our consensus critical data more explicitly controlled and defined.
We suggest to use domain specific storage implementations and merge the data from different sources for the P2PDataStorage as the p2p network domain is not aware of the other domains.
That will also gives us more flexibility about the way how the data are persisted (maybe use a high performance DB for those payload types which creates a lot of disk IO) and make it easier to implement solutions for better scalability (e.g. pruning of old trade statistics, or move them to a data provider for on-demand requests once the data gets too much).

I am working on an implementation for that cahnges at https://github.com/ManfredKarrer/bisq-p2p/commits/storage-provider and would like to ask for feedback (still not complete but basics are in place).

My suggestion uses the AppendOnlyDataStoreService class which maintains a list of storageServices.
Any domain can add a storage service and the AppendOnlyDataStoreService takes care of merging those data sources for the domain agnostic P2PDataStorage.
We can transition from the current data store to the new system by copying over the existing data entries to the new files and then having 2 new storage files: AccountAgeWitnessMap and TradeStatisticsMap (not impl. yet).
With the DAO there will be 2 more: ProposalMap and BlindVoteMap.

We added also support for data which can be removed, which would require the public key and use different data types.
Those are handled in PersistedEntryMapService. As there is currently no use case I have not implemented the support for multiple services but it would follow the same concept as in AppendOnlyDataStoreService. I could be probably consolidated to one implementation with a bit more generics support (thought it would get a bit complicate, so I prefer to have a bit duplicated code rather then very obscure generics).
There might be use cases from the DAO for that PersistedEntryMapService but that is still not 100% clear. If there will be no use case we can remove that as well.

@freimair @sqrrm @cbeams
What do you think about it?

UPDATE: TradeStatisticsMap is implemented as well now.

ManfredKarrer added a commit to ManfredKarrer/archived-bisq-p2p that referenced this issue Jul 8, 2018
- Separate persistence by domains via custom services (See:
bisq-network#8)
- Add AppendOnlyDataStoreService and ProtectedDataStoreService
- Improve handling of reading from resource files
- Rename getHash to get32ByteHash
- Add getCompactHash (20 bytes)
- Add resource files, remove old persistableNetworkPayloadMap
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant