@@ -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,7 @@ 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:: { RecvBody , SendBody , TaggedBase64 , TransactionsWithProof , VidCommonResponse , TX } ;
22
22
23
23
pub use crate :: multiwatcher:: Multiwatcher ;
24
24
pub use crate :: types:: Height ;
@@ -58,11 +58,11 @@ impl Client {
58
58
self . get_with_retry ( u) . await
59
59
}
60
60
61
- pub async fn submit < N > ( & self , nsid : N , cb : & CertifiedBlock < Validated > ) -> Result < ( ) , Error >
61
+ pub async fn submit < N > ( & self , nsid : N , blocks : & [ CertifiedBlock < Validated > ] ) -> Result < ( ) , Error >
62
62
where
63
63
N : Into < NamespaceId > ,
64
64
{
65
- let trx = Transaction :: new ( nsid. into ( ) , minicbor:: to_vec ( cb ) ?) ;
65
+ let trx = Transaction :: new ( nsid. into ( ) , minicbor:: to_vec ( SendBody { blocks } ) ?) ;
66
66
let url = self . config . base_url . join ( "submit/submit" ) ?;
67
67
self . post_with_retry :: < _ , TaggedBase64 < TX > > ( url, & trx)
68
68
. await ?;
@@ -102,34 +102,36 @@ impl Client {
102
102
warn ! ( node = %self . config. label, a = %nsid, b = %ns, height = %hdr. height( ) , "namespace mismatch" ) ;
103
103
return Either :: Left ( empty ( ) ) ;
104
104
}
105
- Either :: Right ( trxs. into_iter ( ) . filter_map ( move |t| {
106
- match minicbor:: decode :: < CertifiedBlock < Unchecked > > ( t. payload ( ) ) {
107
- Ok ( b) => {
108
- let Some ( c) = cvec. get ( b. committee ( ) ) else {
109
- warn ! (
110
- node = %self . config. label,
111
- height = %hdr. height( ) ,
112
- committee = %b. committee( ) ,
113
- "unknown committee"
114
- ) ;
115
- return None ;
116
- } ;
117
- if let Some ( b) = b. validated ( c) {
118
- Some ( b. cert ( ) . data ( ) . num ( ) )
119
- } else {
120
- warn ! ( node = %self . config. label, height = %hdr. height( ) , "invalid block" ) ;
121
- None
122
- }
105
+ Either :: Right ( trxs. into_iter ( ) . flat_map ( move |t| {
106
+ match minicbor:: decode :: < RecvBody > ( t. payload ( ) ) {
107
+ Ok ( body) => {
108
+ Either :: Right ( body. blocks . into_iter ( ) . filter_map ( |b| {
109
+ let Some ( c) = cvec. get ( b. committee ( ) ) else {
110
+ warn ! (
111
+ node = %self . config. label,
112
+ height = %hdr. height( ) ,
113
+ committee = %b. committee( ) ,
114
+ "unknown committee"
115
+ ) ;
116
+ return None ;
117
+ } ;
118
+ if let Some ( b) = b. validated ( c) {
119
+ Some ( b. cert ( ) . data ( ) . num ( ) )
120
+ } else {
121
+ warn ! ( node = %self . config. label, height = %hdr. height( ) , "invalid block" ) ;
122
+ None
123
+ }
124
+ } ) )
123
125
}
124
126
Err ( err) => {
125
127
warn ! (
126
128
node = %self . config. label,
127
129
nsid = %nsid,
128
130
height = %hdr. height( ) ,
129
131
err = %err,
130
- "could not deserialize block "
132
+ "could not decode transaction payload "
131
133
) ;
132
- None
134
+ Either :: Left ( empty ( ) )
133
135
}
134
136
}
135
137
} ) )
0 commit comments