lightningdevkit / lightningdevkit.org

Lightning Development Kit Documentation
https://lightningdevkit.org
MIT License
59 stars 39 forks source link

Make filter initialization compile #63

Closed TheBlueMatt closed 3 years ago

TheBlueMatt commented 3 years ago

I think Box<dyn> is maybe the simplest to understand for new Rust users. We could also use Arc<dyn> or simply &dyn.

Addresses the issue noted at https://github.com/lightningdevkit/lightningdevkit.org/discussions/55#discussioncomment-1044139

netlify[bot] commented 3 years ago

❌ Deploy Preview for ldk-docs-preview failed.

🔨 Explore the source changes: 15c251fb268223baaf4984b50fe2306af0489535

🔍 Inspect the deploy log: https://app.netlify.com/sites/ldk-docs-preview/deploys/60fc5db2d46c3a00073483c0

TheBlueMatt commented 3 years ago

The constructor takes an Option, the struct is parameterized by the thing inside the option (which must be Deref), so this should work. See https://docs.rs/lightning/0.0.99/lightning/chain/chainmonitor/struct.ChainMonitor.html#method.new

jochasinga commented 3 years ago

I think Option<Box<dyn Filter>> isn't allowed because it doesn't implement Deref.

#55 (reply in thread)

I think Option<Box<dyn Filter>> isn't allowed because it doesn't implement Deref.

#55 (reply in thread)

UPDATE: My confusion over ChainMonitor::new(...) accepting Option<Box<dyn Filter>> and Box<dyn Filter>. This is all good.