Compiles.
This commit is contained in:
@@ -129,7 +129,6 @@ impl SleepState {
|
||||
/// Call `import_block()` to import a block asynchronously; `flush_queue()` flushes the queue.
|
||||
pub struct Client {
|
||||
mode: Mutex<Mode>,
|
||||
update_policy: UpdatePolicy,
|
||||
chain: RwLock<Arc<BlockChain>>,
|
||||
tracedb: RwLock<TraceDB<BlockChain>>,
|
||||
engine: Arc<Engine>,
|
||||
@@ -227,6 +226,8 @@ impl Client {
|
||||
accountdb: Default::default(),
|
||||
};
|
||||
|
||||
|
||||
|
||||
let client = Arc::new(Client {
|
||||
sleep_state: Mutex::new(SleepState::new(awake)),
|
||||
liveness: AtomicBool::new(awake),
|
||||
@@ -262,7 +263,7 @@ impl Client {
|
||||
if let Ok(ops_addr) = registrar.get_address(&(&b"operations"[..]).sha3(), "A") {
|
||||
if !ops_addr.is_zero() {
|
||||
trace!(target: "client", "Found operations at {}", ops_addr);
|
||||
*client.updater.lock() = Some(Updater::new(Arc::downgrade(&client), ops_addr));
|
||||
*client.updater.lock() = Some(Updater::new(Arc::downgrade(&client), ops_addr, client.config.update_policy.clone()));
|
||||
}
|
||||
}
|
||||
*client.registrar.lock() = Some(registrar);
|
||||
|
||||
@@ -66,33 +66,39 @@ impl FromStr for DatabaseCompactionProfile {
|
||||
}
|
||||
}
|
||||
|
||||
/// Filter for releases.
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub enum UpdateFilter {
|
||||
/// All releases following the same track.
|
||||
All,
|
||||
/// Only those of the same minor version potentially changing tracks.
|
||||
Patch,
|
||||
/// As with `All`, but only those which are known to be critical.
|
||||
Critical,
|
||||
/// None.
|
||||
None,
|
||||
}
|
||||
|
||||
/// The policy for auto-updating.
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub struct UpdatePolicy {
|
||||
download_only: bool,
|
||||
track: Track,
|
||||
/// Download potential updates.
|
||||
pub enable_downloading: bool,
|
||||
/// Which of those downloaded should be automatically installed.
|
||||
pub filter: UpdateFilter,
|
||||
}
|
||||
|
||||
/// Operating mode for the client.
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub enum UpdatePolicy {
|
||||
/// Always on.
|
||||
Active,
|
||||
/// Goes offline after RLP is inactive for some (given) time, but
|
||||
/// comes back online after a while of inactivity.
|
||||
Passive(Duration, Duration),
|
||||
/// Goes offline after RLP is inactive for some (given) time and
|
||||
/// stays inactive.
|
||||
Dark(Duration),
|
||||
/// Always off.
|
||||
Off,
|
||||
impl Default for UpdatePolicy {
|
||||
fn default() -> Self {
|
||||
UpdatePolicy {
|
||||
enable_downloading: false,
|
||||
filter: UpdateFilter::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl UpdatePolicy {
|
||||
pub fn new() -> Self { Default::default() }
|
||||
}
|
||||
|
||||
/// Operating mode for the client.
|
||||
@@ -130,6 +136,8 @@ impl Display for Mode {
|
||||
/// Client configuration. Includes configs for all sub-systems.
|
||||
#[derive(Debug, PartialEq, Default)]
|
||||
pub struct ClientConfig {
|
||||
/// Updater policy.
|
||||
pub update_policy: UpdatePolicy,
|
||||
/// Block queue configuration.
|
||||
pub queue: QueueConfig,
|
||||
/// Blockchain configuration.
|
||||
|
||||
@@ -26,7 +26,7 @@ mod client;
|
||||
mod updater;
|
||||
|
||||
pub use self::client::*;
|
||||
pub use self::config::{Mode, ClientConfig, UpdatePolicy, Automation, DatabaseCompactionProfile, BlockChainConfig, VMType};
|
||||
pub use self::config::{Mode, ClientConfig, UpdatePolicy, UpdateFilter, DatabaseCompactionProfile, BlockChainConfig, VMType};
|
||||
pub use self::error::Error;
|
||||
pub use types::ids::*;
|
||||
pub use self::test_client::{TestBlockChainClient, EachBlockWith};
|
||||
|
||||
@@ -18,8 +18,7 @@ use std::sync::Weak;
|
||||
use util::misc::{VersionInfo, ReleaseTrack, platform};
|
||||
use util::{Address, H160, H256, FixedHash};
|
||||
use client::operations::Operations;
|
||||
use client::client::Client;
|
||||
use client::BlockId;
|
||||
use client::{Client, UpdatePolicy, BlockId};
|
||||
|
||||
pub struct ReleaseInfo {
|
||||
fork_supported: usize,
|
||||
@@ -34,15 +33,13 @@ pub struct Updater {
|
||||
client: Weak<Client>,
|
||||
operations: Operations,
|
||||
|
||||
|
||||
|
||||
pub this: VersionInfo,
|
||||
pub release_info: Option<ReleaseInfo>,
|
||||
|
||||
}
|
||||
|
||||
impl Updater {
|
||||
pub fn new(client: Weak<Client>, operations: Address) -> Self {
|
||||
pub fn new(client: Weak<Client>, operations: Address, _update_policy: UpdatePolicy) -> Self {
|
||||
let mut u = Updater {
|
||||
client: client.clone(),
|
||||
operations: Operations::new(operations, move |a, d| client.upgrade().ok_or("No client!".into()).and_then(|c| c.call_contract(a, d))),
|
||||
|
||||
Reference in New Issue
Block a user