@@ -17,7 +17,7 @@ use std::fmt;
17
17
use bitcoin:: consensus:: serialize;
18
18
use bitcoin:: { OutPoint , Transaction , Txid } ;
19
19
20
- use crate :: blockchain:: Blockchain ;
20
+ use crate :: blockchain:: GetTx ;
21
21
use crate :: database:: Database ;
22
22
use crate :: error:: Error ;
23
23
@@ -29,7 +29,7 @@ use crate::error::Error;
29
29
/// Depending on the [capabilities](crate::blockchain::Blockchain::get_capabilities) of the
30
30
/// [`Blockchain`] backend, the method could fail when called with old "historical" transactions or
31
31
/// with unconfirmed transactions that have been evicted from the backend's memory.
32
- pub fn verify_tx < D : Database , B : Blockchain > (
32
+ pub fn verify_tx < D : Database , B : GetTx > (
33
33
tx : & Transaction ,
34
34
database : & D ,
35
35
blockchain : & B ,
@@ -104,43 +104,18 @@ impl_error!(bitcoinconsensus::Error, Consensus, VerifyError);
104
104
105
105
#[ cfg( test) ]
106
106
mod test {
107
- use std :: collections :: HashSet ;
108
-
107
+ use super :: * ;
108
+ use crate :: database :: { BatchOperations , MemoryDatabase } ;
109
109
use bitcoin:: consensus:: encode:: deserialize;
110
110
use bitcoin:: hashes:: hex:: FromHex ;
111
111
use bitcoin:: { Transaction , Txid } ;
112
112
113
- use crate :: blockchain:: { Blockchain , Capability , Progress } ;
114
- use crate :: database:: { BatchDatabase , BatchOperations , MemoryDatabase } ;
115
- use crate :: FeeRate ;
116
-
117
- use super :: * ;
118
-
119
113
struct DummyBlockchain ;
120
114
121
- impl Blockchain for DummyBlockchain {
122
- fn get_capabilities ( & self ) -> HashSet < Capability > {
123
- Default :: default ( )
124
- }
125
- fn setup < D : BatchDatabase , P : ' static + Progress > (
126
- & self ,
127
- _database : & mut D ,
128
- _progress_update : P ,
129
- ) -> Result < ( ) , Error > {
130
- Ok ( ( ) )
131
- }
115
+ impl GetTx for DummyBlockchain {
132
116
fn get_tx ( & self , _txid : & Txid ) -> Result < Option < Transaction > , Error > {
133
117
Ok ( None )
134
118
}
135
- fn broadcast ( & self , _tx : & Transaction ) -> Result < ( ) , Error > {
136
- Ok ( ( ) )
137
- }
138
- fn get_height ( & self ) -> Result < u32 , Error > {
139
- Ok ( 42 )
140
- }
141
- fn estimate_fee ( & self , _target : usize ) -> Result < FeeRate , Error > {
142
- Ok ( FeeRate :: default_min_relay_fee ( ) )
143
- }
144
119
}
145
120
146
121
#[ test]
0 commit comments