github.com/lbryio/lbcd@v0.22.119/claimtrie/node/claim_list.go (about)

     1  package node
     2  
     3  import (
     4  	"github.com/lbryio/lbcd/claimtrie/change"
     5  	"github.com/lbryio/lbcd/wire"
     6  )
     7  
     8  type ClaimList []*Claim
     9  
    10  type comparator func(c *Claim) bool
    11  
    12  func byID(id change.ClaimID) comparator {
    13  	return func(c *Claim) bool {
    14  		return c.ClaimID == id
    15  	}
    16  }
    17  
    18  func byOut(out wire.OutPoint) comparator {
    19  	return func(c *Claim) bool {
    20  		return c.OutPoint == out // assuming value comparison
    21  	}
    22  }
    23  
    24  func (l ClaimList) find(cmp comparator) *Claim {
    25  
    26  	for i := range l {
    27  		if cmp(l[i]) {
    28  			return l[i]
    29  		}
    30  	}
    31  
    32  	return nil
    33  }