Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #737 from ethcore/sync
Browse files Browse the repository at this point in the history
Sync fixed again
  • Loading branch information
gavofyork committed Mar 15, 2016
2 parents e5f5496 + b9b0444 commit b0f233a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sync/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ impl ChainSync {
let header_rlp = try!(block_rlp.at(0));
let h = header_rlp.as_raw().sha3();
trace!(target: "sync", "{} -> NewBlock ({})", peer_id, h);
if !self.have_common_block {
trace!(target: "sync", "NewBlock ignored while seeking");
}
let header: BlockHeader = try!(header_rlp.as_val());
let mut unknown = false;
{
Expand All @@ -498,9 +501,10 @@ impl ChainSync {
Ok(_) => {
if self.current_base_block() < header.number {
self.last_imported_block = Some(header.number);
self.last_imported_hash = Some(header.hash());
self.remove_downloaded_blocks(header.number);
}
trace!(target: "sync", "New block queued {:?}", h);
trace!(target: "sync", "New block queued {:?} ({})", h, header.number);
},
Err(Error::Block(BlockError::UnknownParent(p))) => {
unknown = true;
Expand Down Expand Up @@ -779,7 +783,7 @@ impl ChainSync {
{
let headers = self.headers.range_iter().next().unwrap();
let bodies = self.bodies.range_iter().next().unwrap();
if headers.0 != bodies.0 || headers.0 != self.current_base_block() + 1 {
if headers.0 != bodies.0 || headers.0 > self.current_base_block() + 1 {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions util/src/network/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ impl Session {

/// Send a protocol packet to peer.
pub fn send_packet(&mut self, protocol: &str, packet_id: u8, data: &[u8]) -> Result<(), UtilError> {
if self.info.capabilities.is_empty() || !self.had_hello {
debug!(target: "network", "Sending to unconfirmed session {}, protocol: {}, packet: {}", self.token(), protocol, packet_id);
return Err(From::from(NetworkError::BadProtocol));
}
if self.expired() {
return Err(From::from(NetworkError::Expired));
}
Expand Down

0 comments on commit b0f233a

Please sign in to comment.