2016-12-11 19:14:42 +01:00
|
|
|
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
|
2016-03-10 11:32:10 +01:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// 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
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
//! Unique identifiers.
|
|
|
|
|
|
|
|
use util::hash::H256;
|
|
|
|
use header::BlockNumber;
|
|
|
|
|
|
|
|
/// Uniquely identifies block.
|
2016-08-04 18:17:21 +02:00
|
|
|
#[derive(Debug, PartialEq, Copy, Clone, Hash, Eq, Binary)]
|
2016-11-22 10:24:22 +01:00
|
|
|
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.
|
2016-07-14 15:24:12 +02:00
|
|
|
Latest,
|
|
|
|
/// Pending block.
|
|
|
|
Pending,
|
2016-03-10 11:32:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Uniquely identifies transaction.
|
2016-05-16 18:33:32 +02:00
|
|
|
#[derive(Debug, PartialEq, Clone, Hash, Eq, Binary)]
|
2016-11-22 10:24:22 +01:00
|
|
|
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.
|
2016-11-22 10:24:22 +01:00
|
|
|
Location(BlockId, usize)
|
2016-03-10 11:32:10 +01:00
|
|
|
}
|
2016-03-22 16:07:42 +01:00
|
|
|
|
2016-05-02 12:17:30 +02:00
|
|
|
/// Uniquely identifies Trace.
|
2016-07-07 09:39:32 +02:00
|
|
|
#[derive(Binary)]
|
2016-05-02 12:17:30 +02:00
|
|
|
pub struct TraceId {
|
|
|
|
/// Transaction
|
2016-11-22 10:24:22 +01:00
|
|
|
pub transaction: TransactionId,
|
2016-05-02 12:17:30 +02:00
|
|
|
/// Trace address within transaction.
|
|
|
|
pub address: Vec<usize>,
|
|
|
|
}
|
|
|
|
|
2016-03-22 16:07:42 +01:00
|
|
|
/// Uniquely identifies Uncle.
|
2016-11-04 17:35:02 +01:00
|
|
|
#[derive(Debug, PartialEq, Eq, Copy, Clone, Binary)]
|
2016-11-22 10:24:22 +01:00
|
|
|
pub struct UncleId {
|
2016-03-22 16:07:42 +01:00
|
|
|
/// Block id.
|
2016-11-22 10:24:22 +01:00
|
|
|
pub block: BlockId,
|
2016-03-22 16:07:42 +01:00
|
|
|
/// Position in block.
|
2016-07-01 20:37:17 +02:00
|
|
|
pub position: usize
|
|
|
|
}
|