lightninglabs / neutrino

Privacy-Preserving Bitcoin Light Client
MIT License
908 stars 183 forks source link

filterdb: Implement PurgeFilters. #199

Closed roeierez closed 4 years ago

roeierez commented 4 years ago

This PR adds the ability to purge the filters from the db. Neutrino has the PersistToDisk query option which is useful for background sync in mobile applications. These apps can set a background job to fetch the filters periodically, preparing the data for the app when it starts by the user, which achieves a fast sync time and immediate readiness for payment. This change adds a way to purge these filters and enables the app to implement its own eviction strategy preventing the db from growing boundlessly.

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-0.03%) to 72.129% when pulling bcf1bbc636fc4c112112598ab25bc21b5d6e4eb6 on breez:purge-filters into d84efcc5b276e6d55636708ad7846c7fd86c3723 on lightninglabs:master.

Crypt-iQ commented 4 years ago

I like this change, but do you notice a change in the size of the db when running this? bbolt doesn't shrink when deleting things (keeps the freed pages on disk still). May be useful if/when neutrino migrates to an abstracted k/v store that supports things besides bbolt.

roeierez commented 4 years ago

The bolt db file size indeed doesn't change but with this change the app layer at least can make sure it's eviction strategy prevents the db from growing too much. As far as I know the only way to shrink the db is to run compact and this is also an option (that should be done with care) for applications that already have a big db file.

Crypt-iQ commented 4 years ago

The bolt db file size indeed doesn't change but with this change the app layer at least can make sure it's eviction strategy prevents the db from growing too much. As far as I know the only way to shrink the db is to run compact and this is also an option (that should be done with care) for applications that already have a big db file.

Ah I see, I'll take a look at the code :)