mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 06:15:33 +00:00
The main change here is to use encoding/json to encode and decode RPC parameters, rather than the custom tmjson package. This includes: - Update the HTTP POST handler parameter handling. - Add field tags to 64-bit integer types to get string encoding (to match amino/tmjson). - Add marshalers to struct types that mention interfaces. - Inject wrappers to decode interface arguments in RPC handlers.
27 lines
802 B
Go
27 lines
802 B
Go
package core
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/tendermint/tendermint/rpc/coretypes"
|
|
)
|
|
|
|
// BroadcastEvidence broadcasts evidence of the misbehavior.
|
|
// More: https://docs.tendermint.com/master/rpc/#/Evidence/broadcast_evidence
|
|
func (env *Environment) BroadcastEvidence(
|
|
ctx context.Context,
|
|
ev coretypes.Evidence,
|
|
) (*coretypes.ResultBroadcastEvidence, error) {
|
|
if ev.Value == nil {
|
|
return nil, fmt.Errorf("%w: no evidence was provided", coretypes.ErrInvalidRequest)
|
|
}
|
|
if err := ev.Value.ValidateBasic(); err != nil {
|
|
return nil, fmt.Errorf("evidence.ValidateBasic failed: %w", err)
|
|
}
|
|
if err := env.EvidencePool.AddEvidence(ev.Value); err != nil {
|
|
return nil, fmt.Errorf("failed to add evidence: %w", err)
|
|
}
|
|
return &coretypes.ResultBroadcastEvidence{Hash: ev.Value.Hash()}, nil
|
|
}
|