thruput_node_rpc/
sched_db.rs1#![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))]
31#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
32#[derive(schemars::JsonSchema)]
33#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
34#[repr(C)]
35pub struct ShardCard {
36 pub protocol: ProtocolCommit,
37 pub upid: UPID,
38 pub block_height: BlockHeight,
39 pub address_for_exec: ServerAddress,
41 pub address_for_sched: ServerAddress,
43 pub address_for_auth: ServerAddress,
45}
46
47#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
48#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
49#[derive(schemars::JsonSchema)]
50#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
51#[repr(C)]
52pub struct Delta {
53 pub address: ContractAddress,
54 pub native_token_delta: int128_xdr,
55}
56
57#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
71#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
72#[derive(schemars::JsonSchema)]
73#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
74#[repr(C)]
75pub struct NativeTokensTransferredChunk {
76 pub block: BlockHeight,
79 pub chunk_index: u32,
85 pub chunk_count: u32,
86 pub deltas: VecM<Delta>,
87}
88
89
90#[allow(non_camel_case_types)]
94pub trait SchedDb_SchedDb1: Send + Sync { fn scheddb_intro_shard(&self, arg0 : ShardCard) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>> + Send;
98 fn scheddb_native_tokens_transferred_chunk(&self, arg0 : NativeTokensTransferredChunk) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>> + Send;
113}
114
115
116#[allow(non_camel_case_types)]
117pub struct SchedDb_SchedDb1_Dispatcher<__Handler> {
118 inner: Box<__Handler>,
119}
120
121impl<__Handler: SchedDb_SchedDb1> SchedDb_SchedDb1_Dispatcher<__Handler> {
122 pub fn new(inner: Box<__Handler>) -> Self {
123 Self { inner }
124 }
125}
126
127#[async_trait::async_trait]
128impl<__Handler: SchedDb_SchedDb1> ::thruput_rpc_api::RpcHandler for SchedDb_SchedDb1_Dispatcher<__Handler> {
129 fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
130 ::thruput_rpc_api::ProgVers::new(0x7ee79998, 1)
131 }
132 async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
133 match proc {
134 1 => {
136 let args: (ShardCard, ) =
137 xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
138 let res = self.inner.scheddb_intro_shard(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
139 xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
140 }
141 4 => {
143 let args: (NativeTokensTransferredChunk, ) =
144 xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
145 let res = self.inner.scheddb_native_tokens_transferred_chunk(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
146 xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
147 }
148 _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
149 }
150 }
151}
152
153#[derive(Clone)]
154pub struct SchedDb_SchedDb1_Client {
155 handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
156}
157
158impl SchedDb_SchedDb1_Client {
159 pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
160 Self { handle }
161 }
162
163 fn prog_vers() -> ::thruput_rpc_api::ProgVers {
164 ::thruput_rpc_api::ProgVers::new(0x7ee79998, 1)
165 }
166 pub async fn scheddb_intro_shard(&self, arg0 : &(impl xdrs::EncodesAs<ShardCard> + ?Sized)) -> Result<(), ::thruput_rpc_api::RpcError> {
167 let mut call = self.handle.call_buf();
168 call.append_with(|buf| {
169 let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
170 let r = xdrs::write_xdr(&(arg0), &mut w);
171 *buf = w.into();
172 r
173 }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
174 let mut out = ::core::option::Option::None;
175 let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
176 out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
177 Ok(())
178 };
179 unsafe { self.handle.send_call_decoded(Self::prog_vers(), 1, call, &mut decode) }.await?;
184 out.ok_or(::thruput_rpc_api::RpcError::SystemError)
185 }
186 pub async fn scheddb_native_tokens_transferred_chunk(&self, arg0 : &(impl xdrs::EncodesAs<NativeTokensTransferredChunk> + ?Sized)) -> Result<(), ::thruput_rpc_api::RpcError> {
187 let mut call = self.handle.call_buf();
188 call.append_with(|buf| {
189 let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
190 let r = xdrs::write_xdr(&(arg0), &mut w);
191 *buf = w.into();
192 r
193 }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
194 let mut out = ::core::option::Option::None;
195 let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
196 out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
197 Ok(())
198 };
199 unsafe { self.handle.send_call_decoded(Self::prog_vers(), 4, call, &mut decode) }.await?;
204 out.ok_or(::thruput_rpc_api::RpcError::SystemError)
205 }
206}
207
208impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for SchedDb_SchedDb1_Client {
209 fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
210 Self::new(handle)
211 }
212}
213
214
215
216