Skip to content

Commit

Permalink
All txs in our mempool should be deserializable
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Nov 11, 2022
1 parent d06c845 commit 9b11bde
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/src/lib/node/ledger/shell/prepare_proposal/tx_bins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,24 @@ impl TxAllotedSpace {

/// Try to allocate space for a new transaction.
#[allow(dead_code)]
pub fn try_alloc_tx(&mut self, tx_bytes: &[u8]) -> Result<bool, TxError> {
pub fn try_alloc_tx(&mut self, tx_bytes: &[u8]) -> bool {
let tx = Tx::try_from(tx_bytes)
.map_err(|err| TxError::Deserialization(format!("{err}")))
.and_then(process_tx)?;
.and_then(process_tx)
.expect(
"Mempool validation passed for the given tx, so it should be \
a valid tx",
);

Ok(match tx {
match tx {
TxType::Raw(_) => {
// nothing to do for raw txs
true
}
TxType::Protocol(_) => self.try_alloc_protocol_tx(tx_bytes),
TxType::Wrapper(_) => self.try_alloc_encrypted_tx(tx_bytes),
TxType::Decrypted(_) => self.try_alloc_decrypted_tx(tx_bytes),
})
}
}

/// Try to allocate space for a new protocol transaction.
Expand Down

0 comments on commit 9b11bde

Please sign in to comment.