refactor!: comet_info to struct (#17689)

This commit is contained in:
Marko 2023-09-12 12:55:43 +02:00 committed by GitHub
parent 5eaa7b8d3c
commit 71dc28af0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 36 deletions

View File

@ -37,6 +37,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]
* [#17468](https://github.com/cosmos/cosmos-sdk/pull/17468) Add `appmodule.HasPreBlocker` interface.
* [#17689](https://github.com/cosmos/cosmos-sdk/pull/17689) Move Comet service to return structs instead of interfaces.
* `BlockInfo` was renamed to `Info` and `BlockInfoService` was renamed to `CometInfoService`
## [v0.10.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.10.0)

View File

@ -6,18 +6,18 @@ import (
)
// BlockInfoService is an interface that can be used to get information specific to Comet
type BlockInfoService interface {
GetCometBlockInfo(context.Context) BlockInfo
type CometInfoService interface {
GetCometInfo(context.Context) Info
}
// BlockInfo is the information comet provides apps in ABCI
type BlockInfo interface {
GetEvidence() EvidenceList // Evidence misbehavior of the block
// Info is the information comet provides apps in ABCI
type Info struct {
Evidence []Evidence // Evidence misbehavior of the block
// ValidatorsHash returns the hash of the validators
// For Comet, it is the hash of the next validator set
GetValidatorsHash() []byte
GetProposerAddress() []byte // ProposerAddress returns the address of the block proposer
GetLastCommit() CommitInfo // DecidedLastCommit returns the last commit info
ValidatorsHash []byte
ProposerAddress []byte // ProposerAddress is the address of the block proposer
LastCommit CommitInfo // DecidedLastCommit returns the last commit info
}
// MisbehaviorType is the type of misbehavior for a validator
@ -29,36 +29,25 @@ const (
LightClientAttack MisbehaviorType = 2
)
// Validator is the validator information of ABCI
type Validator interface {
Address() []byte
Power() int64
}
type EvidenceList interface {
Len() int
Get(int) Evidence
}
// Evidence is the misbehavior information of ABCI
type Evidence interface {
Type() MisbehaviorType
Validator() Validator
Height() int64
Time() time.Time
TotalVotingPower() int64
type Evidence struct {
Type MisbehaviorType
Validator Validator
Height int64
Time time.Time
TotalVotingPower int64
}
// CommitInfo is the commit information of ABCI
type CommitInfo interface {
Round() int32
Votes() VoteInfos
type CommitInfo struct {
Round int32
Votes []VoteInfo
}
// VoteInfos is an interface to get specific votes in a efficient way
type VoteInfos interface {
Len() int
Get(int) VoteInfo
// VoteInfo is the vote information of ABCI
type VoteInfo struct {
Validator Validator
BlockIDFlag BlockIDFlag
}
// BlockIdFlag indicates which BlockID the signature is for
@ -74,8 +63,8 @@ const (
BlockIDFlagNil BlockIDFlag = 3
)
// VoteInfo is the vote information of ABCI
type VoteInfo interface {
Validator() Validator
GetBlockIDFlag() BlockIDFlag
// Validator is the validator information of ABCI
type Validator struct {
Address []byte
Power int64
}