Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 162
Enable deferred writing#782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -23,9 +23,7 @@ use lightning::routing::gossip; | ||
| use lightning::routing::router::DefaultRouter; | ||
| use lightning::routing::scoring::{CombinedScorer, ProbabilisticScoringFeeParameters}; | ||
| use lightning::sign::InMemorySigner; | ||
| use lightning::util::persist::{ | ||
| KVStore, KVStoreSync, MonitorUpdatingPersister, MonitorUpdatingPersisterAsync, | ||
| }; | ||
| use lightning::util::persist::{KVStore, KVStoreSync, MonitorUpdatingPersisterAsync}; | ||
| use lightning::util::ser::{Readable, Writeable, Writer}; | ||
| use lightning::util::sweep::OutputSweeper; | ||
| use lightning_block_sync::gossip::GossipVerifier; | ||
| @@ -135,6 +133,39 @@ impl<'a> KVStoreSync for dyn DynStoreTrait + 'a { | ||
| pub(crate) type DynStore = dyn DynStoreTrait; | ||
| // Newtype wrapper that implements `KVStore` for `Arc<DynStore>`. This is needed because `KVStore` | ||
| // methods return `impl Future`, which is not object-safe. `DynStoreTrait` works around this by | ||
| // returning `Pin<Box<dyn Future>>` instead, and this wrapper bridges the two by delegating | ||
| // `KVStore` methods to the corresponding `DynStoreTrait::*_async` methods. | ||
| #[derive(Clone)] | ||
| pub(crate) struct DynStoreRef(pub(crate) Arc<DynStore>); | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise still an unresolved question to me. | ||
| impl KVStore for DynStoreRef { | ||
| fn read( | ||
| &self, primary_namespace: &str, secondary_namespace: &str, key: &str, | ||
| ) -> impl Future<Output = Result<Vec<u8>, bitcoin::io::Error>> + Send + 'static { | ||
| DynStoreTrait::read_async(&*self.0, primary_namespace, secondary_namespace, key) | ||
| } | ||
| fn write( | ||
| &self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: Vec<u8>, | ||
| ) -> impl Future<Output = Result<(), bitcoin::io::Error>> + Send + 'static { | ||
| DynStoreTrait::write_async(&*self.0, primary_namespace, secondary_namespace, key, buf) | ||
| } | ||
| fn remove( | ||
| &self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool, | ||
| ) -> impl Future<Output = Result<(), bitcoin::io::Error>> + Send + 'static { | ||
| DynStoreTrait::remove_async(&*self.0, primary_namespace, secondary_namespace, key, lazy) | ||
| } | ||
| fn list( | ||
| &self, primary_namespace: &str, secondary_namespace: &str, | ||
| ) -> impl Future<Output = Result<Vec<String>, bitcoin::io::Error>> + Send + 'static { | ||
| DynStoreTrait::list_async(&*self.0, primary_namespace, secondary_namespace) | ||
| } | ||
| } | ||
| pub(crate) struct DynStoreWrapper<T: SyncAndAsyncKVStore + Send + Sync>(pub(crate) T); | ||
| impl<T: SyncAndAsyncKVStore + Send + Sync> DynStoreTrait for DynStoreWrapper<T> { | ||
| @@ -188,7 +219,7 @@ impl<T: SyncAndAsyncKVStore + Send + Sync> DynStoreTrait for DynStoreWrapper<T> | ||
| } | ||
| pub(crate) type AsyncPersister = MonitorUpdatingPersisterAsync< | ||
| Arc<DynStore>, | ||
| DynStoreRef, | ||
| RuntimeSpawner, | ||
| Arc<Logger>, | ||
| Arc<KeysManager>, | ||
| @@ -197,22 +228,21 @@ pub(crate) type AsyncPersister = MonitorUpdatingPersisterAsync< | ||
| Arc<OnchainFeeEstimator>, | ||
| >; | ||
| pub type Persister = MonitorUpdatingPersister< | ||
| Arc<DynStore>, | ||
| Arc<Logger>, | ||
| Arc<KeysManager>, | ||
| Arc<KeysManager>, | ||
| Arc<Broadcaster>, | ||
| Arc<OnchainFeeEstimator>, | ||
| >; | ||
| pub(crate) type ChainMonitor = chainmonitor::ChainMonitor< | ||
| InMemorySigner, | ||
| Arc<ChainSource>, | ||
| Arc<Broadcaster>, | ||
| Arc<OnchainFeeEstimator>, | ||
| Arc<Logger>, | ||
| Arc<Persister>, | ||
| chainmonitor::AsyncPersister< | ||
| DynStoreRef, | ||
| RuntimeSpawner, | ||
| Arc<Logger>, | ||
| Arc<KeysManager>, | ||
| Arc<KeysManager>, | ||
| Arc<Broadcaster>, | ||
| Arc<OnchainFeeEstimator>, | ||
| >, | ||
| Arc<KeysManager>, | ||
| >; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might or might not conflict with #811, we'll also need to think through this depending on the order these land.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, concern still stands, I'll see to continue work on #811 in the next days so we can decide better.