Skip to main content

thruput_node_rpc/
auth_rpc.rs

1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: cb9cab8a8d69ace37c18d49b505f1e93ec802af8
5
6#![allow(non_camel_case_types)]
7#![allow(non_snake_case)]
8#![allow(non_upper_case_globals)]
9#![allow(unused_imports)]
10#![allow(dead_code)]
11#![allow(unused_variables)]
12#![allow(clippy::unnecessary_cast)]
13
14use crate::*;
15use core::option::Option;
16use core::ops::{Deref, DerefMut};
17
18#[cfg(feature = "std")]
19use std::io::{Read, Write};
20use xdrs::*;
21
22
23#[cfg(feature = "serde")]
24use ::serde::{{Serialize, Deserialize}};
25
26
27
28#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
29#[cfg_attr(feature = "serde", serde(transparent))]
30#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
31#[derive(schemars::JsonSchema)]
32#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
33#[derive(Copy)]
34#[repr(transparent)]
35pub struct AuthErrorCode(pub i32);
36
37impl AuthErrorCode {
38    pub const kAuthSuccess: Self = Self(0);
39    pub const kAuthFailed: Self = Self(1);
40
41    // The query is for a block height that is not the most recent committed block height.
42    // This can happen if a query is made for an old block height,
43    // or if (concurrent with the query) a block commits and updates to the auth data begin to stream in.
44    // The verification can be retried in either case.
45    // TODO: We could switch this around, to retry at the higher block height.
46    pub const kAuthStaleBlockHeight: Self = Self(2);
47
48    // Either an internal auth error or forwarded from an internal DB error
49    pub const kAuthInternal: Self = Self(3);
50}
51impl From<i32> for AuthErrorCode {
52    fn from(v: i32) -> Self {
53        Self(v)
54    }
55}
56#[cfg(feature = "std")]
57impl core::fmt::Display for AuthErrorCode {
58    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
59        match self.0 {
60            x if x == Self::kAuthSuccess.0 => {
61                write!(f, "AuthErrorCode::kAuthSuccess")
62            },
63            x if x == Self::kAuthFailed.0 => {
64                write!(f, "AuthErrorCode::kAuthFailed")
65            },
66            x if x == Self::kAuthStaleBlockHeight.0 => {
67                write!(f, "AuthErrorCode::kAuthStaleBlockHeight")
68            },
69            x if x == Self::kAuthInternal.0 => {
70                write!(f, "AuthErrorCode::kAuthInternal")
71            },
72            _ => {
73                write!(f, "AuthErrorCode({})", self.0)
74            }
75        }
76    }
77}
78
79
80pub type AuthErrorCodeBatch = VecM::<AuthErrorCode>;
81
82
83/// Each handler replies with anything that encodes like the reply type.
84/// Implementations can be plain `async fn`s returning a concrete reply type
85/// under `#[allow(refining_impl_trait)]`.
86#[allow(non_camel_case_types)]
87pub trait AuthMempool_AuthMempool1: Send + Sync {        // Verify a list of transactions.  This version returns a result for each transaction.
88    // The BlockHeight is the height of the most recently committed block,
89    // i.e. the block height of the block that produced the snapshot auth data against which
90    // the transactions are to be verified.
91
92    fn authmempool_verify_transactions(&self, arg0 : BlockHeight, arg1 : SignedTransactionBatch) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<AuthErrorCodeBatch>, ::thruput_rpc_api::ProgramError>> + Send;
93        // Verify a batch of transactions.  This version returns a single result for the batch,
94    // i.e. are all correct or is there at least one invalid transaction?
95    // This version should be called when validating a proposal, in which if even one
96    // transaction is invalid then the whole block can be rejected.
97    // This version can use batch verification to speed up the verification.
98
99    fn authmempool_verify_batch(&self, arg0 : BlockHeight, arg1 : SignedTransactionBatch) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<AuthErrorCode>, ::thruput_rpc_api::ProgramError>> + Send;
100}
101
102
103#[allow(non_camel_case_types)]
104pub struct AuthMempool_AuthMempool1_Dispatcher<__Handler> {
105  inner: Box<__Handler>,
106}
107
108impl<__Handler: AuthMempool_AuthMempool1> AuthMempool_AuthMempool1_Dispatcher<__Handler> {
109  pub fn new(inner: Box<__Handler>) -> Self {
110    Self { inner }
111  }
112}
113
114#[async_trait::async_trait]
115impl<__Handler: AuthMempool_AuthMempool1> ::thruput_rpc_api::RpcHandler for AuthMempool_AuthMempool1_Dispatcher<__Handler> {
116    fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
117        ::thruput_rpc_api::ProgVers::new(0x8aa87aa7, 1)
118    }
119    async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
120        match proc {
121            // authmempool_verify_transactions
122            2 => {
123                let args: (BlockHeight, SignedTransactionBatch, ) =
124                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
125                let res = self.inner.authmempool_verify_transactions(args.0, args.1).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
126                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
127            }
128            // authmempool_verify_batch
129            3 => {
130                let args: (BlockHeight, SignedTransactionBatch, ) =
131                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
132                let res = self.inner.authmempool_verify_batch(args.0, args.1).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
133                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
134            }
135            _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
136        }
137    }
138}
139
140#[derive(Clone)]
141pub struct AuthMempool_AuthMempool1_Client {
142    handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
143}
144
145impl AuthMempool_AuthMempool1_Client {
146    pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
147        Self { handle }
148    }
149
150    fn prog_vers() -> ::thruput_rpc_api::ProgVers {
151        ::thruput_rpc_api::ProgVers::new(0x8aa87aa7, 1)
152    }
153    pub async fn authmempool_verify_transactions(&self, arg0 : &(impl xdrs::EncodesAs<BlockHeight> + ?Sized), arg1 : &(impl xdrs::EncodesAs<SignedTransactionBatch> + ?Sized)) -> Result<AuthErrorCodeBatch, ::thruput_rpc_api::RpcError> {
154         let mut call = self.handle.call_buf();
155         call.append_with(|buf| {
156             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
157             let r = xdrs::write_xdr(&(arg0, arg1), &mut w);
158             *buf = w.into();
159             r
160         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
161         let mut out = ::core::option::Option::None;
162         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
163             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
164             Ok(())
165         };
166         // SAFETY: the call future is awaited right here, so it lives in
167         // this method's future along with `out` and `decode`. Once that
168         // is polled it is pinned, so neither can be freed without the
169         // call future being dropped first. Decoding never blocks.
170         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 2, call, &mut decode) }.await?;
171         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
172    }
173    pub async fn authmempool_verify_batch(&self, arg0 : &(impl xdrs::EncodesAs<BlockHeight> + ?Sized), arg1 : &(impl xdrs::EncodesAs<SignedTransactionBatch> + ?Sized)) -> Result<AuthErrorCode, ::thruput_rpc_api::RpcError> {
174         let mut call = self.handle.call_buf();
175         call.append_with(|buf| {
176             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
177             let r = xdrs::write_xdr(&(arg0, arg1), &mut w);
178             *buf = w.into();
179             r
180         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
181         let mut out = ::core::option::Option::None;
182         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
183             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
184             Ok(())
185         };
186         // SAFETY: the call future is awaited right here, so it lives in
187         // this method's future along with `out` and `decode`. Once that
188         // is polled it is pinned, so neither can be freed without the
189         // call future being dropped first. Decoding never blocks.
190         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 3, call, &mut decode) }.await?;
191         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
192    }
193}
194
195impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for AuthMempool_AuthMempool1_Client {
196    fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
197        Self::new(handle)
198    }
199}
200
201
202#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
203#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
204#[derive(schemars::JsonSchema)]
205#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
206#[repr(C)]
207pub struct KeyChange {
208    pub address: ContractAddress,
209    pub auth_data: Option<AddressAuthData>,
210}
211
212pub type KeyChangeBatch = VecM::<KeyChange>;
213
214// A committed block's auth-data changes travel as a run of chunks, each a
215// KeyChangeChunk, from the db to the auth server and on from the auth server
216// to the mempool, because the one-record form grew with the number of
217// accounts whose auth data a block changed. The sender chooses
218// the chunk size; the wire bounds a chunk only by the link's record cap. The
219// chunks of a run may be sent concurrently and over several connections, so
220// they can arrive in any order, and a sender may have the runs of several
221// heights in flight at once, so the chunks of different heights can
222// interleave. A receiver treats a height's changes as complete only once
223// every chunk of its run has arrived, and applies heights in order.
224#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
225#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
226#[derive(schemars::JsonSchema)]
227#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
228#[repr(C)]
229pub struct KeyChangeChunk {
230    // The height of the block that made these changes.
231    pub height: BlockHeight,
232    // This chunk's position in the height's run, from 0, and the run's length.
233    // Every chunk of a run carries the same chunk_count, and each index in
234    // [0, chunk_count) is sent exactly once. A block that changed no auth data
235    // is a run of one empty chunk, so every committed block still sends a run
236    // and each receiver's height advances with every block.
237    pub chunk_index: u32,
238    pub chunk_count: u32,
239    pub changes: VecM<KeyChange>,
240}
241
242
243/// Each handler replies with anything that encodes like the reply type.
244/// Implementations can be plain `async fn`s returning a concrete reply type
245/// under `#[allow(refining_impl_trait)]`.
246#[allow(non_camel_case_types)]
247pub trait AuthDB_AuthDB1: Send + Sync {        // Retired number, never to be reused, so that a peer built against it
248    // fails to dispatch rather than misparse a newer payload:
249    //   1: authdb_forward_key_changes(BlockHeight, KeyChangeBatch), a block's
250    //      auth-data changes in one unbounded record, which a block that
251    //      changes enough accounts' auth data grows past any single-record
252    //      cap.
253
254    // Deliver one chunk of a committed block's auth-data changes to the auth
255    // server.
256
257    fn authdb_forward_key_changes_chunk(&self, arg0 : KeyChangeChunk) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>> + Send;
258}
259
260
261#[allow(non_camel_case_types)]
262pub struct AuthDB_AuthDB1_Dispatcher<__Handler> {
263  inner: Box<__Handler>,
264}
265
266impl<__Handler: AuthDB_AuthDB1> AuthDB_AuthDB1_Dispatcher<__Handler> {
267  pub fn new(inner: Box<__Handler>) -> Self {
268    Self { inner }
269  }
270}
271
272#[async_trait::async_trait]
273impl<__Handler: AuthDB_AuthDB1> ::thruput_rpc_api::RpcHandler for AuthDB_AuthDB1_Dispatcher<__Handler> {
274    fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
275        ::thruput_rpc_api::ProgVers::new(0x8aa87aa8, 1)
276    }
277    async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
278        match proc {
279            // authdb_forward_key_changes_chunk
280            2 => {
281                let args: (KeyChangeChunk, ) =
282                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
283                let res = self.inner.authdb_forward_key_changes_chunk(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
284                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
285            }
286            _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
287        }
288    }
289}
290
291#[derive(Clone)]
292pub struct AuthDB_AuthDB1_Client {
293    handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
294}
295
296impl AuthDB_AuthDB1_Client {
297    pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
298        Self { handle }
299    }
300
301    fn prog_vers() -> ::thruput_rpc_api::ProgVers {
302        ::thruput_rpc_api::ProgVers::new(0x8aa87aa8, 1)
303    }
304    pub async fn authdb_forward_key_changes_chunk(&self, arg0 : &(impl xdrs::EncodesAs<KeyChangeChunk> + ?Sized)) -> Result<(), ::thruput_rpc_api::RpcError> {
305         let mut call = self.handle.call_buf();
306         call.append_with(|buf| {
307             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
308             let r = xdrs::write_xdr(&(arg0), &mut w);
309             *buf = w.into();
310             r
311         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
312         let mut out = ::core::option::Option::None;
313         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
314             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
315             Ok(())
316         };
317         // SAFETY: the call future is awaited right here, so it lives in
318         // this method's future along with `out` and `decode`. Once that
319         // is polled it is pinned, so neither can be freed without the
320         // call future being dropped first. Decoding never blocks.
321         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 2, call, &mut decode) }.await?;
322         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
323    }
324}
325
326impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for AuthDB_AuthDB1_Client {
327    fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
328        Self::new(handle)
329    }
330}
331
332
333#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
334#[cfg_attr(feature = "serde", serde(transparent))]
335#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
336#[derive(schemars::JsonSchema)]
337#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
338#[derive(Copy)]
339#[repr(transparent)]
340pub struct DBAuthError(pub i32);
341
342impl DBAuthError {
343    pub const kDBAuthSuccess: Self = Self(0);
344    pub const kDBAuthNotFound: Self = Self(1);
345    pub const kDBAuthStaleBlockHeight: Self = Self(2);
346    pub const kDBAuthInternal: Self = Self(3);
347}
348impl From<i32> for DBAuthError {
349    fn from(v: i32) -> Self {
350        Self(v)
351    }
352}
353#[cfg(feature = "std")]
354impl core::fmt::Display for DBAuthError {
355    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
356        match self.0 {
357            x if x == Self::kDBAuthSuccess.0 => {
358                write!(f, "DBAuthError::kDBAuthSuccess")
359            },
360            x if x == Self::kDBAuthNotFound.0 => {
361                write!(f, "DBAuthError::kDBAuthNotFound")
362            },
363            x if x == Self::kDBAuthStaleBlockHeight.0 => {
364                write!(f, "DBAuthError::kDBAuthStaleBlockHeight")
365            },
366            x if x == Self::kDBAuthInternal.0 => {
367                write!(f, "DBAuthError::kDBAuthInternal")
368            },
369            _ => {
370                write!(f, "DBAuthError({})", self.0)
371            }
372        }
373    }
374}
375
376
377#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
378#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
379#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
380#[derive(schemars::JsonSchema)]
381#[repr(i32)]
382#[non_exhaustive]
383pub enum DBAuthResult {
384    // case kDBAuthSuccess:
385    //   AddressAuthData auth_data;
386    kDBAuthSuccess { auth_data: AddressAuthData } = DBAuthError::kDBAuthSuccess.0 as i32,
387    // default:
388    //   void;
389    #[xdr(default_variant)] Default { error: i32 },
390}
391
392#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
393#[cfg_attr(feature = "serde", serde(transparent))]
394#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
395#[derive(schemars::JsonSchema)]
396#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
397#[derive(Copy)]
398#[repr(transparent)]
399pub struct DBAuthIntroOutcome(pub i32);
400
401impl DBAuthIntroOutcome {
402    pub const kIntroSuccess: Self = Self(0);
403    pub const kIntroFailure: Self = Self(1);
404}
405impl From<i32> for DBAuthIntroOutcome {
406    fn from(v: i32) -> Self {
407        Self(v)
408    }
409}
410#[cfg(feature = "std")]
411impl core::fmt::Display for DBAuthIntroOutcome {
412    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
413        match self.0 {
414            x if x == Self::kIntroSuccess.0 => {
415                write!(f, "DBAuthIntroOutcome::kIntroSuccess")
416            },
417            x if x == Self::kIntroFailure.0 => {
418                write!(f, "DBAuthIntroOutcome::kIntroFailure")
419            },
420            _ => {
421                write!(f, "DBAuthIntroOutcome({})", self.0)
422            }
423        }
424    }
425}
426
427
428#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
429#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
430#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
431#[derive(schemars::JsonSchema)]
432#[repr(i32)]
433#[non_exhaustive]
434pub enum DBAuthIntroResult {
435    // case kIntroSuccess:
436    //   BlockHeight current_height;
437    kIntroSuccess { current_height: BlockHeight } = DBAuthIntroOutcome::kIntroSuccess.0 as i32,
438    // default:
439    //   void;
440    #[xdr(default_variant)] Default { outcome: i32 },
441}
442
443pub type DBAuthResultBatch = VecM::<DBAuthResult>;
444
445
446/// Each handler replies with anything that encodes like the reply type.
447/// Implementations can be plain `async fn`s returning a concrete reply type
448/// under `#[allow(refining_impl_trait)]`.
449#[allow(non_camel_case_types)]
450pub trait DBAuth_DBAuth1: Send + Sync {        // Get the auth data for a single address.
451    // If some block concurrently commits which modifies the auth data,
452    // then this call can return kDBAuthStaleBlockHeight.
453
454    fn authdb_get_auth_data(&self, arg0 : BlockHeight, arg1 : ContractAddress) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<DBAuthResult>, ::thruput_rpc_api::ProgramError>> + Send;
455        // Get the auth data for a batch of addresses.
456
457    fn authdb_get_auth_data_batch(&self, arg0 : BlockHeight, arg1 : ContractAddressBatch) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<DBAuthResultBatch>, ::thruput_rpc_api::ProgramError>> + Send;
458        // Introduce an auth server to a db shard,
459    // and subscribe to updates to auth data
460
461    fn dbauth_intro(&self, arg0 : AuthCard) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<DBAuthIntroResult>, ::thruput_rpc_api::ProgramError>> + Send;
462}
463
464
465#[allow(non_camel_case_types)]
466pub struct DBAuth_DBAuth1_Dispatcher<__Handler> {
467  inner: Box<__Handler>,
468}
469
470impl<__Handler: DBAuth_DBAuth1> DBAuth_DBAuth1_Dispatcher<__Handler> {
471  pub fn new(inner: Box<__Handler>) -> Self {
472    Self { inner }
473  }
474}
475
476#[async_trait::async_trait]
477impl<__Handler: DBAuth_DBAuth1> ::thruput_rpc_api::RpcHandler for DBAuth_DBAuth1_Dispatcher<__Handler> {
478    fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
479        ::thruput_rpc_api::ProgVers::new(0x8aa87aa9, 1)
480    }
481    async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
482        match proc {
483            // authdb_get_auth_data
484            0 => {
485                let args: (BlockHeight, ContractAddress, ) =
486                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
487                let res = self.inner.authdb_get_auth_data(args.0, args.1).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
488                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
489            }
490            // authdb_get_auth_data_batch
491            1 => {
492                let args: (BlockHeight, ContractAddressBatch, ) =
493                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
494                let res = self.inner.authdb_get_auth_data_batch(args.0, args.1).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
495                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
496            }
497            // dbauth_intro
498            2 => {
499                let args: (AuthCard, ) =
500                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
501                let res = self.inner.dbauth_intro(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
502                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
503            }
504            _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
505        }
506    }
507}
508
509#[derive(Clone)]
510pub struct DBAuth_DBAuth1_Client {
511    handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
512}
513
514impl DBAuth_DBAuth1_Client {
515    pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
516        Self { handle }
517    }
518
519    fn prog_vers() -> ::thruput_rpc_api::ProgVers {
520        ::thruput_rpc_api::ProgVers::new(0x8aa87aa9, 1)
521    }
522    pub async fn authdb_get_auth_data(&self, arg0 : &(impl xdrs::EncodesAs<BlockHeight> + ?Sized), arg1 : &(impl xdrs::EncodesAs<ContractAddress> + ?Sized)) -> Result<DBAuthResult, ::thruput_rpc_api::RpcError> {
523         let mut call = self.handle.call_buf();
524         call.append_with(|buf| {
525             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
526             let r = xdrs::write_xdr(&(arg0, arg1), &mut w);
527             *buf = w.into();
528             r
529         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
530         let mut out = ::core::option::Option::None;
531         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
532             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
533             Ok(())
534         };
535         // SAFETY: the call future is awaited right here, so it lives in
536         // this method's future along with `out` and `decode`. Once that
537         // is polled it is pinned, so neither can be freed without the
538         // call future being dropped first. Decoding never blocks.
539         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 0, call, &mut decode) }.await?;
540         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
541    }
542    pub async fn authdb_get_auth_data_batch(&self, arg0 : &(impl xdrs::EncodesAs<BlockHeight> + ?Sized), arg1 : &(impl xdrs::EncodesAs<ContractAddressBatch> + ?Sized)) -> Result<DBAuthResultBatch, ::thruput_rpc_api::RpcError> {
543         let mut call = self.handle.call_buf();
544         call.append_with(|buf| {
545             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
546             let r = xdrs::write_xdr(&(arg0, arg1), &mut w);
547             *buf = w.into();
548             r
549         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
550         let mut out = ::core::option::Option::None;
551         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
552             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
553             Ok(())
554         };
555         // SAFETY: the call future is awaited right here, so it lives in
556         // this method's future along with `out` and `decode`. Once that
557         // is polled it is pinned, so neither can be freed without the
558         // call future being dropped first. Decoding never blocks.
559         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 1, call, &mut decode) }.await?;
560         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
561    }
562    pub async fn dbauth_intro(&self, arg0 : &(impl xdrs::EncodesAs<AuthCard> + ?Sized)) -> Result<DBAuthIntroResult, ::thruput_rpc_api::RpcError> {
563         let mut call = self.handle.call_buf();
564         call.append_with(|buf| {
565             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
566             let r = xdrs::write_xdr(&(arg0), &mut w);
567             *buf = w.into();
568             r
569         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
570         let mut out = ::core::option::Option::None;
571         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
572             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
573             Ok(())
574         };
575         // SAFETY: the call future is awaited right here, so it lives in
576         // this method's future along with `out` and `decode`. Once that
577         // is polled it is pinned, so neither can be freed without the
578         // call future being dropped first. Decoding never blocks.
579         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 2, call, &mut decode) }.await?;
580         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
581    }
582}
583
584impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for DBAuth_DBAuth1_Client {
585    fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
586        Self::new(handle)
587    }
588}
589
590
591#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
592#[cfg_attr(feature = "serde", serde(transparent))]
593#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
594#[derive(schemars::JsonSchema)]
595#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
596#[derive(Copy)]
597#[repr(transparent)]
598pub struct IntroAuthOutcome(pub i32);
599
600impl IntroAuthOutcome {
601    pub const kSuccess: Self = Self(0);
602    pub const kFailure: Self = Self(1);
603}
604impl From<i32> for IntroAuthOutcome {
605    fn from(v: i32) -> Self {
606        Self(v)
607    }
608}
609#[cfg(feature = "std")]
610impl core::fmt::Display for IntroAuthOutcome {
611    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
612        match self.0 {
613            x if x == Self::kSuccess.0 => {
614                write!(f, "IntroAuthOutcome::kSuccess")
615            },
616            x if x == Self::kFailure.0 => {
617                write!(f, "IntroAuthOutcome::kFailure")
618            },
619            _ => {
620                write!(f, "IntroAuthOutcome({})", self.0)
621            }
622        }
623    }
624}
625
626
627#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
628#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
629#[derive(schemars::JsonSchema)]
630#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
631#[repr(C)]
632pub struct MempoolAuthIntroSuccess {
633    pub shards: VecM<ShardCard>,
634    pub network_hash: NetworkHash,
635}
636
637#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
638#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
639#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
640#[derive(schemars::JsonSchema)]
641#[repr(i32)]
642#[non_exhaustive]
643pub enum IntroAuthResult {
644    // case kSuccess:
645    //   MempoolAuthIntroSuccess success;
646    kSuccess { success: MempoolAuthIntroSuccess } = IntroAuthOutcome::kSuccess.0 as i32,
647    // default:
648    //   void;
649    #[xdr(default_variant)] Default { outcome: i32 },
650}
651
652
653/// Each handler replies with anything that encodes like the reply type.
654/// Implementations can be plain `async fn`s returning a concrete reply type
655/// under `#[allow(refining_impl_trait)]`.
656#[allow(non_camel_case_types)]
657pub trait MempoolAuth_MempoolAuth1: Send + Sync {        // Register an auth server with the mempool. The mempool serves the
658    // coordinator only once an auth server has registered, so an auth server
659    // registers only after it has subscribed to the db's auth-data changes
660    // (dbauth_intro), finding the db shards with mempoolauth_get_auth_info.
661    // Otherwise a block could commit before the subscription, and its changes
662    // would never reach the mempool. The result repeats what
663    // mempoolauth_get_auth_info returned.
664
665    fn mempoolauth_intro_auth(&self, arg0 : AuthCard) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<IntroAuthResult>, ::thruput_rpc_api::ProgramError>> + Send;
666        // Retired number, never to be reused, so that a peer built against it
667    // fails to dispatch rather than misparse a newer payload:
668    //   1: mempoolauth_auth_data_changed(BlockHeight, KeyChangeBatch), a
669    //      block's auth-data changes in one unbounded record.
670
671    // Deliver one chunk of a committed block's auth-data changes from the auth
672    // server to the mempool. The auth server sends a height's run only after
673    // it has applied the whole height itself.
674
675    fn mempoolauth_auth_data_changed_chunk(&self, arg0 : KeyChangeChunk) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>> + Send;
676        // Return the db shards and the network hash, which an auth server needs
677    // to subscribe to the db before it registers. Unlike
678    // mempoolauth_intro_auth, this does not register the auth server.
679
680    fn mempoolauth_get_auth_info(&self, arg0 : ProtocolCommit) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<IntroAuthResult>, ::thruput_rpc_api::ProgramError>> + Send;
681}
682
683
684#[allow(non_camel_case_types)]
685pub struct MempoolAuth_MempoolAuth1_Dispatcher<__Handler> {
686  inner: Box<__Handler>,
687}
688
689impl<__Handler: MempoolAuth_MempoolAuth1> MempoolAuth_MempoolAuth1_Dispatcher<__Handler> {
690  pub fn new(inner: Box<__Handler>) -> Self {
691    Self { inner }
692  }
693}
694
695#[async_trait::async_trait]
696impl<__Handler: MempoolAuth_MempoolAuth1> ::thruput_rpc_api::RpcHandler for MempoolAuth_MempoolAuth1_Dispatcher<__Handler> {
697    fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
698        ::thruput_rpc_api::ProgVers::new(0x8aa87aaa, 1)
699    }
700    async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
701        match proc {
702            // mempoolauth_intro_auth
703            0 => {
704                let args: (AuthCard, ) =
705                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
706                let res = self.inner.mempoolauth_intro_auth(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
707                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
708            }
709            // mempoolauth_auth_data_changed_chunk
710            2 => {
711                let args: (KeyChangeChunk, ) =
712                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
713                let res = self.inner.mempoolauth_auth_data_changed_chunk(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
714                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
715            }
716            // mempoolauth_get_auth_info
717            3 => {
718                let args: (ProtocolCommit, ) =
719                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
720                let res = self.inner.mempoolauth_get_auth_info(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
721                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
722            }
723            _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
724        }
725    }
726}
727
728#[derive(Clone)]
729pub struct MempoolAuth_MempoolAuth1_Client {
730    handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
731}
732
733impl MempoolAuth_MempoolAuth1_Client {
734    pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
735        Self { handle }
736    }
737
738    fn prog_vers() -> ::thruput_rpc_api::ProgVers {
739        ::thruput_rpc_api::ProgVers::new(0x8aa87aaa, 1)
740    }
741    pub async fn mempoolauth_intro_auth(&self, arg0 : &(impl xdrs::EncodesAs<AuthCard> + ?Sized)) -> Result<IntroAuthResult, ::thruput_rpc_api::RpcError> {
742         let mut call = self.handle.call_buf();
743         call.append_with(|buf| {
744             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
745             let r = xdrs::write_xdr(&(arg0), &mut w);
746             *buf = w.into();
747             r
748         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
749         let mut out = ::core::option::Option::None;
750         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
751             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
752             Ok(())
753         };
754         // SAFETY: the call future is awaited right here, so it lives in
755         // this method's future along with `out` and `decode`. Once that
756         // is polled it is pinned, so neither can be freed without the
757         // call future being dropped first. Decoding never blocks.
758         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 0, call, &mut decode) }.await?;
759         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
760    }
761    pub async fn mempoolauth_auth_data_changed_chunk(&self, arg0 : &(impl xdrs::EncodesAs<KeyChangeChunk> + ?Sized)) -> Result<(), ::thruput_rpc_api::RpcError> {
762         let mut call = self.handle.call_buf();
763         call.append_with(|buf| {
764             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
765             let r = xdrs::write_xdr(&(arg0), &mut w);
766             *buf = w.into();
767             r
768         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
769         let mut out = ::core::option::Option::None;
770         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
771             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
772             Ok(())
773         };
774         // SAFETY: the call future is awaited right here, so it lives in
775         // this method's future along with `out` and `decode`. Once that
776         // is polled it is pinned, so neither can be freed without the
777         // call future being dropped first. Decoding never blocks.
778         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 2, call, &mut decode) }.await?;
779         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
780    }
781    pub async fn mempoolauth_get_auth_info(&self, arg0 : &(impl xdrs::EncodesAs<ProtocolCommit> + ?Sized)) -> Result<IntroAuthResult, ::thruput_rpc_api::RpcError> {
782         let mut call = self.handle.call_buf();
783         call.append_with(|buf| {
784             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
785             let r = xdrs::write_xdr(&(arg0), &mut w);
786             *buf = w.into();
787             r
788         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
789         let mut out = ::core::option::Option::None;
790         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
791             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
792             Ok(())
793         };
794         // SAFETY: the call future is awaited right here, so it lives in
795         // this method's future along with `out` and `decode`. Once that
796         // is polled it is pinned, so neither can be freed without the
797         // call future being dropped first. Decoding never blocks.
798         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 3, call, &mut decode) }.await?;
799         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
800    }
801}
802
803impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for MempoolAuth_MempoolAuth1_Client {
804    fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
805        Self::new(handle)
806    }
807}
808
809
810
811//
812// XDR internals below this point
813//
814
815impl DBAuthResult {
816    #[allow(clippy::match_single_binding)]
817    pub fn error(&self) -> DBAuthError {
818        match self {
819            DBAuthResult::Default{ error } => (*error).into(),
820
821            _ => (unsafe { *(self as *const Self as *const i32) }).into(),
822        }
823    }
824}
825
826impl DBAuthIntroResult {
827    #[allow(clippy::match_single_binding)]
828    pub fn outcome(&self) -> DBAuthIntroOutcome {
829        match self {
830            DBAuthIntroResult::Default{ outcome } => (*outcome).into(),
831
832            _ => (unsafe { *(self as *const Self as *const i32) }).into(),
833        }
834    }
835}
836
837impl IntroAuthResult {
838    #[allow(clippy::match_single_binding)]
839    pub fn outcome(&self) -> IntroAuthOutcome {
840        match self {
841            IntroAuthResult::Default{ outcome } => (*outcome).into(),
842
843            _ => (unsafe { *(self as *const Self as *const i32) }).into(),
844        }
845    }
846}
847
848