2021-07-06 18:39:56 -07:00
|
|
|
package node
|
|
|
|
|
2021-07-19 16:59:28 -04:00
|
|
|
import (
|
|
|
|
"github.com/btcsuite/btcd/claimtrie/change"
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
|
|
|
)
|
2021-07-06 18:39:56 -07:00
|
|
|
|
|
|
|
type ClaimList []*Claim
|
|
|
|
|
|
|
|
type comparator func(c *Claim) bool
|
|
|
|
|
2021-07-19 16:59:28 -04:00
|
|
|
func byID(id change.ClaimID) comparator {
|
2021-07-06 18:39:56 -07:00
|
|
|
return func(c *Claim) bool {
|
|
|
|
return c.ClaimID == id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func byOut(out wire.OutPoint) comparator {
|
|
|
|
return func(c *Claim) bool {
|
|
|
|
return c.OutPoint == out // assuming value comparison
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l ClaimList) find(cmp comparator) *Claim {
|
|
|
|
|
|
|
|
for i := range l {
|
|
|
|
if cmp(l[i]) {
|
|
|
|
return l[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|