id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
159,800
keybase/client
go/teams/loader.go
NewTeamLoaderAndInstall
func NewTeamLoaderAndInstall(g *libkb.GlobalContext) *TeamLoader { world := NewLoaderContextFromG(g) st := NewStorage(g) l := NewTeamLoader(g, world, st) g.SetTeamLoader(l) g.AddLogoutHook(l, "teamLoader") g.AddDbNukeHook(l, "teamLoader") return l }
go
func NewTeamLoaderAndInstall(g *libkb.GlobalContext) *TeamLoader { world := NewLoaderContextFromG(g) st := NewStorage(g) l := NewTeamLoader(g, world, st) g.SetTeamLoader(l) g.AddLogoutHook(l, "teamLoader") g.AddDbNukeHook(l, "teamLoader") return l }
[ "func", "NewTeamLoaderAndInstall", "(", "g", "*", "libkb", ".", "GlobalContext", ")", "*", "TeamLoader", "{", "world", ":=", "NewLoaderContextFromG", "(", "g", ")", "\n", "st", ":=", "NewStorage", "(", "g", ")", "\n", "l", ":=", "NewTeamLoader", "(", "g", ...
// NewTeamLoaderAndInstall creates a new loader and installs it into G.
[ "NewTeamLoaderAndInstall", "creates", "a", "new", "loader", "and", "installs", "it", "into", "G", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L93-L101
159,801
keybase/client
go/teams/loader.go
ResolveNameToIDUntrusted
func (l *TeamLoader) ResolveNameToIDUntrusted(ctx context.Context, teamName keybase1.TeamName, public bool, allowCache bool) (id keybase1.TeamID, err error) { defer l.G().CVTrace(ctx, libkb.VLog0, fmt.Sprintf("resolveNameToUIDUntrusted(%s,%v,%v)", teamName.String(), public, allowCache), func() error { return err })() // For root team names, just hash. if teamName.IsRootTeam() { return teamName.ToTeamID(public), nil } if !allowCache { return resolveNameToIDUntrustedAPICall(ctx, l.G(), teamName, public) } var idVoidPointer interface{} key := nameLookupBurstCacheKey{teamName, public} idVoidPointer, err = l.nameLookupBurstCache.Load(ctx, key, l.makeNameLookupBurstCacheLoader(ctx, l.G(), key)) if err != nil { return keybase1.TeamID(""), err } if idPointer, ok := idVoidPointer.(*keybase1.TeamID); ok && idPointer != nil { id = *idPointer } else { return keybase1.TeamID(""), errors.New("bad cast out of nameLookupBurstCache") } return id, nil }
go
func (l *TeamLoader) ResolveNameToIDUntrusted(ctx context.Context, teamName keybase1.TeamName, public bool, allowCache bool) (id keybase1.TeamID, err error) { defer l.G().CVTrace(ctx, libkb.VLog0, fmt.Sprintf("resolveNameToUIDUntrusted(%s,%v,%v)", teamName.String(), public, allowCache), func() error { return err })() // For root team names, just hash. if teamName.IsRootTeam() { return teamName.ToTeamID(public), nil } if !allowCache { return resolveNameToIDUntrustedAPICall(ctx, l.G(), teamName, public) } var idVoidPointer interface{} key := nameLookupBurstCacheKey{teamName, public} idVoidPointer, err = l.nameLookupBurstCache.Load(ctx, key, l.makeNameLookupBurstCacheLoader(ctx, l.G(), key)) if err != nil { return keybase1.TeamID(""), err } if idPointer, ok := idVoidPointer.(*keybase1.TeamID); ok && idPointer != nil { id = *idPointer } else { return keybase1.TeamID(""), errors.New("bad cast out of nameLookupBurstCache") } return id, nil }
[ "func", "(", "l", "*", "TeamLoader", ")", "ResolveNameToIDUntrusted", "(", "ctx", "context", ".", "Context", ",", "teamName", "keybase1", ".", "TeamName", ",", "public", "bool", ",", "allowCache", "bool", ")", "(", "id", "keybase1", ".", "TeamID", ",", "er...
// Resolve a team name to a team ID. // Will always hit the server for subteams. The server can lie in this return value.
[ "Resolve", "a", "team", "name", "to", "a", "team", "ID", ".", "Will", "always", "hit", "the", "server", "for", "subteams", ".", "The", "server", "can", "lie", "in", "this", "return", "value", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L158-L183
159,802
keybase/client
go/teams/loader.go
load2
func (l *TeamLoader) load2(ctx context.Context, arg load2ArgT) (ret *load2ResT, err error) { ctx = libkb.WithLogTag(ctx, "LT") // Load team if arg.reason != "" { ctx = libkb.WithLogTag(ctx, "LT2") // Load team recursive } traceLabel := fmt.Sprintf("TeamLoader#load2(%v, public:%v)", arg.teamID, arg.public) if len(arg.reason) > 0 { traceLabel = traceLabel + " '" + arg.reason + "'" } defer l.G().CTraceTimed(ctx, traceLabel, func() error { return err })() ret, err = l.load2Inner(ctx, arg) return ret, err }
go
func (l *TeamLoader) load2(ctx context.Context, arg load2ArgT) (ret *load2ResT, err error) { ctx = libkb.WithLogTag(ctx, "LT") // Load team if arg.reason != "" { ctx = libkb.WithLogTag(ctx, "LT2") // Load team recursive } traceLabel := fmt.Sprintf("TeamLoader#load2(%v, public:%v)", arg.teamID, arg.public) if len(arg.reason) > 0 { traceLabel = traceLabel + " '" + arg.reason + "'" } defer l.G().CTraceTimed(ctx, traceLabel, func() error { return err })() ret, err = l.load2Inner(ctx, arg) return ret, err }
[ "func", "(", "l", "*", "TeamLoader", ")", "load2", "(", "ctx", "context", ".", "Context", ",", "arg", "load2ArgT", ")", "(", "ret", "*", "load2ResT", ",", "err", "error", ")", "{", "ctx", "=", "libkb", ".", "WithLogTag", "(", "ctx", ",", "\"", "\""...
// Load2 does the rest of the work loading a team. // It is `playchain` described in the pseudocode in teamplayer.txt
[ "Load2", "does", "the", "rest", "of", "the", "work", "loading", "a", "team", ".", "It", "is", "playchain", "described", "in", "the", "pseudocode", "in", "teamplayer", ".", "txt" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L386-L399
159,803
keybase/client
go/teams/loader.go
userPreload
func (l *TeamLoader) userPreload(ctx context.Context, links []*ChainLinkUnpacked, fullVerifyCutoff keybase1.Seqno) (cancel func()) { ctx, cancel = context.WithCancel(ctx) if teamEnv.UserPreloadEnable { uidSet := make(map[keybase1.UID]struct{}) for _, link := range links { // fullVerify definition copied from verifyLink fullVerify := (link.LinkType() != libkb.SigchainV2TypeTeamLeave) || (link.Seqno() >= fullVerifyCutoff) || (link.source.EldestSeqno == 0) if !link.isStubbed() && fullVerify { uidSet[link.inner.Body.Key.UID] = struct{}{} } } l.G().Log.CDebugf(ctx, "TeamLoader userPreload uids: %v", len(uidSet)) if teamEnv.UserPreloadParallel { // Note this is full-parallel. Probably want pipelining if this is to be turned on by default. var wg sync.WaitGroup for uid := range uidSet { wg.Add(1) go func(uid keybase1.UID) { _, _, err := l.G().GetUPAKLoader().LoadV2( libkb.NewLoadUserArg(l.G()).WithUID(uid).WithPublicKeyOptional().WithNetContext(ctx)) if err != nil { l.G().Log.CDebugf(ctx, "error preloading uid %v", uid) } wg.Done() }(uid) } if teamEnv.UserPreloadWait { wg.Wait() } } else { for uid := range uidSet { _, _, err := l.G().GetUPAKLoader().LoadV2( libkb.NewLoadUserArg(l.G()).WithUID(uid).WithPublicKeyOptional().WithNetContext(ctx)) if err != nil { l.G().Log.CDebugf(ctx, "error preloading uid %v", uid) } } } } return cancel }
go
func (l *TeamLoader) userPreload(ctx context.Context, links []*ChainLinkUnpacked, fullVerifyCutoff keybase1.Seqno) (cancel func()) { ctx, cancel = context.WithCancel(ctx) if teamEnv.UserPreloadEnable { uidSet := make(map[keybase1.UID]struct{}) for _, link := range links { // fullVerify definition copied from verifyLink fullVerify := (link.LinkType() != libkb.SigchainV2TypeTeamLeave) || (link.Seqno() >= fullVerifyCutoff) || (link.source.EldestSeqno == 0) if !link.isStubbed() && fullVerify { uidSet[link.inner.Body.Key.UID] = struct{}{} } } l.G().Log.CDebugf(ctx, "TeamLoader userPreload uids: %v", len(uidSet)) if teamEnv.UserPreloadParallel { // Note this is full-parallel. Probably want pipelining if this is to be turned on by default. var wg sync.WaitGroup for uid := range uidSet { wg.Add(1) go func(uid keybase1.UID) { _, _, err := l.G().GetUPAKLoader().LoadV2( libkb.NewLoadUserArg(l.G()).WithUID(uid).WithPublicKeyOptional().WithNetContext(ctx)) if err != nil { l.G().Log.CDebugf(ctx, "error preloading uid %v", uid) } wg.Done() }(uid) } if teamEnv.UserPreloadWait { wg.Wait() } } else { for uid := range uidSet { _, _, err := l.G().GetUPAKLoader().LoadV2( libkb.NewLoadUserArg(l.G()).WithUID(uid).WithPublicKeyOptional().WithNetContext(ctx)) if err != nil { l.G().Log.CDebugf(ctx, "error preloading uid %v", uid) } } } } return cancel }
[ "func", "(", "l", "*", "TeamLoader", ")", "userPreload", "(", "ctx", "context", ".", "Context", ",", "links", "[", "]", "*", "ChainLinkUnpacked", ",", "fullVerifyCutoff", "keybase1", ".", "Seqno", ")", "(", "cancel", "func", "(", ")", ")", "{", "ctx", ...
// userPreload warms the upak cache with users who will probably need to be loaded to verify the chain. // Uses teamEnv and may be disabled.
[ "userPreload", "warms", "the", "upak", "cache", "with", "users", "who", "will", "probably", "need", "to", "be", "loaded", "to", "verify", "the", "chain", ".", "Uses", "teamEnv", "and", "may", "be", "disabled", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L820-L862
159,804
keybase/client
go/teams/loader.go
satisfiesNeedAdmin
func (l *TeamLoader) satisfiesNeedAdmin(ctx context.Context, me keybase1.UserVersion, teamData *keybase1.TeamData) bool { if teamData == nil { return false } if (TeamSigChainState{inner: teamData.Chain}.HasAnyStubbedLinks()) { return false } if !l.hasSyncedSecrets(teamData) { return false } state := TeamSigChainState{inner: teamData.Chain} role, err := state.GetUserRole(me) if err != nil { l.G().Log.CDebugf(ctx, "TeamLoader error getting my role: %v", err) return false } if !role.IsAdminOrAbove() { if !state.IsSubteam() { return false } yes, err := l.isImplicitAdminOf(ctx, state.GetID(), state.GetParentID(), me, me) if err != nil { l.G().Log.CDebugf(ctx, "TeamLoader error getting checking implicit admin: %s", err) return false } if !yes { return false } } return true }
go
func (l *TeamLoader) satisfiesNeedAdmin(ctx context.Context, me keybase1.UserVersion, teamData *keybase1.TeamData) bool { if teamData == nil { return false } if (TeamSigChainState{inner: teamData.Chain}.HasAnyStubbedLinks()) { return false } if !l.hasSyncedSecrets(teamData) { return false } state := TeamSigChainState{inner: teamData.Chain} role, err := state.GetUserRole(me) if err != nil { l.G().Log.CDebugf(ctx, "TeamLoader error getting my role: %v", err) return false } if !role.IsAdminOrAbove() { if !state.IsSubteam() { return false } yes, err := l.isImplicitAdminOf(ctx, state.GetID(), state.GetParentID(), me, me) if err != nil { l.G().Log.CDebugf(ctx, "TeamLoader error getting checking implicit admin: %s", err) return false } if !yes { return false } } return true }
[ "func", "(", "l", "*", "TeamLoader", ")", "satisfiesNeedAdmin", "(", "ctx", "context", ".", "Context", ",", "me", "keybase1", ".", "UserVersion", ",", "teamData", "*", "keybase1", ".", "TeamData", ")", "bool", "{", "if", "teamData", "==", "nil", "{", "re...
// Whether the user is an admin at the snapshot, and there are no stubbed links, and keys are up to date.
[ "Whether", "the", "user", "is", "an", "admin", "at", "the", "snapshot", "and", "there", "are", "no", "stubbed", "links", "and", "keys", "are", "up", "to", "date", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1027-L1057
159,805
keybase/client
go/teams/loader.go
isImplicitAdminOf
func (l *TeamLoader) isImplicitAdminOf(ctx context.Context, teamID keybase1.TeamID, ancestorID *keybase1.TeamID, me keybase1.UserVersion, uv keybase1.UserVersion) (bool, error) { // IDs of ancestors that were not freshly polled. // Check them again with forceRepoll if the affirmative is not found cached. checkAgain := make(map[keybase1.TeamID]bool) check1 := func(chain *TeamSigChainState) bool { role, err := chain.GetUserRole(uv) if err != nil { return false } return role.IsAdminOrAbove() } i := 0 for { i++ if i >= 100 { // Break in case there's a bug in this loop. return false, fmt.Errorf("stuck in a loop while checking for implicit admin: %v", ancestorID) } // Use load2 so that we can use subteam-reader and get secretless teams. ancestor, err := l.load2(ctx, load2ArgT{ teamID: *ancestorID, reason: "isImplicitAdminOf-1", me: me, readSubteamID: &teamID, }) if err != nil { return false, err } // Be wary, `ancestor` could be, and is likely, a secretless team. // Do not let it out of sight. ancestorChain := TeamSigChainState{inner: ancestor.team.Chain} if !ancestor.didRepoll { checkAgain[ancestorChain.GetID()] = true } if check1(&ancestorChain) { return true, nil } if !ancestorChain.IsSubteam() { break } // Get the next level up. ancestorID = ancestorChain.GetParentID() } // The answer was not found to be yes in the cache. // Try again with the teams that were not polled as they might have unseen updates. for ancestorID := range checkAgain { ancestor, err := l.load2(ctx, load2ArgT{ teamID: ancestorID, reason: "isImplicitAdminOf-again", me: me, forceRepoll: true, // Get the latest info. readSubteamID: &teamID, }) if err != nil { return false, err } // Be wary, `ancestor` could be, and is likely, a secretless team. // Do not let it out of sight. ancestorChain := TeamSigChainState{inner: ancestor.team.Chain} if check1(&ancestorChain) { return true, nil } } return false, nil }
go
func (l *TeamLoader) isImplicitAdminOf(ctx context.Context, teamID keybase1.TeamID, ancestorID *keybase1.TeamID, me keybase1.UserVersion, uv keybase1.UserVersion) (bool, error) { // IDs of ancestors that were not freshly polled. // Check them again with forceRepoll if the affirmative is not found cached. checkAgain := make(map[keybase1.TeamID]bool) check1 := func(chain *TeamSigChainState) bool { role, err := chain.GetUserRole(uv) if err != nil { return false } return role.IsAdminOrAbove() } i := 0 for { i++ if i >= 100 { // Break in case there's a bug in this loop. return false, fmt.Errorf("stuck in a loop while checking for implicit admin: %v", ancestorID) } // Use load2 so that we can use subteam-reader and get secretless teams. ancestor, err := l.load2(ctx, load2ArgT{ teamID: *ancestorID, reason: "isImplicitAdminOf-1", me: me, readSubteamID: &teamID, }) if err != nil { return false, err } // Be wary, `ancestor` could be, and is likely, a secretless team. // Do not let it out of sight. ancestorChain := TeamSigChainState{inner: ancestor.team.Chain} if !ancestor.didRepoll { checkAgain[ancestorChain.GetID()] = true } if check1(&ancestorChain) { return true, nil } if !ancestorChain.IsSubteam() { break } // Get the next level up. ancestorID = ancestorChain.GetParentID() } // The answer was not found to be yes in the cache. // Try again with the teams that were not polled as they might have unseen updates. for ancestorID := range checkAgain { ancestor, err := l.load2(ctx, load2ArgT{ teamID: ancestorID, reason: "isImplicitAdminOf-again", me: me, forceRepoll: true, // Get the latest info. readSubteamID: &teamID, }) if err != nil { return false, err } // Be wary, `ancestor` could be, and is likely, a secretless team. // Do not let it out of sight. ancestorChain := TeamSigChainState{inner: ancestor.team.Chain} if check1(&ancestorChain) { return true, nil } } return false, nil }
[ "func", "(", "l", "*", "TeamLoader", ")", "isImplicitAdminOf", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ",", "ancestorID", "*", "keybase1", ".", "TeamID", ",", "me", "keybase1", ".", "UserVersion", ",", "uv", "keybas...
// Check whether a user is an implicit admin of a team.
[ "Check", "whether", "a", "user", "is", "an", "implicit", "admin", "of", "a", "team", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1060-L1134
159,806
keybase/client
go/teams/loader.go
satisfiesNeedKeyGeneration
func (l *TeamLoader) satisfiesNeedKeyGeneration(ctx context.Context, needKeyGeneration keybase1.PerTeamKeyGeneration, state *keybase1.TeamData) error { if needKeyGeneration == 0 { return nil } if state == nil { return fmt.Errorf("nil team does not contain key generation: %v", needKeyGeneration) } key, err := TeamSigChainState{inner: state.Chain}.GetLatestPerTeamKey() if err != nil { return err } if needKeyGeneration > key.Gen { return fmt.Errorf("team key generation too low: %v < %v", key.Gen, needKeyGeneration) } _, ok := state.PerTeamKeySeedsUnverified[needKeyGeneration] if !ok { return fmt.Errorf("team key secret missing for generation: %v", needKeyGeneration) } return nil }
go
func (l *TeamLoader) satisfiesNeedKeyGeneration(ctx context.Context, needKeyGeneration keybase1.PerTeamKeyGeneration, state *keybase1.TeamData) error { if needKeyGeneration == 0 { return nil } if state == nil { return fmt.Errorf("nil team does not contain key generation: %v", needKeyGeneration) } key, err := TeamSigChainState{inner: state.Chain}.GetLatestPerTeamKey() if err != nil { return err } if needKeyGeneration > key.Gen { return fmt.Errorf("team key generation too low: %v < %v", key.Gen, needKeyGeneration) } _, ok := state.PerTeamKeySeedsUnverified[needKeyGeneration] if !ok { return fmt.Errorf("team key secret missing for generation: %v", needKeyGeneration) } return nil }
[ "func", "(", "l", "*", "TeamLoader", ")", "satisfiesNeedKeyGeneration", "(", "ctx", "context", ".", "Context", ",", "needKeyGeneration", "keybase1", ".", "PerTeamKeyGeneration", ",", "state", "*", "keybase1", ".", "TeamData", ")", "error", "{", "if", "needKeyGen...
// Whether the snapshot has loaded at least up to the key generation and has the secret.
[ "Whether", "the", "snapshot", "has", "loaded", "at", "least", "up", "to", "the", "key", "generation", "and", "has", "the", "secret", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1156-L1175
159,807
keybase/client
go/teams/loader.go
satisfiesNeedApplicationsAtGenerations
func (l *TeamLoader) satisfiesNeedApplicationsAtGenerations(ctx context.Context, needApplicationsAtGenerations map[keybase1.PerTeamKeyGeneration][]keybase1.TeamApplication, state *keybase1.TeamData) error { if len(needApplicationsAtGenerations) == 0 { return nil } if state == nil { return fmt.Errorf("nil team does not contain applications: %v", needApplicationsAtGenerations) } for ptkGen, apps := range needApplicationsAtGenerations { for _, app := range apps { if _, err := ApplicationKeyAtGeneration(libkb.NewMetaContext(ctx, l.G()), state, app, ptkGen); err != nil { return err } } } return nil }
go
func (l *TeamLoader) satisfiesNeedApplicationsAtGenerations(ctx context.Context, needApplicationsAtGenerations map[keybase1.PerTeamKeyGeneration][]keybase1.TeamApplication, state *keybase1.TeamData) error { if len(needApplicationsAtGenerations) == 0 { return nil } if state == nil { return fmt.Errorf("nil team does not contain applications: %v", needApplicationsAtGenerations) } for ptkGen, apps := range needApplicationsAtGenerations { for _, app := range apps { if _, err := ApplicationKeyAtGeneration(libkb.NewMetaContext(ctx, l.G()), state, app, ptkGen); err != nil { return err } } } return nil }
[ "func", "(", "l", "*", "TeamLoader", ")", "satisfiesNeedApplicationsAtGenerations", "(", "ctx", "context", ".", "Context", ",", "needApplicationsAtGenerations", "map", "[", "keybase1", ".", "PerTeamKeyGeneration", "]", "[", "]", "keybase1", ".", "TeamApplication", "...
// Whether the snapshot has loaded the reader key masks and key generations we // need.
[ "Whether", "the", "snapshot", "has", "loaded", "the", "reader", "key", "masks", "and", "key", "generations", "we", "need", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1179-L1195
159,808
keybase/client
go/teams/loader.go
satisfiesWantMembers
func (l *TeamLoader) satisfiesWantMembers(ctx context.Context, wantMembers []keybase1.UserVersion, wantMembersRole keybase1.TeamRole, state *keybase1.TeamData) error { if wantMembersRole == keybase1.TeamRole_NONE { // Default to writer. wantMembersRole = keybase1.TeamRole_WRITER } if len(wantMembers) == 0 { return nil } if state == nil { return fmt.Errorf("nil team does not have wanted members") } for _, uv := range wantMembers { role, err := TeamSigChainState{inner: state.Chain}.GetUserRole(uv) if err != nil { return fmt.Errorf("could not get wanted user role: %v", err) } if !role.IsOrAbove(wantMembersRole) { return fmt.Errorf("wanted user %v is a %v which is not at least %v", uv, role, wantMembersRole) } } return nil }
go
func (l *TeamLoader) satisfiesWantMembers(ctx context.Context, wantMembers []keybase1.UserVersion, wantMembersRole keybase1.TeamRole, state *keybase1.TeamData) error { if wantMembersRole == keybase1.TeamRole_NONE { // Default to writer. wantMembersRole = keybase1.TeamRole_WRITER } if len(wantMembers) == 0 { return nil } if state == nil { return fmt.Errorf("nil team does not have wanted members") } for _, uv := range wantMembers { role, err := TeamSigChainState{inner: state.Chain}.GetUserRole(uv) if err != nil { return fmt.Errorf("could not get wanted user role: %v", err) } if !role.IsOrAbove(wantMembersRole) { return fmt.Errorf("wanted user %v is a %v which is not at least %v", uv, role, wantMembersRole) } } return nil }
[ "func", "(", "l", "*", "TeamLoader", ")", "satisfiesWantMembers", "(", "ctx", "context", ".", "Context", ",", "wantMembers", "[", "]", "keybase1", ".", "UserVersion", ",", "wantMembersRole", "keybase1", ".", "TeamRole", ",", "state", "*", "keybase1", ".", "T...
// Whether the snapshot has each of `wantMembers` as a member.
[ "Whether", "the", "snapshot", "has", "each", "of", "wantMembers", "as", "a", "member", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1218-L1241
159,809
keybase/client
go/teams/loader.go
seqnosContains
func (l *TeamLoader) seqnosContains(xs []keybase1.Seqno, y keybase1.Seqno) bool { for _, x := range xs { if x.Eq(y) { return true } } return false }
go
func (l *TeamLoader) seqnosContains(xs []keybase1.Seqno, y keybase1.Seqno) bool { for _, x := range xs { if x.Eq(y) { return true } } return false }
[ "func", "(", "l", "*", "TeamLoader", ")", "seqnosContains", "(", "xs", "[", "]", "keybase1", ".", "Seqno", ",", "y", "keybase1", ".", "Seqno", ")", "bool", "{", "for", "_", ",", "x", ":=", "range", "xs", "{", "if", "x", ".", "Eq", "(", "y", ")"...
// Whether y is in xs.
[ "Whether", "y", "is", "in", "xs", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1261-L1268
159,810
keybase/client
go/teams/loader.go
seqnosMax
func (l *TeamLoader) seqnosMax(seqnos []keybase1.Seqno) (ret keybase1.Seqno) { for _, x := range seqnos { if x > ret { ret = x } } return ret }
go
func (l *TeamLoader) seqnosMax(seqnos []keybase1.Seqno) (ret keybase1.Seqno) { for _, x := range seqnos { if x > ret { ret = x } } return ret }
[ "func", "(", "l", "*", "TeamLoader", ")", "seqnosMax", "(", "seqnos", "[", "]", "keybase1", ".", "Seqno", ")", "(", "ret", "keybase1", ".", "Seqno", ")", "{", "for", "_", ",", "x", ":=", "range", "seqnos", "{", "if", "x", ">", "ret", "{", "ret", ...
// Return the max in a list of positive seqnos. Returns 0 if the list is empty
[ "Return", "the", "max", "in", "a", "list", "of", "positive", "seqnos", ".", "Returns", "0", "if", "the", "list", "is", "empty" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1271-L1278
159,811
keybase/client
go/teams/loader.go
isFresh
func (l *TeamLoader) isFresh(ctx context.Context, cachedAt keybase1.Time) bool { if cachedAt.IsZero() { // This should never happen. l.G().Log.CWarningf(ctx, "TeamLoader encountered zero cached time") return false } diff := l.G().Clock().Now().Sub(cachedAt.Time()) fresh := (diff <= freshnessLimit) if !fresh { l.G().Log.CDebugf(ctx, "TeamLoader cached snapshot is old: %v", diff) } return fresh }
go
func (l *TeamLoader) isFresh(ctx context.Context, cachedAt keybase1.Time) bool { if cachedAt.IsZero() { // This should never happen. l.G().Log.CWarningf(ctx, "TeamLoader encountered zero cached time") return false } diff := l.G().Clock().Now().Sub(cachedAt.Time()) fresh := (diff <= freshnessLimit) if !fresh { l.G().Log.CDebugf(ctx, "TeamLoader cached snapshot is old: %v", diff) } return fresh }
[ "func", "(", "l", "*", "TeamLoader", ")", "isFresh", "(", "ctx", "context", ".", "Context", ",", "cachedAt", "keybase1", ".", "Time", ")", "bool", "{", "if", "cachedAt", ".", "IsZero", "(", ")", "{", "// This should never happen.", "l", ".", "G", "(", ...
// Whether a TeamData from the cache is fresh.
[ "Whether", "a", "TeamData", "from", "the", "cache", "is", "fresh", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1281-L1293
159,812
keybase/client
go/teams/loader.go
hasSyncedSecrets
func (l *TeamLoader) hasSyncedSecrets(state *keybase1.TeamData) bool { onChainGen := keybase1.PerTeamKeyGeneration(len(state.Chain.PerTeamKeys)) offChainGen := keybase1.PerTeamKeyGeneration(len(state.PerTeamKeySeedsUnverified)) return onChainGen == offChainGen }
go
func (l *TeamLoader) hasSyncedSecrets(state *keybase1.TeamData) bool { onChainGen := keybase1.PerTeamKeyGeneration(len(state.Chain.PerTeamKeys)) offChainGen := keybase1.PerTeamKeyGeneration(len(state.PerTeamKeySeedsUnverified)) return onChainGen == offChainGen }
[ "func", "(", "l", "*", "TeamLoader", ")", "hasSyncedSecrets", "(", "state", "*", "keybase1", ".", "TeamData", ")", "bool", "{", "onChainGen", ":=", "keybase1", ".", "PerTeamKeyGeneration", "(", "len", "(", "state", ".", "Chain", ".", "PerTeamKeys", ")", ")...
// Whether the teams secrets are synced to the same point as its sigchain // Does not check RKMs.
[ "Whether", "the", "teams", "secrets", "are", "synced", "to", "the", "same", "point", "as", "its", "sigchain", "Does", "not", "check", "RKMs", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1297-L1301
159,813
keybase/client
go/teams/loader.go
ImplicitAdmins
func (l *TeamLoader) ImplicitAdmins(ctx context.Context, teamID keybase1.TeamID) (impAdmins []keybase1.UserVersion, err error) { impAdminsMap := make(map[string]keybase1.UserVersion) // map to remove dups err = l.MapTeamAncestors(ctx, func(t keybase1.TeamSigChainState) error { ancestorChain := TeamSigChainState{inner: t} // Gather the admins. adminRoles := []keybase1.TeamRole{keybase1.TeamRole_OWNER, keybase1.TeamRole_ADMIN} for _, role := range adminRoles { uvs, err := ancestorChain.GetUsersWithRole(role) if err != nil { return err } for _, uv := range uvs { impAdminsMap[uv.String()] = uv } } return nil }, teamID, "implicitAdminsAncestor", func(keybase1.TeamSigChainState) bool { return true }) if err != nil { return nil, err } for _, uv := range impAdminsMap { impAdmins = append(impAdmins, uv) } return impAdmins, nil }
go
func (l *TeamLoader) ImplicitAdmins(ctx context.Context, teamID keybase1.TeamID) (impAdmins []keybase1.UserVersion, err error) { impAdminsMap := make(map[string]keybase1.UserVersion) // map to remove dups err = l.MapTeamAncestors(ctx, func(t keybase1.TeamSigChainState) error { ancestorChain := TeamSigChainState{inner: t} // Gather the admins. adminRoles := []keybase1.TeamRole{keybase1.TeamRole_OWNER, keybase1.TeamRole_ADMIN} for _, role := range adminRoles { uvs, err := ancestorChain.GetUsersWithRole(role) if err != nil { return err } for _, uv := range uvs { impAdminsMap[uv.String()] = uv } } return nil }, teamID, "implicitAdminsAncestor", func(keybase1.TeamSigChainState) bool { return true }) if err != nil { return nil, err } for _, uv := range impAdminsMap { impAdmins = append(impAdmins, uv) } return impAdmins, nil }
[ "func", "(", "l", "*", "TeamLoader", ")", "ImplicitAdmins", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ")", "(", "impAdmins", "[", "]", "keybase1", ".", "UserVersion", ",", "err", "error", ")", "{", "impAdminsMap", "...
// List all the admins of ancestor teams. // Includes admins of the specified team only if they are also admins of ancestor teams. // The specified team must be a subteam, or an error is returned. // Always sends a flurry of RPCs to get the most up to date info.
[ "List", "all", "the", "admins", "of", "ancestor", "teams", ".", "Includes", "admins", "of", "the", "specified", "team", "only", "if", "they", "are", "also", "admins", "of", "ancestor", "teams", ".", "The", "specified", "team", "must", "be", "a", "subteam",...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1368-L1392
159,814
keybase/client
go/teams/loader.go
MapTeamAncestors
func (l *TeamLoader) MapTeamAncestors(ctx context.Context, f func(t keybase1.TeamSigChainState) error, teamID keybase1.TeamID, reason string, forceFullReloadOnceToAssert func(t keybase1.TeamSigChainState) bool) (err error) { me, err := l.world.getMe(ctx) if err != nil { return err } // Load the argument team team, err := l.load1(ctx, me, keybase1.LoadTeamArg{ ID: teamID, Public: teamID.IsPublic(), StaleOK: true, // We only use immutable fields. }) if err != nil { return err } teamChain := TeamSigChainState{inner: team.Chain} if !teamChain.IsSubteam() { return fmt.Errorf("cannot map over parents of a root team: %v", teamID) } return l.mapTeamAncestorsHelper(ctx, f, teamID, teamChain.GetParentID(), reason, forceFullReloadOnceToAssert) }
go
func (l *TeamLoader) MapTeamAncestors(ctx context.Context, f func(t keybase1.TeamSigChainState) error, teamID keybase1.TeamID, reason string, forceFullReloadOnceToAssert func(t keybase1.TeamSigChainState) bool) (err error) { me, err := l.world.getMe(ctx) if err != nil { return err } // Load the argument team team, err := l.load1(ctx, me, keybase1.LoadTeamArg{ ID: teamID, Public: teamID.IsPublic(), StaleOK: true, // We only use immutable fields. }) if err != nil { return err } teamChain := TeamSigChainState{inner: team.Chain} if !teamChain.IsSubteam() { return fmt.Errorf("cannot map over parents of a root team: %v", teamID) } return l.mapTeamAncestorsHelper(ctx, f, teamID, teamChain.GetParentID(), reason, forceFullReloadOnceToAssert) }
[ "func", "(", "l", "*", "TeamLoader", ")", "MapTeamAncestors", "(", "ctx", "context", ".", "Context", ",", "f", "func", "(", "t", "keybase1", ".", "TeamSigChainState", ")", "error", ",", "teamID", "keybase1", ".", "TeamID", ",", "reason", "string", ",", "...
// MapTeamAncestors does NOT map over the team itself.
[ "MapTeamAncestors", "does", "NOT", "map", "over", "the", "team", "itself", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader.go#L1395-L1415
159,815
keybase/client
go/service/ctl.go
Stop
func (c *CtlHandler) Stop(ctx context.Context, args keybase1.StopArg) error { c.G().Log.Info("Ctl: Stop: StopAllButService") install.StopAllButService(libkb.NewMetaContext(ctx, c.G()), args.ExitCode) c.G().Log.Info("Ctl: Stop: Stopping service") c.service.Stop(args.ExitCode) return nil }
go
func (c *CtlHandler) Stop(ctx context.Context, args keybase1.StopArg) error { c.G().Log.Info("Ctl: Stop: StopAllButService") install.StopAllButService(libkb.NewMetaContext(ctx, c.G()), args.ExitCode) c.G().Log.Info("Ctl: Stop: Stopping service") c.service.Stop(args.ExitCode) return nil }
[ "func", "(", "c", "*", "CtlHandler", ")", "Stop", "(", "ctx", "context", ".", "Context", ",", "args", "keybase1", ".", "StopArg", ")", "error", "{", "c", ".", "G", "(", ")", ".", "Log", ".", "Info", "(", "\"", "\"", ")", "\n", "install", ".", "...
// Stop is called on the rpc keybase.1.ctl.stop, which shuts down the service.
[ "Stop", "is", "called", "on", "the", "rpc", "keybase", ".", "1", ".", "ctl", ".", "stop", "which", "shuts", "down", "the", "service", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/ctl.go#L30-L36
159,816
keybase/client
go/kbfs/libkbfs/md_util.go
isReadableOrError
func isReadableOrError( ctx context.Context, kbpki KBPKI, syncGetter syncedTlfGetterSetter, md ReadOnlyRootMetadata) error { if !md.IsInitialized() || md.IsReadable() { return nil } // this should only be the case if we're a new device not yet // added to the set of reader/writer keys. session, err := kbpki.GetCurrentSession(ctx) if err != nil { return err } err = errors.Errorf("%s is not readable by %s (uid:%s)", md.TlfID(), session.Name, session.UID) return makeRekeyReadError( ctx, err, kbpki, syncGetter, md, session.UID, session.Name) }
go
func isReadableOrError( ctx context.Context, kbpki KBPKI, syncGetter syncedTlfGetterSetter, md ReadOnlyRootMetadata) error { if !md.IsInitialized() || md.IsReadable() { return nil } // this should only be the case if we're a new device not yet // added to the set of reader/writer keys. session, err := kbpki.GetCurrentSession(ctx) if err != nil { return err } err = errors.Errorf("%s is not readable by %s (uid:%s)", md.TlfID(), session.Name, session.UID) return makeRekeyReadError( ctx, err, kbpki, syncGetter, md, session.UID, session.Name) }
[ "func", "isReadableOrError", "(", "ctx", "context", ".", "Context", ",", "kbpki", "KBPKI", ",", "syncGetter", "syncedTlfGetterSetter", ",", "md", "ReadOnlyRootMetadata", ")", "error", "{", "if", "!", "md", ".", "IsInitialized", "(", ")", "||", "md", ".", "Is...
// Helper which returns nil if the md block is uninitialized or readable by // the current user. Otherwise an appropriate read access error is returned.
[ "Helper", "which", "returns", "nil", "if", "the", "md", "block", "is", "uninitialized", "or", "readable", "by", "the", "current", "user", ".", "Otherwise", "an", "appropriate", "read", "access", "error", "is", "returned", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_util.go#L70-L86
159,817
keybase/client
go/kbfs/libkbfs/md_util.go
getSingleMD
func getSingleMD(ctx context.Context, config Config, id tlf.ID, bid kbfsmd.BranchID, rev kbfsmd.Revision, mStatus kbfsmd.MergeStatus, lockBeforeGet *keybase1.LockID) ( ImmutableRootMetadata, error) { rmds, err := getMDRange( ctx, config, id, bid, rev, rev, mStatus, lockBeforeGet) if err != nil { return ImmutableRootMetadata{}, err } if len(rmds) != 1 { return ImmutableRootMetadata{}, fmt.Errorf("Single expected revision %d not found", rev) } return rmds[0], nil }
go
func getSingleMD(ctx context.Context, config Config, id tlf.ID, bid kbfsmd.BranchID, rev kbfsmd.Revision, mStatus kbfsmd.MergeStatus, lockBeforeGet *keybase1.LockID) ( ImmutableRootMetadata, error) { rmds, err := getMDRange( ctx, config, id, bid, rev, rev, mStatus, lockBeforeGet) if err != nil { return ImmutableRootMetadata{}, err } if len(rmds) != 1 { return ImmutableRootMetadata{}, fmt.Errorf("Single expected revision %d not found", rev) } return rmds[0], nil }
[ "func", "getSingleMD", "(", "ctx", "context", ".", "Context", ",", "config", "Config", ",", "id", "tlf", ".", "ID", ",", "bid", "kbfsmd", ".", "BranchID", ",", "rev", "kbfsmd", ".", "Revision", ",", "mStatus", "kbfsmd", ".", "MergeStatus", ",", "lockBefo...
// getSingleMD returns an MD that is required to exist.
[ "getSingleMD", "returns", "an", "MD", "that", "is", "required", "to", "exist", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_util.go#L177-L191
159,818
keybase/client
go/kbfs/libkbfs/md_util.go
MakeCopyWithDecryptedPrivateData
func MakeCopyWithDecryptedPrivateData( ctx context.Context, config Config, irmdToDecrypt, irmdWithKeys ImmutableRootMetadata, uid keybase1.UID) ( rmdDecrypted ImmutableRootMetadata, err error) { pmd, err := decryptMDPrivateData( ctx, config.Codec(), config.Crypto(), config.BlockCache(), config.BlockOps(), config.KeyManager(), config.KBPKI(), config, config.Mode(), uid, irmdToDecrypt.GetSerializedPrivateMetadata(), irmdToDecrypt, irmdWithKeys, config.MakeLogger("")) if err != nil { return ImmutableRootMetadata{}, err } rmdCopy, err := irmdToDecrypt.deepCopy(config.Codec()) if err != nil { return ImmutableRootMetadata{}, err } rmdCopy.data = pmd return MakeImmutableRootMetadata(rmdCopy, irmdToDecrypt.LastModifyingWriterVerifyingKey(), irmdToDecrypt.MdID(), irmdToDecrypt.LocalTimestamp(), irmdToDecrypt.putToServer), nil }
go
func MakeCopyWithDecryptedPrivateData( ctx context.Context, config Config, irmdToDecrypt, irmdWithKeys ImmutableRootMetadata, uid keybase1.UID) ( rmdDecrypted ImmutableRootMetadata, err error) { pmd, err := decryptMDPrivateData( ctx, config.Codec(), config.Crypto(), config.BlockCache(), config.BlockOps(), config.KeyManager(), config.KBPKI(), config, config.Mode(), uid, irmdToDecrypt.GetSerializedPrivateMetadata(), irmdToDecrypt, irmdWithKeys, config.MakeLogger("")) if err != nil { return ImmutableRootMetadata{}, err } rmdCopy, err := irmdToDecrypt.deepCopy(config.Codec()) if err != nil { return ImmutableRootMetadata{}, err } rmdCopy.data = pmd return MakeImmutableRootMetadata(rmdCopy, irmdToDecrypt.LastModifyingWriterVerifyingKey(), irmdToDecrypt.MdID(), irmdToDecrypt.LocalTimestamp(), irmdToDecrypt.putToServer), nil }
[ "func", "MakeCopyWithDecryptedPrivateData", "(", "ctx", "context", ".", "Context", ",", "config", "Config", ",", "irmdToDecrypt", ",", "irmdWithKeys", "ImmutableRootMetadata", ",", "uid", "keybase1", ".", "UID", ")", "(", "rmdDecrypted", "ImmutableRootMetadata", ",", ...
// MakeCopyWithDecryptedPrivateData makes a copy of the given IRMD, // decrypting it with the given IRMD with keys.
[ "MakeCopyWithDecryptedPrivateData", "makes", "a", "copy", "of", "the", "given", "IRMD", "decrypting", "it", "with", "the", "given", "IRMD", "with", "keys", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_util.go#L195-L219
159,819
keybase/client
go/kbfs/libkbfs/md_util.go
GetMDRevisionByTime
func GetMDRevisionByTime( ctx context.Context, config Config, handle *tlfhandle.Handle, serverTime time.Time) (kbfsmd.Revision, error) { id := handle.TlfID() if id == tlf.NullID { return kbfsmd.RevisionUninitialized, errors.Errorf( "No ID set in handle %s", handle.GetCanonicalPath()) } md, err := config.MDOps().GetForTLFByTime(ctx, id, serverTime) if err != nil { return kbfsmd.RevisionUninitialized, err } return md.Revision(), nil }
go
func GetMDRevisionByTime( ctx context.Context, config Config, handle *tlfhandle.Handle, serverTime time.Time) (kbfsmd.Revision, error) { id := handle.TlfID() if id == tlf.NullID { return kbfsmd.RevisionUninitialized, errors.Errorf( "No ID set in handle %s", handle.GetCanonicalPath()) } md, err := config.MDOps().GetForTLFByTime(ctx, id, serverTime) if err != nil { return kbfsmd.RevisionUninitialized, err } return md.Revision(), nil }
[ "func", "GetMDRevisionByTime", "(", "ctx", "context", ".", "Context", ",", "config", "Config", ",", "handle", "*", "tlfhandle", ".", "Handle", ",", "serverTime", "time", ".", "Time", ")", "(", "kbfsmd", ".", "Revision", ",", "error", ")", "{", "id", ":="...
// GetMDRevisionByTime returns the revision number of the earliest // merged MD of `handle` with a server timestamp greater or equal to // `serverTime`.
[ "GetMDRevisionByTime", "returns", "the", "revision", "number", "of", "the", "earliest", "merged", "MD", "of", "handle", "with", "a", "server", "timestamp", "greater", "or", "equal", "to", "serverTime", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_util.go#L396-L411
159,820
keybase/client
go/kbfs/libkbfs/md_util.go
decryptMDPrivateData
func decryptMDPrivateData(ctx context.Context, codec kbfscodec.Codec, crypto Crypto, bcache data.BlockCache, bops BlockOps, keyGetter mdDecryptionKeyGetter, teamChecker kbfsmd.TeamMembershipChecker, osg idutil.OfflineStatusGetter, mode InitMode, uid keybase1.UID, serializedPrivateMetadata []byte, rmdToDecrypt, rmdWithKeys libkey.KeyMetadata, log logger.Logger) (PrivateMetadata, error) { handle := rmdToDecrypt.GetTlfHandle() var pmd PrivateMetadata if handle.TypeForKeying() == tlf.PublicKeying { if err := codec.Decode(serializedPrivateMetadata, &pmd); err != nil { return PrivateMetadata{}, err } } else { // decrypt the root data for non-public directories var encryptedPrivateMetadata kbfscrypto.EncryptedPrivateMetadata if err := codec.Decode(serializedPrivateMetadata, &encryptedPrivateMetadata); err != nil { return PrivateMetadata{}, err } k, err := keyGetter.GetTLFCryptKeyForMDDecryption(ctx, rmdToDecrypt, rmdWithKeys) if err != nil { log.CDebugf(ctx, "Couldn't get crypt key for %s (%s): %+v", handle.GetCanonicalPath(), rmdToDecrypt.TlfID(), err) isReader, readerErr := isReaderFromHandle( ctx, handle, teamChecker, osg, uid) if readerErr != nil { return PrivateMetadata{}, readerErr } _, isSelfRekeyError := err.(NeedSelfRekeyError) _, isOtherRekeyError := err.(NeedOtherRekeyError) if isReader && (isOtherRekeyError || isSelfRekeyError) { // Rekey errors are expected if this client is a // valid folder participant but doesn't have the // shared crypt key. } else { return PrivateMetadata{}, err } } else { pmd, err = crypto.DecryptPrivateMetadata( encryptedPrivateMetadata, k) if err != nil { return PrivateMetadata{}, err } } } // Re-embed the block changes if it's needed. err := reembedBlockChanges( ctx, codec, bcache, bops, mode, rmdWithKeys.TlfID(), &pmd, rmdWithKeys, log) if err != nil { return PrivateMetadata{}, err } return pmd, nil }
go
func decryptMDPrivateData(ctx context.Context, codec kbfscodec.Codec, crypto Crypto, bcache data.BlockCache, bops BlockOps, keyGetter mdDecryptionKeyGetter, teamChecker kbfsmd.TeamMembershipChecker, osg idutil.OfflineStatusGetter, mode InitMode, uid keybase1.UID, serializedPrivateMetadata []byte, rmdToDecrypt, rmdWithKeys libkey.KeyMetadata, log logger.Logger) (PrivateMetadata, error) { handle := rmdToDecrypt.GetTlfHandle() var pmd PrivateMetadata if handle.TypeForKeying() == tlf.PublicKeying { if err := codec.Decode(serializedPrivateMetadata, &pmd); err != nil { return PrivateMetadata{}, err } } else { // decrypt the root data for non-public directories var encryptedPrivateMetadata kbfscrypto.EncryptedPrivateMetadata if err := codec.Decode(serializedPrivateMetadata, &encryptedPrivateMetadata); err != nil { return PrivateMetadata{}, err } k, err := keyGetter.GetTLFCryptKeyForMDDecryption(ctx, rmdToDecrypt, rmdWithKeys) if err != nil { log.CDebugf(ctx, "Couldn't get crypt key for %s (%s): %+v", handle.GetCanonicalPath(), rmdToDecrypt.TlfID(), err) isReader, readerErr := isReaderFromHandle( ctx, handle, teamChecker, osg, uid) if readerErr != nil { return PrivateMetadata{}, readerErr } _, isSelfRekeyError := err.(NeedSelfRekeyError) _, isOtherRekeyError := err.(NeedOtherRekeyError) if isReader && (isOtherRekeyError || isSelfRekeyError) { // Rekey errors are expected if this client is a // valid folder participant but doesn't have the // shared crypt key. } else { return PrivateMetadata{}, err } } else { pmd, err = crypto.DecryptPrivateMetadata( encryptedPrivateMetadata, k) if err != nil { return PrivateMetadata{}, err } } } // Re-embed the block changes if it's needed. err := reembedBlockChanges( ctx, codec, bcache, bops, mode, rmdWithKeys.TlfID(), &pmd, rmdWithKeys, log) if err != nil { return PrivateMetadata{}, err } return pmd, nil }
[ "func", "decryptMDPrivateData", "(", "ctx", "context", ".", "Context", ",", "codec", "kbfscodec", ".", "Codec", ",", "crypto", "Crypto", ",", "bcache", "data", ".", "BlockCache", ",", "bops", "BlockOps", ",", "keyGetter", "mdDecryptionKeyGetter", ",", "teamCheck...
// decryptMDPrivateData does not use uid if the handle is a public one.
[ "decryptMDPrivateData", "does", "not", "use", "uid", "if", "the", "handle", "is", "a", "public", "one", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_util.go#L609-L669
159,821
keybase/client
go/client/cmd_simplefs.go
NewCmdSimpleFS
func NewCmdSimpleFS(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { return cli.Command{ Name: "fs", Usage: "Perform filesystem operations", ArgumentHelp: "[arguments...]", Subcommands: append([]cli.Command{ NewCmdSimpleFSList(cl, g), NewCmdSimpleFSCopy(cl, g), NewCmdSimpleFSMove(cl, g), NewCmdSimpleFSSymlink(cl, g), NewCmdSimpleFSRead(cl, g), NewCmdSimpleFSRemove(cl, g), NewCmdSimpleFSMkdir(cl, g), NewCmdSimpleFSStat(cl, g), NewCmdSimpleFSGetStatus(cl, g), NewCmdSimpleFSKill(cl, g), NewCmdSimpleFSPs(cl, g), NewCmdSimpleFSWrite(cl, g), NewCmdSimpleFSDebug(cl, g), NewCmdSimpleFSSetDebugLevel(cl, g), NewCmdSimpleFSHistory(cl, g), NewCmdSimpleFSQuota(cl, g), NewCmdSimpleFSRecover(cl, g), NewCmdSimpleFSReset(cl, g), NewCmdSimpleFSClearConflicts(cl, g), NewCmdSimpleFSSync(cl, g), }, getBuildSpecificFSCommands(cl, g)...), } }
go
func NewCmdSimpleFS(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { return cli.Command{ Name: "fs", Usage: "Perform filesystem operations", ArgumentHelp: "[arguments...]", Subcommands: append([]cli.Command{ NewCmdSimpleFSList(cl, g), NewCmdSimpleFSCopy(cl, g), NewCmdSimpleFSMove(cl, g), NewCmdSimpleFSSymlink(cl, g), NewCmdSimpleFSRead(cl, g), NewCmdSimpleFSRemove(cl, g), NewCmdSimpleFSMkdir(cl, g), NewCmdSimpleFSStat(cl, g), NewCmdSimpleFSGetStatus(cl, g), NewCmdSimpleFSKill(cl, g), NewCmdSimpleFSPs(cl, g), NewCmdSimpleFSWrite(cl, g), NewCmdSimpleFSDebug(cl, g), NewCmdSimpleFSSetDebugLevel(cl, g), NewCmdSimpleFSHistory(cl, g), NewCmdSimpleFSQuota(cl, g), NewCmdSimpleFSRecover(cl, g), NewCmdSimpleFSReset(cl, g), NewCmdSimpleFSClearConflicts(cl, g), NewCmdSimpleFSSync(cl, g), }, getBuildSpecificFSCommands(cl, g)...), } }
[ "func", "NewCmdSimpleFS", "(", "cl", "*", "libcmdline", ".", "CommandLine", ",", "g", "*", "libkb", ".", "GlobalContext", ")", "cli", ".", "Command", "{", "return", "cli", ".", "Command", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", "...
// NewCmdSimpleFS creates the device command, which is just a holder // for subcommands.
[ "NewCmdSimpleFS", "creates", "the", "device", "command", "which", "is", "just", "a", "holder", "for", "subcommands", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_simplefs.go#L27-L55
159,822
keybase/client
go/client/cmd_simplefs.go
checkPathIsDir
func checkPathIsDir(ctx context.Context, cli keybase1.SimpleFSInterface, path keybase1.Path) (bool, string, error) { var isDir bool var pathString string var err error pathType, _ := path.PathType() switch pathType { case keybase1.PathType_KBFS, keybase1.PathType_KBFS_ARCHIVED: if pathType == keybase1.PathType_KBFS { pathString = path.Kbfs() } else { pathString = path.KbfsArchived().Path } // See if the dest is a path or file destEnt, err := cli.SimpleFSStat(ctx, keybase1.SimpleFSStatArg{Path: path}) if err != nil { return false, "", err } if destEnt.DirentType == keybase1.DirentType_DIR { isDir = true } case keybase1.PathType_LOCAL: pathString = path.Local() // An error is OK, could be a target filename // that does not exist yet fileInfo, err := os.Stat(pathString) if err == nil { if fileInfo.IsDir() { isDir = true } } } return isDir, pathString, err }
go
func checkPathIsDir(ctx context.Context, cli keybase1.SimpleFSInterface, path keybase1.Path) (bool, string, error) { var isDir bool var pathString string var err error pathType, _ := path.PathType() switch pathType { case keybase1.PathType_KBFS, keybase1.PathType_KBFS_ARCHIVED: if pathType == keybase1.PathType_KBFS { pathString = path.Kbfs() } else { pathString = path.KbfsArchived().Path } // See if the dest is a path or file destEnt, err := cli.SimpleFSStat(ctx, keybase1.SimpleFSStatArg{Path: path}) if err != nil { return false, "", err } if destEnt.DirentType == keybase1.DirentType_DIR { isDir = true } case keybase1.PathType_LOCAL: pathString = path.Local() // An error is OK, could be a target filename // that does not exist yet fileInfo, err := os.Stat(pathString) if err == nil { if fileInfo.IsDir() { isDir = true } } } return isDir, pathString, err }
[ "func", "checkPathIsDir", "(", "ctx", "context", ".", "Context", ",", "cli", "keybase1", ".", "SimpleFSInterface", ",", "path", "keybase1", ".", "Path", ")", "(", "bool", ",", "string", ",", "error", ")", "{", "var", "isDir", "bool", "\n", "var", "pathSt...
// Check whether the given path is a directory and return its string
[ "Check", "whether", "the", "given", "path", "is", "a", "directory", "and", "return", "its", "string" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_simplefs.go#L160-L194
159,823
keybase/client
go/client/cmd_simplefs.go
makeDestPath
func makeDestPath( ctx context.Context, g *libkb.GlobalContext, cli keybase1.SimpleFSInterface, src keybase1.Path, dest keybase1.Path, isDestPath bool, destPathString string) (keybase1.Path, error) { isSrcDir, srcPathString, err := checkPathIsDir(ctx, cli, src) // TODO: this error should really be checked, but when I added // code to check it, tests broke and it wasn't clear how to fix. g.Log.Debug("makeDestPath: srcPathString: %s isSrcDir: %v", src, isSrcDir) if isDestPath { // Source file and dest dir is an append case appendDest := !isSrcDir if isSrcDir { // Here, we have both source and dest as paths, so // we have to check whether dest exists. If so, append. err2 := checkElementExists(ctx, cli, dest) if err2 == ErrTargetFileExists { appendDest = true } g.Log.Debug("makeDestPath: src and dest both dir. append: %v", appendDest) } if appendDest { destType, _ := dest.PathType() // In this case, we must append the destination filename dest = joinSimpleFSPaths(destType, destPathString, srcPathString) g.Log.Debug("makeDestPath: new path with file: %s", dest) } } err = checkElementExists(ctx, cli, dest) return dest, err }
go
func makeDestPath( ctx context.Context, g *libkb.GlobalContext, cli keybase1.SimpleFSInterface, src keybase1.Path, dest keybase1.Path, isDestPath bool, destPathString string) (keybase1.Path, error) { isSrcDir, srcPathString, err := checkPathIsDir(ctx, cli, src) // TODO: this error should really be checked, but when I added // code to check it, tests broke and it wasn't clear how to fix. g.Log.Debug("makeDestPath: srcPathString: %s isSrcDir: %v", src, isSrcDir) if isDestPath { // Source file and dest dir is an append case appendDest := !isSrcDir if isSrcDir { // Here, we have both source and dest as paths, so // we have to check whether dest exists. If so, append. err2 := checkElementExists(ctx, cli, dest) if err2 == ErrTargetFileExists { appendDest = true } g.Log.Debug("makeDestPath: src and dest both dir. append: %v", appendDest) } if appendDest { destType, _ := dest.PathType() // In this case, we must append the destination filename dest = joinSimpleFSPaths(destType, destPathString, srcPathString) g.Log.Debug("makeDestPath: new path with file: %s", dest) } } err = checkElementExists(ctx, cli, dest) return dest, err }
[ "func", "makeDestPath", "(", "ctx", "context", ".", "Context", ",", "g", "*", "libkb", ".", "GlobalContext", ",", "cli", "keybase1", ".", "SimpleFSInterface", ",", "src", "keybase1", ".", "Path", ",", "dest", "keybase1", ".", "Path", ",", "isDestPath", "bo...
// Make sure the destination ends with the same filename as the source, // if any, unless the destination is not a directory
[ "Make", "sure", "the", "destination", "ends", "with", "the", "same", "filename", "as", "the", "source", "if", "any", "unless", "the", "destination", "is", "not", "a", "directory" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_simplefs.go#L226-L264
159,824
keybase/client
go/client/cmd_simplefs.go
parseSrcDestArgs
func parseSrcDestArgs(g *libkb.GlobalContext, ctx *cli.Context, name string) ([]keybase1.Path, keybase1.Path, error) { nargs := len(ctx.Args()) var srcType, destType keybase1.PathType var srcPaths []keybase1.Path var destPath keybase1.Path if nargs < 2 { return srcPaths, destPath, errors.New(name + " requires one or more source arguments and a destination argument") } for i, src := range ctx.Args() { rev := int64(0) timeString := "" relTimeString := "" if i != nargs-1 { // All source paths use the same revision. rev = int64(ctx.Int("rev")) timeString = ctx.String("time") relTimeString = getRelTime(ctx) } argPath, err := makeSimpleFSPathWithArchiveParams( src, rev, timeString, relTimeString) if err != nil { return nil, keybase1.Path{}, err } tempPathType, err := argPath.PathType() if err != nil { return srcPaths, destPath, err } // Make sure all source paths are the same type if i == 0 { srcType = tempPathType } else if i == nargs-1 { destPath = argPath destType = tempPathType break } else if tempPathType != srcType { return srcPaths, destPath, errors.New(name + " requires all sources to be the same type") } srcPaths = append(srcPaths, argPath) } if srcType == keybase1.PathType_LOCAL && destType == keybase1.PathType_LOCAL { return srcPaths, destPath, errors.New(name + " requires KBFS source and/or destination") } return srcPaths, destPath, nil }
go
func parseSrcDestArgs(g *libkb.GlobalContext, ctx *cli.Context, name string) ([]keybase1.Path, keybase1.Path, error) { nargs := len(ctx.Args()) var srcType, destType keybase1.PathType var srcPaths []keybase1.Path var destPath keybase1.Path if nargs < 2 { return srcPaths, destPath, errors.New(name + " requires one or more source arguments and a destination argument") } for i, src := range ctx.Args() { rev := int64(0) timeString := "" relTimeString := "" if i != nargs-1 { // All source paths use the same revision. rev = int64(ctx.Int("rev")) timeString = ctx.String("time") relTimeString = getRelTime(ctx) } argPath, err := makeSimpleFSPathWithArchiveParams( src, rev, timeString, relTimeString) if err != nil { return nil, keybase1.Path{}, err } tempPathType, err := argPath.PathType() if err != nil { return srcPaths, destPath, err } // Make sure all source paths are the same type if i == 0 { srcType = tempPathType } else if i == nargs-1 { destPath = argPath destType = tempPathType break } else if tempPathType != srcType { return srcPaths, destPath, errors.New(name + " requires all sources to be the same type") } srcPaths = append(srcPaths, argPath) } if srcType == keybase1.PathType_LOCAL && destType == keybase1.PathType_LOCAL { return srcPaths, destPath, errors.New(name + " requires KBFS source and/or destination") } return srcPaths, destPath, nil }
[ "func", "parseSrcDestArgs", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "ctx", "*", "cli", ".", "Context", ",", "name", "string", ")", "(", "[", "]", "keybase1", ".", "Path", ",", "keybase1", ".", "Path", ",", "error", ")", "{", "nargs", ":=",...
// Make a list of source paths and one destination path from the given command line args
[ "Make", "a", "list", "of", "source", "paths", "and", "one", "destination", "path", "from", "the", "given", "command", "line", "args" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_simplefs.go#L275-L321
159,825
keybase/client
go/slotctx/slotctx.go
Use
func (s *Slot) Use(ctx context.Context) context.Context { ctx, cancel := context.WithCancel(ctx) s.mu.Lock() s.cancel, cancel = cancel, s.cancel s.mu.Unlock() if cancel != nil { cancel() } return ctx }
go
func (s *Slot) Use(ctx context.Context) context.Context { ctx, cancel := context.WithCancel(ctx) s.mu.Lock() s.cancel, cancel = cancel, s.cancel s.mu.Unlock() if cancel != nil { cancel() } return ctx }
[ "func", "(", "s", "*", "Slot", ")", "Use", "(", "ctx", "context", ".", "Context", ")", "context", ".", "Context", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "s", ".", "mu", ".", "Lock", "(", ")", "\n", ...
// Use derives a context bound to the slot. // Cancels any context previously bound to the slot.
[ "Use", "derives", "a", "context", "bound", "to", "the", "slot", ".", "Cancels", "any", "context", "previously", "bound", "to", "the", "slot", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/slotctx/slotctx.go#L20-L29
159,826
keybase/client
go/slotctx/slotctx.go
Use
func (s *PrioritySlot) Use(ctx context.Context, priority int) context.Context { ctx, cancel := context.WithCancel(ctx) s.mu.Lock() defer s.mu.Unlock() if s.shutdown { // Not accepting new processes. cancel() return ctx } if s.cancel == nil { // First use s.cancel = cancel s.priority = priority return ctx } if s.priority <= priority { // Argument wins s.cancel() s.cancel = cancel s.priority = priority return ctx } // Incumbent wins cancel() return ctx }
go
func (s *PrioritySlot) Use(ctx context.Context, priority int) context.Context { ctx, cancel := context.WithCancel(ctx) s.mu.Lock() defer s.mu.Unlock() if s.shutdown { // Not accepting new processes. cancel() return ctx } if s.cancel == nil { // First use s.cancel = cancel s.priority = priority return ctx } if s.priority <= priority { // Argument wins s.cancel() s.cancel = cancel s.priority = priority return ctx } // Incumbent wins cancel() return ctx }
[ "func", "(", "s", "*", "PrioritySlot", ")", "Use", "(", "ctx", "context", ".", "Context", ",", "priority", "int", ")", "context", ".", "Context", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "s", ".", "mu", ...
// Use derives a new context. // Whichever of the argument and the incumbent are lower priority is canceled. // In a tie the incumbent is canceled.
[ "Use", "derives", "a", "new", "context", ".", "Whichever", "of", "the", "argument", "and", "the", "incumbent", "are", "lower", "priority", "is", "canceled", ".", "In", "a", "tie", "the", "incumbent", "is", "canceled", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/slotctx/slotctx.go#L56-L81
159,827
keybase/client
go/slotctx/slotctx.go
Shutdown
func (s *PrioritySlot) Shutdown() { s.mu.Lock() defer s.mu.Unlock() if s.cancel != nil { s.cancel() s.cancel = nil s.priority = 0 } s.shutdown = true }
go
func (s *PrioritySlot) Shutdown() { s.mu.Lock() defer s.mu.Unlock() if s.cancel != nil { s.cancel() s.cancel = nil s.priority = 0 } s.shutdown = true }
[ "func", "(", "s", "*", "PrioritySlot", ")", "Shutdown", "(", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "cancel", "!=", "nil", "{", "s", ".", "cancel", "(", ...
// Shutdown disables the slot forever.
[ "Shutdown", "disables", "the", "slot", "forever", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/slotctx/slotctx.go#L95-L104
159,828
keybase/client
go/chat/s3/ctx.go
NewFakeS3Context
func NewFakeS3Context(ctx context.Context) context.Context { return context.WithValue(ctx, fakeS3Key, true) }
go
func NewFakeS3Context(ctx context.Context) context.Context { return context.WithValue(ctx, fakeS3Key, true) }
[ "func", "NewFakeS3Context", "(", "ctx", "context", ".", "Context", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "fakeS3Key", ",", "true", ")", "\n", "}" ]
// NewFakeS3Context returns a context with the fakeS3Key flag set.
[ "NewFakeS3Context", "returns", "a", "context", "with", "the", "fakeS3Key", "flag", "set", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/ctx.go#L12-L14
159,829
keybase/client
go/protocol/stellar1/extras.go
CheckInvariants
func (r Bundle) CheckInvariants() error { accountIDs := make(map[AccountID]bool) var foundPrimary bool for _, entry := range r.Accounts { _, found := accountIDs[entry.AccountID] if found { return fmt.Errorf("duplicate account ID: %v", entry.AccountID) } accountIDs[entry.AccountID] = true if entry.IsPrimary { if foundPrimary { return errors.New("multiple primary accounts") } foundPrimary = true } if entry.Mode == AccountMode_NONE { return errors.New("account missing mode") } if entry.AcctBundleRevision < 1 { return fmt.Errorf("account bundle revision %v < 1 for %v", entry.AcctBundleRevision, entry.AccountID) } } if !foundPrimary { return errors.New("missing primary account") } if r.Revision < 1 { return fmt.Errorf("revision %v < 1", r.Revision) } for accID, accBundle := range r.AccountBundles { if accID != accBundle.AccountID { return fmt.Errorf("account ID mismatch in bundle for %v", accID) } var AccountBundleInAccounts bool for _, accountListAccount := range r.Accounts { if accountListAccount.AccountID == accID { AccountBundleInAccounts = true } } if !AccountBundleInAccounts { return fmt.Errorf("account in AccountBundles not in Accounts %v", accID) } } return nil }
go
func (r Bundle) CheckInvariants() error { accountIDs := make(map[AccountID]bool) var foundPrimary bool for _, entry := range r.Accounts { _, found := accountIDs[entry.AccountID] if found { return fmt.Errorf("duplicate account ID: %v", entry.AccountID) } accountIDs[entry.AccountID] = true if entry.IsPrimary { if foundPrimary { return errors.New("multiple primary accounts") } foundPrimary = true } if entry.Mode == AccountMode_NONE { return errors.New("account missing mode") } if entry.AcctBundleRevision < 1 { return fmt.Errorf("account bundle revision %v < 1 for %v", entry.AcctBundleRevision, entry.AccountID) } } if !foundPrimary { return errors.New("missing primary account") } if r.Revision < 1 { return fmt.Errorf("revision %v < 1", r.Revision) } for accID, accBundle := range r.AccountBundles { if accID != accBundle.AccountID { return fmt.Errorf("account ID mismatch in bundle for %v", accID) } var AccountBundleInAccounts bool for _, accountListAccount := range r.Accounts { if accountListAccount.AccountID == accID { AccountBundleInAccounts = true } } if !AccountBundleInAccounts { return fmt.Errorf("account in AccountBundles not in Accounts %v", accID) } } return nil }
[ "func", "(", "r", "Bundle", ")", "CheckInvariants", "(", ")", "error", "{", "accountIDs", ":=", "make", "(", "map", "[", "AccountID", "]", "bool", ")", "\n", "var", "foundPrimary", "bool", "\n", "for", "_", ",", "entry", ":=", "range", "r", ".", "Acc...
// CheckInvariants checks that the Bundle satisfies // 1. No duplicate account IDs // 2. Exactly one primary account // 3. Non-negative revision numbers // 4. Account Bundle accountIDs are consistent // 5. every account in AccountBundles is also in Accounts
[ "CheckInvariants", "checks", "that", "the", "Bundle", "satisfies", "1", ".", "No", "duplicate", "account", "IDs", "2", ".", "Exactly", "one", "primary", "account", "3", ".", "Non", "-", "negative", "revision", "numbers", "4", ".", "Account", "Bundle", "accou...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/stellar1/extras.go#L141-L184
159,830
keybase/client
go/engine/prove_check.go
NewProveCheck
func NewProveCheck(g *libkb.GlobalContext, sigID keybase1.SigID) *ProveCheck { return &ProveCheck{ Contextified: libkb.NewContextified(g), sigID: sigID, } }
go
func NewProveCheck(g *libkb.GlobalContext, sigID keybase1.SigID) *ProveCheck { return &ProveCheck{ Contextified: libkb.NewContextified(g), sigID: sigID, } }
[ "func", "NewProveCheck", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "sigID", "keybase1", ".", "SigID", ")", "*", "ProveCheck", "{", "return", "&", "ProveCheck", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "sigID",...
// NewProveCheck creates a ProveCheck engine.
[ "NewProveCheck", "creates", "a", "ProveCheck", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/prove_check.go#L27-L32
159,831
keybase/client
go/libkb/resolve.go
putToMemCache
func (r *ResolverImpl) putToMemCache(m MetaContext, key string, res ResolveResult) { if r.cache == nil { return } // Don't cache errors or deleted users if res.err != nil || res.deleted { return } if !res.HasPrimaryKey() { m.Warning("Mistaken UID put to mem cache") if m.G().Env.GetDebug() { debug.PrintStack() } return } res.cachedAt = m.G().Clock().Now() res.body = nil // Don't cache body r.cache.Set(key, &res) }
go
func (r *ResolverImpl) putToMemCache(m MetaContext, key string, res ResolveResult) { if r.cache == nil { return } // Don't cache errors or deleted users if res.err != nil || res.deleted { return } if !res.HasPrimaryKey() { m.Warning("Mistaken UID put to mem cache") if m.G().Env.GetDebug() { debug.PrintStack() } return } res.cachedAt = m.G().Clock().Now() res.body = nil // Don't cache body r.cache.Set(key, &res) }
[ "func", "(", "r", "*", "ResolverImpl", ")", "putToMemCache", "(", "m", "MetaContext", ",", "key", "string", ",", "res", "ResolveResult", ")", "{", "if", "r", ".", "cache", "==", "nil", "{", "return", "\n", "}", "\n", "// Don't cache errors or deleted users",...
// Put receives a copy of a ResolveResult, clears out the body // to avoid caching data that can go stale, and stores the result.
[ "Put", "receives", "a", "copy", "of", "a", "ResolveResult", "clears", "out", "the", "body", "to", "avoid", "caching", "data", "that", "can", "go", "stale", "and", "stores", "the", "result", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/resolve.go#L687-L705
159,832
keybase/client
go/engine/login_provisioned_device.go
NewLoginProvisionedDevice
func NewLoginProvisionedDevice(g *libkb.GlobalContext, username string) *LoginProvisionedDevice { return &LoginProvisionedDevice{ username: libkb.NewNormalizedUsername(username), Contextified: libkb.NewContextified(g), } }
go
func NewLoginProvisionedDevice(g *libkb.GlobalContext, username string) *LoginProvisionedDevice { return &LoginProvisionedDevice{ username: libkb.NewNormalizedUsername(username), Contextified: libkb.NewContextified(g), } }
[ "func", "NewLoginProvisionedDevice", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "username", "string", ")", "*", "LoginProvisionedDevice", "{", "return", "&", "LoginProvisionedDevice", "{", "username", ":", "libkb", ".", "NewNormalizedUsername", "(", "usernam...
// newLoginCurrentDevice creates a loginProvisionedDevice engine.
[ "newLoginCurrentDevice", "creates", "a", "loginProvisionedDevice", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provisioned_device.go#L24-L29
159,833
keybase/client
go/chat/storage/outbox.go
PullAllConversations
func (o *Outbox) PullAllConversations(ctx context.Context, includeErrors bool, remove bool) ([]chat1.OutboxRecord, error) { locks.Outbox.Lock() defer locks.Outbox.Unlock() // Read outbox for the user obox, err := o.readStorage(ctx) if err != nil { return nil, err } var res, errors []chat1.OutboxRecord for _, obr := range obox.Records { state, err := obr.State.State() if err != nil { o.Debug(ctx, "PullAllConversations: unknown state item: skipping: err: %s", err.Error()) continue } if state == chat1.OutboxStateType_ERROR { if includeErrors { res = append(res, obr) } else { errors = append(errors, obr) } } else { res = append(res, obr) } } if remove { // Write out diskbox obox.Records = errors obox.Version = outboxVersion if err := o.writeStorage(ctx, obox); err != nil { return nil, err } } return res, nil }
go
func (o *Outbox) PullAllConversations(ctx context.Context, includeErrors bool, remove bool) ([]chat1.OutboxRecord, error) { locks.Outbox.Lock() defer locks.Outbox.Unlock() // Read outbox for the user obox, err := o.readStorage(ctx) if err != nil { return nil, err } var res, errors []chat1.OutboxRecord for _, obr := range obox.Records { state, err := obr.State.State() if err != nil { o.Debug(ctx, "PullAllConversations: unknown state item: skipping: err: %s", err.Error()) continue } if state == chat1.OutboxStateType_ERROR { if includeErrors { res = append(res, obr) } else { errors = append(errors, obr) } } else { res = append(res, obr) } } if remove { // Write out diskbox obox.Records = errors obox.Version = outboxVersion if err := o.writeStorage(ctx, obox); err != nil { return nil, err } } return res, nil }
[ "func", "(", "o", "*", "Outbox", ")", "PullAllConversations", "(", "ctx", "context", ".", "Context", ",", "includeErrors", "bool", ",", "remove", "bool", ")", "(", "[", "]", "chat1", ".", "OutboxRecord", ",", "error", ")", "{", "locks", ".", "Outbox", ...
// PullAllConversations grabs all outbox entries for the current outbox, and optionally deletes them // from storage
[ "PullAllConversations", "grabs", "all", "outbox", "entries", "for", "the", "current", "outbox", "and", "optionally", "deletes", "them", "from", "storage" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/outbox.go#L210-L247
159,834
keybase/client
go/chat/storage/outbox.go
MarkAsError
func (o *Outbox) MarkAsError(ctx context.Context, obr chat1.OutboxRecord, errRec chat1.OutboxStateError) (res chat1.OutboxRecord, err error) { locks.Outbox.Lock() defer locks.Outbox.Unlock() // Read outbox for the user obox, err := o.readStorage(ctx) if err != nil { return res, err } // Loop through and find record var recs []chat1.OutboxRecord added := false for _, iobr := range obox.Records { if iobr.OutboxID.Eq(&obr.OutboxID) { iobr.State = chat1.NewOutboxStateWithError(errRec) added = true res = iobr } recs = append(recs, iobr) } if !added { obr.State = chat1.NewOutboxStateWithError(errRec) res = obr recs = append(recs, obr) sort.Sort(ByCtimeOrder(recs)) } // Write out diskbox obox.Records = recs if err := o.writeStorage(ctx, obox); err != nil { return res, err } return res, nil }
go
func (o *Outbox) MarkAsError(ctx context.Context, obr chat1.OutboxRecord, errRec chat1.OutboxStateError) (res chat1.OutboxRecord, err error) { locks.Outbox.Lock() defer locks.Outbox.Unlock() // Read outbox for the user obox, err := o.readStorage(ctx) if err != nil { return res, err } // Loop through and find record var recs []chat1.OutboxRecord added := false for _, iobr := range obox.Records { if iobr.OutboxID.Eq(&obr.OutboxID) { iobr.State = chat1.NewOutboxStateWithError(errRec) added = true res = iobr } recs = append(recs, iobr) } if !added { obr.State = chat1.NewOutboxStateWithError(errRec) res = obr recs = append(recs, obr) sort.Sort(ByCtimeOrder(recs)) } // Write out diskbox obox.Records = recs if err := o.writeStorage(ctx, obox); err != nil { return res, err } return res, nil }
[ "func", "(", "o", "*", "Outbox", ")", "MarkAsError", "(", "ctx", "context", ".", "Context", ",", "obr", "chat1", ".", "OutboxRecord", ",", "errRec", "chat1", ".", "OutboxStateError", ")", "(", "res", "chat1", ".", "OutboxRecord", ",", "err", "error", ")"...
// MarkAsError will either mark an existing record as an error, or it will add the passed // record as an error with the specified error state
[ "MarkAsError", "will", "either", "mark", "an", "existing", "record", "as", "an", "error", "or", "it", "will", "add", "the", "passed", "record", "as", "an", "error", "with", "the", "specified", "error", "state" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/outbox.go#L333-L367
159,835
keybase/client
go/engine/pgp_purge.go
NewPGPPurge
func NewPGPPurge(g *libkb.GlobalContext, arg keybase1.PGPPurgeArg) *PGPPurge { return &PGPPurge{ Contextified: libkb.NewContextified(g), arg: arg, } }
go
func NewPGPPurge(g *libkb.GlobalContext, arg keybase1.PGPPurgeArg) *PGPPurge { return &PGPPurge{ Contextified: libkb.NewContextified(g), arg: arg, } }
[ "func", "NewPGPPurge", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "arg", "keybase1", ".", "PGPPurgeArg", ")", "*", "PGPPurge", "{", "return", "&", "PGPPurge", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "arg", "...
// NewPGPPurge creates a PGPPurge engine.
[ "NewPGPPurge", "creates", "a", "PGPPurge", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_purge.go#L25-L30
159,836
keybase/client
go/kbfs/libfs/metrics_file.go
GetEncodedMetrics
func GetEncodedMetrics(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error) { return func(context.Context) ([]byte, time.Time, error) { if registry := config.MetricsRegistry(); registry != nil { b := bytes.NewBuffer(nil) metricsutil.WriteMetrics(registry, b) return b.Bytes(), time.Time{}, nil } return []byte("Metrics have been turned off.\n"), time.Time{}, nil } }
go
func GetEncodedMetrics(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error) { return func(context.Context) ([]byte, time.Time, error) { if registry := config.MetricsRegistry(); registry != nil { b := bytes.NewBuffer(nil) metricsutil.WriteMetrics(registry, b) return b.Bytes(), time.Time{}, nil } return []byte("Metrics have been turned off.\n"), time.Time{}, nil } }
[ "func", "GetEncodedMetrics", "(", "config", "libkbfs", ".", "Config", ")", "func", "(", "context", ".", "Context", ")", "(", "[", "]", "byte", ",", "time", ".", "Time", ",", "error", ")", "{", "return", "func", "(", "context", ".", "Context", ")", "(...
// GetEncodedMetrics returns metrics encoded as bytes for metrics file.
[ "GetEncodedMetrics", "returns", "metrics", "encoded", "as", "bytes", "for", "metrics", "file", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/metrics_file.go#L17-L26
159,837
keybase/client
go/chat/flip/flip.go
NewDealer
func NewDealer(dh DealersHelper) *Dealer { return &Dealer{ dh: dh, games: make(map[GameKey](chan<- *GameMessageWrapped)), gameIDs: make(map[GameIDKey]GameMetadata), chatInputCh: make(chan *GameMessageWrapped), gameUpdateCh: make(chan GameStateUpdateMessage, 500), previousGames: make(map[GameIDKey]bool), } }
go
func NewDealer(dh DealersHelper) *Dealer { return &Dealer{ dh: dh, games: make(map[GameKey](chan<- *GameMessageWrapped)), gameIDs: make(map[GameIDKey]GameMetadata), chatInputCh: make(chan *GameMessageWrapped), gameUpdateCh: make(chan GameStateUpdateMessage, 500), previousGames: make(map[GameIDKey]bool), } }
[ "func", "NewDealer", "(", "dh", "DealersHelper", ")", "*", "Dealer", "{", "return", "&", "Dealer", "{", "dh", ":", "dh", ",", "games", ":", "make", "(", "map", "[", "GameKey", "]", "(", "chan", "<-", "*", "GameMessageWrapped", ")", ")", ",", "gameIDs...
// NewDealer makes a new Dealer with a given DealersHelper
[ "NewDealer", "makes", "a", "new", "Dealer", "with", "a", "given", "DealersHelper" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L79-L88
159,838
keybase/client
go/chat/flip/flip.go
Run
func (d *Dealer) Run(ctx context.Context) error { d.shutdownMu.Lock() shutdownCh := make(chan struct{}) d.shutdownCh = shutdownCh d.shutdownMu.Unlock() for { select { case <-ctx.Done(): return ctx.Err() // This channel never closes case msg := <-d.chatInputCh: err := d.handleMessage(ctx, msg) if err != nil { d.dh.CLogf(ctx, "Error reading message: %s", err.Error()) } // exit the loop if we've shutdown case <-shutdownCh: return io.EOF } } }
go
func (d *Dealer) Run(ctx context.Context) error { d.shutdownMu.Lock() shutdownCh := make(chan struct{}) d.shutdownCh = shutdownCh d.shutdownMu.Unlock() for { select { case <-ctx.Done(): return ctx.Err() // This channel never closes case msg := <-d.chatInputCh: err := d.handleMessage(ctx, msg) if err != nil { d.dh.CLogf(ctx, "Error reading message: %s", err.Error()) } // exit the loop if we've shutdown case <-shutdownCh: return io.EOF } } }
[ "func", "(", "d", "*", "Dealer", ")", "Run", "(", "ctx", "context", ".", "Context", ")", "error", "{", "d", ".", "shutdownMu", ".", "Lock", "(", ")", "\n", "shutdownCh", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "d", ".", "shutdow...
// Run a dealer in a given context. It will run as long as it isn't shutdown.
[ "Run", "a", "dealer", "in", "a", "given", "context", ".", "It", "will", "run", "as", "long", "as", "it", "isn", "t", "shutdown", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L97-L121
159,839
keybase/client
go/chat/flip/flip.go
Stop
func (d *Dealer) Stop() { d.shutdownMu.Lock() if d.shutdownCh != nil { close(d.shutdownCh) d.shutdownCh = nil } d.shutdownMu.Unlock() d.stopGames() }
go
func (d *Dealer) Stop() { d.shutdownMu.Lock() if d.shutdownCh != nil { close(d.shutdownCh) d.shutdownCh = nil } d.shutdownMu.Unlock() d.stopGames() }
[ "func", "(", "d", "*", "Dealer", ")", "Stop", "(", ")", "{", "d", ".", "shutdownMu", ".", "Lock", "(", ")", "\n", "if", "d", ".", "shutdownCh", "!=", "nil", "{", "close", "(", "d", ".", "shutdownCh", ")", "\n", "d", ".", "shutdownCh", "=", "nil...
// Stop a dealer on process shutdown.
[ "Stop", "a", "dealer", "on", "process", "shutdown", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L124-L132
159,840
keybase/client
go/chat/flip/flip.go
StartFlip
func (d *Dealer) StartFlip(ctx context.Context, start Start, conversationID chat1.ConversationID) (err error) { _, err = d.startFlip(ctx, start, conversationID) return err }
go
func (d *Dealer) StartFlip(ctx context.Context, start Start, conversationID chat1.ConversationID) (err error) { _, err = d.startFlip(ctx, start, conversationID) return err }
[ "func", "(", "d", "*", "Dealer", ")", "StartFlip", "(", "ctx", "context", ".", "Context", ",", "start", "Start", ",", "conversationID", "chat1", ".", "ConversationID", ")", "(", "err", "error", ")", "{", "_", ",", "err", "=", "d", ".", "startFlip", "...
// StartFlip starts a new flip. Pass it some start parameters as well as a chat conversationID that it // will take place in.
[ "StartFlip", "starts", "a", "new", "flip", ".", "Pass", "it", "some", "start", "parameters", "as", "well", "as", "a", "chat", "conversationID", "that", "it", "will", "take", "place", "in", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L136-L139
159,841
keybase/client
go/chat/flip/flip.go
StartFlipWithGameID
func (d *Dealer) StartFlipWithGameID(ctx context.Context, start Start, conversationID chat1.ConversationID, gameID chat1.FlipGameID) (err error) { _, err = d.startFlipWithGameID(ctx, start, conversationID, gameID) return err }
go
func (d *Dealer) StartFlipWithGameID(ctx context.Context, start Start, conversationID chat1.ConversationID, gameID chat1.FlipGameID) (err error) { _, err = d.startFlipWithGameID(ctx, start, conversationID, gameID) return err }
[ "func", "(", "d", "*", "Dealer", ")", "StartFlipWithGameID", "(", "ctx", "context", ".", "Context", ",", "start", "Start", ",", "conversationID", "chat1", ".", "ConversationID", ",", "gameID", "chat1", ".", "FlipGameID", ")", "(", "err", "error", ")", "{",...
// StartFlipWithGameID starts a new flip. Pass it some start parameters as well as a chat conversationID // that it will take place in. Also takes a GameID
[ "StartFlipWithGameID", "starts", "a", "new", "flip", ".", "Pass", "it", "some", "start", "parameters", "as", "well", "as", "a", "chat", "conversationID", "that", "it", "will", "take", "place", "in", ".", "Also", "takes", "a", "GameID" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L143-L147
159,842
keybase/client
go/chat/flip/flip.go
InjectIncomingChat
func (d *Dealer) InjectIncomingChat(ctx context.Context, sender UserDevice, conversationID chat1.ConversationID, gameID chat1.FlipGameID, body GameMessageEncoded, firstInConversation bool) error { gmwe := GameMessageWrappedEncoded{ Sender: sender, GameID: gameID, Body: body, FirstInConversation: firstInConversation, } msg, err := gmwe.Decode() if err != nil { return err } if !msg.Msg.Md.ConversationID.Eq(conversationID) { return BadChannelError{G: msg.Msg.Md, C: conversationID} } if !msg.isForwardable() { return UnforwardableMessageError{G: msg.Msg.Md} } if !msg.Msg.Md.GameID.Eq(gameID) { return BadGameIDError{G: msg.Msg.Md, I: gameID} } d.chatInputCh <- msg return nil }
go
func (d *Dealer) InjectIncomingChat(ctx context.Context, sender UserDevice, conversationID chat1.ConversationID, gameID chat1.FlipGameID, body GameMessageEncoded, firstInConversation bool) error { gmwe := GameMessageWrappedEncoded{ Sender: sender, GameID: gameID, Body: body, FirstInConversation: firstInConversation, } msg, err := gmwe.Decode() if err != nil { return err } if !msg.Msg.Md.ConversationID.Eq(conversationID) { return BadChannelError{G: msg.Msg.Md, C: conversationID} } if !msg.isForwardable() { return UnforwardableMessageError{G: msg.Msg.Md} } if !msg.Msg.Md.GameID.Eq(gameID) { return BadGameIDError{G: msg.Msg.Md, I: gameID} } d.chatInputCh <- msg return nil }
[ "func", "(", "d", "*", "Dealer", ")", "InjectIncomingChat", "(", "ctx", "context", ".", "Context", ",", "sender", "UserDevice", ",", "conversationID", "chat1", ".", "ConversationID", ",", "gameID", "chat1", ".", "FlipGameID", ",", "body", "GameMessageEncoded", ...
// InjectIncomingChat should be called whenever a new flip game comes in that's relevant for flips. // Call this with the sender's information, the channel information, and the body data that came in. // The last bool is true only if this is the first message in the channel. The current model is that only // one "game" is allowed for each chat channel. So any prior messages in the channel mean it might be replay. // This is significantly less general than an earlier model, which is why we introduced the concept of // a gameID, so it might be changed in the future.
[ "InjectIncomingChat", "should", "be", "called", "whenever", "a", "new", "flip", "game", "comes", "in", "that", "s", "relevant", "for", "flips", ".", "Call", "this", "with", "the", "sender", "s", "information", "the", "channel", "information", "and", "the", "...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L155-L179
159,843
keybase/client
go/chat/flip/flip.go
NewStartWithBool
func NewStartWithBool(now time.Time, nPlayers int) Start { ret := newStart(now, nPlayers) ret.Params = NewFlipParametersWithBool() return ret }
go
func NewStartWithBool(now time.Time, nPlayers int) Start { ret := newStart(now, nPlayers) ret.Params = NewFlipParametersWithBool() return ret }
[ "func", "NewStartWithBool", "(", "now", "time", ".", "Time", ",", "nPlayers", "int", ")", "Start", "{", "ret", ":=", "newStart", "(", "now", ",", "nPlayers", ")", "\n", "ret", ".", "Params", "=", "NewFlipParametersWithBool", "(", ")", "\n", "return", "re...
// NewStartWithBool makes new start parameters that yield a coinflip game.
[ "NewStartWithBool", "makes", "new", "start", "parameters", "that", "yield", "a", "coinflip", "game", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L182-L186
159,844
keybase/client
go/chat/flip/flip.go
NewStartWithInt
func NewStartWithInt(now time.Time, mod int64, nPlayers int) Start { ret := newStart(now, nPlayers) ret.Params = NewFlipParametersWithInt(mod) return ret }
go
func NewStartWithInt(now time.Time, mod int64, nPlayers int) Start { ret := newStart(now, nPlayers) ret.Params = NewFlipParametersWithInt(mod) return ret }
[ "func", "NewStartWithInt", "(", "now", "time", ".", "Time", ",", "mod", "int64", ",", "nPlayers", "int", ")", "Start", "{", "ret", ":=", "newStart", "(", "now", ",", "nPlayers", ")", "\n", "ret", ".", "Params", "=", "NewFlipParametersWithInt", "(", "mod"...
// NewStartWithInt makes new start parameters that yield a coinflip game that picks an int between // 0 and mod.
[ "NewStartWithInt", "makes", "new", "start", "parameters", "that", "yield", "a", "coinflip", "game", "that", "picks", "an", "int", "between", "0", "and", "mod", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L190-L194
159,845
keybase/client
go/chat/flip/flip.go
NewStartWithBigInt
func NewStartWithBigInt(now time.Time, mod *big.Int, nPlayers int) Start { ret := newStart(now, nPlayers) ret.Params = NewFlipParametersWithBig(mod.Bytes()) return ret }
go
func NewStartWithBigInt(now time.Time, mod *big.Int, nPlayers int) Start { ret := newStart(now, nPlayers) ret.Params = NewFlipParametersWithBig(mod.Bytes()) return ret }
[ "func", "NewStartWithBigInt", "(", "now", "time", ".", "Time", ",", "mod", "*", "big", ".", "Int", ",", "nPlayers", "int", ")", "Start", "{", "ret", ":=", "newStart", "(", "now", ",", "nPlayers", ")", "\n", "ret", ".", "Params", "=", "NewFlipParameters...
// NewStartWithBigInt makes new start parameters that yield a coinflip game that picks big int between // 0 and mod.
[ "NewStartWithBigInt", "makes", "new", "start", "parameters", "that", "yield", "a", "coinflip", "game", "that", "picks", "big", "int", "between", "0", "and", "mod", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L198-L202
159,846
keybase/client
go/chat/flip/flip.go
NewStartWithShuffle
func NewStartWithShuffle(now time.Time, n int64, nPlayers int) Start { ret := newStart(now, nPlayers) ret.Params = NewFlipParametersWithShuffle(n) return ret }
go
func NewStartWithShuffle(now time.Time, n int64, nPlayers int) Start { ret := newStart(now, nPlayers) ret.Params = NewFlipParametersWithShuffle(n) return ret }
[ "func", "NewStartWithShuffle", "(", "now", "time", ".", "Time", ",", "n", "int64", ",", "nPlayers", "int", ")", "Start", "{", "ret", ":=", "newStart", "(", "now", ",", "nPlayers", ")", "\n", "ret", ".", "Params", "=", "NewFlipParametersWithShuffle", "(", ...
// NewStartWithShuffle makes new start parameters for a coinflip that randomly permutes the numbers // between 0 and n, exclusive. This can be used to shuffle an array of names.
[ "NewStartWithShuffle", "makes", "new", "start", "parameters", "for", "a", "coinflip", "that", "randomly", "permutes", "the", "numbers", "between", "0", "and", "n", "exclusive", ".", "This", "can", "be", "used", "to", "shuffle", "an", "array", "of", "names", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/flip.go#L206-L210
159,847
keybase/client
go/kbfs/kbfsedits/tlf_history.go
AddNotifications
func (th *TlfHistory) AddNotifications( writerName string, messages []string) (maxRev kbfsmd.Revision, err error) { newEdits := make(notificationsByRevision, 0, len(messages)) // Unmarshal and sort the new messages. for _, msg := range messages { var revList []NotificationMessage err := json.Unmarshal([]byte(msg), &revList) if err != nil { // The messages might be from a new version we don't // understand, so swallow the error. continue } for j := len(revList) - 1; j >= 0; j-- { revMsg := revList[j] if revMsg.Version != NotificationV2 { // Ignore messages that are too new for us to understand. continue } revMsg.numWithinRevision = j newEdits = append(newEdits, revMsg) } } th.lock.Lock() defer th.lock.Unlock() wn, existed := th.byWriter[writerName] if !existed { wn = &writerNotifications{writerName, nil, nil} } oldLen := len(wn.notifications) newEdits = append(newEdits, wn.notifications...) sort.Sort(newEdits) if len(newEdits) > 0 { maxRev = newEdits[0].Revision } wn.notifications = newEdits.uniquify() if len(wn.notifications) == oldLen { // No new messages. return maxRev, nil } if !existed { th.byWriter[writerName] = wn } // Invalidate the cached results. th.computed = false th.cachedLoggedInUser = "" return maxRev, nil }
go
func (th *TlfHistory) AddNotifications( writerName string, messages []string) (maxRev kbfsmd.Revision, err error) { newEdits := make(notificationsByRevision, 0, len(messages)) // Unmarshal and sort the new messages. for _, msg := range messages { var revList []NotificationMessage err := json.Unmarshal([]byte(msg), &revList) if err != nil { // The messages might be from a new version we don't // understand, so swallow the error. continue } for j := len(revList) - 1; j >= 0; j-- { revMsg := revList[j] if revMsg.Version != NotificationV2 { // Ignore messages that are too new for us to understand. continue } revMsg.numWithinRevision = j newEdits = append(newEdits, revMsg) } } th.lock.Lock() defer th.lock.Unlock() wn, existed := th.byWriter[writerName] if !existed { wn = &writerNotifications{writerName, nil, nil} } oldLen := len(wn.notifications) newEdits = append(newEdits, wn.notifications...) sort.Sort(newEdits) if len(newEdits) > 0 { maxRev = newEdits[0].Revision } wn.notifications = newEdits.uniquify() if len(wn.notifications) == oldLen { // No new messages. return maxRev, nil } if !existed { th.byWriter[writerName] = wn } // Invalidate the cached results. th.computed = false th.cachedLoggedInUser = "" return maxRev, nil }
[ "func", "(", "th", "*", "TlfHistory", ")", "AddNotifications", "(", "writerName", "string", ",", "messages", "[", "]", "string", ")", "(", "maxRev", "kbfsmd", ".", "Revision", ",", "err", "error", ")", "{", "newEdits", ":=", "make", "(", "notificationsByRe...
// AddNotifications takes in a set of messages in this TLF by // `writer`, and adds them to the history. Once done adding messages, // the caller should call `Recompute` to find out if more messages // should be added for any particular writer. It returns the maximum // known revision including an update from this writer.
[ "AddNotifications", "takes", "in", "a", "set", "of", "messages", "in", "this", "TLF", "by", "writer", "and", "adds", "them", "to", "the", "history", ".", "Once", "done", "adding", "messages", "the", "caller", "should", "call", "Recompute", "to", "find", "o...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsedits/tlf_history.go#L126-L176
159,848
keybase/client
go/kbfs/kbfsedits/tlf_history.go
AddUnflushedNotifications
func (th *TlfHistory) AddUnflushedNotifications( loggedInUser string, msgs []NotificationMessage) { th.lock.Lock() defer th.lock.Unlock() if th.unflushed == nil { th.unflushed = &writerNotifications{loggedInUser, nil, nil} } if th.unflushed.writerName != loggedInUser { panic(fmt.Sprintf("Logged-in user %s doesn't match unflushed user %s", loggedInUser, th.unflushed.writerName)) } newEdits := append( notificationsByRevision(msgs), th.unflushed.notifications...) sort.Sort(newEdits) th.unflushed.notifications = newEdits.uniquify() // Invalidate the cached results. th.computed = false th.cachedLoggedInUser = "" }
go
func (th *TlfHistory) AddUnflushedNotifications( loggedInUser string, msgs []NotificationMessage) { th.lock.Lock() defer th.lock.Unlock() if th.unflushed == nil { th.unflushed = &writerNotifications{loggedInUser, nil, nil} } if th.unflushed.writerName != loggedInUser { panic(fmt.Sprintf("Logged-in user %s doesn't match unflushed user %s", loggedInUser, th.unflushed.writerName)) } newEdits := append( notificationsByRevision(msgs), th.unflushed.notifications...) sort.Sort(newEdits) th.unflushed.notifications = newEdits.uniquify() // Invalidate the cached results. th.computed = false th.cachedLoggedInUser = "" }
[ "func", "(", "th", "*", "TlfHistory", ")", "AddUnflushedNotifications", "(", "loggedInUser", "string", ",", "msgs", "[", "]", "NotificationMessage", ")", "{", "th", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "th", ".", "lock", ".", "Unlock", "(",...
// AddUnflushedNotifications adds notifications to a special // "unflushed" list that takes precedences over the regular // notifications with revision numbers equal or greater to the minimum // unflushed revision.
[ "AddUnflushedNotifications", "adds", "notifications", "to", "a", "special", "unflushed", "list", "that", "takes", "precedences", "over", "the", "regular", "notifications", "with", "revision", "numbers", "equal", "or", "greater", "to", "the", "minimum", "unflushed", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsedits/tlf_history.go#L182-L200
159,849
keybase/client
go/kbfs/kbfsedits/tlf_history.go
FlushRevision
func (th *TlfHistory) FlushRevision(rev kbfsmd.Revision) { th.lock.Lock() defer th.lock.Unlock() if th.unflushed == nil { return } lastToKeep := len(th.unflushed.notifications) - 1 for ; lastToKeep >= 0; lastToKeep-- { if th.unflushed.notifications[lastToKeep].Revision > rev { break } } if lastToKeep < len(th.unflushed.notifications)-1 { th.unflushed.notifications = th.unflushed.notifications[:lastToKeep+1] // Invalidate the cached results. th.computed = false th.cachedLoggedInUser = "" } }
go
func (th *TlfHistory) FlushRevision(rev kbfsmd.Revision) { th.lock.Lock() defer th.lock.Unlock() if th.unflushed == nil { return } lastToKeep := len(th.unflushed.notifications) - 1 for ; lastToKeep >= 0; lastToKeep-- { if th.unflushed.notifications[lastToKeep].Revision > rev { break } } if lastToKeep < len(th.unflushed.notifications)-1 { th.unflushed.notifications = th.unflushed.notifications[:lastToKeep+1] // Invalidate the cached results. th.computed = false th.cachedLoggedInUser = "" } }
[ "func", "(", "th", "*", "TlfHistory", ")", "FlushRevision", "(", "rev", "kbfsmd", ".", "Revision", ")", "{", "th", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "th", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "th", ".", "unflushed", ...
// FlushRevision clears all any unflushed notifications with a // revision equal or less than `rev`.
[ "FlushRevision", "clears", "all", "any", "unflushed", "notifications", "with", "a", "revision", "equal", "or", "less", "than", "rev", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsedits/tlf_history.go#L204-L222
159,850
keybase/client
go/kbfs/kbfsedits/tlf_history.go
ClearAllUnflushed
func (th *TlfHistory) ClearAllUnflushed() { th.lock.Lock() defer th.lock.Unlock() if th.unflushed != nil { // Invalidate the cached results. th.computed = false th.cachedLoggedInUser = "" } th.unflushed = nil }
go
func (th *TlfHistory) ClearAllUnflushed() { th.lock.Lock() defer th.lock.Unlock() if th.unflushed != nil { // Invalidate the cached results. th.computed = false th.cachedLoggedInUser = "" } th.unflushed = nil }
[ "func", "(", "th", "*", "TlfHistory", ")", "ClearAllUnflushed", "(", ")", "{", "th", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "th", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "th", ".", "unflushed", "!=", "nil", "{", "// Invalidate...
// ClearAllUnflushed clears all unflushed notifications.
[ "ClearAllUnflushed", "clears", "all", "unflushed", "notifications", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsedits/tlf_history.go#L225-L234
159,851
keybase/client
go/kbfs/kbfsblock/server_errors.go
ToStatus
func (e ServerErrorUnauthorized) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorUnauthorized s.Name = "SESSION_UNAUTHORIZED" s.Desc = e.Msg return }
go
func (e ServerErrorUnauthorized) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorUnauthorized s.Name = "SESSION_UNAUTHORIZED" s.Desc = e.Msg return }
[ "func", "(", "e", "ServerErrorUnauthorized", ")", "ToStatus", "(", ")", "(", "s", "keybase1", ".", "Status", ")", "{", "s", ".", "Code", "=", "StatusCodeServerErrorUnauthorized", "\n", "s", ".", "Name", "=", "\"", "\"", "\n", "s", ".", "Desc", "=", "e"...
// ToStatus implements the ExportableError interface for ServerErrorUnauthorized.
[ "ToStatus", "implements", "the", "ExportableError", "interface", "for", "ServerErrorUnauthorized", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/server_errors.go#L87-L92
159,852
keybase/client
go/kbfs/kbfsblock/server_errors.go
ToStatus
func (e ServerErrorOverQuota) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorOverQuota s.Name = "QUOTA_EXCEEDED" s.Desc = e.Msg s.Fields = append(s.Fields, keybase1.StringKVPair{ Key: "QUOTA_USAGE", Value: strconv.FormatInt(e.Usage, 10), }) s.Fields = append(s.Fields, keybase1.StringKVPair{ Key: "QUOTA_LIMIT", Value: strconv.FormatInt(e.Limit, 10), }) s.Fields = append(s.Fields, keybase1.StringKVPair{ Key: "QUOTA_THROTTLE", Value: strconv.FormatBool(e.Throttled), }) return }
go
func (e ServerErrorOverQuota) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorOverQuota s.Name = "QUOTA_EXCEEDED" s.Desc = e.Msg s.Fields = append(s.Fields, keybase1.StringKVPair{ Key: "QUOTA_USAGE", Value: strconv.FormatInt(e.Usage, 10), }) s.Fields = append(s.Fields, keybase1.StringKVPair{ Key: "QUOTA_LIMIT", Value: strconv.FormatInt(e.Limit, 10), }) s.Fields = append(s.Fields, keybase1.StringKVPair{ Key: "QUOTA_THROTTLE", Value: strconv.FormatBool(e.Throttled), }) return }
[ "func", "(", "e", "ServerErrorOverQuota", ")", "ToStatus", "(", ")", "(", "s", "keybase1", ".", "Status", ")", "{", "s", ".", "Code", "=", "StatusCodeServerErrorOverQuota", "\n", "s", ".", "Name", "=", "\"", "\"", "\n", "s", ".", "Desc", "=", "e", "....
// ToStatus implements the ExportableError interface for ServerErrorOverQuota.
[ "ToStatus", "implements", "the", "ExportableError", "interface", "for", "ServerErrorOverQuota", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/server_errors.go#L114-L131
159,853
keybase/client
go/kbfs/kbfsblock/server_errors.go
Error
func (e ServerErrorOverQuota) Error() string { return fmt.Sprintf( "ServerErrorOverQuota{Msg: %q, Usage: %d, Limit: %d, Throttled: %t}", e.Msg, e.Usage, e.Limit, e.Throttled) }
go
func (e ServerErrorOverQuota) Error() string { return fmt.Sprintf( "ServerErrorOverQuota{Msg: %q, Usage: %d, Limit: %d, Throttled: %t}", e.Msg, e.Usage, e.Limit, e.Throttled) }
[ "func", "(", "e", "ServerErrorOverQuota", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Msg", ",", "e", ".", "Usage", ",", "e", ".", "Limit", ",", "e", ".", "Throttled", ")", "\n", "}" ]
// Error implements the Error interface for ServerErrorOverQuota.
[ "Error", "implements", "the", "Error", "interface", "for", "ServerErrorOverQuota", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/server_errors.go#L134-L138
159,854
keybase/client
go/kbfs/kbfsblock/server_errors.go
ToStatus
func (e ServerErrorBlockNonExistent) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorBlockNonExistent s.Name = "BLOCK_NONEXISTENT" s.Desc = e.Msg return }
go
func (e ServerErrorBlockNonExistent) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorBlockNonExistent s.Name = "BLOCK_NONEXISTENT" s.Desc = e.Msg return }
[ "func", "(", "e", "ServerErrorBlockNonExistent", ")", "ToStatus", "(", ")", "(", "s", "keybase1", ".", "Status", ")", "{", "s", ".", "Code", "=", "StatusCodeServerErrorBlockNonExistent", "\n", "s", ".", "Name", "=", "\"", "\"", "\n", "s", ".", "Desc", "=...
// ToStatus implements the ExportableError interface for ServerErrorBlockNonExistent
[ "ToStatus", "implements", "the", "ExportableError", "interface", "for", "ServerErrorBlockNonExistent" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/server_errors.go#L146-L151
159,855
keybase/client
go/kbfs/kbfsblock/server_errors.go
ToStatus
func (e ServerErrorBlockDeleted) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorBlockDeleted s.Name = "BLOCK_DELETED" s.Desc = e.Msg return }
go
func (e ServerErrorBlockDeleted) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorBlockDeleted s.Name = "BLOCK_DELETED" s.Desc = e.Msg return }
[ "func", "(", "e", "ServerErrorBlockDeleted", ")", "ToStatus", "(", ")", "(", "s", "keybase1", ".", "Status", ")", "{", "s", ".", "Code", "=", "StatusCodeServerErrorBlockDeleted", "\n", "s", ".", "Name", "=", "\"", "\"", "\n", "s", ".", "Desc", "=", "e"...
// ToStatus implements the ExportableError interface for ServerErrorBlockDeleted
[ "ToStatus", "implements", "the", "ExportableError", "interface", "for", "ServerErrorBlockDeleted" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/server_errors.go#L188-L193
159,856
keybase/client
go/kbfs/kbfsblock/server_errors.go
ToStatus
func (e ServerErrorNonceNonExistent) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorNonceNonExistent s.Name = "BLOCK_NONCENONEXISTENT" s.Desc = e.Msg return }
go
func (e ServerErrorNonceNonExistent) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorNonceNonExistent s.Name = "BLOCK_NONCENONEXISTENT" s.Desc = e.Msg return }
[ "func", "(", "e", "ServerErrorNonceNonExistent", ")", "ToStatus", "(", ")", "(", "s", "keybase1", ".", "Status", ")", "{", "s", ".", "Code", "=", "StatusCodeServerErrorNonceNonExistent", "\n", "s", ".", "Name", "=", "\"", "\"", "\n", "s", ".", "Desc", "=...
// ToStatus implements the ExportableError interface for ServerErrorNonceNonExistent
[ "ToStatus", "implements", "the", "ExportableError", "interface", "for", "ServerErrorNonceNonExistent" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/server_errors.go#L230-L235
159,857
keybase/client
go/kbfs/kbfsblock/server_errors.go
ToStatus
func (e ServerErrorMaxRefExceeded) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorMaxRefExceeded s.Name = "BLOCK_MAXREFEXCEEDED" s.Desc = e.Msg return }
go
func (e ServerErrorMaxRefExceeded) ToStatus() (s keybase1.Status) { s.Code = StatusCodeServerErrorMaxRefExceeded s.Name = "BLOCK_MAXREFEXCEEDED" s.Desc = e.Msg return }
[ "func", "(", "e", "ServerErrorMaxRefExceeded", ")", "ToStatus", "(", ")", "(", "s", "keybase1", ".", "Status", ")", "{", "s", ".", "Code", "=", "StatusCodeServerErrorMaxRefExceeded", "\n", "s", ".", "Name", "=", "\"", "\"", "\n", "s", ".", "Desc", "=", ...
// ToStatus implements the ExportableError interface for ServerErrorMaxRefExceeded
[ "ToStatus", "implements", "the", "ExportableError", "interface", "for", "ServerErrorMaxRefExceeded" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/server_errors.go#L251-L256
159,858
keybase/client
go/kbfs/kbfsblock/server_errors.go
IsThrottleError
func IsThrottleError(err error) bool { if _, ok := err.(ServerErrorThrottle); ok { return true } if quotaErr, ok := err.(ServerErrorOverQuota); ok && quotaErr.Throttled { return true } return false }
go
func IsThrottleError(err error) bool { if _, ok := err.(ServerErrorThrottle); ok { return true } if quotaErr, ok := err.(ServerErrorOverQuota); ok && quotaErr.Throttled { return true } return false }
[ "func", "IsThrottleError", "(", "err", "error", ")", "bool", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "ServerErrorThrottle", ")", ";", "ok", "{", "return", "true", "\n", "}", "\n", "if", "quotaErr", ",", "ok", ":=", "err", ".", "(", "Serve...
// IsThrottleError returns whether or not the given error signals // throttling.
[ "IsThrottleError", "returns", "whether", "or", "not", "the", "given", "error", "signals", "throttling", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/server_errors.go#L367-L375
159,859
keybase/client
go/engine/selfprovision.go
NewSelfProvisionEngine
func NewSelfProvisionEngine(g *libkb.GlobalContext, deviceName string) *SelfProvisionEngine { return &SelfProvisionEngine{ Contextified: libkb.NewContextified(g), DeviceName: deviceName, } }
go
func NewSelfProvisionEngine(g *libkb.GlobalContext, deviceName string) *SelfProvisionEngine { return &SelfProvisionEngine{ Contextified: libkb.NewContextified(g), DeviceName: deviceName, } }
[ "func", "NewSelfProvisionEngine", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "deviceName", "string", ")", "*", "SelfProvisionEngine", "{", "return", "&", "SelfProvisionEngine", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ","...
// If a device is cloned, we can provision a new device from the current device // to get out of the cloned state.
[ "If", "a", "device", "is", "cloned", "we", "can", "provision", "a", "new", "device", "from", "the", "current", "device", "to", "get", "out", "of", "the", "cloned", "state", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/selfprovision.go#L24-L29
159,860
keybase/client
go/engine/selfprovision.go
makeDeviceKeysWithSigner
func (e *SelfProvisionEngine) makeDeviceKeysWithSigner(m libkb.MetaContext, signer libkb.GenericKey) error { if err := e.ensureLKSec(m); err != nil { return err } _, _, deviceType, err := m.G().GetUPAKLoader().LookupUsernameAndDevice(m.Ctx(), e.User.GetUID(), e.G().ActiveDevice.DeviceID()) if err != nil { return err } args := &DeviceWrapArgs{ Me: e.User, DeviceName: e.DeviceName, DeviceType: deviceType, Lks: e.lks, IsEldest: false, // just to be explicit IsSelfProvision: true, PerUserKeyring: e.perUserKeyring, EldestKID: e.User.GetEldestKID(), Signer: signer, EkReboxer: e.ekReboxer, } e.deviceWrapEng = NewDeviceWrap(m.G(), args) return RunEngine2(m, e.deviceWrapEng) }
go
func (e *SelfProvisionEngine) makeDeviceKeysWithSigner(m libkb.MetaContext, signer libkb.GenericKey) error { if err := e.ensureLKSec(m); err != nil { return err } _, _, deviceType, err := m.G().GetUPAKLoader().LookupUsernameAndDevice(m.Ctx(), e.User.GetUID(), e.G().ActiveDevice.DeviceID()) if err != nil { return err } args := &DeviceWrapArgs{ Me: e.User, DeviceName: e.DeviceName, DeviceType: deviceType, Lks: e.lks, IsEldest: false, // just to be explicit IsSelfProvision: true, PerUserKeyring: e.perUserKeyring, EldestKID: e.User.GetEldestKID(), Signer: signer, EkReboxer: e.ekReboxer, } e.deviceWrapEng = NewDeviceWrap(m.G(), args) return RunEngine2(m, e.deviceWrapEng) }
[ "func", "(", "e", "*", "SelfProvisionEngine", ")", "makeDeviceKeysWithSigner", "(", "m", "libkb", ".", "MetaContext", ",", "signer", "libkb", ".", "GenericKey", ")", "error", "{", "if", "err", ":=", "e", ".", "ensureLKSec", "(", "m", ")", ";", "err", "!=...
// makeDeviceKeysWithSigner creates device keys given a signing key.
[ "makeDeviceKeysWithSigner", "creates", "device", "keys", "given", "a", "signing", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/selfprovision.go#L183-L208
159,861
keybase/client
go/engine/selfprovision.go
ppStream
func (e *SelfProvisionEngine) ppStream(m libkb.MetaContext) (*libkb.PassphraseStream, error) { if m.LoginContext() == nil { return nil, errors.New("SelfProvisionEngine: ppStream() -> nil ctx.LoginContext") } cached := m.LoginContext().PassphraseStreamCache() if cached == nil { return nil, errors.New("SelfProvisionEngine: ppStream() -> nil PassphraseStreamCache") } return cached.PassphraseStream(), nil }
go
func (e *SelfProvisionEngine) ppStream(m libkb.MetaContext) (*libkb.PassphraseStream, error) { if m.LoginContext() == nil { return nil, errors.New("SelfProvisionEngine: ppStream() -> nil ctx.LoginContext") } cached := m.LoginContext().PassphraseStreamCache() if cached == nil { return nil, errors.New("SelfProvisionEngine: ppStream() -> nil PassphraseStreamCache") } return cached.PassphraseStream(), nil }
[ "func", "(", "e", "*", "SelfProvisionEngine", ")", "ppStream", "(", "m", "libkb", ".", "MetaContext", ")", "(", "*", "libkb", ".", "PassphraseStream", ",", "error", ")", "{", "if", "m", ".", "LoginContext", "(", ")", "==", "nil", "{", "return", "nil", ...
// copied from loginProvision // ppStream gets the passphrase stream from the cache
[ "copied", "from", "loginProvision", "ppStream", "gets", "the", "passphrase", "stream", "from", "the", "cache" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/selfprovision.go#L228-L237
159,862
keybase/client
go/engine/engine.go
isLoggedInWithUIDAndError
func isLoggedInWithUIDAndError(m libkb.MetaContext) (ret bool, uid keybase1.UID, err error) { ret, uid, err = libkb.BootstrapActiveDeviceWithMetaContext(m) return ret, uid, err }
go
func isLoggedInWithUIDAndError(m libkb.MetaContext) (ret bool, uid keybase1.UID, err error) { ret, uid, err = libkb.BootstrapActiveDeviceWithMetaContext(m) return ret, uid, err }
[ "func", "isLoggedInWithUIDAndError", "(", "m", "libkb", ".", "MetaContext", ")", "(", "ret", "bool", ",", "uid", "keybase1", ".", "UID", ",", "err", "error", ")", "{", "ret", ",", "uid", ",", "err", "=", "libkb", ".", "BootstrapActiveDeviceWithMetaContext", ...
// isLoggedInWithUIDAndError conveys if the user is in a logged-in state or not. // If this function returns `true`, it's because the user is logged in, // is on a provisioned device, and has an unlocked device key, If this // function returns `false`, it's because either no one has ever logged onto // this device, or someone has, and then clicked `logout`. If the return // value is `false`, and `err` is `nil`, then the service is in one of // those expected "logged out" states. If the return value is `false` // and `err` is non-`nil`, then something went wrong, and the app is in some // sort of unexpected state. If `ret` is `true`, then `uid` will convey // which user is logged in. // // Under the hood, IsLoggedIn is going through the BootstrapActiveDevice // flow and therefore will try its best to unlocked locked keys if it can // without user interaction.
[ "isLoggedInWithUIDAndError", "conveys", "if", "the", "user", "is", "in", "a", "logged", "-", "in", "state", "or", "not", ".", "If", "this", "function", "returns", "true", "it", "s", "because", "the", "user", "is", "logged", "in", "is", "on", "a", "provis...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/engine.go#L49-L52
159,863
keybase/client
go/libkb/client.go
genClientConfigForInternalAPI
func genClientConfigForInternalAPI(g *GlobalContext) (*ClientConfig, error) { e := g.Env serverURI := e.GetServerURI() if e.GetTorMode().Enabled() { serverURI = e.GetTorHiddenAddress() } if serverURI == "" { err := fmt.Errorf("Cannot find a server URL") return nil, err } url, err := url.Parse(serverURI) if err != nil { return nil, err } if url.Scheme == "" { return nil, fmt.Errorf("Server URL missing Scheme") } if url.Host == "" { return nil, fmt.Errorf("Server URL missing Host") } useTLS := (url.Scheme == "https") host, port, e2 := SplitHost(url.Host) if e2 != nil { return nil, e2 } var rootCAs *x509.CertPool if rawCA := e.GetBundledCA(host); len(rawCA) > 0 { rootCAs, err = ParseCA(rawCA) if err != nil { err = fmt.Errorf("In parsing CAs for %s: %s", host, err) return nil, err } g.Log.Debug(fmt.Sprintf("Using special root CA for %s: %s", host, ShortCA(rawCA))) } // If we're using proxies, they might have their own CAs. if rootCAs, err = GetProxyCAs(rootCAs, e.config); err != nil { return nil, err } ret := &ClientConfig{host, port, useTLS, url, rootCAs, url.Path, true, e.GetAPITimeout()} return ret, nil }
go
func genClientConfigForInternalAPI(g *GlobalContext) (*ClientConfig, error) { e := g.Env serverURI := e.GetServerURI() if e.GetTorMode().Enabled() { serverURI = e.GetTorHiddenAddress() } if serverURI == "" { err := fmt.Errorf("Cannot find a server URL") return nil, err } url, err := url.Parse(serverURI) if err != nil { return nil, err } if url.Scheme == "" { return nil, fmt.Errorf("Server URL missing Scheme") } if url.Host == "" { return nil, fmt.Errorf("Server URL missing Host") } useTLS := (url.Scheme == "https") host, port, e2 := SplitHost(url.Host) if e2 != nil { return nil, e2 } var rootCAs *x509.CertPool if rawCA := e.GetBundledCA(host); len(rawCA) > 0 { rootCAs, err = ParseCA(rawCA) if err != nil { err = fmt.Errorf("In parsing CAs for %s: %s", host, err) return nil, err } g.Log.Debug(fmt.Sprintf("Using special root CA for %s: %s", host, ShortCA(rawCA))) } // If we're using proxies, they might have their own CAs. if rootCAs, err = GetProxyCAs(rootCAs, e.config); err != nil { return nil, err } ret := &ClientConfig{host, port, useTLS, url, rootCAs, url.Path, true, e.GetAPITimeout()} return ret, nil }
[ "func", "genClientConfigForInternalAPI", "(", "g", "*", "GlobalContext", ")", "(", "*", "ClientConfig", ",", "error", ")", "{", "e", ":=", "g", ".", "Env", "\n", "serverURI", ":=", "e", ".", "GetServerURI", "(", ")", "\n\n", "if", "e", ".", "GetTorMode",...
// GenClientConfigForInternalAPI pulls the information out of the environment configuration, // and build a Client config that will be used in all API server // requests
[ "GenClientConfigForInternalAPI", "pulls", "the", "information", "out", "of", "the", "environment", "configuration", "and", "build", "a", "Client", "config", "that", "will", "be", "used", "in", "all", "API", "server", "requests" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/client.go#L83-L131
159,864
keybase/client
go/kbfs/libpages/server.go
allowDomain
func (s *Server) allowDomain(ctx context.Context, host string) (err error) { host = strings.ToLower(strings.TrimSpace(host)) if err = s.config.checkDomainLists(host); err != nil { return err } // DoS protection: look up kbp TXT record before attempting ACME cert // issuance, and only allow those that have DNS records configured. This is // in case someone keeps sending us TLS handshakes with random SNIs, // causing us to be rate-limited by the ACME server. // // TODO: cache the parsed root somewhere so we don't end up doing it twice // for each connection. if _, err = s.rootLoader.LoadRoot(host); err != nil { return err } return nil }
go
func (s *Server) allowDomain(ctx context.Context, host string) (err error) { host = strings.ToLower(strings.TrimSpace(host)) if err = s.config.checkDomainLists(host); err != nil { return err } // DoS protection: look up kbp TXT record before attempting ACME cert // issuance, and only allow those that have DNS records configured. This is // in case someone keeps sending us TLS handshakes with random SNIs, // causing us to be rate-limited by the ACME server. // // TODO: cache the parsed root somewhere so we don't end up doing it twice // for each connection. if _, err = s.rootLoader.LoadRoot(host); err != nil { return err } return nil }
[ "func", "(", "s", "*", "Server", ")", "allowDomain", "(", "ctx", "context", ".", "Context", ",", "host", "string", ")", "(", "err", "error", ")", "{", "host", "=", "strings", ".", "ToLower", "(", "strings", ".", "TrimSpace", "(", "host", ")", ")", ...
// allowDomain is used to determine whether a given domain should be // served. It's also used as a HostPolicy in autocert package.
[ "allowDomain", "is", "used", "to", "determine", "whether", "a", "given", "domain", "should", "be", "served", ".", "It", "s", "also", "used", "as", "a", "HostPolicy", "in", "autocert", "package", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/server.go#L435-L453
159,865
keybase/client
go/kbfs/libpages/server.go
ListenAndServe
func ListenAndServe(ctx context.Context, config *ServerConfig, kbfsConfig libkbfs.Config) (err error) { ctx, cancel := context.WithCancel(ctx) defer cancel() libmime.Patch(additionalMimeTypes) server := &Server{ config: config, kbfsConfig: kbfsConfig, rootLoader: DNSRootLoader{log: config.Logger}, } server.siteCache, err = lru.NewWithEvict(fsCacheSize, server.siteCacheEvict) if err != nil { return err } manager, err := makeACMEManager( config.UseStaging, config.UseDiskCertCache, server.allowDomain) if err != nil { return err } httpsServer := http.Server{ Handler: server, ReadHeaderTimeout: httpReadHeaderTimeout, IdleTimeout: httpIdleTimeout, } httpServer := http.Server{ Addr: ":80", // Enable http-01 by calling the HTTPHandler method, and set the // fallback HTTP handler to nil. As described in the autocert doc // (https://github.com/golang/crypto/blob/13931e22f9e72ea58bb73048bc752b48c6d4d4ac/acme/autocert/autocert.go#L248-L251), // this means for requests not for ACME domain verification, a default // fallback handler is used, which redirects all HTTP traffic using GET // and HEAD to HTTPS using 302 Found, and responds with 400 Bad Request // for requests with other methods. Handler: manager.HTTPHandler(nil), ReadHeaderTimeout: httpReadHeaderTimeout, IdleTimeout: httpIdleTimeout, } go func() { <-ctx.Done() shutdownCtx, cancel := context.WithTimeout( context.Background(), gracefulShutdownTimeout) defer cancel() httpsServer.Shutdown(shutdownCtx) httpServer.Shutdown(shutdownCtx) }() go func() { err := httpServer.ListenAndServe() if err != nil { config.Logger.Error("http.ListenAndServe:80", zap.Error(err)) } }() return httpsServer.Serve(manager.Listener()) }
go
func ListenAndServe(ctx context.Context, config *ServerConfig, kbfsConfig libkbfs.Config) (err error) { ctx, cancel := context.WithCancel(ctx) defer cancel() libmime.Patch(additionalMimeTypes) server := &Server{ config: config, kbfsConfig: kbfsConfig, rootLoader: DNSRootLoader{log: config.Logger}, } server.siteCache, err = lru.NewWithEvict(fsCacheSize, server.siteCacheEvict) if err != nil { return err } manager, err := makeACMEManager( config.UseStaging, config.UseDiskCertCache, server.allowDomain) if err != nil { return err } httpsServer := http.Server{ Handler: server, ReadHeaderTimeout: httpReadHeaderTimeout, IdleTimeout: httpIdleTimeout, } httpServer := http.Server{ Addr: ":80", // Enable http-01 by calling the HTTPHandler method, and set the // fallback HTTP handler to nil. As described in the autocert doc // (https://github.com/golang/crypto/blob/13931e22f9e72ea58bb73048bc752b48c6d4d4ac/acme/autocert/autocert.go#L248-L251), // this means for requests not for ACME domain verification, a default // fallback handler is used, which redirects all HTTP traffic using GET // and HEAD to HTTPS using 302 Found, and responds with 400 Bad Request // for requests with other methods. Handler: manager.HTTPHandler(nil), ReadHeaderTimeout: httpReadHeaderTimeout, IdleTimeout: httpIdleTimeout, } go func() { <-ctx.Done() shutdownCtx, cancel := context.WithTimeout( context.Background(), gracefulShutdownTimeout) defer cancel() httpsServer.Shutdown(shutdownCtx) httpServer.Shutdown(shutdownCtx) }() go func() { err := httpServer.ListenAndServe() if err != nil { config.Logger.Error("http.ListenAndServe:80", zap.Error(err)) } }() return httpsServer.Serve(manager.Listener()) }
[ "func", "ListenAndServe", "(", "ctx", "context", ".", "Context", ",", "config", "*", "ServerConfig", ",", "kbfsConfig", "libkbfs", ".", "Config", ")", "(", "err", "error", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")...
// ListenAndServe listens on 443 and 80 ports of all addresses, and serve // Keybase Pages based on config and kbfsConfig. HTTPs setup is handled with // ACME.
[ "ListenAndServe", "listens", "on", "443", "and", "80", "ports", "of", "all", "addresses", "and", "serve", "Keybase", "Pages", "based", "on", "config", "and", "kbfsConfig", ".", "HTTPs", "setup", "is", "handled", "with", "ACME", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/server.go#L500-L560
159,866
keybase/client
go/kbfs/libpages/stats.go
ReportServedRequest
func (m multiStatReporter) ReportServedRequest( r *ServedRequestInfo) { for _, reporter := range m { reporter.ReportServedRequest(r) } }
go
func (m multiStatReporter) ReportServedRequest( r *ServedRequestInfo) { for _, reporter := range m { reporter.ReportServedRequest(r) } }
[ "func", "(", "m", "multiStatReporter", ")", "ReportServedRequest", "(", "r", "*", "ServedRequestInfo", ")", "{", "for", "_", ",", "reporter", ":=", "range", "m", "{", "reporter", ".", "ReportServedRequest", "(", "r", ")", "\n", "}", "\n", "}" ]
// ReportServedRequest implements the StatsReporter interface.
[ "ReportServedRequest", "implements", "the", "StatsReporter", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/stats.go#L85-L90
159,867
keybase/client
go/kbfs/libpages/stats.go
NewFileBasedActivityStatsStorer
func NewFileBasedActivityStatsStorer( rootPath string, logger *zap.Logger) (ActivityStatsStorer, error) { err := os.MkdirAll(filepath.Join(rootPath, dirnameTlfStamps), os.ModeDir|0700) if err != nil { return nil, err } err = os.MkdirAll(filepath.Join(rootPath, dirnameHostStamps), os.ModeDir|0700) if err != nil { return nil, err } s := &fileBasedActivityStatsStorer{ root: rootPath, logger: logger, ch: make(chan activity, fbassChSize), } go s.processLoop() return s, nil }
go
func NewFileBasedActivityStatsStorer( rootPath string, logger *zap.Logger) (ActivityStatsStorer, error) { err := os.MkdirAll(filepath.Join(rootPath, dirnameTlfStamps), os.ModeDir|0700) if err != nil { return nil, err } err = os.MkdirAll(filepath.Join(rootPath, dirnameHostStamps), os.ModeDir|0700) if err != nil { return nil, err } s := &fileBasedActivityStatsStorer{ root: rootPath, logger: logger, ch: make(chan activity, fbassChSize), } go s.processLoop() return s, nil }
[ "func", "NewFileBasedActivityStatsStorer", "(", "rootPath", "string", ",", "logger", "*", "zap", ".", "Logger", ")", "(", "ActivityStatsStorer", ",", "error", ")", "{", "err", ":=", "os", ".", "MkdirAll", "(", "filepath", ".", "Join", "(", "rootPath", ",", ...
// NewFileBasedActivityStatsStorer creates an ActivityStatsStorer that stores // activities on a local filesystem. // // NOTE that this is meant to be for development and // testing only and does not scale well.
[ "NewFileBasedActivityStatsStorer", "creates", "an", "ActivityStatsStorer", "that", "stores", "activities", "on", "a", "local", "filesystem", ".", "NOTE", "that", "this", "is", "meant", "to", "be", "for", "development", "and", "testing", "only", "and", "does", "not...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/stats.go#L161-L178
159,868
keybase/client
go/kbfs/libpages/stats.go
RecordActives
func (s *fileBasedActivityStatsStorer) RecordActives(tlf tlf.ID, host string) { s.ch <- activity{tlfID: tlf, host: host} }
go
func (s *fileBasedActivityStatsStorer) RecordActives(tlf tlf.ID, host string) { s.ch <- activity{tlfID: tlf, host: host} }
[ "func", "(", "s", "*", "fileBasedActivityStatsStorer", ")", "RecordActives", "(", "tlf", "tlf", ".", "ID", ",", "host", "string", ")", "{", "s", ".", "ch", "<-", "activity", "{", "tlfID", ":", "tlf", ",", "host", ":", "host", "}", "\n", "}" ]
// RecordActives implement the ActivityStatsStorer interface.
[ "RecordActives", "implement", "the", "ActivityStatsStorer", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/stats.go#L181-L183
159,869
keybase/client
go/kbfs/libpages/stats.go
GetActivesGetter
func (s *fileBasedActivityStatsStorer) GetActivesGetter() ( getter ActivesGetter, err error) { tlfStamps, err := ioutil.ReadDir(filepath.Join(s.root, dirnameTlfStamps)) if err != nil { return nil, err } hostStamps, err := ioutil.ReadDir(filepath.Join(s.root, dirnameHostStamps)) if err != nil { return nil, err } return &fileinfoActivesGetter{ tlfs: tlfStamps, hosts: hostStamps, }, nil }
go
func (s *fileBasedActivityStatsStorer) GetActivesGetter() ( getter ActivesGetter, err error) { tlfStamps, err := ioutil.ReadDir(filepath.Join(s.root, dirnameTlfStamps)) if err != nil { return nil, err } hostStamps, err := ioutil.ReadDir(filepath.Join(s.root, dirnameHostStamps)) if err != nil { return nil, err } return &fileinfoActivesGetter{ tlfs: tlfStamps, hosts: hostStamps, }, nil }
[ "func", "(", "s", "*", "fileBasedActivityStatsStorer", ")", "GetActivesGetter", "(", ")", "(", "getter", "ActivesGetter", ",", "err", "error", ")", "{", "tlfStamps", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "filepath", ".", "Join", "(", "s", ".", ...
// GetActiveTlfs implement the ActivityStatsStorer interface.
[ "GetActiveTlfs", "implement", "the", "ActivityStatsStorer", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/stats.go#L216-L230
159,870
keybase/client
go/kbfs/libfs/time_equal.go
TimeEqual
func TimeEqual(a, b time.Time) bool { if runtime.GOOS == "darwin" { a = a.Truncate(1 * time.Second) b = b.Truncate(1 * time.Second) } return a.Equal(b) }
go
func TimeEqual(a, b time.Time) bool { if runtime.GOOS == "darwin" { a = a.Truncate(1 * time.Second) b = b.Truncate(1 * time.Second) } return a.Equal(b) }
[ "func", "TimeEqual", "(", "a", ",", "b", "time", ".", "Time", ")", "bool", "{", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "a", "=", "a", ".", "Truncate", "(", "1", "*", "time", ".", "Second", ")", "\n", "b", "=", "b", ".", "Truncat...
// TimeEqual compares two filesystem-related timestamps. // // On platforms that don't use nanosecond-accurate timestamps in their // filesystem APIs, it truncates the timestamps to make them // comparable.
[ "TimeEqual", "compares", "two", "filesystem", "-", "related", "timestamps", ".", "On", "platforms", "that", "don", "t", "use", "nanosecond", "-", "accurate", "timestamps", "in", "their", "filesystem", "APIs", "it", "truncates", "the", "timestamps", "to", "make",...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/time_equal.go#L17-L23
159,871
keybase/client
go/teams/proofs.go
AddNeededHappensBeforeProof
func (p *proofSetT) AddNeededHappensBeforeProof(ctx context.Context, a proofTerm, b proofTerm, reason string) { var action string defer func() { if action != "discard-easy" && !ShouldSuppressLogging(ctx) { p.G().Log.CDebugf(ctx, "proofSet add(%v --> %v) [%v] '%v'", a.shortForm(), b.shortForm(), action, reason) } }() idx := newProofIndex(a.leafID, b.leafID) if idx.a.Equal(idx.b) { // If both terms are on the same chain if a.lessThanOrEqual(b) { // The proof is self-evident. // Discard it. action = "discard-easy" return } // The proof is self-evident FALSE. // Add it and return immediately so the rest of this function doesn't have to trip over it. // It should be failed later by the checker. action = "added-easy-false" p.proofs[idx] = append(p.proofs[idx], proof{a, b, reason}) return } set := p.proofs[idx] for i := len(set) - 1; i >= 0; i-- { existing := set[i] if existing.a.lessThanOrEqual(a) && b.lessThanOrEqual(existing.b) { // If the new proof is surrounded by the old proof. existing.a = existing.a.max(a) existing.b = existing.b.min(b) set[i] = existing action = "collapsed" return } if existing.a.equal(a) && existing.b.lessThanOrEqual(b) { // If the new proof is the same on the left and weaker on the right. // Discard the new proof, as it is implied by the existing one. action = "discard-weak" return } } action = "added" p.proofs[idx] = append(p.proofs[idx], proof{a, b, reason}) return }
go
func (p *proofSetT) AddNeededHappensBeforeProof(ctx context.Context, a proofTerm, b proofTerm, reason string) { var action string defer func() { if action != "discard-easy" && !ShouldSuppressLogging(ctx) { p.G().Log.CDebugf(ctx, "proofSet add(%v --> %v) [%v] '%v'", a.shortForm(), b.shortForm(), action, reason) } }() idx := newProofIndex(a.leafID, b.leafID) if idx.a.Equal(idx.b) { // If both terms are on the same chain if a.lessThanOrEqual(b) { // The proof is self-evident. // Discard it. action = "discard-easy" return } // The proof is self-evident FALSE. // Add it and return immediately so the rest of this function doesn't have to trip over it. // It should be failed later by the checker. action = "added-easy-false" p.proofs[idx] = append(p.proofs[idx], proof{a, b, reason}) return } set := p.proofs[idx] for i := len(set) - 1; i >= 0; i-- { existing := set[i] if existing.a.lessThanOrEqual(a) && b.lessThanOrEqual(existing.b) { // If the new proof is surrounded by the old proof. existing.a = existing.a.max(a) existing.b = existing.b.min(b) set[i] = existing action = "collapsed" return } if existing.a.equal(a) && existing.b.lessThanOrEqual(b) { // If the new proof is the same on the left and weaker on the right. // Discard the new proof, as it is implied by the existing one. action = "discard-weak" return } } action = "added" p.proofs[idx] = append(p.proofs[idx], proof{a, b, reason}) return }
[ "func", "(", "p", "*", "proofSetT", ")", "AddNeededHappensBeforeProof", "(", "ctx", "context", ".", "Context", ",", "a", "proofTerm", ",", "b", "proofTerm", ",", "reason", "string", ")", "{", "var", "action", "string", "\n", "defer", "func", "(", ")", "{...
// AddNeededHappensBeforeProof adds a new needed proof to the proof set. The // proof is that `a` happened before `b`. If there are other proofs in the proof set // that prove the same thing, then we can tighten those proofs with a and b if // it makes sense. For instance, if there is an existing proof that c<d, // but we know that c<a and b<d, then it suffices to replace c<d with a<b as // the needed proof. Each proof in the proof set in the end will correspond // to a merkle tree lookup, so it makes sense to be stingy. Return the modified // proof set with the new proofs needed, but the original argument p will // be mutated.
[ "AddNeededHappensBeforeProof", "adds", "a", "new", "needed", "proof", "to", "the", "proof", "set", ".", "The", "proof", "is", "that", "a", "happened", "before", "b", ".", "If", "there", "are", "other", "proofs", "in", "the", "proof", "set", "that", "prove"...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/proofs.go#L112-L160
159,872
keybase/client
go/teams/proofs.go
SetTeamLinkMap
func (p *proofSetT) SetTeamLinkMap(ctx context.Context, teamID keybase1.TeamID, linkMap linkMapT) { p.teamLinkMaps[teamID] = linkMap }
go
func (p *proofSetT) SetTeamLinkMap(ctx context.Context, teamID keybase1.TeamID, linkMap linkMapT) { p.teamLinkMaps[teamID] = linkMap }
[ "func", "(", "p", "*", "proofSetT", ")", "SetTeamLinkMap", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ",", "linkMap", "linkMapT", ")", "{", "p", ".", "teamLinkMaps", "[", "teamID", "]", "=", "linkMap", "\n", "}" ]
// Set the latest link map for the team
[ "Set", "the", "latest", "link", "map", "for", "the", "team" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/proofs.go#L163-L165
159,873
keybase/client
go/teams/proofs.go
lookupMerkleTreeChain
func (p proof) lookupMerkleTreeChain(ctx context.Context, world LoaderContext) (ret *libkb.MerkleTriple, err error) { return world.merkleLookupTripleAtHashMeta(ctx, p.a.isPublic(), p.a.leafID, p.b.sigMeta.PrevMerkleRootSigned.HashMeta) }
go
func (p proof) lookupMerkleTreeChain(ctx context.Context, world LoaderContext) (ret *libkb.MerkleTriple, err error) { return world.merkleLookupTripleAtHashMeta(ctx, p.a.isPublic(), p.a.leafID, p.b.sigMeta.PrevMerkleRootSigned.HashMeta) }
[ "func", "(", "p", "proof", ")", "lookupMerkleTreeChain", "(", "ctx", "context", ".", "Context", ",", "world", "LoaderContext", ")", "(", "ret", "*", "libkb", ".", "MerkleTriple", ",", "err", "error", ")", "{", "return", "world", ".", "merkleLookupTripleAtHas...
// lookupMerkleTreeChain loads the path up to the merkle tree and back down that corresponds // to this proof. It will contact the API server. Returns the sigchain tail on success.
[ "lookupMerkleTreeChain", "loads", "the", "path", "up", "to", "the", "merkle", "tree", "and", "back", "down", "that", "corresponds", "to", "this", "proof", ".", "It", "will", "contact", "the", "API", "server", ".", "Returns", "the", "sigchain", "tail", "on", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/proofs.go#L205-L207
159,874
keybase/client
go/teams/proofs.go
check
func (p proof) check(ctx context.Context, g *libkb.GlobalContext, world LoaderContext, proofSet *proofSetT) (err error) { defer func() { g.Log.CDebugf(ctx, "TeamLoader proofSet check1(%v) -> %v", p.shortForm(), err) }() triple, err := p.lookupMerkleTreeChain(ctx, world) if err != nil { return err } // laterSeqno is the tail of chain A at the time when B was signed // earlierSeqno is the tail of chain A at the time when A was signed laterSeqno := triple.Seqno earlierSeqno := p.a.sigMeta.SigChainLocation.Seqno if earlierSeqno > laterSeqno { return NewProofError(p, fmt.Sprintf("seqno %d > %d", earlierSeqno, laterSeqno)) } linkID, err := p.findLink(ctx, g, world, p.a.leafID, laterSeqno, p.a.linkMap, proofSet) if err != nil { return err } if !triple.LinkID.Export().Eq(linkID) { g.Log.CDebugf(ctx, "proof error: %s", spew.Sdump(p)) return NewProofError(p, fmt.Sprintf("hash mismatch: %s != %s", triple.LinkID, linkID)) } return nil }
go
func (p proof) check(ctx context.Context, g *libkb.GlobalContext, world LoaderContext, proofSet *proofSetT) (err error) { defer func() { g.Log.CDebugf(ctx, "TeamLoader proofSet check1(%v) -> %v", p.shortForm(), err) }() triple, err := p.lookupMerkleTreeChain(ctx, world) if err != nil { return err } // laterSeqno is the tail of chain A at the time when B was signed // earlierSeqno is the tail of chain A at the time when A was signed laterSeqno := triple.Seqno earlierSeqno := p.a.sigMeta.SigChainLocation.Seqno if earlierSeqno > laterSeqno { return NewProofError(p, fmt.Sprintf("seqno %d > %d", earlierSeqno, laterSeqno)) } linkID, err := p.findLink(ctx, g, world, p.a.leafID, laterSeqno, p.a.linkMap, proofSet) if err != nil { return err } if !triple.LinkID.Export().Eq(linkID) { g.Log.CDebugf(ctx, "proof error: %s", spew.Sdump(p)) return NewProofError(p, fmt.Sprintf("hash mismatch: %s != %s", triple.LinkID, linkID)) } return nil }
[ "func", "(", "p", "proof", ")", "check", "(", "ctx", "context", ".", "Context", ",", "g", "*", "libkb", ".", "GlobalContext", ",", "world", "LoaderContext", ",", "proofSet", "*", "proofSetT", ")", "(", "err", "error", ")", "{", "defer", "func", "(", ...
// check a single proof. Call to the merkle API endpoint, and then ensure that the // data that comes back fits the proof and previously checked sigchain links.
[ "check", "a", "single", "proof", ".", "Call", "to", "the", "merkle", "API", "endpoint", "and", "then", "ensure", "that", "the", "data", "that", "comes", "back", "fits", "the", "proof", "and", "previously", "checked", "sigchain", "links", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/proofs.go#L211-L239
159,875
keybase/client
go/teams/proofs.go
findLink
func (p proof) findLink(ctx context.Context, g *libkb.GlobalContext, world LoaderContext, leafID keybase1.UserOrTeamID, seqno keybase1.Seqno, firstLinkMap linkMapT, proofSet *proofSetT) (linkID keybase1.LinkID, err error) { lm := firstLinkMap if leafID.IsTeamOrSubteam() { // Pull in the latest link map, instead of the one from the proof object. tid := leafID.AsTeamOrBust() lm2, ok := proofSet.teamLinkMaps[tid] if ok { lm = lm2 } } if lm == nil { return linkID, NewProofError(p, "nil link map") } linkID, ok := lm[seqno] if ok { return linkID, nil } // We loaded this user originally to get a sigchain as fresh as a certain key provisioning. // In this scenario, we might need a fresher version, so force a poll all the way through // the server, and then try again. If we fail the second time, we a force repoll, then // we're toast. if leafID.IsUser() { g.Log.CDebugf(ctx, "proof#findLink: missed load for %s at %d; trying a force repoll", leafID.String(), seqno) lm, err := world.forceLinkMapRefreshForUser(ctx, leafID.AsUserOrBust()) if err != nil { return linkID, err } linkID, ok = lm[seqno] } if !ok { return linkID, NewProofError(p, fmt.Sprintf("no linkID for seqno %d", seqno)) } return linkID, nil }
go
func (p proof) findLink(ctx context.Context, g *libkb.GlobalContext, world LoaderContext, leafID keybase1.UserOrTeamID, seqno keybase1.Seqno, firstLinkMap linkMapT, proofSet *proofSetT) (linkID keybase1.LinkID, err error) { lm := firstLinkMap if leafID.IsTeamOrSubteam() { // Pull in the latest link map, instead of the one from the proof object. tid := leafID.AsTeamOrBust() lm2, ok := proofSet.teamLinkMaps[tid] if ok { lm = lm2 } } if lm == nil { return linkID, NewProofError(p, "nil link map") } linkID, ok := lm[seqno] if ok { return linkID, nil } // We loaded this user originally to get a sigchain as fresh as a certain key provisioning. // In this scenario, we might need a fresher version, so force a poll all the way through // the server, and then try again. If we fail the second time, we a force repoll, then // we're toast. if leafID.IsUser() { g.Log.CDebugf(ctx, "proof#findLink: missed load for %s at %d; trying a force repoll", leafID.String(), seqno) lm, err := world.forceLinkMapRefreshForUser(ctx, leafID.AsUserOrBust()) if err != nil { return linkID, err } linkID, ok = lm[seqno] } if !ok { return linkID, NewProofError(p, fmt.Sprintf("no linkID for seqno %d", seqno)) } return linkID, nil }
[ "func", "(", "p", "proof", ")", "findLink", "(", "ctx", "context", ".", "Context", ",", "g", "*", "libkb", ".", "GlobalContext", ",", "world", "LoaderContext", ",", "leafID", "keybase1", ".", "UserOrTeamID", ",", "seqno", "keybase1", ".", "Seqno", ",", "...
// Find the LinkID for the leaf at the seqno.
[ "Find", "the", "LinkID", "for", "the", "leaf", "at", "the", "seqno", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/proofs.go#L242-L279
159,876
keybase/client
go/teams/proofs.go
check
func (p *proofSetT) check(ctx context.Context, world LoaderContext, parallel bool) (err error) { defer p.G().CTrace(ctx, "TeamLoader proofSet check", func() error { return err })() if parallel { return p.checkParallel(ctx, world) } var total int for _, v := range p.proofs { total += len(v) } var i int for _, v := range p.proofs { for _, proof := range v { p.G().Log.CDebugf(ctx, "TeamLoader proofSet check [%v / %v]", i, total) err = proof.check(ctx, p.G(), world, p) if err != nil { return err } i++ } } return nil }
go
func (p *proofSetT) check(ctx context.Context, world LoaderContext, parallel bool) (err error) { defer p.G().CTrace(ctx, "TeamLoader proofSet check", func() error { return err })() if parallel { return p.checkParallel(ctx, world) } var total int for _, v := range p.proofs { total += len(v) } var i int for _, v := range p.proofs { for _, proof := range v { p.G().Log.CDebugf(ctx, "TeamLoader proofSet check [%v / %v]", i, total) err = proof.check(ctx, p.G(), world, p) if err != nil { return err } i++ } } return nil }
[ "func", "(", "p", "*", "proofSetT", ")", "check", "(", "ctx", "context", ".", "Context", ",", "world", "LoaderContext", ",", "parallel", "bool", ")", "(", "err", "error", ")", "{", "defer", "p", ".", "G", "(", ")", ".", "CTrace", "(", "ctx", ",", ...
// check the entire proof set, failing if any one proof fails.
[ "check", "the", "entire", "proof", "set", "failing", "if", "any", "one", "proof", "fails", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/proofs.go#L286-L310
159,877
keybase/client
go/kbfs/kbfscrypto/auth_token.go
NewAuthToken
func NewAuthToken(signer Signer, tokenType string, expireIn int, submoduleName, version string, rh AuthTokenRefreshHandler) *AuthToken { clientName := fmt.Sprintf("go %s %s %s", submoduleName, libkb.GetPlatformString(), runtime.GOARCH) authToken := &AuthToken{ signer: signer, tokenType: tokenType, expireIn: expireIn, clientName: clientName, clientVersion: version, refreshHandler: rh, } return authToken }
go
func NewAuthToken(signer Signer, tokenType string, expireIn int, submoduleName, version string, rh AuthTokenRefreshHandler) *AuthToken { clientName := fmt.Sprintf("go %s %s %s", submoduleName, libkb.GetPlatformString(), runtime.GOARCH) authToken := &AuthToken{ signer: signer, tokenType: tokenType, expireIn: expireIn, clientName: clientName, clientVersion: version, refreshHandler: rh, } return authToken }
[ "func", "NewAuthToken", "(", "signer", "Signer", ",", "tokenType", "string", ",", "expireIn", "int", ",", "submoduleName", ",", "version", "string", ",", "rh", "AuthTokenRefreshHandler", ")", "*", "AuthToken", "{", "clientName", ":=", "fmt", ".", "Sprintf", "(...
// NewAuthToken creates a new authentication token.
[ "NewAuthToken", "creates", "a", "new", "authentication", "token", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/auth_token.go#L43-L56
159,878
keybase/client
go/kbfs/kbfscrypto/auth_token.go
signWithUserAndKeyInfo
func (a *AuthToken) signWithUserAndKeyInfo(ctx context.Context, challengeInfo keybase1.ChallengeInfo, uid keybase1.UID, username kbname.NormalizedUsername, key VerifyingKey) (string, error) { // create the token token := auth.NewToken(uid, username, key.KID(), a.tokenType, challengeInfo.Challenge, challengeInfo.Now, a.expireIn, a.clientName, a.clientVersion) // sign the token signature, err := a.signer.SignToString(ctx, token.Bytes()) if err != nil { return "", err } // reset the ticker refreshSeconds := a.expireIn / 2 if refreshSeconds < AuthTokenMinRefreshSeconds { refreshSeconds = AuthTokenMinRefreshSeconds } a.startTicker(refreshSeconds) return signature, nil }
go
func (a *AuthToken) signWithUserAndKeyInfo(ctx context.Context, challengeInfo keybase1.ChallengeInfo, uid keybase1.UID, username kbname.NormalizedUsername, key VerifyingKey) (string, error) { // create the token token := auth.NewToken(uid, username, key.KID(), a.tokenType, challengeInfo.Challenge, challengeInfo.Now, a.expireIn, a.clientName, a.clientVersion) // sign the token signature, err := a.signer.SignToString(ctx, token.Bytes()) if err != nil { return "", err } // reset the ticker refreshSeconds := a.expireIn / 2 if refreshSeconds < AuthTokenMinRefreshSeconds { refreshSeconds = AuthTokenMinRefreshSeconds } a.startTicker(refreshSeconds) return signature, nil }
[ "func", "(", "a", "*", "AuthToken", ")", "signWithUserAndKeyInfo", "(", "ctx", "context", ".", "Context", ",", "challengeInfo", "keybase1", ".", "ChallengeInfo", ",", "uid", "keybase1", ".", "UID", ",", "username", "kbname", ".", "NormalizedUsername", ",", "ke...
// Sign is called to create a new signed authentication token.
[ "Sign", "is", "called", "to", "create", "a", "new", "signed", "authentication", "token", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/auth_token.go#L59-L81
159,879
keybase/client
go/kbfs/kbfscrypto/auth_token.go
SignUserless
func (a *AuthToken) SignUserless( ctx context.Context, key VerifyingKey) ( string, error) { // Pass in a reserved, meaningless UID. return a.signWithUserAndKeyInfo(ctx, keybase1.ChallengeInfo{Now: time.Now().Unix()}, keybase1.PublicUID, "", key) }
go
func (a *AuthToken) SignUserless( ctx context.Context, key VerifyingKey) ( string, error) { // Pass in a reserved, meaningless UID. return a.signWithUserAndKeyInfo(ctx, keybase1.ChallengeInfo{Now: time.Now().Unix()}, keybase1.PublicUID, "", key) }
[ "func", "(", "a", "*", "AuthToken", ")", "SignUserless", "(", "ctx", "context", ".", "Context", ",", "key", "VerifyingKey", ")", "(", "string", ",", "error", ")", "{", "// Pass in a reserved, meaningless UID.", "return", "a", ".", "signWithUserAndKeyInfo", "(", ...
// SignUserless signs the token without a username, UID, or challenge. // This is useful for server-to-server communication where identity is // established using only the KID. Assume the client and server // clocks are roughly synchronized.
[ "SignUserless", "signs", "the", "token", "without", "a", "username", "UID", "or", "challenge", ".", "This", "is", "useful", "for", "server", "-", "to", "-", "server", "communication", "where", "identity", "is", "established", "using", "only", "the", "KID", "...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/auth_token.go#L103-L110
159,880
keybase/client
go/kbfs/kbfscrypto/auth_token.go
stopTicker
func (a *AuthToken) stopTicker() { a.tickerMu.Lock() defer a.tickerMu.Unlock() if a.tickerCancel != nil { a.tickerCancel() a.tickerCancel = nil } }
go
func (a *AuthToken) stopTicker() { a.tickerMu.Lock() defer a.tickerMu.Unlock() if a.tickerCancel != nil { a.tickerCancel() a.tickerCancel = nil } }
[ "func", "(", "a", "*", "AuthToken", ")", "stopTicker", "(", ")", "{", "a", ".", "tickerMu", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "tickerMu", ".", "Unlock", "(", ")", "\n\n", "if", "a", ".", "tickerCancel", "!=", "nil", "{", "a", ".", ...
// Helper to stop the refresh ticker.
[ "Helper", "to", "stop", "the", "refresh", "ticker", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/auth_token.go#L143-L151
159,881
keybase/client
go/logger/rpc_adapter_depthadder.go
CloneWithAddedDepth
func (l LogOutputWithDepthAdder) CloneWithAddedDepth(depth int) rpc.LogOutputWithDepthAdder { return LogOutputWithDepthAdder{l.Logger.CloneWithAddedDepth(depth)} }
go
func (l LogOutputWithDepthAdder) CloneWithAddedDepth(depth int) rpc.LogOutputWithDepthAdder { return LogOutputWithDepthAdder{l.Logger.CloneWithAddedDepth(depth)} }
[ "func", "(", "l", "LogOutputWithDepthAdder", ")", "CloneWithAddedDepth", "(", "depth", "int", ")", "rpc", ".", "LogOutputWithDepthAdder", "{", "return", "LogOutputWithDepthAdder", "{", "l", ".", "Logger", ".", "CloneWithAddedDepth", "(", "depth", ")", "}", "\n", ...
// CloneWithAddedDepth implements the rpc.LogOutput interface.
[ "CloneWithAddedDepth", "implements", "the", "rpc", ".", "LogOutput", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/logger/rpc_adapter_depthadder.go#L12-L14
159,882
keybase/client
go/kbfs/libkbfs/root_metadata.go
DumpPrivateMetadata
func DumpPrivateMetadata( codec kbfscodec.Codec, serializedPMDLength int, pmd PrivateMetadata) (string, error) { s := fmt.Sprintf("Size: %d bytes\n", serializedPMDLength) eq, err := kbfscodec.Equal(codec, pmd, PrivateMetadata{}) if err != nil { return "", err } if eq { s += "<Undecryptable>\n" } else { c := kbfsmd.DumpConfig() // Hardcode the indent level, which depends on the // position of the Ops list. indent := strings.Repeat(c.Indent, 4) var pmdCopy PrivateMetadata kbfscodec.Update(codec, &pmdCopy, pmd) ops := pmdCopy.Changes.Ops for i, op := range ops { ops[i] = verboseOp{op, indent} } s += c.Sdump(pmdCopy) } return s, nil }
go
func DumpPrivateMetadata( codec kbfscodec.Codec, serializedPMDLength int, pmd PrivateMetadata) (string, error) { s := fmt.Sprintf("Size: %d bytes\n", serializedPMDLength) eq, err := kbfscodec.Equal(codec, pmd, PrivateMetadata{}) if err != nil { return "", err } if eq { s += "<Undecryptable>\n" } else { c := kbfsmd.DumpConfig() // Hardcode the indent level, which depends on the // position of the Ops list. indent := strings.Repeat(c.Indent, 4) var pmdCopy PrivateMetadata kbfscodec.Update(codec, &pmdCopy, pmd) ops := pmdCopy.Changes.Ops for i, op := range ops { ops[i] = verboseOp{op, indent} } s += c.Sdump(pmdCopy) } return s, nil }
[ "func", "DumpPrivateMetadata", "(", "codec", "kbfscodec", ".", "Codec", ",", "serializedPMDLength", "int", ",", "pmd", "PrivateMetadata", ")", "(", "string", ",", "error", ")", "{", "s", ":=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "serialized...
// DumpPrivateMetadata returns a detailed dump of the given // PrivateMetadata's contents.
[ "DumpPrivateMetadata", "returns", "a", "detailed", "dump", "of", "the", "given", "PrivateMetadata", "s", "contents", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L63-L90
159,883
keybase/client
go/kbfs/libkbfs/root_metadata.go
makeRootMetadata
func makeRootMetadata(bareMd kbfsmd.MutableRootMetadata, extra kbfsmd.ExtraMetadata, handle *tlfhandle.Handle) *RootMetadata { if bareMd == nil { panic("nil kbfsmd.MutableRootMetadata") } // extra can be nil. if handle == nil { panic("nil handle") } return &RootMetadata{ bareMd: bareMd, extra: extra, tlfHandle: handle, } }
go
func makeRootMetadata(bareMd kbfsmd.MutableRootMetadata, extra kbfsmd.ExtraMetadata, handle *tlfhandle.Handle) *RootMetadata { if bareMd == nil { panic("nil kbfsmd.MutableRootMetadata") } // extra can be nil. if handle == nil { panic("nil handle") } return &RootMetadata{ bareMd: bareMd, extra: extra, tlfHandle: handle, } }
[ "func", "makeRootMetadata", "(", "bareMd", "kbfsmd", ".", "MutableRootMetadata", ",", "extra", "kbfsmd", ".", "ExtraMetadata", ",", "handle", "*", "tlfhandle", ".", "Handle", ")", "*", "RootMetadata", "{", "if", "bareMd", "==", "nil", "{", "panic", "(", "\""...
// makeRootMetadata makes a RootMetadata object from the given // parameters.
[ "makeRootMetadata", "makes", "a", "RootMetadata", "object", "from", "the", "given", "parameters", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L133-L147
159,884
keybase/client
go/kbfs/libkbfs/root_metadata.go
IsReadable
func (md *RootMetadata) IsReadable() bool { return md.TlfID().Type() == tlf.Public || md.data.Dir.IsInitialized() }
go
func (md *RootMetadata) IsReadable() bool { return md.TlfID().Type() == tlf.Public || md.data.Dir.IsInitialized() }
[ "func", "(", "md", "*", "RootMetadata", ")", "IsReadable", "(", ")", "bool", "{", "return", "md", ".", "TlfID", "(", ")", ".", "Type", "(", ")", "==", "tlf", ".", "Public", "||", "md", ".", "data", ".", "Dir", ".", "IsInitialized", "(", ")", "\n"...
// IsReadable returns true if the private metadata can be read.
[ "IsReadable", "returns", "true", "if", "the", "private", "metadata", "can", "be", "read", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L191-L193
159,885
keybase/client
go/kbfs/libkbfs/root_metadata.go
GetTlfHandle
func (md *RootMetadata) GetTlfHandle() *tlfhandle.Handle { if md.tlfHandle == nil { panic(fmt.Sprintf("RootMetadata %v with no handle", md)) } return md.tlfHandle }
go
func (md *RootMetadata) GetTlfHandle() *tlfhandle.Handle { if md.tlfHandle == nil { panic(fmt.Sprintf("RootMetadata %v with no handle", md)) } return md.tlfHandle }
[ "func", "(", "md", "*", "RootMetadata", ")", "GetTlfHandle", "(", ")", "*", "tlfhandle", ".", "Handle", "{", "if", "md", ".", "tlfHandle", "==", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "md", ")", ")", "\n", "}", "\n...
// GetTlfHandle returns the TlfHandle for this RootMetadata.
[ "GetTlfHandle", "returns", "the", "TlfHandle", "for", "this", "RootMetadata", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L333-L339
159,886
keybase/client
go/kbfs/libkbfs/root_metadata.go
MakeBareTlfHandle
func (md *RootMetadata) MakeBareTlfHandle() (tlf.Handle, error) { if md.tlfHandle != nil { panic(errors.New("MakeBareTlfHandle called when md.tlfHandle exists")) } return md.bareMd.MakeBareTlfHandle(md.extra) }
go
func (md *RootMetadata) MakeBareTlfHandle() (tlf.Handle, error) { if md.tlfHandle != nil { panic(errors.New("MakeBareTlfHandle called when md.tlfHandle exists")) } return md.bareMd.MakeBareTlfHandle(md.extra) }
[ "func", "(", "md", "*", "RootMetadata", ")", "MakeBareTlfHandle", "(", ")", "(", "tlf", ".", "Handle", ",", "error", ")", "{", "if", "md", ".", "tlfHandle", "!=", "nil", "{", "panic", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}...
// MakeBareTlfHandle makes a BareTlfHandle for this // RootMetadata. Should be used only by servers and MDOps.
[ "MakeBareTlfHandle", "makes", "a", "BareTlfHandle", "for", "this", "RootMetadata", ".", "Should", "be", "used", "only", "by", "servers", "and", "MDOps", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L348-L354
159,887
keybase/client
go/kbfs/libkbfs/root_metadata.go
IsInitialized
func (md *RootMetadata) IsInitialized() bool { keyGen := md.LatestKeyGeneration() if md.TypeForKeying() == tlf.PublicKeying { return keyGen == kbfsmd.PublicKeyGen } // The data is only initialized once we have at least one set of keys return keyGen >= kbfsmd.FirstValidKeyGen }
go
func (md *RootMetadata) IsInitialized() bool { keyGen := md.LatestKeyGeneration() if md.TypeForKeying() == tlf.PublicKeying { return keyGen == kbfsmd.PublicKeyGen } // The data is only initialized once we have at least one set of keys return keyGen >= kbfsmd.FirstValidKeyGen }
[ "func", "(", "md", "*", "RootMetadata", ")", "IsInitialized", "(", ")", "bool", "{", "keyGen", ":=", "md", ".", "LatestKeyGeneration", "(", ")", "\n", "if", "md", ".", "TypeForKeying", "(", ")", "==", "tlf", ".", "PublicKeying", "{", "return", "keyGen", ...
// IsInitialized returns whether or not this RootMetadata has been initialized
[ "IsInitialized", "returns", "whether", "or", "not", "this", "RootMetadata", "has", "been", "initialized" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L357-L364
159,888
keybase/client
go/kbfs/libkbfs/root_metadata.go
AddRefBlock
func (md *RootMetadata) AddRefBlock(info data.BlockInfo) { md.AddRefBytes(uint64(info.EncodedSize)) md.AddDiskUsage(uint64(info.EncodedSize)) md.data.Changes.AddRefBlock(info.BlockPointer) }
go
func (md *RootMetadata) AddRefBlock(info data.BlockInfo) { md.AddRefBytes(uint64(info.EncodedSize)) md.AddDiskUsage(uint64(info.EncodedSize)) md.data.Changes.AddRefBlock(info.BlockPointer) }
[ "func", "(", "md", "*", "RootMetadata", ")", "AddRefBlock", "(", "info", "data", ".", "BlockInfo", ")", "{", "md", ".", "AddRefBytes", "(", "uint64", "(", "info", ".", "EncodedSize", ")", ")", "\n", "md", ".", "AddDiskUsage", "(", "uint64", "(", "info"...
// AddRefBlock adds the newly-referenced block to the add block change list.
[ "AddRefBlock", "adds", "the", "newly", "-", "referenced", "block", "to", "the", "add", "block", "change", "list", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L367-L371
159,889
keybase/client
go/kbfs/libkbfs/root_metadata.go
AddUnrefBlock
func (md *RootMetadata) AddUnrefBlock(info data.BlockInfo) { if info.EncodedSize > 0 { md.AddUnrefBytes(uint64(info.EncodedSize)) md.SetDiskUsage(md.DiskUsage() - uint64(info.EncodedSize)) md.data.Changes.AddUnrefBlock(info.BlockPointer) } }
go
func (md *RootMetadata) AddUnrefBlock(info data.BlockInfo) { if info.EncodedSize > 0 { md.AddUnrefBytes(uint64(info.EncodedSize)) md.SetDiskUsage(md.DiskUsage() - uint64(info.EncodedSize)) md.data.Changes.AddUnrefBlock(info.BlockPointer) } }
[ "func", "(", "md", "*", "RootMetadata", ")", "AddUnrefBlock", "(", "info", "data", ".", "BlockInfo", ")", "{", "if", "info", ".", "EncodedSize", ">", "0", "{", "md", ".", "AddUnrefBytes", "(", "uint64", "(", "info", ".", "EncodedSize", ")", ")", "\n", ...
// AddUnrefBlock adds the newly-unreferenced block to the add block change list.
[ "AddUnrefBlock", "adds", "the", "newly", "-", "unreferenced", "block", "to", "the", "add", "block", "change", "list", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L374-L380
159,890
keybase/client
go/kbfs/libkbfs/root_metadata.go
AddUpdate
func (md *RootMetadata) AddUpdate(oldInfo data.BlockInfo, newInfo data.BlockInfo) { md.AddUnrefBytes(uint64(oldInfo.EncodedSize)) md.AddRefBytes(uint64(newInfo.EncodedSize)) md.AddDiskUsage(uint64(newInfo.EncodedSize)) md.SetDiskUsage(md.DiskUsage() - uint64(oldInfo.EncodedSize)) md.data.Changes.AddUpdate(oldInfo.BlockPointer, newInfo.BlockPointer) }
go
func (md *RootMetadata) AddUpdate(oldInfo data.BlockInfo, newInfo data.BlockInfo) { md.AddUnrefBytes(uint64(oldInfo.EncodedSize)) md.AddRefBytes(uint64(newInfo.EncodedSize)) md.AddDiskUsage(uint64(newInfo.EncodedSize)) md.SetDiskUsage(md.DiskUsage() - uint64(oldInfo.EncodedSize)) md.data.Changes.AddUpdate(oldInfo.BlockPointer, newInfo.BlockPointer) }
[ "func", "(", "md", "*", "RootMetadata", ")", "AddUpdate", "(", "oldInfo", "data", ".", "BlockInfo", ",", "newInfo", "data", ".", "BlockInfo", ")", "{", "md", ".", "AddUnrefBytes", "(", "uint64", "(", "oldInfo", ".", "EncodedSize", ")", ")", "\n", "md", ...
// AddUpdate adds the newly-updated block to the add block change list.
[ "AddUpdate", "adds", "the", "newly", "-", "updated", "block", "to", "the", "add", "block", "change", "list", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L383-L389
159,891
keybase/client
go/kbfs/libkbfs/root_metadata.go
AddOp
func (md *RootMetadata) AddOp(o op) { md.data.Changes.AddOp(o) }
go
func (md *RootMetadata) AddOp(o op) { md.data.Changes.AddOp(o) }
[ "func", "(", "md", "*", "RootMetadata", ")", "AddOp", "(", "o", "op", ")", "{", "md", ".", "data", ".", "Changes", ".", "AddOp", "(", "o", ")", "\n", "}" ]
// AddOp starts a new operation for this MD update. Subsequent // AddRefBlock, AddUnrefBlock, and AddUpdate calls will be applied to // this operation.
[ "AddOp", "starts", "a", "new", "operation", "for", "this", "MD", "update", ".", "Subsequent", "AddRefBlock", "AddUnrefBlock", "and", "AddUpdate", "calls", "will", "be", "applied", "to", "this", "operation", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L394-L396
159,892
keybase/client
go/kbfs/libkbfs/root_metadata.go
ClearBlockChanges
func (md *RootMetadata) ClearBlockChanges() { md.SetRefBytes(0) md.SetUnrefBytes(0) md.SetMDRefBytes(0) md.data.Changes.sizeEstimate = 0 md.data.Changes.Info = data.BlockInfo{} md.data.Changes.Ops = nil }
go
func (md *RootMetadata) ClearBlockChanges() { md.SetRefBytes(0) md.SetUnrefBytes(0) md.SetMDRefBytes(0) md.data.Changes.sizeEstimate = 0 md.data.Changes.Info = data.BlockInfo{} md.data.Changes.Ops = nil }
[ "func", "(", "md", "*", "RootMetadata", ")", "ClearBlockChanges", "(", ")", "{", "md", ".", "SetRefBytes", "(", "0", ")", "\n", "md", ".", "SetUnrefBytes", "(", "0", ")", "\n", "md", ".", "SetMDRefBytes", "(", "0", ")", "\n", "md", ".", "data", "."...
// ClearBlockChanges resets the block change lists to empty for this // RootMetadata.
[ "ClearBlockChanges", "resets", "the", "block", "change", "lists", "to", "empty", "for", "this", "RootMetadata", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L400-L407
159,893
keybase/client
go/kbfs/libkbfs/root_metadata.go
SetLastGCRevision
func (md *RootMetadata) SetLastGCRevision(rev kbfsmd.Revision) { md.data.LastGCRevision = rev }
go
func (md *RootMetadata) SetLastGCRevision(rev kbfsmd.Revision) { md.data.LastGCRevision = rev }
[ "func", "(", "md", "*", "RootMetadata", ")", "SetLastGCRevision", "(", "rev", "kbfsmd", ".", "Revision", ")", "{", "md", ".", "data", ".", "LastGCRevision", "=", "rev", "\n", "}" ]
// SetLastGCRevision sets the last revision up to and including which // garbage collection was performed on this TLF.
[ "SetLastGCRevision", "sets", "the", "last", "revision", "up", "to", "and", "including", "which", "garbage", "collection", "was", "performed", "on", "this", "TLF", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L411-L413
159,894
keybase/client
go/kbfs/libkbfs/root_metadata.go
GetTLFCryptKeyParams
func (md *RootMetadata) GetTLFCryptKeyParams( keyGen kbfsmd.KeyGen, user keybase1.UID, key kbfscrypto.CryptPublicKey) ( kbfscrypto.TLFEphemeralPublicKey, kbfscrypto.EncryptedTLFCryptKeyClientHalf, kbfscrypto.TLFCryptKeyServerHalfID, bool, error) { return md.bareMd.GetTLFCryptKeyParams(keyGen, user, key, md.extra) }
go
func (md *RootMetadata) GetTLFCryptKeyParams( keyGen kbfsmd.KeyGen, user keybase1.UID, key kbfscrypto.CryptPublicKey) ( kbfscrypto.TLFEphemeralPublicKey, kbfscrypto.EncryptedTLFCryptKeyClientHalf, kbfscrypto.TLFCryptKeyServerHalfID, bool, error) { return md.bareMd.GetTLFCryptKeyParams(keyGen, user, key, md.extra) }
[ "func", "(", "md", "*", "RootMetadata", ")", "GetTLFCryptKeyParams", "(", "keyGen", "kbfsmd", ".", "KeyGen", ",", "user", "keybase1", ".", "UID", ",", "key", "kbfscrypto", ".", "CryptPublicKey", ")", "(", "kbfscrypto", ".", "TLFEphemeralPublicKey", ",", "kbfsc...
// GetTLFCryptKeyParams wraps the respective method of the underlying BareRootMetadata for convenience.
[ "GetTLFCryptKeyParams", "wraps", "the", "respective", "method", "of", "the", "underlying", "BareRootMetadata", "for", "convenience", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L559-L564
159,895
keybase/client
go/kbfs/libkbfs/root_metadata.go
KeyGenerationsToUpdate
func (md *RootMetadata) KeyGenerationsToUpdate() (kbfsmd.KeyGen, kbfsmd.KeyGen) { return md.bareMd.KeyGenerationsToUpdate() }
go
func (md *RootMetadata) KeyGenerationsToUpdate() (kbfsmd.KeyGen, kbfsmd.KeyGen) { return md.bareMd.KeyGenerationsToUpdate() }
[ "func", "(", "md", "*", "RootMetadata", ")", "KeyGenerationsToUpdate", "(", ")", "(", "kbfsmd", ".", "KeyGen", ",", "kbfsmd", ".", "KeyGen", ")", "{", "return", "md", ".", "bareMd", ".", "KeyGenerationsToUpdate", "(", ")", "\n", "}" ]
// KeyGenerationsToUpdate wraps the respective method of the underlying BareRootMetadata for convenience.
[ "KeyGenerationsToUpdate", "wraps", "the", "respective", "method", "of", "the", "underlying", "BareRootMetadata", "for", "convenience", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L567-L569
159,896
keybase/client
go/kbfs/libkbfs/root_metadata.go
TlfID
func (md *RootMetadata) TlfID() tlf.ID { if md == nil || md.bareMd == nil { return tlf.NullID } return md.bareMd.TlfID() }
go
func (md *RootMetadata) TlfID() tlf.ID { if md == nil || md.bareMd == nil { return tlf.NullID } return md.bareMd.TlfID() }
[ "func", "(", "md", "*", "RootMetadata", ")", "TlfID", "(", ")", "tlf", ".", "ID", "{", "if", "md", "==", "nil", "||", "md", ".", "bareMd", "==", "nil", "{", "return", "tlf", ".", "NullID", "\n", "}", "\n", "return", "md", ".", "bareMd", ".", "T...
// TlfID wraps the respective method of the underlying BareRootMetadata for convenience.
[ "TlfID", "wraps", "the", "respective", "method", "of", "the", "underlying", "BareRootMetadata", "for", "convenience", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L577-L582
159,897
keybase/client
go/kbfs/libkbfs/root_metadata.go
SetBranchID
func (md *RootMetadata) SetBranchID(bid kbfsmd.BranchID) { md.bareMd.SetBranchID(bid) }
go
func (md *RootMetadata) SetBranchID(bid kbfsmd.BranchID) { md.bareMd.SetBranchID(bid) }
[ "func", "(", "md", "*", "RootMetadata", ")", "SetBranchID", "(", "bid", "kbfsmd", ".", "BranchID", ")", "{", "md", ".", "bareMd", ".", "SetBranchID", "(", "bid", ")", "\n", "}" ]
// SetBranchID wraps the respective method of the underlying BareRootMetadata for convenience.
[ "SetBranchID", "wraps", "the", "respective", "method", "of", "the", "underlying", "BareRootMetadata", "for", "convenience", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L723-L725
159,898
keybase/client
go/kbfs/libkbfs/root_metadata.go
SetPrevRoot
func (md *RootMetadata) SetPrevRoot(mdID kbfsmd.ID) { md.bareMd.SetPrevRoot(mdID) }
go
func (md *RootMetadata) SetPrevRoot(mdID kbfsmd.ID) { md.bareMd.SetPrevRoot(mdID) }
[ "func", "(", "md", "*", "RootMetadata", ")", "SetPrevRoot", "(", "mdID", "kbfsmd", ".", "ID", ")", "{", "md", ".", "bareMd", ".", "SetPrevRoot", "(", "mdID", ")", "\n", "}" ]
// SetPrevRoot wraps the respective method of the underlying BareRootMetadata for convenience.
[ "SetPrevRoot", "wraps", "the", "respective", "method", "of", "the", "underlying", "BareRootMetadata", "for", "convenience", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L728-L730
159,899
keybase/client
go/kbfs/libkbfs/root_metadata.go
GetSerializedWriterMetadata
func (md *RootMetadata) GetSerializedWriterMetadata( codec kbfscodec.Codec) ([]byte, error) { return md.bareMd.GetSerializedWriterMetadata(codec) }
go
func (md *RootMetadata) GetSerializedWriterMetadata( codec kbfscodec.Codec) ([]byte, error) { return md.bareMd.GetSerializedWriterMetadata(codec) }
[ "func", "(", "md", "*", "RootMetadata", ")", "GetSerializedWriterMetadata", "(", "codec", "kbfscodec", ".", "Codec", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "md", ".", "bareMd", ".", "GetSerializedWriterMetadata", "(", "codec", ")", "...
// GetSerializedWriterMetadata wraps the respective method of the underlying BareRootMetadata for convenience.
[ "GetSerializedWriterMetadata", "wraps", "the", "respective", "method", "of", "the", "underlying", "BareRootMetadata", "for", "convenience", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/root_metadata.go#L738-L741