use std::cmp::{Ord, Ordering, PartialOrd};
use web3::types::H256;
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum EthereumTransactionHash {
Deposit(H256),
Token(H256),
}
#[derive(PartialEq, Eq, Clone)]
pub struct EthereumTransaction {
pub tx_hash: EthereumTransactionHash,
pub block_hash: H256,
pub block: u64,
pub index: u64,
}
impl EthereumTransaction {
pub fn enclosed_hash(&self) -> H256 {
match self.tx_hash {
EthereumTransactionHash::Token(h) => h,
EthereumTransactionHash::Deposit(h) => h,
}
}
}
impl PartialOrd for EthereumTransaction {
fn partial_cmp(&self, o: &Self) -> Option<Ordering> {
self.block.partial_cmp(&o.block)
}
}
impl Ord for EthereumTransaction {
fn cmp(&self, o: &Self) -> Ordering {
self.block.cmp(&o.block)
}
}
#[derive(Default)]
pub struct MemCache {
pub start: u64,
pub txpool: Vec<EthereumTransaction>,
}
impl MemCache {
pub fn new(start: u64) -> Self {
MemCache {
start,
txpool: Vec::new()
}
}
}