Flesh out eventuality task

This commit is contained in:
Luke Parker
2024-08-24 23:43:31 -04:00
parent 945f31dfc7
commit 379780a3c9
11 changed files with 174 additions and 29 deletions

View File

@@ -1,8 +1,12 @@
use std::collections::HashMap;
use std::io;
use std::{io, collections::HashMap};
use crate::Id;
/// A description of a transaction which will eventually happen.
pub trait Eventuality: Sized + Send + Sync {
/// The type used to identify a received output.
type OutputId: Id;
/// A unique byte sequence which can be used to identify potentially resolving transactions.
///
/// Both a transaction and an Eventuality are expected to be able to yield lookup sequences.
@@ -15,6 +19,9 @@ pub trait Eventuality: Sized + Send + Sync {
/// identified, the full check is performed.
fn lookup(&self) -> Vec<u8>;
/// The output this plan forwarded.
fn forwarded_output(&self) -> Option<Self::OutputId>;
/// Read an Eventuality.
fn read<R: io::Read>(reader: &mut R) -> io::Result<Self>;
/// Serialize an Eventuality to a `Vec<u8>`.