add tendermint seal
This commit is contained in:
@@ -19,8 +19,12 @@
|
||||
},
|
||||
"genesis": {
|
||||
"seal": {
|
||||
"generic": {
|
||||
"rlp": "f88980b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f843b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
"tendermint": {
|
||||
"round": "0x0",
|
||||
"proposal": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"precommits": [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
]
|
||||
}
|
||||
},
|
||||
"difficulty": "0x20000",
|
||||
|
||||
@@ -44,6 +44,16 @@ pub struct AuthorityRound {
|
||||
pub signature: H520,
|
||||
}
|
||||
|
||||
/// Tendermint seal.
|
||||
pub struct AuthorityRound {
|
||||
/// Seal round.
|
||||
pub round: usize,
|
||||
/// Proposal seal signature.
|
||||
pub proposal: H520,
|
||||
/// Precommit seal signatures.
|
||||
pub precommits: Vec<H520>,
|
||||
}
|
||||
|
||||
impl Into<Generic> for AuthorityRound {
|
||||
fn into(self) -> Generic {
|
||||
let mut s = RlpStream::new_list(2);
|
||||
@@ -52,6 +62,14 @@ impl Into<Generic> for AuthorityRound {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Generic> for AuthorityRound {
|
||||
fn into(self) -> Generic {
|
||||
let mut s = RlpStream::new_list(3);
|
||||
s.append(&self.round).append(&self.proposal).append(&self.precommits);
|
||||
Generic(s.out())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Generic(pub Vec<u8>);
|
||||
|
||||
/// Genesis seal type.
|
||||
@@ -60,6 +78,8 @@ pub enum Seal {
|
||||
Ethereum(Ethereum),
|
||||
/// AuthorityRound seal.
|
||||
AuthorityRound(AuthorityRound),
|
||||
/// Tendermint seal.
|
||||
Tendermint(Tendermint),
|
||||
/// Generic RLP seal.
|
||||
Generic(Generic),
|
||||
}
|
||||
@@ -75,6 +95,11 @@ impl From<ethjson::spec::Seal> for Seal {
|
||||
step: ar.step.into(),
|
||||
signature: ar.signature.into()
|
||||
}),
|
||||
ethjson::spec::Seal::Tendermint(tender) => Seal::Tendermint(Tendermint {
|
||||
round: tender.round.into(),
|
||||
proposal: tender.proposal.into(),
|
||||
precommits: tender.precommits.into_iter().map(Into::into).collect()
|
||||
}),
|
||||
ethjson::spec::Seal::Generic(g) => Seal::Generic(Generic(g.into())),
|
||||
}
|
||||
}
|
||||
@@ -86,6 +111,7 @@ impl Into<Generic> for Seal {
|
||||
Seal::Generic(generic) => generic,
|
||||
Seal::Ethereum(eth) => eth.into(),
|
||||
Seal::AuthorityRound(ar) => ar.into(),
|
||||
Seal::Tendermint(tender) => tender.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user