commit
b84be93bb7
@ -255,13 +255,13 @@ impl Engine for Arc<Ethash> {
|
|||||||
|
|
||||||
fn on_new_block(&self, block: &mut ExecutedBlock, last_hashes: Arc<LastHashes>) -> Result<(), Error> {
|
fn on_new_block(&self, block: &mut ExecutedBlock, last_hashes: Arc<LastHashes>) -> Result<(), Error> {
|
||||||
let parent_hash = block.fields().header.parent_hash().clone();
|
let parent_hash = block.fields().header.parent_hash().clone();
|
||||||
try!(::engines::common::push_last_hash(block, last_hashes, self, &parent_hash));
|
::engines::common::push_last_hash(block, last_hashes, self, &parent_hash)?;
|
||||||
if block.fields().header.number() == self.ethash_params.dao_hardfork_transition {
|
if block.fields().header.number() == self.ethash_params.dao_hardfork_transition {
|
||||||
let state = block.fields_mut().state;
|
let state = block.fields_mut().state;
|
||||||
for child in &self.ethash_params.dao_hardfork_accounts {
|
for child in &self.ethash_params.dao_hardfork_accounts {
|
||||||
let beneficiary = &self.ethash_params.dao_hardfork_beneficiary;
|
let beneficiary = &self.ethash_params.dao_hardfork_beneficiary;
|
||||||
try!(state.balance(child)
|
state.balance(child)
|
||||||
.and_then(|b| state.transfer_balance(child, beneficiary, &b, CleanupMode::NoEmpty)));
|
.and_then(|b| state.transfer_balance(child, beneficiary, &b, CleanupMode::NoEmpty))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -24,7 +24,7 @@ type DeadlineBox<F> where F: Future = BoxFuture<DeadlineStatus<F::Item>, F::Erro
|
|||||||
/// Complete a passed future or fail if it is not completed within timeout.
|
/// Complete a passed future or fail if it is not completed within timeout.
|
||||||
pub fn deadline<F, T>(duration: Duration, handle: &Handle, future: F) -> Result<Deadline<F>, io::Error>
|
pub fn deadline<F, T>(duration: Duration, handle: &Handle, future: F) -> Result<Deadline<F>, io::Error>
|
||||||
where F: Future<Item = T, Error = io::Error> + Send + 'static, T: 'static {
|
where F: Future<Item = T, Error = io::Error> + Send + 'static, T: 'static {
|
||||||
let timeout = try!(Timeout::new(duration, handle)).map(|_| DeadlineStatus::Timeout).boxed();
|
let timeout = Timeout::new(duration, handle)?.map(|_| DeadlineStatus::Timeout).boxed();
|
||||||
let future = future.map(DeadlineStatus::Meet).boxed();
|
let future = future.map(DeadlineStatus::Meet).boxed();
|
||||||
let deadline = Deadline {
|
let deadline = Deadline {
|
||||||
future: timeout.select(future),
|
future: timeout.select(future),
|
||||||
|
@ -709,7 +709,7 @@ impl LightSync {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut light_proto = LightProtocol::new(params.client.clone(), light_params);
|
let mut light_proto = LightProtocol::new(params.client.clone(), light_params);
|
||||||
let sync_handler = Arc::new(try!(SyncHandler::new(params.client.clone())));
|
let sync_handler = Arc::new(SyncHandler::new(params.client.clone())?);
|
||||||
light_proto.add_handler(sync_handler.clone());
|
light_proto.add_handler(sync_handler.clone());
|
||||||
|
|
||||||
for handler in params.handlers {
|
for handler in params.handlers {
|
||||||
@ -719,7 +719,7 @@ impl LightSync {
|
|||||||
(sync_handler, Arc::new(light_proto))
|
(sync_handler, Arc::new(light_proto))
|
||||||
};
|
};
|
||||||
|
|
||||||
let service = try!(NetworkService::new(params.network_config));
|
let service = NetworkService::new(params.network_config)?;
|
||||||
|
|
||||||
Ok(LightSync {
|
Ok(LightSync {
|
||||||
proto: light_proto,
|
proto: light_proto,
|
||||||
|
@ -551,7 +551,7 @@ impl<L: AsLightClient> LightSync<L> {
|
|||||||
peers: RwLock::new(HashMap::new()),
|
peers: RwLock::new(HashMap::new()),
|
||||||
pending_reqs: Mutex::new(HashSet::new()),
|
pending_reqs: Mutex::new(HashSet::new()),
|
||||||
client: client,
|
client: client,
|
||||||
rng: Mutex::new(try!(OsRng::new())),
|
rng: Mutex::new(OsRng::new()?),
|
||||||
state: Mutex::new(SyncState::Idle),
|
state: Mutex::new(SyncState::Idle),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ impl From<DecoderError> for BasicError {
|
|||||||
|
|
||||||
impl fmt::Display for BasicError {
|
impl fmt::Display for BasicError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
try!(write!(f, "Header response verification error: "));
|
write!(f, "Header response verification error: ")?;
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
BasicError::WrongSkip(ref exp, ref got)
|
BasicError::WrongSkip(ref exp, ref got)
|
||||||
@ -78,13 +78,13 @@ pub fn verify(headers: &[encoded::Header], request: &HeadersRequest) -> Result<V
|
|||||||
|
|
||||||
let reverse = request.reverse;
|
let reverse = request.reverse;
|
||||||
|
|
||||||
try!(Max(request.max as usize).verify(&headers, reverse));
|
Max(request.max as usize).verify(&headers, reverse)?;
|
||||||
match request.start {
|
match request.start {
|
||||||
HashOrNumber::Number(ref num) => try!(StartsAtNumber(*num).verify(&headers, reverse)),
|
HashOrNumber::Number(ref num) => StartsAtNumber(*num).verify(&headers, reverse)?,
|
||||||
HashOrNumber::Hash(ref hash) => try!(StartsAtHash(*hash).verify(&headers, reverse)),
|
HashOrNumber::Hash(ref hash) => StartsAtHash(*hash).verify(&headers, reverse)?,
|
||||||
}
|
}
|
||||||
|
|
||||||
try!(SkipsBetween(request.skip).verify(&headers, reverse));
|
SkipsBetween(request.skip).verify(&headers, reverse)?;
|
||||||
|
|
||||||
Ok(headers)
|
Ok(headers)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user