@@ -68,6 +68,8 @@ pub trait ChainApi: Send + Sync {
6868 type Error : From < error:: Error > + error:: IntoPoolError ;
6969 /// Validate transaction future.
7070 type ValidationFuture : Future < Output =Result < TransactionValidity , Self :: Error > > + Send + Unpin ;
71+ /// Body future (since block body might be remote)
72+ type BodyFuture : Future < Output = Result < Option < Vec < <Self :: Block as traits:: Block >:: Extrinsic > > , Self :: Error > > + Unpin + Send + ' static ;
7173
7274 /// Verify extrinsic at given block.
7375 fn validate_transaction (
@@ -84,6 +86,9 @@ pub trait ChainApi: Send + Sync {
8486
8587 /// Returns hash and encoding length of the extrinsic.
8688 fn hash_and_length ( & self , uxt : & ExtrinsicFor < Self > ) -> ( Self :: Hash , usize ) ;
89+
90+ /// Returns a block body given the block id.
91+ fn block_body ( & self , at : & BlockId < Self :: Block > ) -> Self :: BodyFuture ;
8792}
8893
8994/// Pool configuration options.
@@ -120,7 +125,7 @@ pub struct Pool<B: ChainApi> {
120125
121126impl < B : ChainApi > Pool < B > {
122127 /// Create a new transaction pool.
123- pub fn new ( options : Options , api : B ) -> Self {
128+ pub fn new ( options : Options , api : Arc < B > ) -> Self {
124129 Pool {
125130 validated_pool : Arc :: new ( ValidatedPool :: new ( options, api) ) ,
126131 }
@@ -488,6 +493,7 @@ mod tests {
488493 type Hash = u64 ;
489494 type Error = error:: Error ;
490495 type ValidationFuture = futures:: future:: Ready < error:: Result < TransactionValidity > > ;
496+ type BodyFuture = futures:: future:: Ready < error:: Result < Option < Vec < Extrinsic > > > > ;
491497
492498 /// Verify extrinsic at given block.
493499 fn validate_transaction (
@@ -560,14 +566,18 @@ mod tests {
560566 len
561567 )
562568 }
569+
570+ fn block_body ( & self , _id : & BlockId < Self :: Block > ) -> Self :: BodyFuture {
571+ futures:: future:: ready ( Ok ( None ) )
572+ }
563573 }
564574
565575 fn uxt ( transfer : Transfer ) -> Extrinsic {
566576 Extrinsic :: Transfer ( transfer, Default :: default ( ) )
567577 }
568578
569579 fn pool ( ) -> Pool < TestApi > {
570- Pool :: new ( Default :: default ( ) , TestApi :: default ( ) )
580+ Pool :: new ( Default :: default ( ) , TestApi :: default ( ) . into ( ) )
571581 }
572582
573583 #[ test]
@@ -713,7 +723,7 @@ mod tests {
713723 ready : limit. clone ( ) ,
714724 future : limit. clone ( ) ,
715725 ..Default :: default ( )
716- } , TestApi :: default ( ) ) ;
726+ } , TestApi :: default ( ) . into ( ) ) ;
717727
718728 let hash1 = block_on ( pool. submit_one ( & BlockId :: Number ( 0 ) , uxt ( Transfer {
719729 from : AccountId :: from_h256 ( H256 :: from_low_u64_be ( 1 ) ) ,
@@ -748,7 +758,7 @@ mod tests {
748758 ready : limit. clone ( ) ,
749759 future : limit. clone ( ) ,
750760 ..Default :: default ( )
751- } , TestApi :: default ( ) ) ;
761+ } , TestApi :: default ( ) . into ( ) ) ;
752762
753763 // when
754764 block_on ( pool. submit_one ( & BlockId :: Number ( 0 ) , uxt ( Transfer {
@@ -924,7 +934,7 @@ mod tests {
924934 ready : limit. clone ( ) ,
925935 future : limit. clone ( ) ,
926936 ..Default :: default ( )
927- } , TestApi :: default ( ) ) ;
937+ } , TestApi :: default ( ) . into ( ) ) ;
928938
929939 let xt = uxt ( Transfer {
930940 from : AccountId :: from_h256 ( H256 :: from_low_u64_be ( 1 ) ) ,
@@ -958,7 +968,7 @@ mod tests {
958968 let ( tx, rx) = std:: sync:: mpsc:: sync_channel ( 1 ) ;
959969 let mut api = TestApi :: default ( ) ;
960970 api. delay = Arc :: new ( Mutex :: new ( rx. into ( ) ) ) ;
961- let pool = Arc :: new ( Pool :: new ( Default :: default ( ) , api) ) ;
971+ let pool = Arc :: new ( Pool :: new ( Default :: default ( ) , api. into ( ) ) ) ;
962972
963973 // when
964974 let xt = uxt ( Transfer {
0 commit comments