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 CommittedTransaction
s.
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 |
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 }
Use of the custom type parameter for deserialization:
transactions! {
Transactions {
const SERVICE_ID = 1000;
struct CreateWallet {
public_key: &PublicKey,
name: &str,
}
}
}
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");
pub fn content(&self) -> &T | [src] |
Returns the content of the transaction.
Returns the transaction location in block.
Returns a proof that transaction is recorded in the blockchain.
Returns the status of the transaction execution.
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