Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
feat: add data availability challenge event to vote pool (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing authored Feb 17, 2023
1 parent 532b41a commit 2f0b3bc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions votepool/event_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ const (

// FromBscCrossChainEvent defines the type of cross chain events from BSC to the current chain.
FromBscCrossChainEvent EventType = 2

// DataChallengeEvent defines the type of events for data availability challenges.
DataAvailabilityChallengeEvent EventType = 3
)
3 changes: 1 addition & 2 deletions votepool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ type Pool struct {

// NewVotePool creates a Pool, the init validators should be supplied.
func NewVotePool(logger log.Logger, validators []*types.Validator, eventBus *types.EventBus) (*Pool, error) {
// only used for cross chain votes currently.
eventTypes := []EventType{ToBscCrossChainEvent, FromBscCrossChainEvent}
eventTypes := []EventType{ToBscCrossChainEvent, FromBscCrossChainEvent, DataAvailabilityChallengeEvent}

ticker := time.NewTicker(pruneVoteInterval)
stores := make(map[EventType]*voteStore, len(eventTypes))
Expand Down
4 changes: 3 additions & 1 deletion votepool/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func (v *Vote) ValidateBasic() error {
if len(v.EventHash) != eventHashLen {
return errors.New("invalid event hash")
}
if v.EventType != ToBscCrossChainEvent && v.EventType != FromBscCrossChainEvent {
if v.EventType != ToBscCrossChainEvent &&
v.EventType != FromBscCrossChainEvent &&
v.EventType != DataAvailabilityChallengeEvent {
return errors.New("invalid event type")
}
if len(v.PubKey) != pubKeyLen {
Expand Down
2 changes: 1 addition & 1 deletion votepool/vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestVote_ValidateBasic(t *testing.T) {
vote: Vote{
PubKey: pubKey,
Signature: sign,
EventType: 3,
EventType: 10,
EventHash: eventHash,
expireAt: time.Time{},
},
Expand Down

0 comments on commit 2f0b3bc

Please sign in to comment.