Skip to content

Commit

Permalink
Use EthTransactionKind reference to serialize into bytes (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
birchmd authored Mar 3, 2022
1 parent 0baf60f commit 30a9f59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/relayer_db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where
let block_hash = row.block_hash;
let block_metadata = storage.get_block_metadata(block_hash)?;
let tx: EthTransactionKind = row.into();
let transaction_bytes: Vec<u8> = tx.into();
let transaction_bytes: Vec<u8> = (&tx).into();
let tx_hash = aurora_engine_sdk::keccak(&transaction_bytes);

env.block_height = block_height;
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn consume_message(storage: &mut crate::Storage, message: Message) -> Result
// Only promises possible from `submit` are exit precompiles and we cannot act on those promises
let mut handler = crate::promise::Noop;
let engine_state = engine::get_state(&io)?;
let transaction_bytes: Vec<u8> = tx.into();
let transaction_bytes: Vec<u8> = (&tx).into();
let tx_hash = aurora_engine_sdk::keccak(&transaction_bytes);

let _result = engine::submit(
Expand Down
12 changes: 6 additions & 6 deletions engine-transactions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ impl TryFrom<&[u8]> for EthTransactionKind {
}
}

impl From<EthTransactionKind> for Vec<u8> {
fn from(tx: EthTransactionKind) -> Self {
impl<'a> From<&'a EthTransactionKind> for Vec<u8> {
fn from(tx: &'a EthTransactionKind) -> Self {
let mut stream = rlp::RlpStream::new();
match tx {
match &tx {
EthTransactionKind::Legacy(tx) => {
stream.append(&tx);
stream.append(tx);
}
EthTransactionKind::Eip1559(tx) => {
stream.append(&eip_1559::TYPE_BYTE);
stream.append(&tx);
stream.append(tx);
}
EthTransactionKind::Eip2930(tx) => {
stream.append(&eip_2930::TYPE_BYTE);
stream.append(&tx);
stream.append(tx);
}
}
stream.out().to_vec()
Expand Down

0 comments on commit 30a9f59

Please sign in to comment.