1
- use crate :: { AsyncBlockSourceResult , BlockData , BlockHeaderData , BlockSource , BlockSourceError , UnboundedCache } ;
2
1
use crate :: poll:: { Validate , ValidatedBlockHeader } ;
2
+ use crate :: {
3
+ AsyncBlockSourceResult , BlockData , BlockHeaderData , BlockSource , BlockSourceError ,
4
+ UnboundedCache ,
5
+ } ;
3
6
4
7
use bitcoin:: blockdata:: block:: { Block , Header , Version } ;
5
8
use bitcoin:: blockdata:: constants:: genesis_block;
6
9
use bitcoin:: blockdata:: locktime:: absolute:: LockTime ;
7
10
use bitcoin:: hash_types:: { BlockHash , TxMerkleNode } ;
8
11
use bitcoin:: network:: Network ;
9
- use bitcoin:: Transaction ;
10
12
use bitcoin:: transaction;
13
+ use bitcoin:: Transaction ;
11
14
12
15
use lightning:: chain;
13
16
@@ -48,7 +51,7 @@ impl Blockchain {
48
51
version : transaction:: Version ( 0 ) ,
49
52
lock_time : LockTime :: ZERO ,
50
53
input : vec ! [ ] ,
51
- output : vec ! [ ]
54
+ output : vec ! [ ] ,
52
55
} ;
53
56
let merkle_root = TxMerkleNode :: from_raw_hash ( coinbase. txid ( ) . to_raw_hash ( ) ) ;
54
57
self . blocks . push ( Block {
@@ -135,7 +138,9 @@ impl Blockchain {
135
138
}
136
139
137
140
impl BlockSource for Blockchain {
138
- fn get_header < ' a > ( & ' a self , header_hash : & ' a BlockHash , _height_hint : Option < u32 > ) -> AsyncBlockSourceResult < ' a , BlockHeaderData > {
141
+ fn get_header < ' a > (
142
+ & ' a self , header_hash : & ' a BlockHash , _height_hint : Option < u32 > ,
143
+ ) -> AsyncBlockSourceResult < ' a , BlockHeaderData > {
139
144
Box :: pin ( async move {
140
145
if self . without_headers {
141
146
return Err ( BlockSourceError :: persistent ( "header not found" ) ) ;
@@ -155,7 +160,9 @@ impl BlockSource for Blockchain {
155
160
} )
156
161
}
157
162
158
- fn get_block < ' a > ( & ' a self , header_hash : & ' a BlockHash ) -> AsyncBlockSourceResult < ' a , BlockData > {
163
+ fn get_block < ' a > (
164
+ & ' a self , header_hash : & ' a BlockHash ,
165
+ ) -> AsyncBlockSourceResult < ' a , BlockData > {
159
166
Box :: pin ( async move {
160
167
for ( height, block) in self . blocks . iter ( ) . enumerate ( ) {
161
168
if block. header . block_hash ( ) == * header_hash {
@@ -192,7 +199,10 @@ impl BlockSource for Blockchain {
192
199
pub struct NullChainListener ;
193
200
194
201
impl chain:: Listen for NullChainListener {
195
- fn filtered_block_connected ( & self , _header : & Header , _txdata : & chain:: transaction:: TransactionData , _height : u32 ) { }
202
+ fn filtered_block_connected (
203
+ & self , _header : & Header , _txdata : & chain:: transaction:: TransactionData , _height : u32 ,
204
+ ) {
205
+ }
196
206
fn block_disconnected ( & self , _header : & Header , _height : u32 ) { }
197
207
}
198
208
@@ -240,7 +250,9 @@ impl chain::Listen for MockChainListener {
240
250
}
241
251
}
242
252
243
- fn filtered_block_connected ( & self , header : & Header , _txdata : & chain:: transaction:: TransactionData , height : u32 ) {
253
+ fn filtered_block_connected (
254
+ & self , header : & Header , _txdata : & chain:: transaction:: TransactionData , height : u32 ,
255
+ ) {
244
256
match self . expected_filtered_blocks_connected . borrow_mut ( ) . pop_front ( ) {
245
257
None => {
246
258
panic ! ( "Unexpected filtered block connected: {:?}" , header. block_hash( ) ) ;
0 commit comments