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())))
}
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);
signer(vote_info.sha3()).map(|ref signature| {
let mut s = RlpStream::new_list(2);

View File

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