Validator side of the collation protocol. (#295)

* skeleton of collators object

* awaiting and handling collations. rename `collators` to CollationPool

* add some tests

* add tests

* implement Collators trait for ConsensusNetwork

* plug collators into main polkadot-network

* ignore collator role message

* add a couple more tests

* garbage collection for collations

* ensure disconnected backup collator is removed from pool

* address other grumbles
This commit is contained in:
Robert Habermeier
2018-07-12 09:47:10 +01:00
committed by Gav Wood
parent 907eeef9dd
commit 88c40c8fb4
7 changed files with 514 additions and 34 deletions
+12 -1
View File
@@ -144,7 +144,7 @@ pub struct CandidateReceipt {
pub parachain_index: Id,
/// The collator's relay-chain account ID
pub collator: super::AccountId,
/// Signature on block data by collator.
/// Signature on blake2-256 of the block data by collator.
pub signature: CandidateSignature,
/// The head-data
pub head_data: HeadData,
@@ -195,6 +195,17 @@ impl CandidateReceipt {
use runtime_primitives::traits::{BlakeTwo256, Hash};
BlakeTwo256::hash_of(self)
}
/// Check integrity vs. provided block data.
pub fn check_signature(&self) -> Result<(), ()> {
use runtime_primitives::traits::Verify;
if self.signature.verify(&self.block_data_hash.0[..], &self.collator) {
Ok(())
} else {
Err(())
}
}
}
impl PartialOrd for CandidateReceipt {