2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-10-31 17:32:53 +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/>.
|
|
|
|
|
|
|
|
use ethcore::snapshot::{ManifestData, RestorationStatus, SnapshotService};
|
|
|
|
|
2017-09-06 20:47:45 +02:00
|
|
|
use bytes::Bytes;
|
2018-01-10 13:35:18 +01:00
|
|
|
use ethereum_types::H256;
|
2017-09-04 18:32:55 +02:00
|
|
|
use parking_lot::Mutex;
|
2016-10-31 17:32:53 +01:00
|
|
|
|
|
|
|
/// Mocked snapshot service (used for sync info extensions).
|
|
|
|
pub struct TestSnapshotService {
|
|
|
|
status: Mutex<RestorationStatus>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TestSnapshotService {
|
|
|
|
/// Create a test snapshot service. Only the `status` function matters -- it'll
|
|
|
|
/// return `Inactive` by default.
|
|
|
|
pub fn new() -> Self {
|
|
|
|
TestSnapshotService {
|
|
|
|
status: Mutex::new(RestorationStatus::Inactive),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Set the restoration status.
|
|
|
|
pub fn set_status(&self, status: RestorationStatus) {
|
|
|
|
*self.status.lock() = status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SnapshotService for TestSnapshotService {
|
|
|
|
fn manifest(&self) -> Option<ManifestData> { None }
|
2017-07-18 16:59:33 +02:00
|
|
|
fn supported_versions(&self) -> Option<(u64, u64)> { None }
|
2018-05-16 22:01:55 +02:00
|
|
|
fn completed_chunks(&self) -> Option<Vec<H256>> { Some(vec![]) }
|
2016-10-31 17:32:53 +01:00
|
|
|
fn chunk(&self, _hash: H256) -> Option<Bytes> { None }
|
|
|
|
fn status(&self) -> RestorationStatus { self.status.lock().clone() }
|
|
|
|
fn begin_restore(&self, _manifest: ManifestData) { }
|
|
|
|
fn abort_restore(&self) { }
|
|
|
|
fn restore_state_chunk(&self, _hash: H256, _chunk: Bytes) { }
|
|
|
|
fn restore_block_chunk(&self, _hash: H256, _chunk: Bytes) { }
|
2018-05-29 12:23:15 +02:00
|
|
|
fn shutdown(&self) { }
|
2017-04-19 20:31:53 +02:00
|
|
|
}
|