#[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:
typefield contains transaction type ("in-pool").messageis 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.
Committed(CommittedTransaction)
Transaction is already committed to the blockchain.
Implementations§
Source§impl TransactionInfo
impl TransactionInfo
Sourcepub fn is_in_pool(&self) -> bool
pub fn is_in_pool(&self) -> bool
Is this in-pool transaction?
Sourcepub fn is_committed(&self) -> bool
pub fn is_committed(&self) -> bool
Is this a committed transaction?
Sourcepub fn as_committed(&self) -> Option<&CommittedTransaction>
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
impl Debug for TransactionInfo
Source§impl<'de> Deserialize<'de> for TransactionInfo
impl<'de> Deserialize<'de> for TransactionInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TransactionInfo
impl RefUnwindSafe for TransactionInfo
impl Send for TransactionInfo
impl Sync for TransactionInfo
impl Unpin for TransactionInfo
impl UnwindSafe for TransactionInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more