Enum TransactionInfo

Source
#[non_exhaustive]
pub enum TransactionInfo { InPool { message: Verified<AnyTx>, }, Committed(CommittedTransaction), }
Expand description

Information about the transaction.

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

§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").
  • message is the full transaction message serialized to the hexadecimal form.

§Examples

use exonum_explorer::TransactionInfo;
use exonum::{crypto::KeyPair, runtime::InstanceId};

/// Service interface.
#[exonum_interface]
trait ServiceInterface<Ctx> {
    type Output;
    #[interface_method(id = 0)]
    fn create_wallet(&self, ctx: Ctx, username: String) -> Self::Output;
}

// Create a signed transaction.
let keypair = KeyPair::random();
const SERVICE_ID: InstanceId = 100;
let tx = keypair.create_wallet(SERVICE_ID, "Alice".to_owned());
// This transaction in pool will be represented as follows:
let json = json!({
    "type": "in_pool",
    "message": tx,
});
let parsed: TransactionInfo = serde_json::from_value(json).unwrap();
assert!(parsed.is_in_pool());

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InPool

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

Fields

§message: Verified<AnyTx>

A content of the uncommitted transaction.

§

Committed(CommittedTransaction)

Transaction is already committed to the blockchain.

Implementations§

Source§

impl TransactionInfo

Source

pub fn message(&self) -> &Verified<AnyTx>

Returns the content of this transaction.

Source

pub fn is_in_pool(&self) -> bool

Is this in-pool transaction?

Source

pub fn is_committed(&self) -> bool

Is this a committed transaction?

Source

pub fn as_committed(&self) -> Option<&CommittedTransaction>

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

Trait Implementations§

Source§

impl Debug for TransactionInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TransactionInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TransactionInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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