Commit graph

164 commits

Author SHA1 Message Date
Matt Corallo
793de5fe69
Merge pull request #819 from TheBlueMatt/2021-03-810-rebased
Change ChannelManager deserialization to return an optional blockhash
2021-03-02 16:04:23 -08:00
Valentine Wallace
7c8e740b6e Change ChannelMonitor deserialization to return an optional blockhash.
See previous commit msg for details.
2021-03-02 14:30:56 -05:00
Valentine Wallace
ee995a3a55 Change ChannelManager deserialization to return an optional blockhash
If the ChannelManager never receives any blocks, it'll return a default blockhash
on deserialization. It's preferable for this to be an Option instead.
2021-03-02 14:30:56 -05:00
Jeffrey Czyz
60f4daf2c2
Add validate_best_block_header utility
Refactor synchronize_listeners by pulling out a function returning the
validated block header of a BlockSource's best chain tip. This is needed
when a node is started from scratch and has no listeners to sync.
2021-03-02 10:03:11 -08:00
Jeffrey Czyz
e8ea0d9f04
Implement chain::Listen without using RefCell
The implementation of chain::Listen for ChannelMonitor required using a
RefCell since its block_connected method required a mutable borrow. This
is no longer the case since ChannelMonitor now uses interior mutability
via a Mutex. So the RefCell is no longer needed.
2021-03-01 22:12:26 -08:00
Matt Corallo
a51d5cef58 Update rust-bitcoin 2021-02-26 15:15:18 -05:00
Jeffrey Czyz
8bfdfdc9e4
Utility for syncing a set of chain listeners
Add a utility for syncing a set of chain listeners to a common chain
tip. Required to use before creating an SpvClient when the chain
listener used with the client is actually a set of listeners each of
which may have had left off at a different block. This would occur when
the listeners had been persisted individually at different frequencies
(e.g., a ChainMonitor's individual ChannelMonitors).
2021-02-26 00:54:43 -06:00
Jeffrey Czyz
8505382b19
Add SpvClient used to poll for the best chain tip
Adds a lightweight client for polling one or more block sources for the
best chain tip. Notifies listeners of blocks connected or disconnected
since the last poll. Useful for keeping a Lightning node in sync with
the chain.
2021-02-26 00:54:42 -06:00
Jeffrey Czyz
b1ecfe705d
Add ChainNotifier and define ChainListener trait
Add an interface for being notified of block connected and disconnected
events, along with a notifier for generating such events. Used while
polling block sources for a new tip in order to feed these events into
ChannelManager and ChainMonitor.
2021-02-26 00:54:42 -06:00
Jeffrey Czyz
05ec06129c
Add ChainPoller implementation of Poll trait
ChainPoller defines a strategy for polling a single BlockSource. It
handles validating chain data returned from the BlockSource. Thus, other
implementations of Poll must be defined in terms of ChainPoller.
2021-02-26 00:54:42 -06:00
Jeffrey Czyz
7d6fce7802
Define a Poll trait as an adaptor on BlockSource
SPV clients need to poll one or more block sources for the best chain
tip and to retrieve related chain data. The Poll trait serves as an
adaptor interface for BlockSource. Implementations may define an
appropriate polling strategy.
2021-02-26 00:54:41 -06:00
Jeffrey Czyz
85fdfaaa9c
Implement BlockSource for REST and RPC clients
Interprets HTTP responses as either binary or JSON format, which are
then converted to the appropriate data types.
2021-02-04 07:38:42 -08:00
Jeffrey Czyz
6ca3b8ed49
Add REST and RPC clients to lightning-block-sync
Implements a simple HTTP client that can issue GET and POST requests.
Used to implement REST and RPC clients, respectively. Both clients
support either blocking or non-blocking I/O.
2021-02-04 07:38:42 -08:00
Jeffrey Czyz
9860646e73
Add lightning-block-sync package and library
Defines an interface and related types for fetching block headers and
data from a block source (e.g., Bitcoin Core). Used to keep lightning in
sync with chain activity.
2021-02-03 17:45:54 -08:00