We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
ev, ok := ev.(*types.DuplicateVoteEvidence)
type Evidence interface { ABCI() []abci.Evidence // forms individual evidence to be sent to the application Bytes() []byte // bytes which comprise the evidence Hash() []byte // hash of the evidence Height() int64 // height of the infraction String() string // string format of the evidence Time() time.Time // time of the infraction ValidateBasic() error // basic consistency check } type DuplicateVoteEvidence struct { VoteA *Vote `json:"vote_a"` VoteB *Vote `json:"vote_b"` // abci specific information TotalVotingPower int64 ValidatorPower int64 Timestamp time.Time } evidenceFromEachValidator := make([]types.Evidence, nValidators) // set giá trị cho evidenceFromEachValidator for idx, ev := range evidenceFromEachValidator { ev, ok := ev.(*types.DuplicateVoteEvidence) }
ev
*types.DuplicateVoteEvidence
ok
package main import ( "fmt" "time" ) type Vote struct { } type Evidence interface { ABCI() []Evidence // forms individual evidence to be sent to the application Bytes() []byte // bytes which comprise the evidence Hash() []byte // hash of the evidence Height() int64 // height of the infraction String() string // string format of the evidence Time() time.Time // time of the infraction ValidateBasic() error // basic consistency check } type DuplicateVoteEvidence struct { VoteA *Vote `json:"vote_a"` VoteB *Vote `json:"vote_b"` // abci specific information TotalVotingPower int64 ValidatorPower int64 Timestamp time.Time } func NewEvidence() Evidence { return &DuplicateVoteEvidence{} } func (this *DuplicateVoteEvidence) ABCI() []Evidence { return nil} func (this *DuplicateVoteEvidence)Bytes() []byte{return nil} // bytes which comprise the evidence func (this *DuplicateVoteEvidence)Hash() []byte {return nil} // hash of the evidence func (this *DuplicateVoteEvidence)Height() int64 {return 0} // height of the infraction func (this *DuplicateVoteEvidence)String() string {return ""} // string format of the evidence func (this *DuplicateVoteEvidence)Time() time.Time {return time.Time{}} // time of the infraction func (this *DuplicateVoteEvidence)ValidateBasic() error{return nil} // basic consistency check func main() { evidenceFromEachValidator := make([]Evidence, 0) evidenceFromEachValidator = append(evidenceFromEachValidator, NewEvidence()) // set giá trị cho evidenceFromEachValidator for _, ev := range evidenceFromEachValidator { _, ok := ev.(*DuplicateVoteEvidence) if ok { fmt.Println("Cast success") } else { fmt.Println("Cast fail") } } }
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Input your email to receive reset password link, or if you remember your password, you can click