consensus: sign and verify consensus messages
This commit is contained in:
parent
765c354793
commit
138c94eda3
2 changed files with 79 additions and 1 deletions
|
@ -179,7 +179,10 @@ func getKeyPair(cfg *config.WalletConfig) (crypto.PrivateKey, crypto.PublicKey)
|
|||
|
||||
// OnPayload handles Payload receive.
|
||||
func (s *service) OnPayload(cp *Payload) {
|
||||
if s.cache.Has(cp.Hash()) {
|
||||
if !cp.Verify() {
|
||||
s.log.Debug("can't verify payload from #%d", cp.validatorIndex)
|
||||
return
|
||||
} else if s.cache.Has(cp.Hash()) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -224,6 +227,10 @@ func (s *service) broadcast(p payload.ConsensusPayload) {
|
|||
pr.minerTx = *s.txx.Get(pr.transactionHashes[0]).(*transaction.Transaction)
|
||||
}
|
||||
|
||||
if err := p.(*Payload).Sign(s.dbft.Priv.(*privateKey)); err != nil {
|
||||
s.log.Warnf("can't sign consensus payload: %v", err)
|
||||
}
|
||||
|
||||
s.cache.Add(p)
|
||||
s.Config.Broadcast(p.(*Payload))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue