-
Notifications
You must be signed in to change notification settings - Fork 3k
/
honest_claims.go
36 lines (29 loc) · 1.14 KB
/
honest_claims.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package solver
import "github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
type honestClaimTracker struct {
// agreed tracks the existing claims in the game that the honest actor would make
// The claims may not yet have been made so are tracked by ClaimID not ContractIndex
agreed map[types.ClaimID]bool
// counters tracks the counter claim for a claim by contract index.
// The counter claim may not yet be part of the game state (ie it may be a move the honest actor is planning to make)
counters map[types.ClaimID]types.Claim
}
func newHonestClaimTracker() *honestClaimTracker {
return &honestClaimTracker{
agreed: make(map[types.ClaimID]bool),
counters: make(map[types.ClaimID]types.Claim),
}
}
func (a *honestClaimTracker) AddHonestClaim(parent types.Claim, claim types.Claim) {
a.agreed[claim.ID()] = true
if parent != (types.Claim{}) {
a.counters[parent.ID()] = claim
}
}
func (a *honestClaimTracker) IsHonest(claim types.Claim) bool {
return a.agreed[claim.ID()]
}
func (a *honestClaimTracker) HonestCounter(parent types.Claim) (types.Claim, bool) {
counter, ok := a.counters[parent.ID()]
return counter, ok
}