mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 21:19:24 +00:00
Stop caching the Monero block hash now in processor that we have Block::hash
This commit is contained in:
@@ -13,7 +13,7 @@ use frost::{curve::Ed25519, ThresholdKeys};
|
||||
use monero_serai::{
|
||||
Protocol,
|
||||
transaction::Transaction,
|
||||
block::Block as MBlock,
|
||||
block::Block,
|
||||
rpc::{RpcError, HttpRpc, Rpc},
|
||||
wallet::{
|
||||
ViewPair, Scanner,
|
||||
@@ -134,20 +134,18 @@ pub struct SignableTransaction {
|
||||
actual: MSignableTransaction,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Block([u8; 32], MBlock);
|
||||
impl BlockTrait<Monero> for Block {
|
||||
type Id = [u8; 32];
|
||||
fn id(&self) -> Self::Id {
|
||||
self.0
|
||||
self.hash()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Self::Id {
|
||||
self.1.header.previous
|
||||
self.header.previous
|
||||
}
|
||||
|
||||
fn time(&self) -> u64 {
|
||||
self.1.header.timestamp
|
||||
self.header.timestamp
|
||||
}
|
||||
|
||||
fn median_fee(&self) -> Fee {
|
||||
@@ -256,14 +254,18 @@ impl Coin for Monero {
|
||||
}
|
||||
|
||||
async fn get_block(&self, number: usize) -> Result<Self::Block, CoinError> {
|
||||
let hash = self.rpc.get_block_hash(number).await.map_err(|_| CoinError::ConnectionError)?;
|
||||
let block = self.rpc.get_block(hash).await.map_err(|_| CoinError::ConnectionError)?;
|
||||
Ok(Block(hash, block))
|
||||
Ok(Block(
|
||||
self
|
||||
.rpc
|
||||
.get_block(self.rpc.get_block_hash(number).await.map_err(|_| CoinError::ConnectionError)?)
|
||||
.await
|
||||
.map_err(|_| CoinError::ConnectionError)?,
|
||||
))
|
||||
}
|
||||
|
||||
async fn get_outputs(
|
||||
&self,
|
||||
block: &Self::Block,
|
||||
block: &Block,
|
||||
key: EdwardsPoint,
|
||||
) -> Result<Vec<Self::Output>, CoinError> {
|
||||
let mut txs = Self::scanner(key)
|
||||
@@ -305,7 +307,7 @@ impl Coin for Monero {
|
||||
async fn get_eventuality_completions(
|
||||
&self,
|
||||
eventualities: &mut EventualitiesTracker<Eventuality>,
|
||||
block: &Self::Block,
|
||||
block: &Block,
|
||||
) -> HashMap<[u8; 32], [u8; 32]> {
|
||||
let block = &block.1;
|
||||
|
||||
@@ -317,7 +319,7 @@ impl Coin for Monero {
|
||||
async fn check_block(
|
||||
coin: &Monero,
|
||||
eventualities: &mut EventualitiesTracker<Eventuality>,
|
||||
block: &MBlock,
|
||||
block: &Block,
|
||||
res: &mut HashMap<[u8; 32], [u8; 32]>,
|
||||
) {
|
||||
for hash in &block.txs {
|
||||
|
||||
Reference in New Issue
Block a user