feat(rpc): add txpool namespace (#2591)

This commit is contained in:
Matthias Seitz
2023-05-06 22:47:27 +02:00
committed by GitHub
parent d067e762ba
commit 3591a6f249
15 changed files with 842 additions and 9 deletions

View File

@ -302,6 +302,11 @@ impl Transaction {
}
}
/// Get the transaction's nonce.
pub fn to(&self) -> Option<Address> {
self.kind().to()
}
/// Get transaction type
pub fn tx_type(&self) -> TxType {
match self {
@ -312,8 +317,8 @@ impl Transaction {
}
/// Gets the transaction's value field.
pub fn value(&self) -> &u128 {
match self {
pub fn value(&self) -> u128 {
*match self {
Transaction::Legacy(TxLegacy { value, .. }) => value,
Transaction::Eip2930(TxEip2930 { value, .. }) => value,
Transaction::Eip1559(TxEip1559 { value, .. }) => value,
@ -678,6 +683,16 @@ pub enum TransactionKind {
Call(Address),
}
impl TransactionKind {
/// Returns the address of the contract that will be called or will receive the transfer.
pub fn to(self) -> Option<Address> {
match self {
TransactionKind::Create => None,
TransactionKind::Call(to) => Some(to),
}
}
}
impl Compact for TransactionKind {
fn to_compact<B>(self, buf: &mut B) -> usize
where