[][src]Struct exonum::explorer::CommittedTransaction

pub struct CommittedTransaction<T = Box<dyn Transaction>> { /* fields omitted */ }

Information about a particular transaction in the blockchain.

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

JSON presentation

Name Equivalent type Description
content Box<Transaction> Transaction as recorded in the blockchain
location TxLocation Location of the transaction in the block
location_proof ListProof<Hash> Proof of transaction inclusion into a block
status (custom; see below) Execution status

status field

The status field is a more readable version of the TransactionResult type.

For successfully executed transactions, status is equal to

{ "type": "success" }

For transactions that return an ExecutionError, status contains the error code and an optional description, i.e., has the following type in the Flow / TypeScript notation:

{ type: 'error', code: number, description?: string }

For transactions that have resulted in a panic, status contains an optional description as well:

{ type: 'panic', description?: string }

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!({
    "content": {
        "protocol_version": 0,
        "service_id": 1000,
        "message_id": 0,
        "body": {
            "public_key": // ...
            "name": "Alice"
        },
        "signature": // ...
    },
    "location": { "block_height": "1", "position_in_block": "0" },
    "location_proof": // ...
    "status": { "type": "success" }
});

let parsed: CommittedTransaction<CreateWallet> =
    serde_json::from_value(json).unwrap();
assert_eq!(parsed.location().block_height(), Height(1));
assert_eq!(parsed.content().name(), "Alice");

Methods

impl<T> CommittedTransaction<T>
[src]

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

Returns the content of the transaction.

pub fn location(&self) -> &TxLocation
[src]

Returns the transaction location in block.

pub fn location_proof(&self) -> &ListProof<Hash>
[src]

Returns a proof that transaction is recorded in the blockchain.

pub fn status(&self) -> Result<(), &TransactionError>
[src]

Returns the status of the transaction execution.

Trait Implementations

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

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

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

Auto Trait Implementations

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

impl<T> Sync for CommittedTransaction<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