2019-01-07 11:33:07 +01:00
|
|
|
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
|
|
|
// This file is part of Parity Ethereum.
|
2016-09-06 15:31:13 +02:00
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is free software: you can redistribute it and/or modify
|
2016-09-06 15:31:13 +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,
|
2016-09-06 15:31:13 +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/>.
|
2016-09-06 15:31:13 +02:00
|
|
|
|
|
|
|
use super::{ManifestData, RestorationStatus};
|
2018-01-10 13:35:18 +01:00
|
|
|
use ethereum_types::H256;
|
2017-09-06 20:47:45 +02:00
|
|
|
use bytes::Bytes;
|
2016-09-06 15:31:13 +02:00
|
|
|
|
|
|
|
/// The interface for a snapshot network service.
|
|
|
|
/// This handles:
|
|
|
|
/// - restoration of snapshots to temporary databases.
|
|
|
|
/// - responding to queries for snapshot manifests and chunks
|
|
|
|
pub trait SnapshotService : Sync + Send {
|
|
|
|
/// Query the most recent manifest data.
|
|
|
|
fn manifest(&self) -> Option<ManifestData>;
|
|
|
|
|
2017-07-18 16:59:33 +02:00
|
|
|
/// Get the supported range of snapshot version numbers.
|
2017-05-17 12:41:33 +02:00
|
|
|
/// `None` indicates warp sync isn't supported by the consensus engine.
|
2017-07-18 16:59:33 +02:00
|
|
|
fn supported_versions(&self) -> Option<(u64, u64)>;
|
2017-05-17 12:41:33 +02:00
|
|
|
|
2018-05-16 22:01:55 +02:00
|
|
|
/// Returns a list of the completed chunks
|
|
|
|
fn completed_chunks(&self) -> Option<Vec<H256>>;
|
|
|
|
|
2016-09-06 15:31:13 +02:00
|
|
|
/// Get raw chunk for a given hash.
|
|
|
|
fn chunk(&self, hash: H256) -> Option<Bytes>;
|
|
|
|
|
|
|
|
/// Ask the snapshot service for the restoration status.
|
|
|
|
fn status(&self) -> RestorationStatus;
|
|
|
|
|
|
|
|
/// Begin snapshot restoration.
|
|
|
|
/// If restoration in-progress, this will reset it.
|
|
|
|
/// From this point on, any previous snapshot may become unavailable.
|
|
|
|
fn begin_restore(&self, manifest: ManifestData);
|
|
|
|
|
|
|
|
/// Abort an in-progress restoration if there is one.
|
|
|
|
fn abort_restore(&self);
|
|
|
|
|
|
|
|
/// Feed a raw state chunk to the service to be processed asynchronously.
|
|
|
|
/// no-op if not currently restoring.
|
|
|
|
fn restore_state_chunk(&self, hash: H256, chunk: Bytes);
|
|
|
|
|
|
|
|
/// Feed a raw block chunk to the service to be processed asynchronously.
|
|
|
|
/// no-op if currently restoring.
|
|
|
|
fn restore_block_chunk(&self, hash: H256, chunk: Bytes);
|
2018-05-29 12:23:15 +02:00
|
|
|
|
2019-06-25 15:38:29 +02:00
|
|
|
/// Abort in-progress snapshotting if there is one.
|
|
|
|
fn abort_snapshot(&self);
|
|
|
|
|
2018-05-29 12:23:15 +02:00
|
|
|
/// Shutdown the Snapshot Service by aborting any ongoing restore
|
|
|
|
fn shutdown(&self);
|
2016-09-06 15:31:13 +02:00
|
|
|
}
|