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