2020-09-22 14:53:52 +02:00
|
|
|
// Copyright 2015-2020 Parity Technologies (UK) Ltd.
|
|
|
|
// This file is part of OpenEthereum.
|
2016-03-04 11:56:04 +01:00
|
|
|
|
2020-09-22 14:53:52 +02:00
|
|
|
// OpenEthereum is free software: you can redistribute it and/or modify
|
2016-03-04 11:56:04 +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-04 11:56:04 +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-04 11:56:04 +01:00
|
|
|
|
2016-11-10 18:30:17 +01:00
|
|
|
//! Block verification utilities.
|
|
|
|
|
2016-03-04 11:56:04 +01:00
|
|
|
mod canon_verifier;
|
|
|
|
mod noop_verifier;
|
2016-09-27 16:50:24 +02:00
|
|
|
pub mod queue;
|
2018-07-25 14:36:46 +02:00
|
|
|
mod verification;
|
|
|
|
mod verifier;
|
2016-03-04 11:56:04 +01:00
|
|
|
|
|
|
|
pub use self::{
|
|
|
|
canon_verifier::CanonVerifier,
|
|
|
|
noop_verifier::NoopVerifier,
|
2016-09-27 16:50:24 +02:00
|
|
|
queue::{BlockQueue, Config as QueueConfig, QueueInfo, VerificationQueue},
|
|
|
|
verification::*,
|
2016-03-04 11:56:04 +01:00
|
|
|
verifier::Verifier,
|
2016-09-27 16:50:24 +02:00
|
|
|
};
|
2016-06-28 13:23:15 +02:00
|
|
|
|
2019-01-17 16:43:08 +01:00
|
|
|
use call_contract::CallContract;
|
|
|
|
use client::BlockInfo;
|
2018-03-03 18:42:13 +01:00
|
|
|
|
2016-06-28 13:23:15 +02:00
|
|
|
/// Verifier type.
|
2016-09-06 15:31:13 +02:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-06-28 13:23:15 +02:00
|
|
|
pub enum VerifierType {
|
|
|
|
/// Verifies block normally.
|
|
|
|
Canon,
|
2016-10-24 15:09:13 +02:00
|
|
|
/// Verifies block normallly, but skips seal verification.
|
|
|
|
CanonNoSeal,
|
2016-06-28 13:23:15 +02:00
|
|
|
/// Does not verify block at all.
|
|
|
|
/// Used in tests.
|
|
|
|
Noop,
|
|
|
|
}
|
|
|
|
|
2016-11-10 18:30:17 +01:00
|
|
|
/// Create a new verifier based on type.
|
2020-07-29 10:36:15 +02:00
|
|
|
pub fn new<C: BlockInfo + CallContract>(v: VerifierType) -> Box<dyn Verifier<C>> {
|
2016-06-28 13:23:15 +02:00
|
|
|
match v {
|
2016-10-24 15:09:13 +02:00
|
|
|
VerifierType::Canon | VerifierType::CanonNoSeal => Box::new(CanonVerifier),
|
2016-06-28 13:23:15 +02:00
|
|
|
VerifierType::Noop => Box::new(NoopVerifier),
|
|
|
|
}
|
|
|
|
}
|
2016-10-24 15:09:13 +02:00
|
|
|
|
|
|
|
impl VerifierType {
|
|
|
|
/// Check if seal verification is enabled for this verifier type.
|
|
|
|
pub fn verifying_seal(&self) -> bool {
|
|
|
|
match *self {
|
|
|
|
VerifierType::Canon => true,
|
|
|
|
VerifierType::Noop | VerifierType::CanonNoSeal => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|