[][src]Enum exonum::explorer::TransactionInfo

pub enum TransactionInfo<T = Box<dyn Transaction>> {
    InPool {
        content: T,
    },
    Committed(CommittedTransaction<T>),
}

Information about the transaction.

Values of this type are returned by the transaction() method of the BlockchainExplorer.

The type parameter corresponds to some representation of Box<Transaction>. This generalization is needed to deserialize TransactionInfo.

JSON presentation

Committed transactions

Committed transactions are represented just like a CommittedTransaction, with the additional type field equal to "committed".

Transaction in pool

Transactions in pool are represented with a 2-field object:

  • type field contains transaction type ("in-pool").
  • content is JSON serialization of the transaction.

Examples

Use of the custom type parameter for deserialization:

transactions! {
    Transactions {
        const SERVICE_ID = 1000;

        struct CreateWallet {
            public_key: &PublicKey,
            name: &str,
        }
        // other transaction types...
    }
}

let json = json!({
    "type": "in-pool",
    "content": {
        "protocol_version": 0,
        "service_id": 1000,
        "message_id": 0,
        "body": {
            "public_key": // ...
            "name": "Alice"
        },
        "signature": // ...
    }
});

let parsed: TransactionInfo<CreateWallet> = serde_json::from_value(json).unwrap();
assert!(parsed.is_in_pool());
assert_eq!(parsed.content().name(), "Alice");

Variants

InPool

Transaction is in the memory pool, but not yet committed to the blockchain.

Fields of InPool

content: T

Transaction contents.

Committed(CommittedTransaction<T>)

Transaction is already committed to the blockchain.

Methods

impl<T> TransactionInfo<T>
[src]

pub fn content(&self) -> &T
[src]

Returns the content of this transaction.

pub fn is_in_pool(&self) -> bool
[src]

Is this in-pool transaction?

pub fn is_committed(&self) -> bool
[src]

Is this a committed transaction?

pub fn as_committed(&self) -> Option<&CommittedTransaction<T>>
[src]

Returns a reference to the inner committed transaction if this transaction is committed. For transactions in pool, returns None.

Trait Implementations

impl<T: Debug> Debug for TransactionInfo<T>
[src]

impl<'de, T> Deserialize<'de> for TransactionInfo<T> where
    T: Deserialize<'de>, 
[src]

impl<T> Serialize for TransactionInfo<T> where
    T: SerializeContent
[src]

Auto Trait Implementations

impl<T> Send for TransactionInfo<T> where
    T: Send

impl<T> Sync for TransactionInfo<T> where
    T: Sync

Blanket Implementations

impl<T> SerializeContent for T where
    T: Serialize
[src]

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T> Erased for T

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Same for T

type Output = T

Should always be Self