<commit_before>package libkb

import (
	"fmt"
	"github.com/keybase/go-jsonw"
	"sync"
	"time"
)

// Can either be a RemoteProofChainLink or one of the identities
// listed in a tracking statement
type TrackIdComponent interface {
	ToIdString() string
	ToKeyValuePair() (string, string)
	GetProofState() int
	LastWriterWins() bool
}

type TrackSet struct {
	ids      map[string]TrackIdComponent
	services map[string]bool
}

func NewTrackSet() *TrackSet {
	return &TrackSet{
		ids:      make(map[string]TrackIdComponent),
		services: make(map[string]bool),
	}
}

func (ts TrackSet) Add(t TrackIdComponent) {
	ts.ids[t.ToIdString()] = t
}

func (a TrackSet) GetProofState(tic TrackIdComponent) int {
	ret := PROOF_STATE_NONE
	if obj := a.ids[tic.ToIdString()]; obj != nil {
		ret = obj.GetProofState()
	}
	return ret
}

func (A TrackSet) Subtract(B TrackSet) (out []TrackIdComponent) {
	for _, c := range A.ids {
		if !B.HasMember(c) {
			out = append(out, c)
		}
	}
	return
}

func (a TrackSet) HasMember(t TrackIdComponent) bool {
	_, found := a.ids[t.ToIdString()]
	return found
}

func (a TrackSet) LenEq(b TrackSet) bool {
	return len(a.ids) == len(b.ids)
}

//=====================================================================

type TrackInstructions struct {
	Local  bool
	Remote bool
}

//=====================================================================

type TrackLookup struct {
	link  *TrackChainLink     // The original chain link that I signed
	set   *TrackSet           // The total set of tracked identities
	ids   map[string][]string // A http -> [foo.com, boo.com] lookup
	mutex *sync.Mutex         // in case we're accessing in mutliple threads
}

func (l TrackLookup) GetProofState(tic TrackIdComponent) int {
	return l.set.GetProofState(tic)
}
<commit_msg>Changed github proofs shouldn't be counted as "missing"<commit_after>package libkb

import (
	"fmt"
	"github.com/keybase/go-jsonw"
	"sync"
	"time"
)

// Can either be a RemoteProofChainLink or one of the identities
// listed in a tracking statement
type TrackIdComponent interface {
	ToIdString() string
	ToKeyValuePair() (string, string)
	GetProofState() int
	LastWriterWins() bool
}

type TrackSet struct {
	ids      map[string]TrackIdComponent
	services map[string]bool
}

func NewTrackSet() *TrackSet {
	return &TrackSet{
		ids:      make(map[string]TrackIdComponent),
		services: make(map[string]bool),
	}
}

func (ts TrackSet) Add(t TrackIdComponent) {
	ts.ids[t.ToIdString()] = t
	if t.LastWriterWins() {
		k, _ := t.ToKeyValuePair()
		ts.services[k] = true
	}
}

func (a TrackSet) GetProofState(tic TrackIdComponent) int {
	ret := PROOF_STATE_NONE
	if obj := a.ids[tic.ToIdString()]; obj != nil {
		ret = obj.GetProofState()
	}
	return ret
}

func (A TrackSet) Subtract(B TrackSet) (out []TrackIdComponent) {
	for _, c := range A.ids {
		if !B.HasMember(c) {
			out = append(out, c)
		}
	}
	return
}

func (A TrackSet) HasMember(t TrackIdComponent) bool {
	var found bool

	// For LastWriterWins like social networks, then it just matters
	// that there is some proof for the service.  For non-last-writer-wins,
	// like HTTPS and DNS, then the full proof needs to show up in A.
	if t.LastWriterWins() {
		k, _ := t.ToKeyValuePair()
		_, found = A.services[k]
	} else {
		_, found = A.ids[t.ToIdString()]
	}
	return found
}

func (a TrackSet) LenEq(b TrackSet) bool {
	return len(a.ids) == len(b.ids)
}

//=====================================================================

type TrackInstructions struct {
	Local  bool
	Remote bool
}

//=====================================================================

type TrackLookup struct {
	link  *TrackChainLink     // The original chain link that I signed
	set   *TrackSet           // The total set of tracked identities
	ids   map[string][]string // A http -> [foo.com, boo.com] lookup
	mutex *sync.Mutex         // in case we're accessing in mutliple threads
}

func (l TrackLookup) GetProofState(tic TrackIdComponent) int {
	return l.set.GetProofState(tic)
}

{'fraction_non_alphanumeric': 0.17875, 'fraction_numerical': 0.0, 'mean_word_length': 4.013784461152882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '387878', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1322, 'n_words': 378}