Skip to content

Commit

Permalink
feat(mempool): fix fixed_codec (nervosnetwork#25)
Browse files Browse the repository at this point in the history
* fix fixed_codec

* remove rlp ref

* remove rlp ref of Cargo.lock
  • Loading branch information
rev-chaos authored and yejiayu committed Oct 24, 2019
1 parent 831aa65 commit c1ac607
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 75 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion core/mempool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ rand = "0.6"
hex = "0.3"
serde_derive = "1.0"
serde = "1.0"
rlp = "0.4"

[dev-dependencies]
chashmap = "2.2"
8 changes: 3 additions & 5 deletions core/mempool/src/adapter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod message;
mod rlp_types;

use std::{
marker::PhantomData,
Expand All @@ -10,10 +9,10 @@ use std::{
};

use async_trait::async_trait;
use bytes::Bytes;

use common_crypto::Crypto;
use protocol::{
fixed_codec::ProtocolFixedCodec,
traits::{Context, Gossip, MemPoolAdapter, Priority, Rpc, Storage},
types::{Hash, SignedTransaction},
ProtocolResult,
Expand All @@ -22,7 +21,6 @@ use protocol::{
use crate::adapter::message::{
MsgNewTxs, MsgPullTxs, MsgPushTxs, END_GOSSIP_NEW_TXS, END_RPC_PULL_TXS,
};
use crate::adapter::rlp_types::RlpRawTransaction;
use crate::MemPoolError;

pub struct DefaultMemPoolAdapter<C, N, S> {
Expand Down Expand Up @@ -99,8 +97,8 @@ where
// TODO: Cycle limit?
async fn check_transaction(&self, _ctx: Context, stx: SignedTransaction) -> ProtocolResult<()> {
// Verify transaction hash
let rlp_stx = rlp::encode(&RlpRawTransaction { inner: &stx.raw });
let stx_hash = Hash::digest(Bytes::from(rlp_stx));
let rlp_stx = stx.encode_fixed()?;
let stx_hash = Hash::digest(rlp_stx);

if stx_hash != stx.tx_hash {
let wrong_hash = MemPoolError::CheckHash {
Expand Down
68 changes: 0 additions & 68 deletions core/mempool/src/adapter/rlp_types.rs

This file was deleted.

0 comments on commit c1ac607

Please sign in to comment.