openethereum/crates/ethcore/types/src/ids.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
1.8 KiB
Rust
Raw Normal View History

2020-09-22 14:53:52 +02:00
// Copyright 2015-2020 Parity Technologies (UK) Ltd.
// This file is part of OpenEthereum.
2016-03-10 11:32:10 +01:00
2020-09-22 14:53:52 +02:00
// OpenEthereum is free software: you can redistribute it and/or modify
2016-03-10 11:32:10 +01:00
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2020-09-22 14:53:52 +02:00
// OpenEthereum is distributed in the hope that it will be useful,
2016-03-10 11:32:10 +01:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
2020-09-22 14:53:52 +02:00
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
2016-03-10 11:32:10 +01:00
//! Unique identifiers.
use crate::BlockNumber;
use ethereum_types::H256;
2016-03-10 11:32:10 +01:00
/// Uniquely identifies block.
#[derive(Debug, PartialEq, Copy, Clone, Hash, Eq)]
pub enum BlockId {
2016-03-10 11:32:10 +01:00
/// Block's sha3.
/// Querying by hash is always faster.
Hash(H256),
/// Block number within canon blockchain.
Number(BlockNumber),
/// Earliest block (genesis).
Earliest,
/// Latest mined block.
Latest,
2016-03-10 11:32:10 +01:00
}
/// Uniquely identifies transaction.
#[derive(Debug, PartialEq, Clone, Hash, Eq)]
pub enum TransactionId {
2016-03-10 11:32:10 +01:00
/// Transaction's sha3.
Hash(H256),
/// Block id and transaction index within this block.
/// Querying by block position is always faster.
Location(BlockId, usize),
2016-03-10 11:32:10 +01:00
}
2016-03-22 16:07:42 +01:00
/// Uniquely identifies Trace.
pub struct TraceId {
/// Transaction
pub transaction: TransactionId,
/// Trace address within transaction.
pub address: Vec<usize>,
}
2016-03-22 16:07:42 +01:00
/// Uniquely identifies Uncle.
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub struct UncleId {
2016-03-22 16:07:42 +01:00
/// Block id.
pub block: BlockId,
2016-03-22 16:07:42 +01:00
/// Position in block.
pub position: usize,
}