Improve storage API
There are multiple ways to create a Storage struct, which seems to be a source for confusion and improper usage. In context of bitmask-core being integrated into an Desktop app we currently only storage.InitAppStorage() and storage.GetStorage() should be public APIs to initialize the storage. The issue we faced was that BoldDB only allows one open DB connection. Having different APIs to create DB connections easily leads to DB timeout failures when trying to open the connection.
As for the mobile API we should only use InitAppStorageWith(store). Even though there's no similar restriction like for the BoldDB store implementation (the store implementation in Java uses encrypted shared preferences which allows to have multiple references at the same time), the APIs seem to be just more aligned if we always used one global storage reference.
-
make NewStorageWithDefault and NewStoreageWithStore private -
always return an error if global appStorage is not initilized and GetStorage() was called -
remove storage from BitmaskMobile struct and use global appStorage reference (via GetStorage()) -
initialize storage in BitmaskMobile with InitAppStorageWith(store) -
initilize storage in Tests always with InitAppStorage()
somewhat unrelated improvements for the storage API:
-
change Setter methods in store interface so that they return errors -
change MaybeUpdateLastIntroducer make it a storeage struct method, remove the close() call