2018-10-13 18:58:32 +09:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/tendermint/tendermint/crypto"
|
|
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
|
|
|
"github.com/tendermint/tendermint/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ### Query Parameters
|
|
|
|
//
|
|
|
|
// | Parameter | Type | Default | Required | Description |
|
|
|
|
// |-----------+--------+---------+----------+-------------------------------|
|
|
|
|
// | pubkey | PubKey | nil | true | PubKey of the byzantine actor |
|
|
|
|
// | vote1 | Vote | nil | true | First vote |
|
|
|
|
// | vote2 | Vote | nil | true | Second vote |
|
|
|
|
func BroadcastDuplicateVote(pubkey crypto.PubKey, vote1 types.Vote, vote2 types.Vote) (*ctypes.ResultBroadcastDuplicateVote, error) {
|
|
|
|
chainID := p2pTransport.NodeInfo().Network
|
|
|
|
ev := &types.DuplicateVoteEvidence{pubkey, &vote1, &vote2}
|
|
|
|
if err := vote1.Verify(chainID, pubkey); err != nil {
|
2018-11-06 18:11:10 +01:00
|
|
|
return nil, fmt.Errorf("Error broadcasting evidence, invalid vote1: %v", err)
|
|
|
|
}
|
|
|
|
if err := vote2.Verify(chainID, pubkey); err != nil {
|
|
|
|
return nil, fmt.Errorf("Error broadcasting evidence, invalid vote2: %v", err)
|
2018-10-13 18:58:32 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
err := evidencePool.AddEvidence(ev)
|
|
|
|
if err != nil {
|
2018-11-06 18:11:10 +01:00
|
|
|
return nil, fmt.Errorf("Error broadcasting evidence, adding evidence: %v", err)
|
2018-10-13 18:58:32 +09:00
|
|
|
}
|
|
|
|
return &ctypes.ResultBroadcastDuplicateVote{ev.Hash()}, nil
|
|
|
|
}
|