near_api_types/
reference.rs

1// Source: <https://github.com/near/near-workspaces-rs/blob/10a6c1a00b2b6c937242043312455e05f0d4a125/workspaces/src/types/mod.rs#L513C1-L537C2>
2
3use crate::{BlockHeight, CryptoHash};
4
5/// A reference to a specific block. This type is used to specify the block for most queries.
6///
7/// It represents the finality of a transaction or block in which transaction is included in. For more info
8/// go to the [NEAR finality](https://docs.near.org/docs/concepts/transaction#finality) docs.
9#[derive(Clone, Debug)]
10pub enum Reference {
11    /// Optimistic finality. The latest block recorded on the node that responded to our query
12    /// (<1 second delay after the transaction is submitted).
13    Optimistic,
14    /// Near-final finality. Similarly to `Final` finality, but delay should be roughly 1 second.
15    NearFinal,
16    /// Final finality. The block that has been validated on at least 66% of the nodes in the
17    /// network. (At max, should be 2 second delay after the transaction is submitted.)
18    Final,
19    /// Reference to a specific block.
20    AtBlock(BlockHeight),
21    /// Reference to a specific block hash.
22    AtBlockHash(CryptoHash),
23}
24
25/// A reference to a specific epoch. This type is used to specify the epoch for some queries.
26#[derive(Clone, Debug)]
27pub enum EpochReference {
28    /// Reference to a specific Epoch Id
29    AtEpoch(CryptoHash),
30    /// Reference to an epoch at a specific block height.
31    AtBlock(BlockHeight),
32    /// Reference to an epoch at a specific block hash.
33    AtBlockHash(CryptoHash),
34    /// Latest epoch on the node
35    Latest,
36}