mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Finish the tree logic in the transaction-chaining scheduler
Also completes the DB functions, makes Scheduler never instantiated, and ensures tree roots have change outputs.
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
use std::io;
|
||||
|
||||
use scale::{Encode, Decode, IoReader};
|
||||
|
||||
use serai_primitives::{Balance, Data};
|
||||
use serai_coins_primitives::OutInstructionWithBalance;
|
||||
|
||||
@@ -27,6 +31,7 @@ impl<A: Address> Payment<A> {
|
||||
pub fn new(address: A, balance: Balance, data: Option<Vec<u8>>) -> Self {
|
||||
Payment { address, balance, data }
|
||||
}
|
||||
|
||||
/// The address to pay.
|
||||
pub fn address(&self) -> &A {
|
||||
&self.address
|
||||
@@ -39,4 +44,20 @@ impl<A: Address> Payment<A> {
|
||||
pub fn data(&self) -> &Option<Vec<u8>> {
|
||||
&self.data
|
||||
}
|
||||
|
||||
/// Read a Payment.
|
||||
pub fn read(reader: &mut impl io::Read) -> io::Result<Self> {
|
||||
let address = A::read(reader)?;
|
||||
let reader = &mut IoReader(reader);
|
||||
let balance = Balance::decode(reader).map_err(io::Error::other)?;
|
||||
let data = Option::<Vec<u8>>::decode(reader).map_err(io::Error::other)?;
|
||||
Ok(Self { address, balance, data })
|
||||
}
|
||||
/// Write the Payment.
|
||||
pub fn write(&self, writer: &mut impl io::Write) -> io::Result<()> {
|
||||
self.address.write(writer).unwrap();
|
||||
self.balance.encode_to(writer);
|
||||
self.data.encode_to(writer);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user