Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
fix(mempool): rebase master
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroqn committed Apr 30, 2020
1 parent 01953ab commit 996ab1c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions core/mempool/src/adapter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,21 @@ where
}

async fn check_signature(&self, ctx: Context, tx: SignedTransaction) -> ProtocolResult<()> {
let network = self.network.clone();

let blocking_res = tokio::task::spawn_blocking(move || {
// Verify transaction hash
let fixed_bytes = tx.raw.encode_fixed()?;
let tx_hash = Hash::digest(fixed_bytes);

if tx_hash != tx.tx_hash {
if ctx.is_network_origin_txs() {
self.network.report(
network.report(
ctx,
TrustFeedback::Worse(format!("Mempool wrong tx_hash of tx {:?}", tx.tx_hash)),
TrustFeedback::Worse(format!(
"Mempool wrong tx_hash of tx {:?}",
tx.tx_hash
)),
);
}

Expand All @@ -257,9 +262,12 @@ where

C::verify_signature(hash.as_ref(), sig, pub_key).map_err(|_| {
if ctx.is_network_origin_txs() {
self.network.report(
network.report(
ctx,
TrustFeedback::Worse(format!("Mempool wrong signature of tx {:?}", tx.tx_hash)),
TrustFeedback::Worse(format!(
"Mempool wrong signature of tx {:?}",
tx.tx_hash
)),
);
}

Expand All @@ -283,7 +291,8 @@ where
// TODO: Verify Fee?
// TODO: Verify Nonce?
// TODO: Cycle limit?
async fn check_transaction(&self, ctx: Context, stx: SignedTransaction) -> ProtocolResult<()> { let fixed_bytes = stx.raw.encode_fixed()?;
async fn check_transaction(&self, ctx: Context, stx: SignedTransaction) -> ProtocolResult<()> {
let fixed_bytes = stx.raw.encode_fixed()?;
let size = fixed_bytes.len() as u64;
let tx_hash = stx.tx_hash.clone();

Expand Down

0 comments on commit 996ab1c

Please sign in to comment.