return signing failure error

This commit is contained in:
keorn 2016-12-01 14:10:42 +00:00
parent 66b4f1ac47
commit 344999aaf7
2 changed files with 17 additions and 8 deletions

View File

@ -165,7 +165,7 @@ pub fn message_info_rlp_from_header(header: &Header) -> Result<Bytes, ::rlp::Dec
Ok(message_info_rlp(header.number() as Height, round, Step::Precommit, Some(header.bare_hash()))) Ok(message_info_rlp(header.number() as Height, round, Step::Precommit, Some(header.bare_hash())))
} }
pub fn message_full_rlp<F>(signer: F, height: Height, round: Round, step: Step, block_hash: Option<BlockHash>) -> Option<Bytes> where F: FnOnce(H256) -> Option<H520> { pub fn message_full_rlp<F>(signer: F, height: Height, round: Round, step: Step, block_hash: Option<BlockHash>) -> Result<Bytes, ::account_provider::Error> where F: FnOnce(H256) -> Result<H520, ::account_provider::Error> {
let vote_info = message_info_rlp(height, round, step, block_hash); let vote_info = message_info_rlp(height, round, step, block_hash);
signer(vote_info.sha3()).map(|ref signature| { signer(vote_info.sha3()).map(|ref signature| {
let mut s = RlpStream::new_list(2); let mut s = RlpStream::new_list(2);

View File

@ -138,18 +138,26 @@ impl Tendermint {
Ok(_) => trace!(target: "poa", "broadcast_message: BroadcastMessage message sent."), Ok(_) => trace!(target: "poa", "broadcast_message: BroadcastMessage message sent."),
Err(err) => warn!(target: "poa", "broadcast_message: Could not send a sealing message {}.", err), Err(err) => warn!(target: "poa", "broadcast_message: Could not send a sealing message {}.", err),
} }
} else {
warn!(target: "poa", "broadcast_message: No IoChannel available.");
} }
} }
fn generate_message(&self, block_hash: Option<BlockHash>) -> Option<Bytes> { fn generate_message(&self, block_hash: Option<BlockHash>) -> Option<Bytes> {
if let Some(ref ap) = *self.account_provider.lock() { if let Some(ref ap) = *self.account_provider.lock() {
message_full_rlp( match message_full_rlp(
|mh| ap.sign(*self.authority.read(), self.password.read().clone(), mh).ok().map(H520::from), |mh| ap.sign(*self.authority.read(), self.password.read().clone(), mh).map(H520::from),
self.height.load(AtomicOrdering::SeqCst), self.height.load(AtomicOrdering::SeqCst),
self.round.load(AtomicOrdering::SeqCst), self.round.load(AtomicOrdering::SeqCst),
*self.step.read(), *self.step.read(),
block_hash block_hash
) ) {
Ok(m) => Some(m),
Err(e) => {
warn!(target: "poa", "generate_message: Could not sign the message {}", e);
None
},
}
} else { } else {
warn!(target: "poa", "generate_message: No AccountProvider available."); warn!(target: "poa", "generate_message: No AccountProvider available.");
None None
@ -166,12 +174,12 @@ impl Tendermint {
*self.step.write() = step; *self.step.write() = step;
match step { match step {
Step::Propose => { Step::Propose => {
trace!(target: "poa", "to_step: Transitioning to Propose."); trace!(target: "poa", "to_step: Propose.");
*self.proposal.write() = None; *self.proposal.write() = None;
self.update_sealing() self.update_sealing()
}, },
Step::Prevote => { Step::Prevote => {
trace!(target: "poa", "to_step: Transitioning to Prevote."); trace!(target: "poa", "to_step: Prevote.");
let block_hash = match *self.lock_change.read() { let block_hash = match *self.lock_change.read() {
Some(ref m) if self.should_unlock(m.round) => self.proposal.read().clone(), Some(ref m) if self.should_unlock(m.round) => self.proposal.read().clone(),
Some(ref m) => m.block_hash, Some(ref m) => m.block_hash,
@ -180,7 +188,7 @@ impl Tendermint {
self.generate_and_broadcast_message(block_hash); self.generate_and_broadcast_message(block_hash);
}, },
Step::Precommit => { Step::Precommit => {
trace!(target: "poa", "to_step: Transitioning to Precommit."); trace!(target: "poa", "to_step: Precommit.");
let block_hash = match *self.lock_change.read() { let block_hash = match *self.lock_change.read() {
Some(ref m) if self.is_round(m) => { Some(ref m) if self.is_round(m) => {
self.last_lock.store(m.round, AtomicOrdering::SeqCst); self.last_lock.store(m.round, AtomicOrdering::SeqCst);
@ -191,7 +199,7 @@ impl Tendermint {
self.generate_and_broadcast_message(block_hash); self.generate_and_broadcast_message(block_hash);
}, },
Step::Commit => { Step::Commit => {
trace!(target: "poa", "to_step: Transitioning to Commit."); trace!(target: "poa", "to_step: Commit.");
// Commit the block using a complete signature set. // Commit the block using a complete signature set.
let round = self.round.load(AtomicOrdering::SeqCst); let round = self.round.load(AtomicOrdering::SeqCst);
if let Some(block_hash) = *self.proposal.read() { if let Some(block_hash) = *self.proposal.read() {
@ -482,6 +490,7 @@ impl Engine for Tendermint {
} }
fn register_message_channel(&self, message_channel: IoChannel<ClientIoMessage>) { fn register_message_channel(&self, message_channel: IoChannel<ClientIoMessage>) {
trace!(target: "poa", "register_message_channel: Register the IoChannel.");
*self.message_channel.lock() = Some(message_channel); *self.message_channel.lock() = Some(message_channel);
} }