Add cache to HeaderChain struct.
This commit is contained in:
@@ -27,6 +27,10 @@ use ethcore::spec::Spec;
|
||||
use io::{IoContext, IoError, IoHandler, IoService};
|
||||
use util::kvdb::{Database, DatabaseConfig};
|
||||
|
||||
use cache::Cache;
|
||||
use time::Duration;
|
||||
use util::Mutex;
|
||||
|
||||
use super::{Client, Config as ClientConfig};
|
||||
|
||||
/// Errors on service initialization.
|
||||
@@ -56,6 +60,8 @@ pub struct Service {
|
||||
impl Service {
|
||||
/// Start the service: initialize I/O workers and client itself.
|
||||
pub fn start(config: ClientConfig, spec: &Spec, path: &Path) -> Result<Self, Error> {
|
||||
let cache = Arc::new(Mutex::new(Cache::new(Default::default(), Duration::hours(6))));
|
||||
|
||||
// initialize database.
|
||||
let mut db_config = DatabaseConfig::with_columns(db::NUM_COLUMNS);
|
||||
|
||||
@@ -78,6 +84,7 @@ impl Service {
|
||||
db::COL_LIGHT_CHAIN,
|
||||
spec,
|
||||
io_service.channel(),
|
||||
cache,
|
||||
).map_err(Error::Database)?);
|
||||
io_service.register_handler(Arc::new(ImportBlocks(client.clone()))).map_err(Error::Io)?;
|
||||
Ok(Service {
|
||||
|
||||
Reference in New Issue
Block a user