-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6c2699
commit 6b71e22
Showing
2 changed files
with
80 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package dispute | ||
|
||
import ( | ||
"github.com/ChainSafe/gossamer/lib/common" | ||
"github.com/ChainSafe/gossamer/lib/parachain" | ||
) | ||
|
||
// CandidateComparator comparator for ordering of disputes for candidate. | ||
type CandidateComparator struct { | ||
relayParentBlockNumber *uint32 | ||
candidateHash common.Hash | ||
} | ||
|
||
// ParticipationRequest a dispute participation request | ||
type ParticipationRequest struct { | ||
candidateHash common.Hash | ||
candidateReceipt parachain.CandidateReceipt | ||
session parachain.SessionIndex | ||
//TODO: requestTimer for metrics | ||
} | ||
|
||
type ParticipationStatement struct{} | ||
|
||
type Participation interface { | ||
// Queue a dispute for the node to participate in | ||
Queue(request ParticipationRequest, priority ParticipationPriority) error | ||
|
||
// GetResult gets the outcome of a ... dispute? | ||
GetResult(statement ParticipationStatement) error | ||
|
||
// TODO: implement this once we have the message bus | ||
// ProcessActiveLeavesUpdate processes an active leaves update | ||
// ProcessActiveLeavesUpdate(update parachain.ActiveLeavesUpdate) error | ||
|
||
// BumpPriority bumps the priority for the given receipts | ||
BumpPriority(receipts []parachain.CandidateReceipt) error | ||
} | ||
|
||
type participation struct { | ||
runningParticipation map[common.Hash]struct{} | ||
queue Queue | ||
//TODO: worker sender channel | ||
recentBlock uint32 | ||
//TODO: metrics | ||
} | ||
|
||
func (p participation) Queue(request ParticipationRequest, priority ParticipationPriority) error { | ||
if _, ok := p.runningParticipation[request.candidateHash]; ok { | ||
return nil | ||
} | ||
|
||
// TODO: if we already have a recent block, participate right away | ||
|
||
// TODO: if not, add it to the queue | ||
|
||
return nil | ||
} | ||
|
||
func (p participation) GetResult(statement ParticipationStatement) error { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (p participation) BumpPriority(receipts []parachain.CandidateReceipt) error { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func NewParticipation() Participation { | ||
return &participation{ | ||
runningParticipation: make(map[common.Hash]struct{}), | ||
queue: NewQueue(), | ||
} | ||
} | ||
|
||
// TODO: implement this once we have the network protocols | ||
func (p participation) participate() error { | ||
//TODO implement me | ||
panic("implement me") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters