2019-01-07 11:33:07 +01:00
|
|
|
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
|
|
|
// This file is part of Parity Ethereum.
|
2018-07-02 18:50:05 +02:00
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is free software: you can redistribute it and/or modify
|
2018-07-02 18:50:05 +02: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.
|
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is distributed in the hope that it will be useful,
|
2018-07-02 18:50:05 +02: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
|
2019-01-07 11:33:07 +01:00
|
|
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
2018-07-02 18:50:05 +02:00
|
|
|
|
|
|
|
//! Impls of the `AsHashDB` upcast trait for all different variants of DB
|
2020-08-05 06:08:03 +02:00
|
|
|
use crate::{AsKeyedHashDB, KeyedHashDB};
|
2018-07-02 18:50:05 +02:00
|
|
|
use archivedb::ArchiveDB;
|
|
|
|
use earlymergedb::EarlyMergeDB;
|
2020-08-05 06:08:03 +02:00
|
|
|
use hash_db::{AsHashDB, HashDB};
|
|
|
|
use keccak_hasher::KeccakHasher;
|
|
|
|
use kvdb::DBValue;
|
|
|
|
use overlaydb::OverlayDB;
|
2018-07-02 18:50:05 +02:00
|
|
|
use overlayrecentdb::OverlayRecentDB;
|
|
|
|
use refcounteddb::RefCountedDB;
|
|
|
|
|
2018-10-09 22:07:25 +02:00
|
|
|
impl AsHashDB<KeccakHasher, DBValue> for ArchiveDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2018-07-02 18:50:05 +02:00
|
|
|
}
|
|
|
|
|
2018-10-09 22:07:25 +02:00
|
|
|
impl AsHashDB<KeccakHasher, DBValue> for EarlyMergeDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2018-07-02 18:50:05 +02:00
|
|
|
}
|
|
|
|
|
2018-10-09 22:07:25 +02:00
|
|
|
impl AsHashDB<KeccakHasher, DBValue> for OverlayRecentDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2018-07-02 18:50:05 +02:00
|
|
|
}
|
|
|
|
|
2018-10-09 22:07:25 +02:00
|
|
|
impl AsHashDB<KeccakHasher, DBValue> for RefCountedDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2018-07-02 18:50:05 +02:00
|
|
|
}
|
|
|
|
|
2018-10-09 22:07:25 +02:00
|
|
|
impl AsHashDB<KeccakHasher, DBValue> for OverlayDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2019-02-20 19:09:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl AsKeyedHashDB for ArchiveDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_keyed_hash_db(&self) -> &dyn KeyedHashDB {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2019-02-20 19:09:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl AsKeyedHashDB for EarlyMergeDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_keyed_hash_db(&self) -> &dyn KeyedHashDB {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2019-02-20 19:09:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl AsKeyedHashDB for OverlayRecentDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_keyed_hash_db(&self) -> &dyn KeyedHashDB {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2019-02-20 19:09:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl AsKeyedHashDB for RefCountedDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_keyed_hash_db(&self) -> &dyn KeyedHashDB {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2019-02-20 19:09:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl AsKeyedHashDB for OverlayDB {
|
2020-07-29 10:36:15 +02:00
|
|
|
fn as_keyed_hash_db(&self) -> &dyn KeyedHashDB {
|
2020-08-05 06:08:03 +02:00
|
|
|
self
|
|
|
|
}
|
2018-10-09 22:07:25 +02:00
|
|
|
}
|