@@ -17,7 +17,7 @@ use std::fmt;
1717use bitcoin:: consensus:: serialize;
1818use bitcoin:: { OutPoint , Transaction , Txid } ;
1919
20- use crate :: blockchain:: Blockchain ;
20+ use crate :: blockchain:: GetTx ;
2121use crate :: database:: Database ;
2222use crate :: error:: Error ;
2323
@@ -29,7 +29,7 @@ use crate::error::Error;
2929/// Depending on the [capabilities](crate::blockchain::Blockchain::get_capabilities) of the
3030/// [`Blockchain`] backend, the method could fail when called with old "historical" transactions or
3131/// 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 > (
3333 tx : & Transaction ,
3434 database : & D ,
3535 blockchain : & B ,
@@ -104,43 +104,18 @@ impl_error!(bitcoinconsensus::Error, Consensus, VerifyError);
104104
105105#[ cfg( test) ]
106106mod test {
107- use std :: collections :: HashSet ;
108-
107+ use super :: * ;
108+ use crate :: database :: { BatchOperations , MemoryDatabase } ;
109109 use bitcoin:: consensus:: encode:: deserialize;
110110 use bitcoin:: hashes:: hex:: FromHex ;
111111 use bitcoin:: { Transaction , Txid } ;
112112
113- use crate :: blockchain:: { Blockchain , Capability , Progress } ;
114- use crate :: database:: { BatchDatabase , BatchOperations , MemoryDatabase } ;
115- use crate :: FeeRate ;
116-
117- use super :: * ;
118-
119113 struct DummyBlockchain ;
120114
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 {
132116 fn get_tx ( & self , _txid : & Txid ) -> Result < Option < Transaction > , Error > {
133117 Ok ( None )
134118 }
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- }
144119 }
145120
146121 #[ test]
0 commit comments