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
.
Committed transactions are represented just like a CommittedTransaction
,
with the additional type
field equal to "committed"
.
Transactions in pool are represented with a 2-field object:
type
field contains transaction type ("in-pool"
).
content
is JSON serialization of the transaction.
Use of the custom type parameter for deserialization:
transactions! {
Transactions {
const SERVICE_ID = 1000;
struct CreateWallet {
public_key: &PublicKey,
name: &str,
}
}
}
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");
Transaction is in the memory pool, but not yet committed to the blockchain.
Fields of InPool
Transaction is already committed to the blockchain.
pub fn content(&self) -> &T | [src] |
Returns the content of this transaction.
Is this in-pool transaction?
Is this a committed transaction?
Returns a reference to the inner committed transaction if this transaction is committed.
For transactions in pool, returns None
.
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more
Serializes content of a transaction with the given serializer.
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static