Poc-1 backwards compatibility (#291)

This commit is contained in:
Arkadiy Paronyan
2018-07-10 09:49:42 +02:00
committed by Gav Wood
parent a472fe4430
commit 48aae39343
4 changed files with 20 additions and 5 deletions
+1 -2
View File
@@ -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 }
}
};
+3
View File
@@ -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,
}
}
+11 -2
View File
@@ -95,6 +95,8 @@ pub enum Role {
Light,
/// Parachain validator.
Authority,
/// Same as `Authority`
Validator,
}
impl Role {
@@ -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
@@ -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
}
@@ -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.
+5 -1
View File
@@ -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;
@@ -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))
}