@@ -9,7 +9,7 @@ use std::time::Duration;
9
9
10
10
use either:: Either ;
11
11
use espresso_types:: { Header , NamespaceId , Transaction } ;
12
- use multisig:: { Unchecked , Validated } ;
12
+ use multisig:: Validated ;
13
13
use reqwest:: { StatusCode , Url } ;
14
14
use serde:: { Serialize , de:: DeserializeOwned } ;
15
15
use serde_json as json;
@@ -18,7 +18,9 @@ use timeboost_types::{BlockNumber, CertifiedBlock};
18
18
use tokio:: time:: sleep;
19
19
use tracing:: { debug, warn} ;
20
20
21
- use crate :: types:: { TX , TaggedBase64 , TransactionsWithProof , VidCommonResponse } ;
21
+ use crate :: types:: {
22
+ RecvBody , SendBody , TX , TaggedBase64 , TransactionsWithProof , VidCommonResponse ,
23
+ } ;
22
24
23
25
pub use crate :: multiwatcher:: Multiwatcher ;
24
26
pub use crate :: types:: Height ;
@@ -58,11 +60,15 @@ impl Client {
58
60
self . get_with_retry ( u) . await
59
61
}
60
62
61
- pub async fn submit < N > ( & self , nsid : N , cb : & CertifiedBlock < Validated > ) -> Result < ( ) , Error >
63
+ pub async fn submit < N > (
64
+ & self ,
65
+ nsid : N ,
66
+ blocks : & [ CertifiedBlock < Validated > ] ,
67
+ ) -> Result < ( ) , Error >
62
68
where
63
69
N : Into < NamespaceId > ,
64
70
{
65
- let trx = Transaction :: new ( nsid. into ( ) , minicbor:: to_vec ( cb ) ?) ;
71
+ let trx = Transaction :: new ( nsid. into ( ) , minicbor:: to_vec ( SendBody { blocks } ) ?) ;
66
72
let url = self . config . base_url . join ( "submit/submit" ) ?;
67
73
self . post_with_retry :: < _ , TaggedBase64 < TX > > ( url, & trx)
68
74
. await ?;
@@ -102,9 +108,9 @@ impl Client {
102
108
warn ! ( node = %self . config. label, a = %nsid, b = %ns, height = %hdr. height( ) , "namespace mismatch" ) ;
103
109
return Either :: Left ( empty ( ) ) ;
104
110
}
105
- Either :: Right ( trxs. into_iter ( ) . filter_map ( move |t| {
106
- match minicbor:: decode :: < CertifiedBlock < Unchecked > > ( t. payload ( ) ) {
107
- Ok ( b ) => {
111
+ Either :: Right ( trxs. into_iter ( ) . flat_map ( move |t| {
112
+ match minicbor:: decode :: < RecvBody > ( t. payload ( ) ) {
113
+ Ok ( body ) => Either :: Right ( body . blocks . into_iter ( ) . filter_map ( |b| {
108
114
let Some ( c) = cvec. get ( b. committee ( ) ) else {
109
115
warn ! (
110
116
node = %self . config. label,
@@ -120,16 +126,16 @@ impl Client {
120
126
warn ! ( node = %self . config. label, height = %hdr. height( ) , "invalid block" ) ;
121
127
None
122
128
}
123
- }
129
+ } ) ) ,
124
130
Err ( err) => {
125
131
warn ! (
126
132
node = %self . config. label,
127
133
nsid = %nsid,
128
134
height = %hdr. height( ) ,
129
135
err = %err,
130
- "could not deserialize block "
136
+ "could not decode transaction payload "
131
137
) ;
132
- None
138
+ Either :: Left ( empty ( ) )
133
139
}
134
140
}
135
141
} ) )
0 commit comments