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

Commit

Permalink
Poc-1 backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Jul 9, 2018
1 parent 2e9b52e commit 5b243e9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 1 addition & 2 deletions polkadot/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ impl Specialization<Block> for PolkadotProtocol {
let local_status = match Status::decode(&mut &status.chain_status[..]) {
Some(status) => status,
None => {
ctx.disable_peer(peer_id);
return;
Status { collating_for: None }
}
};

Expand Down
3 changes: 3 additions & 0 deletions polkadot/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ fn make_status(status: &Status, roles: Vec<Role>) -> FullStatus {
best_hash: Default::default(),
genesis_hash: Default::default(),
chain_status: status.encode(),
parachain_id: None,
validator_id: None,
validator_signature: None,
}
}

Expand Down
13 changes: 11 additions & 2 deletions substrate/network/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ pub enum Role {
Light,
/// Parachain validator.
Authority,
/// Same as `Authority`
Validator,
}

impl Role {
Expand All @@ -105,7 +107,7 @@ impl Role {
match *r {
Role::Full => flags = flags | RoleFlags::FULL,
Role::Light => flags = flags | RoleFlags::LIGHT,
Role::Authority => flags = flags | RoleFlags::AUTHORITY,
Role::Authority | Role::Validator => flags = flags | RoleFlags::AUTHORITY,
}
}
flags
Expand All @@ -122,7 +124,7 @@ impl From<RoleFlags> for Vec<Role> where {
roles.push(Role::Light);
}
if !(flags & RoleFlags::AUTHORITY).is_empty() {
roles.push(Role::Authority);
roles.push(Role::Validator);
}
roles
}
Expand Down Expand Up @@ -371,7 +373,14 @@ pub mod generic {
/// Genesis block hash.
pub genesis_hash: Hash,
/// Chain-specific status.
#[serde(skip)]
pub chain_status: Vec<u8>,
/// Signatue of `best_hash` made with validator address. Required for the validator role.
pub validator_signature: Option<ed25519::Signature>,
/// Validator address. Required for the validator role.
pub validator_id: Option<AuthorityId>,
/// Parachain id. Required for the collator role.
pub parachain_id: Option<u64>,
}

/// Request block data from a peer.
Expand Down
6 changes: 5 additions & 1 deletion substrate/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use error;
const REQUEST_TIMEOUT_SEC: u64 = 40;

/// Current protocol version.
pub (crate) const CURRENT_VERSION: u32 = 1;
pub (crate) const CURRENT_VERSION: u32 = 0;
/// Current packet count.
pub (crate) const CURRENT_PACKET_COUNT: u8 = 1;

Expand Down Expand Up @@ -526,6 +526,10 @@ impl<B: BlockT, S: Specialization<B>> Protocol<B, S> where B::Header: HeaderT<Nu
best_number: info.chain.best_number,
best_hash: info.chain.best_hash,
chain_status: self.specialization.read().status(),

parachain_id: None,
validator_id: None,
validator_signature: None,
};
self.send_message(io, peer_id, GenericMessage::Status(status))
}
Expand Down

0 comments on commit 5b243e9

Please sign in to comment.