Gossip refactoring (#1811)

* First part of gossip protocol refactoring

* Message validation in GRANDPA

* Reverted to time-based expiration for future round messages

* Removed collect_garbage_for_topic

* Use consensus engine id instead of kind

* Use try_init

Co-Authored-By: arkpar <arkady.paronyan@gmail.com>

* Comment

Co-Authored-By: arkpar <arkady.paronyan@gmail.com>

* Added expiration check on broadcast

Co-Authored-By: arkpar <arkady.paronyan@gmail.com>

* Apply suggestions from code review

Co-Authored-By: arkpar <arkady.paronyan@gmail.com>

* Style

* Style
This commit is contained in:
Arkadiy Paronyan
2019-02-20 12:40:03 +01:00
committed by Gav Wood
parent 21779b8cf2
commit b3eae17f65
10 changed files with 456 additions and 269 deletions
+15 -4
View File
@@ -30,6 +30,9 @@ pub use self::generic::{
/// A unique ID of a request.
pub type RequestId = u64;
/// Consensus engine unique ID.
pub type ConsensusEngineId = [u8; 4];
/// Type alias for using the message type using block type parameters.
pub type Message<B> = generic::Message<
<B as BlockT>::Header,
@@ -132,10 +135,16 @@ pub mod generic {
use crate::config::Roles;
use super::{
BlockAttributes, RemoteCallResponse, RemoteReadResponse,
RequestId, Transactions, Direction
RequestId, Transactions, Direction, ConsensusEngineId,
};
/// Consensus is opaque to us
pub type ConsensusMessage = Vec<u8>;
/// Consensus is mostly opaque to us
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
pub struct ConsensusMessage {
/// Identifies consensus engine.
pub engine_id: ConsensusEngineId,
/// Message payload.
pub data: Vec<u8>,
}
/// Block data sent in the response.
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
@@ -177,7 +186,7 @@ pub mod generic {
/// Transactions.
Transactions(Transactions<Extrinsic>),
/// Consensus protocol message.
Consensus(Hash, ConsensusMessage, bool), // topic, opaque Vec<u8>, broadcast
Consensus(ConsensusMessage),
/// Remote method call request.
RemoteCallRequest(RemoteCallRequest<Hash>),
/// Remote method call response.
@@ -216,6 +225,8 @@ pub mod generic {
pub struct Status<Hash, Number> {
/// Protocol version.
pub version: u32,
/// Minimum supported version.
pub min_supported_version: u32,
/// Supported roles.
pub roles: Roles,
/// Best block number.