|
package core
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/tendermint/tendermint/evidence"
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
|
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
|
|
"github.com/tendermint/tendermint/types"
|
|
)
|
|
|
|
// BroadcastEvidence broadcasts evidence of the misbehavior.
|
|
// More: https://docs.tendermint.com/master/rpc/#/Info/broadcast_evidence
|
|
func BroadcastEvidence(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
|
|
if err := ev.ValidateBasic(); err != nil {
|
|
return nil, fmt.Errorf("evidence.ValidateBasic failed: %w", err)
|
|
}
|
|
|
|
err := evidencePool.AddEvidence(ev)
|
|
if _, ok := err.(evidence.ErrEvidenceAlreadyStored); err == nil || ok {
|
|
return &ctypes.ResultBroadcastEvidence{Hash: ev.Hash()}, nil
|
|
}
|
|
return nil, err
|
|
}
|