mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-21 06:38:56 +00:00
Better document the forwarded output flow
This commit is contained in:
parent
fadc88d2ad
commit
f11a6b4ff1
3 changed files with 25 additions and 7 deletions
|
@ -19,8 +19,11 @@ pub trait Eventuality: Sized + Send + Sync {
|
||||||
/// identified, the full check is performed.
|
/// identified, the full check is performed.
|
||||||
fn lookup(&self) -> Vec<u8>;
|
fn lookup(&self) -> Vec<u8>;
|
||||||
|
|
||||||
/// The output this plan forwarded.
|
/// The output the resolution of this Eventuality was supposed to spend.
|
||||||
fn forwarded_output(&self) -> Option<Self::OutputId>;
|
///
|
||||||
|
/// If the resolution of this Eventuality has multiple inputs, there is no singular spent output
|
||||||
|
/// so this MUST return None.
|
||||||
|
fn singular_spent_output(&self) -> Option<Self::OutputId>;
|
||||||
|
|
||||||
/// Read an Eventuality.
|
/// Read an Eventuality.
|
||||||
fn read(reader: &mut impl io::Read) -> io::Result<Self>;
|
fn read(reader: &mut impl io::Read) -> io::Result<Self>;
|
||||||
|
|
|
@ -352,19 +352,24 @@ impl<D: Db, S: ScannerFeed, Sch: Scheduler<S>> ContinuallyRan for EventualityTas
|
||||||
non_external_outputs.iter().filter(|output| output.kind() == OutputType::Forwarded)
|
non_external_outputs.iter().filter(|output| output.kind() == OutputType::Forwarded)
|
||||||
{
|
{
|
||||||
let Some(eventuality) = completed_eventualities.get(&output.transaction_id()) else {
|
let Some(eventuality) = completed_eventualities.get(&output.transaction_id()) else {
|
||||||
// Output sent to the forwarding address yet not actually forwarded
|
// Output sent to the forwarding address yet not one we made
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Some(forwarded) = eventuality.forwarded_output() else {
|
let Some(forwarded) = eventuality.singular_spent_output() else {
|
||||||
// This was a TX made by us, yet someone burned to the forwarding address
|
// This was a TX made by us, yet someone burned to the forwarding address as it doesn't
|
||||||
|
// follow the structure of forwarding transactions
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let (return_address, in_instruction) =
|
let Some((return_address, in_instruction)) =
|
||||||
ScannerGlobalDb::<S>::return_address_and_in_instruction_for_forwarded_output(
|
ScannerGlobalDb::<S>::return_address_and_in_instruction_for_forwarded_output(
|
||||||
&txn, &forwarded,
|
&txn, &forwarded,
|
||||||
)
|
)
|
||||||
.expect("forwarded an output yet didn't save its InInstruction to the DB");
|
else {
|
||||||
|
// This was a TX made by us, coincidentally with the necessary structure, yet wasn't
|
||||||
|
// forwarding an output
|
||||||
|
continue;
|
||||||
|
};
|
||||||
queue_output_until_block::<S>(
|
queue_output_until_block::<S>(
|
||||||
&mut txn,
|
&mut txn,
|
||||||
b + S::WINDOW_LENGTH,
|
b + S::WINDOW_LENGTH,
|
||||||
|
|
|
@ -216,14 +216,24 @@ pub struct SchedulerUpdate<S: ScannerFeed> {
|
||||||
|
|
||||||
impl<S: ScannerFeed> SchedulerUpdate<S> {
|
impl<S: ScannerFeed> SchedulerUpdate<S> {
|
||||||
/// The outputs to accumulate.
|
/// The outputs to accumulate.
|
||||||
|
///
|
||||||
|
/// These MUST be accumulated.
|
||||||
pub fn outputs(&self) -> &[OutputFor<S>] {
|
pub fn outputs(&self) -> &[OutputFor<S>] {
|
||||||
&self.outputs
|
&self.outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The outputs to forward to the latest multisig.
|
/// The outputs to forward to the latest multisig.
|
||||||
|
///
|
||||||
|
/// These MUST be forwarded in a 1-input 1-output transaction or dropped (if the fees are too
|
||||||
|
/// high to make the forwarding transaction).
|
||||||
pub fn forwards(&self) -> &[OutputFor<S>] {
|
pub fn forwards(&self) -> &[OutputFor<S>] {
|
||||||
&self.forwards
|
&self.forwards
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The outputs to return.
|
/// The outputs to return.
|
||||||
|
///
|
||||||
|
/// These SHOULD be returned as specified (potentially in batch). They MAY be dropped if the fees
|
||||||
|
/// are too high to make the return transaction.
|
||||||
pub fn returns(&self) -> &[Return<S>] {
|
pub fn returns(&self) -> &[Return<S>] {
|
||||||
&self.returns
|
&self.returns
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue