This commit is contained in:
Gav Wood 2016-01-16 21:02:31 +01:00
parent cf1e9f24b6
commit bffbba32d2

View File

@ -3,7 +3,7 @@ use util::*;
use header::*; use header::*;
use transaction::*; use transaction::*;
/// View onto block rlp. /// View onto transaction rlp.
pub struct TransactionView<'a> { pub struct TransactionView<'a> {
rlp: Rlp<'a> rlp: Rlp<'a>
} }
@ -28,23 +28,31 @@ impl<'a> TransactionView<'a> {
&self.rlp &self.rlp
} }
/// Get the nonce field of the transaction.
pub fn nonce(&self) -> U256 { self.rlp.val_at(0) } pub fn nonce(&self) -> U256 { self.rlp.val_at(0) }
/// Get the gas_price field of the transaction.
pub fn gas_price(&self) -> U256 { self.rlp.val_at(1) } pub fn gas_price(&self) -> U256 { self.rlp.val_at(1) }
/// Get the gas field of the transaction.
pub fn gas(&self) -> U256 { self.rlp.val_at(2) } pub fn gas(&self) -> U256 { self.rlp.val_at(2) }
// TODO: something like pub fn action(&self) -> Action { self.rlp.val_at(3) } /// Get the value field of the transaction.
pub fn value(&self) -> U256 { self.rlp.val_at(4) } pub fn value(&self) -> U256 { self.rlp.val_at(4) }
/// Get the data field of the transaction.
pub fn data(&self) -> Bytes { self.rlp.val_at(5) } pub fn data(&self) -> Bytes { self.rlp.val_at(5) }
/// Get the v field of the transaction.
pub fn v(&self) -> u8 { let r: u16 = self.rlp.val_at(6); r as u8 } pub fn v(&self) -> u8 { let r: u16 = self.rlp.val_at(6); r as u8 }
/// Get the r field of the transaction.
pub fn r(&self) -> U256 { self.rlp.val_at(7) } pub fn r(&self) -> U256 { self.rlp.val_at(7) }
/// Get the s field of the transaction.
pub fn s(&self) -> U256 { self.rlp.val_at(8) } pub fn s(&self) -> U256 { self.rlp.val_at(8) }
// TODO: something like pub fn action(&self) -> Action { self.rlp.val_at(3) }
} }
impl<'a> Hashable for TransactionView<'a> { impl<'a> Hashable for TransactionView<'a> {