add substrate finality grandpa primitives for WASM

This commit is contained in:
Robert Habermeier
2018-10-28 20:36:59 +01:00
parent 66dafbcb0b
commit 442e300163
7 changed files with 111 additions and 23 deletions
+3 -22
View File
@@ -14,11 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
// tag::description[]
//! Integration of the GRANDPA finality gadget into substrate.
//!
//! This is a long-running future that produces finality notifications.
// end::description[]
extern crate finality_grandpa as grandpa;
extern crate futures;
@@ -29,6 +27,7 @@ extern crate substrate_primitives;
extern crate tokio;
extern crate parking_lot;
extern crate parity_codec as codec;
extern crate substrate_fg_primitives as fg_primitives;
#[macro_use]
extern crate log;
@@ -64,6 +63,8 @@ use std::time::{Instant, Duration};
use authorities::SharedAuthoritySet;
pub use fg_primitives::ScheduledChange;
mod authorities;
const LAST_COMPLETED_KEY: &[u8] = b"grandpa_completed_round";
@@ -485,26 +486,6 @@ impl<Block: BlockT, B, E, N> grandpa::Chain<Block::Hash, NumberFor<Block>> for E
}
}
/// A scheduled change of authority set.
#[derive(Debug, PartialEq)]
pub struct ScheduledChange<N> {
/// The new authorities after the change, along with their respective weights.
pub next_authorities: Vec<(AuthorityId, u64)>,
/// The number of blocks to delay.
pub delay: N,
}
/// A GRANDPA-compatible DigestItem. This can describe when GRANDPA set changes
/// are scheduled.
//
// With specialization, could do a blanket implementation so this trait
// doesn't have to be implemented by users.
pub trait CompatibleDigestItem<N> {
/// If this digest item notes a GRANDPA set change, return information about
/// the scheduled change.
fn scheduled_change(&self) -> Option<ScheduledChange<N>> { None }
}
/// A new authority set along with the canonical block it changed at.
#[derive(Debug)]
struct NewAuthoritySet<H, N> {