mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Fill in various DB functions
This commit is contained in:
@@ -23,9 +23,9 @@ pub trait Eventuality: Sized + Send + Sync {
|
||||
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>`.
|
||||
fn serialize(&self) -> Vec<u8>;
|
||||
fn read(reader: &mut impl io::Read) -> io::Result<Self>;
|
||||
/// Write an Eventuality.
|
||||
fn write(&self, writer: &mut impl io::Write) -> io::Result<()>;
|
||||
}
|
||||
|
||||
/// A tracker of unresolved Eventualities.
|
||||
@@ -36,3 +36,16 @@ pub struct EventualityTracker<E: Eventuality> {
|
||||
/// These are keyed by their lookups.
|
||||
pub active_eventualities: HashMap<Vec<u8>, E>,
|
||||
}
|
||||
|
||||
impl<E: Eventuality> Default for EventualityTracker<E> {
|
||||
fn default() -> Self {
|
||||
EventualityTracker { active_eventualities: HashMap::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Eventuality> EventualityTracker<E> {
|
||||
/// Insert an Eventuality into the tracker.
|
||||
pub fn insert(&mut self, eventuality: E) {
|
||||
self.active_eventualities.insert(eventuality.lookup(), eventuality);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,12 @@ use serai_primitives::{ExternalAddress, Balance};
|
||||
use crate::Id;
|
||||
|
||||
/// An address on the external network.
|
||||
pub trait Address: Send + Sync + TryFrom<ExternalAddress> {}
|
||||
pub trait Address: Send + Sync + TryFrom<ExternalAddress> {
|
||||
/// Write this address.
|
||||
fn write(&self, writer: &mut impl io::Write) -> io::Result<()>;
|
||||
/// Read an address.
|
||||
fn read(reader: &mut impl io::Read) -> io::Result<Self>;
|
||||
}
|
||||
|
||||
/// The type of the output.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user