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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
160,900 | keybase/client | go/kbfs/libfs/root_fs.go | Join | func (rfs *RootFS) Join(elem ...string) string {
return path.Clean(path.Join(elem...))
} | go | func (rfs *RootFS) Join(elem ...string) string {
return path.Clean(path.Join(elem...))
} | [
"func",
"(",
"rfs",
"*",
"RootFS",
")",
"Join",
"(",
"elem",
"...",
"string",
")",
"string",
"{",
"return",
"path",
".",
"Clean",
"(",
"path",
".",
"Join",
"(",
"elem",
"...",
")",
")",
"\n",
"}"
] | // Join implements the billy.Filesystem interface for RootFS. | [
"Join",
"implements",
"the",
"billy",
".",
"Filesystem",
"interface",
"for",
"RootFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L106-L108 |
160,901 | keybase/client | go/kbfs/libfs/root_fs.go | ReadDir | func (rfs *RootFS) ReadDir(p string) (fis []os.FileInfo, err error) {
if p == "" {
p = "."
}
if p != "." {
return nil, os.ErrNotExist
}
now := rfs.config.Clock().Now()
return []os.FileInfo{
&wrappedReadFileInfo{"private", 0, now, true},
&wrappedReadFileInfo{"public", 0, now, true},
&wrappedReadFileInfo{"team", 0, now, true},
}, nil
} | go | func (rfs *RootFS) ReadDir(p string) (fis []os.FileInfo, err error) {
if p == "" {
p = "."
}
if p != "." {
return nil, os.ErrNotExist
}
now := rfs.config.Clock().Now()
return []os.FileInfo{
&wrappedReadFileInfo{"private", 0, now, true},
&wrappedReadFileInfo{"public", 0, now, true},
&wrappedReadFileInfo{"team", 0, now, true},
}, nil
} | [
"func",
"(",
"rfs",
"*",
"RootFS",
")",
"ReadDir",
"(",
"p",
"string",
")",
"(",
"fis",
"[",
"]",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"{",
"if",
"p",
"==",
"\"",
"\"",
"{",
"p",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"if",
"p",
"!... | // ReadDir implements the billy.Filesystem interface for RootFS. | [
"ReadDir",
"implements",
"the",
"billy",
".",
"Filesystem",
"interface",
"for",
"RootFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L111-L126 |
160,902 | keybase/client | go/kbfs/libfs/root_fs.go | Readlink | func (rfs *RootFS) Readlink(_ string) (target string, err error) {
return "", errors.New("RootFS cannot read links")
} | go | func (rfs *RootFS) Readlink(_ string) (target string, err error) {
return "", errors.New("RootFS cannot read links")
} | [
"func",
"(",
"rfs",
"*",
"RootFS",
")",
"Readlink",
"(",
"_",
"string",
")",
"(",
"target",
"string",
",",
"err",
"error",
")",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Readlink implements the billy.Filesystem interface for RootFS. | [
"Readlink",
"implements",
"the",
"billy",
".",
"Filesystem",
"interface",
"for",
"RootFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L129-L131 |
160,903 | keybase/client | go/kbfs/libfs/root_fs.go | Chroot | func (rfs *RootFS) Chroot(_ string) (newFS billy.Filesystem, err error) {
// Don't allow chroot'ing anywhere outside of the root FS since we
// haven't yet implemented folderlist browsing.
return nil, errors.New("RootFS cannot chroot")
} | go | func (rfs *RootFS) Chroot(_ string) (newFS billy.Filesystem, err error) {
// Don't allow chroot'ing anywhere outside of the root FS since we
// haven't yet implemented folderlist browsing.
return nil, errors.New("RootFS cannot chroot")
} | [
"func",
"(",
"rfs",
"*",
"RootFS",
")",
"Chroot",
"(",
"_",
"string",
")",
"(",
"newFS",
"billy",
".",
"Filesystem",
",",
"err",
"error",
")",
"{",
"// Don't allow chroot'ing anywhere outside of the root FS since we",
"// haven't yet implemented folderlist browsing.",
"... | // Chroot implements the billy.Filesystem interface for RootFS. | [
"Chroot",
"implements",
"the",
"billy",
".",
"Filesystem",
"interface",
"for",
"RootFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L134-L138 |
160,904 | keybase/client | go/kbfs/libfs/root_fs.go | Rename | func (rfs *RootFS) Rename(_, _ string) (err error) {
return errors.New("RootFS cannot rename files")
} | go | func (rfs *RootFS) Rename(_, _ string) (err error) {
return errors.New("RootFS cannot rename files")
} | [
"func",
"(",
"rfs",
"*",
"RootFS",
")",
"Rename",
"(",
"_",
",",
"_",
"string",
")",
"(",
"err",
"error",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Rename implements the billy.Filesystem interface for RootFS. | [
"Rename",
"implements",
"the",
"billy",
".",
"Filesystem",
"interface",
"for",
"RootFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L153-L155 |
160,905 | keybase/client | go/kbfs/libfs/root_fs.go | MkdirAll | func (rfs *RootFS) MkdirAll(_ string, _ os.FileMode) (err error) {
return errors.New("RootFS cannot mkdir")
} | go | func (rfs *RootFS) MkdirAll(_ string, _ os.FileMode) (err error) {
return errors.New("RootFS cannot mkdir")
} | [
"func",
"(",
"rfs",
"*",
"RootFS",
")",
"MkdirAll",
"(",
"_",
"string",
",",
"_",
"os",
".",
"FileMode",
")",
"(",
"err",
"error",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // MkdirAll implements the billy.Filesystem interface for RootFS. | [
"MkdirAll",
"implements",
"the",
"billy",
".",
"Filesystem",
"interface",
"for",
"RootFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L168-L170 |
160,906 | keybase/client | go/ephemeral/lib.go | GetTeamEK | func (e *EKLib) GetTeamEK(mctx libkb.MetaContext, teamID keybase1.TeamID, generation keybase1.EkGeneration,
contentCtime *gregor1.Time) (teamEK keybase1.TeamEk, err error) {
defer mctx.TraceTimed("GetTeamEK", func() error { return err })()
teamEKBoxStorage := mctx.G().GetTeamEKBoxStorage()
teamEK, err = teamEKBoxStorage.Get(mctx, teamID, generation, contentCtime)
if err != nil {
switch err.(type) {
case EphemeralKeyError:
mctx.Debug(err.Error())
// If we are unable to get the current max generation, try to kick
// off creation of a new key.
go func(mctx libkb.MetaContext) {
maxGeneration, err := teamEKBoxStorage.MaxGeneration(mctx, teamID, true)
if err != nil {
mctx.Debug("Unable to get MaxGeneration: %v", err)
return
}
if generation == maxGeneration {
_, created, cerr := e.GetOrCreateLatestTeamEK(mctx, teamID)
if cerr != nil {
mctx.Debug("Unable to GetOrCreateLatestTeamEK: %v", cerr)
}
if e.backgroundCreationTestCh != nil {
e.backgroundCreationTestCh <- created
}
}
}(libkb.NewMetaContextBackground(mctx.G()))
}
}
return teamEK, err
} | go | func (e *EKLib) GetTeamEK(mctx libkb.MetaContext, teamID keybase1.TeamID, generation keybase1.EkGeneration,
contentCtime *gregor1.Time) (teamEK keybase1.TeamEk, err error) {
defer mctx.TraceTimed("GetTeamEK", func() error { return err })()
teamEKBoxStorage := mctx.G().GetTeamEKBoxStorage()
teamEK, err = teamEKBoxStorage.Get(mctx, teamID, generation, contentCtime)
if err != nil {
switch err.(type) {
case EphemeralKeyError:
mctx.Debug(err.Error())
// If we are unable to get the current max generation, try to kick
// off creation of a new key.
go func(mctx libkb.MetaContext) {
maxGeneration, err := teamEKBoxStorage.MaxGeneration(mctx, teamID, true)
if err != nil {
mctx.Debug("Unable to get MaxGeneration: %v", err)
return
}
if generation == maxGeneration {
_, created, cerr := e.GetOrCreateLatestTeamEK(mctx, teamID)
if cerr != nil {
mctx.Debug("Unable to GetOrCreateLatestTeamEK: %v", cerr)
}
if e.backgroundCreationTestCh != nil {
e.backgroundCreationTestCh <- created
}
}
}(libkb.NewMetaContextBackground(mctx.G()))
}
}
return teamEK, err
} | [
"func",
"(",
"e",
"*",
"EKLib",
")",
"GetTeamEK",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"teamID",
"keybase1",
".",
"TeamID",
",",
"generation",
"keybase1",
".",
"EkGeneration",
",",
"contentCtime",
"*",
"gregor1",
".",
"Time",
")",
"(",
"teamEK",
... | // Try to get the TeamEK for the given `generation`. If this fails and the
// `generation` is also the current maxGeneration, create a new teamEK. | [
"Try",
"to",
"get",
"the",
"TeamEK",
"for",
"the",
"given",
"generation",
".",
"If",
"this",
"fails",
"and",
"the",
"generation",
"is",
"also",
"the",
"current",
"maxGeneration",
"create",
"a",
"new",
"teamEK",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/ephemeral/lib.go#L536-L567 |
160,907 | keybase/client | go/install/install_windows.go | AutoInstall | func AutoInstall(context Context, binPath string, force bool, timeout time.Duration, log Log) (bool, error) {
return false, nil
} | go | func AutoInstall(context Context, binPath string, force bool, timeout time.Duration, log Log) (bool, error) {
return false, nil
} | [
"func",
"AutoInstall",
"(",
"context",
"Context",
",",
"binPath",
"string",
",",
"force",
"bool",
",",
"timeout",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"(",
"bool",
",",
"error",
")",
"{",
"return",
"false",
",",
"nil",
"\n",
"}"
] | // AutoInstall is not supported on Windows | [
"AutoInstall",
"is",
"not",
"supported",
"on",
"Windows"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/install/install_windows.go#L45-L47 |
160,908 | keybase/client | go/install/install_windows.go | InstallLogPath | func InstallLogPath() (string, error) {
// Get the 3 newest keybase logs - sorting by name works because timestamp
keybaseLogFiles, err := filepath.Glob(os.ExpandEnv(filepath.Join("${TEMP}", "Keybase*.log")))
sort.Sort(sort.Reverse(sort.StringSlice(keybaseLogFiles)))
if len(keybaseLogFiles) > 6 {
keybaseLogFiles = keybaseLogFiles[:6]
}
// Get the latest msi log - this is the clean install .msi log
msiLogFiles, err := filepath.Glob(os.ExpandEnv(filepath.Join("${TEMP}", "MSI*.LOG")))
sort.Sort(sort.Reverse(sort.StringSlice(msiLogFiles)))
if len(msiLogFiles) >= 1 {
keybaseLogFiles = append(keybaseLogFiles, msiLogFiles[0])
}
// Get the 2 newest dokan logs - sorting by name works because timestamp
dokanLogFiles, err := filepath.Glob(os.ExpandEnv(filepath.Join("${TEMP}", "Dokan*.log")))
sort.Sort(sort.Reverse(sort.StringSlice(dokanLogFiles)))
if len(dokanLogFiles) > 2 {
dokanLogFiles = dokanLogFiles[:2]
}
keybaseLogFiles = append(keybaseLogFiles, dokanLogFiles...)
logName, logFile, err := libkb.OpenTempFile("KeybaseInstallUpload", ".log", 0)
defer logFile.Close()
if err != nil {
return "", err
}
getVersionAndDrivers(logFile)
if len(keybaseLogFiles) == 0 {
fmt.Fprintf(logFile, " --- NO INSTALL LOGS FOUND!?! ---\n")
}
for _, path := range keybaseLogFiles {
fmt.Fprintf(logFile, " --- %s ---\n", path)
// We have to parse the contents and write them because some files need to
// be decoded from utf16
s, err := newScannerUTF16or8(path)
if err != nil {
fmt.Fprintf(logFile, " --- NewScannerUTF16(%s) returns %v---\n", path, err)
} else {
scanner := bufio.NewScanner(s)
for scanner.Scan() {
fmt.Fprintln(logFile, scanner.Text()) // Println will add back the final '\n'
}
if err := scanner.Err(); err != nil {
fmt.Fprintf(logFile, " --- error reading (%s): %v---\n", path, err)
}
}
fmt.Fprint(logFile, "\n\n")
}
return logName, err
} | go | func InstallLogPath() (string, error) {
// Get the 3 newest keybase logs - sorting by name works because timestamp
keybaseLogFiles, err := filepath.Glob(os.ExpandEnv(filepath.Join("${TEMP}", "Keybase*.log")))
sort.Sort(sort.Reverse(sort.StringSlice(keybaseLogFiles)))
if len(keybaseLogFiles) > 6 {
keybaseLogFiles = keybaseLogFiles[:6]
}
// Get the latest msi log - this is the clean install .msi log
msiLogFiles, err := filepath.Glob(os.ExpandEnv(filepath.Join("${TEMP}", "MSI*.LOG")))
sort.Sort(sort.Reverse(sort.StringSlice(msiLogFiles)))
if len(msiLogFiles) >= 1 {
keybaseLogFiles = append(keybaseLogFiles, msiLogFiles[0])
}
// Get the 2 newest dokan logs - sorting by name works because timestamp
dokanLogFiles, err := filepath.Glob(os.ExpandEnv(filepath.Join("${TEMP}", "Dokan*.log")))
sort.Sort(sort.Reverse(sort.StringSlice(dokanLogFiles)))
if len(dokanLogFiles) > 2 {
dokanLogFiles = dokanLogFiles[:2]
}
keybaseLogFiles = append(keybaseLogFiles, dokanLogFiles...)
logName, logFile, err := libkb.OpenTempFile("KeybaseInstallUpload", ".log", 0)
defer logFile.Close()
if err != nil {
return "", err
}
getVersionAndDrivers(logFile)
if len(keybaseLogFiles) == 0 {
fmt.Fprintf(logFile, " --- NO INSTALL LOGS FOUND!?! ---\n")
}
for _, path := range keybaseLogFiles {
fmt.Fprintf(logFile, " --- %s ---\n", path)
// We have to parse the contents and write them because some files need to
// be decoded from utf16
s, err := newScannerUTF16or8(path)
if err != nil {
fmt.Fprintf(logFile, " --- NewScannerUTF16(%s) returns %v---\n", path, err)
} else {
scanner := bufio.NewScanner(s)
for scanner.Scan() {
fmt.Fprintln(logFile, scanner.Text()) // Println will add back the final '\n'
}
if err := scanner.Err(); err != nil {
fmt.Fprintf(logFile, " --- error reading (%s): %v---\n", path, err)
}
}
fmt.Fprint(logFile, "\n\n")
}
return logName, err
} | [
"func",
"InstallLogPath",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Get the 3 newest keybase logs - sorting by name works because timestamp",
"keybaseLogFiles",
",",
"err",
":=",
"filepath",
".",
"Glob",
"(",
"os",
".",
"ExpandEnv",
"(",
"filepath",
".",
... | // InstallLogPath combines a handful of install logs in to one for
// server upload.
// Unfortunately, Dokan can generate UTF16 logs, so we test each file
// and translate if necessary. | [
"InstallLogPath",
"combines",
"a",
"handful",
"of",
"install",
"logs",
"in",
"to",
"one",
"for",
"server",
"upload",
".",
"Unfortunately",
"Dokan",
"can",
"generate",
"UTF16",
"logs",
"so",
"we",
"test",
"each",
"file",
"and",
"translate",
"if",
"necessary",
... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/install/install_windows.go#L122-L177 |
160,909 | keybase/client | go/install/install_windows.go | WatchdogLogPath | func WatchdogLogPath(logGlobPath string) (string, error) {
// Get the 5 newest watchdog logs - sorting by name works because timestamp
watchdogLogFiles, err := filepath.Glob(logGlobPath)
sort.Sort(sort.Reverse(sort.StringSlice(watchdogLogFiles)))
if len(watchdogLogFiles) > 5 {
watchdogLogFiles = watchdogLogFiles[:5]
}
logName, logFile, err := libkb.OpenTempFile("KeybaseWatchdogUpload", ".log", 0)
defer logFile.Close()
if err != nil {
return "", err
}
if len(watchdogLogFiles) == 0 {
fmt.Fprintf(logFile, " --- NO WATCHDOG LOGS FOUND!?! ---\n")
}
for _, path := range watchdogLogFiles {
fmt.Fprintf(logFile, " --- %s ---\n", path)
// append the files
func() {
fd, err := os.Open(path)
defer fd.Close()
if err != nil {
fmt.Fprintf(logFile, "open error: %s\n", err.Error())
return
}
_, err = io.Copy(logFile, fd)
if err != nil {
fmt.Fprintf(logFile, "copy error: %s\n", err.Error())
}
}()
}
return logName, err
} | go | func WatchdogLogPath(logGlobPath string) (string, error) {
// Get the 5 newest watchdog logs - sorting by name works because timestamp
watchdogLogFiles, err := filepath.Glob(logGlobPath)
sort.Sort(sort.Reverse(sort.StringSlice(watchdogLogFiles)))
if len(watchdogLogFiles) > 5 {
watchdogLogFiles = watchdogLogFiles[:5]
}
logName, logFile, err := libkb.OpenTempFile("KeybaseWatchdogUpload", ".log", 0)
defer logFile.Close()
if err != nil {
return "", err
}
if len(watchdogLogFiles) == 0 {
fmt.Fprintf(logFile, " --- NO WATCHDOG LOGS FOUND!?! ---\n")
}
for _, path := range watchdogLogFiles {
fmt.Fprintf(logFile, " --- %s ---\n", path)
// append the files
func() {
fd, err := os.Open(path)
defer fd.Close()
if err != nil {
fmt.Fprintf(logFile, "open error: %s\n", err.Error())
return
}
_, err = io.Copy(logFile, fd)
if err != nil {
fmt.Fprintf(logFile, "copy error: %s\n", err.Error())
}
}()
}
return logName, err
} | [
"func",
"WatchdogLogPath",
"(",
"logGlobPath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Get the 5 newest watchdog logs - sorting by name works because timestamp",
"watchdogLogFiles",
",",
"err",
":=",
"filepath",
".",
"Glob",
"(",
"logGlobPath",
")",
"\... | // WatchdogLogPath combines a handful of watchdog logs in to one for
// server upload. | [
"WatchdogLogPath",
"combines",
"a",
"handful",
"of",
"watchdog",
"logs",
"in",
"to",
"one",
"for",
"server",
"upload",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/install/install_windows.go#L181-L217 |
160,910 | keybase/client | go/kbfs/libkbfs/unflushed_path_cache.go | addUnflushedPaths | func addUnflushedPaths(ctx context.Context,
uid keybase1.UID, key kbfscrypto.VerifyingKey, codec kbfscodec.Codec,
log logger.Logger, osg idutil.OfflineStatusGetter, mdInfos []unflushedPathMDInfo,
cpp chainsPathPopulator, unflushedPaths unflushedPathsMap) error {
// Make chains over the entire range to get the unflushed files.
chains := newCRChainsEmpty()
processedOne := false
for _, mdInfo := range mdInfos {
offline := keybase1.OfflineAvailability_NONE
if osg != nil {
offline = osg.OfflineAvailabilityForID(mdInfo.kmd.TlfID())
}
winfo := newWriterInfo(uid, key, mdInfo.revision, offline)
if _, ok := unflushedPaths[mdInfo.revision]; ok {
if processedOne {
return fmt.Errorf("Couldn't skip revision %d after "+
"already processing one", mdInfo.revision)
}
log.CDebugf(ctx, "Skipping unflushed paths for revision %d "+
"since it's already in the cache", mdInfo.revision)
continue
}
unflushedPaths[mdInfo.revision] = make(map[string]bool)
processedOne = true
err := chains.addOps(codec, mdInfo.pmd, winfo, mdInfo.localTimestamp)
if err != nil {
return err
}
}
if !processedOne {
return nil
}
mostRecentMDInfo := mdInfos[len(mdInfos)-1]
chains.mostRecentChainMDInfo = mostRecentMDInfo.kmd
// Does the last op already have a valid path in each chain? If
// so, we don't need to bother populating the paths, which can
// take a fair amount of CPU since the node cache isn't already
// up-to-date with the current set of pointers (because the MDs
// haven't been committed yet).
populatePaths := false
for _, chain := range chains.byOriginal {
if len(chain.ops) > 0 &&
!chain.ops[len(chain.ops)-1].getFinalPath().IsValid() {
populatePaths = true
break
}
}
if populatePaths {
err := cpp.populateChainPaths(ctx, log, chains, true)
if err != nil {
return err
}
}
for _, chain := range chains.byOriginal {
if len(chain.ops) > 0 {
// Use the same final path from the chain for all ops.
finalPath := chain.ops[len(chain.ops)-1].getFinalPath().
CanonicalPathString()
for _, op := range chain.ops {
revPaths, ok := unflushedPaths[op.getWriterInfo().revision]
if !ok {
panic(fmt.Sprintf("No rev map for revision %d",
op.getWriterInfo().revision))
}
revPaths[finalPath] = true
}
}
}
return nil
} | go | func addUnflushedPaths(ctx context.Context,
uid keybase1.UID, key kbfscrypto.VerifyingKey, codec kbfscodec.Codec,
log logger.Logger, osg idutil.OfflineStatusGetter, mdInfos []unflushedPathMDInfo,
cpp chainsPathPopulator, unflushedPaths unflushedPathsMap) error {
// Make chains over the entire range to get the unflushed files.
chains := newCRChainsEmpty()
processedOne := false
for _, mdInfo := range mdInfos {
offline := keybase1.OfflineAvailability_NONE
if osg != nil {
offline = osg.OfflineAvailabilityForID(mdInfo.kmd.TlfID())
}
winfo := newWriterInfo(uid, key, mdInfo.revision, offline)
if _, ok := unflushedPaths[mdInfo.revision]; ok {
if processedOne {
return fmt.Errorf("Couldn't skip revision %d after "+
"already processing one", mdInfo.revision)
}
log.CDebugf(ctx, "Skipping unflushed paths for revision %d "+
"since it's already in the cache", mdInfo.revision)
continue
}
unflushedPaths[mdInfo.revision] = make(map[string]bool)
processedOne = true
err := chains.addOps(codec, mdInfo.pmd, winfo, mdInfo.localTimestamp)
if err != nil {
return err
}
}
if !processedOne {
return nil
}
mostRecentMDInfo := mdInfos[len(mdInfos)-1]
chains.mostRecentChainMDInfo = mostRecentMDInfo.kmd
// Does the last op already have a valid path in each chain? If
// so, we don't need to bother populating the paths, which can
// take a fair amount of CPU since the node cache isn't already
// up-to-date with the current set of pointers (because the MDs
// haven't been committed yet).
populatePaths := false
for _, chain := range chains.byOriginal {
if len(chain.ops) > 0 &&
!chain.ops[len(chain.ops)-1].getFinalPath().IsValid() {
populatePaths = true
break
}
}
if populatePaths {
err := cpp.populateChainPaths(ctx, log, chains, true)
if err != nil {
return err
}
}
for _, chain := range chains.byOriginal {
if len(chain.ops) > 0 {
// Use the same final path from the chain for all ops.
finalPath := chain.ops[len(chain.ops)-1].getFinalPath().
CanonicalPathString()
for _, op := range chain.ops {
revPaths, ok := unflushedPaths[op.getWriterInfo().revision]
if !ok {
panic(fmt.Sprintf("No rev map for revision %d",
op.getWriterInfo().revision))
}
revPaths[finalPath] = true
}
}
}
return nil
} | [
"func",
"addUnflushedPaths",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
",",
"key",
"kbfscrypto",
".",
"VerifyingKey",
",",
"codec",
"kbfscodec",
".",
"Codec",
",",
"log",
"logger",
".",
"Logger",
",",
"osg",
"idutil",
".",
... | // addUnflushedPaths populates the given unflushed paths object. The
// caller should NOT be holding any locks, as it's possible that
// blocks will need to be fetched. | [
"addUnflushedPaths",
"populates",
"the",
"given",
"unflushed",
"paths",
"object",
".",
"The",
"caller",
"should",
"NOT",
"be",
"holding",
"any",
"locks",
"as",
"it",
"s",
"possible",
"that",
"blocks",
"will",
"need",
"to",
"be",
"fetched",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/unflushed_path_cache.go#L158-L233 |
160,911 | keybase/client | go/kbfs/libkbfs/unflushed_path_cache.go | prepUnflushedPaths | func (upc *unflushedPathCache) prepUnflushedPaths(ctx context.Context,
uid keybase1.UID, key kbfscrypto.VerifyingKey, codec kbfscodec.Codec,
log logger.Logger, osg idutil.OfflineStatusGetter, mdInfo unflushedPathMDInfo) (
unflushedPathsPerRevMap, error) {
cpp := func() chainsPathPopulator {
upc.lock.Lock()
defer upc.lock.Unlock()
return upc.chainsPopulator
}()
// The unflushed paths haven't been initialized yet.
if cpp == nil {
return nil, nil
}
newUnflushedPaths := make(unflushedPathsMap)
mdInfos := []unflushedPathMDInfo{mdInfo}
err := addUnflushedPaths(
ctx, uid, key, codec, log, osg, mdInfos, cpp, newUnflushedPaths)
if err != nil {
return nil, err
}
if len(newUnflushedPaths) > 1 {
return nil, fmt.Errorf("%d unflushed revisions on a single put",
len(newUnflushedPaths))
}
perRevMap, ok := newUnflushedPaths[mdInfo.revision]
if !ok {
panic(fmt.Errorf("Cannot find per-revision map for revision %d",
mdInfo.revision))
}
return perRevMap, nil
} | go | func (upc *unflushedPathCache) prepUnflushedPaths(ctx context.Context,
uid keybase1.UID, key kbfscrypto.VerifyingKey, codec kbfscodec.Codec,
log logger.Logger, osg idutil.OfflineStatusGetter, mdInfo unflushedPathMDInfo) (
unflushedPathsPerRevMap, error) {
cpp := func() chainsPathPopulator {
upc.lock.Lock()
defer upc.lock.Unlock()
return upc.chainsPopulator
}()
// The unflushed paths haven't been initialized yet.
if cpp == nil {
return nil, nil
}
newUnflushedPaths := make(unflushedPathsMap)
mdInfos := []unflushedPathMDInfo{mdInfo}
err := addUnflushedPaths(
ctx, uid, key, codec, log, osg, mdInfos, cpp, newUnflushedPaths)
if err != nil {
return nil, err
}
if len(newUnflushedPaths) > 1 {
return nil, fmt.Errorf("%d unflushed revisions on a single put",
len(newUnflushedPaths))
}
perRevMap, ok := newUnflushedPaths[mdInfo.revision]
if !ok {
panic(fmt.Errorf("Cannot find per-revision map for revision %d",
mdInfo.revision))
}
return perRevMap, nil
} | [
"func",
"(",
"upc",
"*",
"unflushedPathCache",
")",
"prepUnflushedPaths",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
",",
"key",
"kbfscrypto",
".",
"VerifyingKey",
",",
"codec",
"kbfscodec",
".",
"Codec",
",",
"log",
"logger",... | // prepUnflushedPaths returns a set of paths that were updated in the
// given revision. | [
"prepUnflushedPaths",
"returns",
"a",
"set",
"of",
"paths",
"that",
"were",
"updated",
"in",
"the",
"given",
"revision",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/unflushed_path_cache.go#L237-L272 |
160,912 | keybase/client | go/kbfs/libkbfs/unflushed_path_cache.go | appendToCache | func (upc *unflushedPathCache) appendToCache(mdInfo unflushedPathMDInfo,
perRevMap unflushedPathsPerRevMap) bool {
upc.lock.Lock()
defer upc.lock.Unlock()
switch upc.state {
case upcUninitialized:
// Nothing to do.
case upcInitializing:
// Append to queue for processing at the end of initialization.
upc.queue = append(upc.queue, upcQueuedOp{
op: upcOpAppend,
info: mdInfo,
rev: mdInfo.revision,
})
case upcInitialized:
if perRevMap == nil {
// This was prepared before `upc.chainsPopulator` was set,
// and needs to be done again.
return false
}
// Update the cache with the prepared paths.
upc.unflushedPaths[mdInfo.revision] = perRevMap
default:
panic(fmt.Sprintf("Unknown unflushedPathsCache state: %v", upc.state))
}
return true
} | go | func (upc *unflushedPathCache) appendToCache(mdInfo unflushedPathMDInfo,
perRevMap unflushedPathsPerRevMap) bool {
upc.lock.Lock()
defer upc.lock.Unlock()
switch upc.state {
case upcUninitialized:
// Nothing to do.
case upcInitializing:
// Append to queue for processing at the end of initialization.
upc.queue = append(upc.queue, upcQueuedOp{
op: upcOpAppend,
info: mdInfo,
rev: mdInfo.revision,
})
case upcInitialized:
if perRevMap == nil {
// This was prepared before `upc.chainsPopulator` was set,
// and needs to be done again.
return false
}
// Update the cache with the prepared paths.
upc.unflushedPaths[mdInfo.revision] = perRevMap
default:
panic(fmt.Sprintf("Unknown unflushedPathsCache state: %v", upc.state))
}
return true
} | [
"func",
"(",
"upc",
"*",
"unflushedPathCache",
")",
"appendToCache",
"(",
"mdInfo",
"unflushedPathMDInfo",
",",
"perRevMap",
"unflushedPathsPerRevMap",
")",
"bool",
"{",
"upc",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"upc",
".",
"lock",
".",
"Unlo... | // appendToCache returns true when successful, and false if it needs
// to be retried after the per-revision map is recomputed. | [
"appendToCache",
"returns",
"true",
"when",
"successful",
"and",
"false",
"if",
"it",
"needs",
"to",
"be",
"retried",
"after",
"the",
"per",
"-",
"revision",
"map",
"is",
"recomputed",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/unflushed_path_cache.go#L276-L302 |
160,913 | keybase/client | go/kbfs/libkbfs/unflushed_path_cache.go | reinitializeWithResolution | func (upc *unflushedPathCache) reinitializeWithResolution(
mdInfo unflushedPathMDInfo, perRevMap unflushedPathsPerRevMap,
isLocalSquash bool) bool {
upc.lock.Lock()
defer upc.lock.Unlock()
if perRevMap == nil {
switch upc.state {
case upcInitialized:
// Initialization started since the perRevMap was created,
// so try again.
return false
case upcInitializing:
// Save this reinit for later.
upc.queue = append(upc.queue, upcQueuedOp{
op: upcOpReinit,
info: mdInfo,
rev: mdInfo.revision,
isLocalSquash: isLocalSquash,
})
return true
default:
// We can't initialize with a nil revision map.
return true
}
}
if upc.unflushedPaths != nil {
reinitUpcCache(
mdInfo.revision, upc.unflushedPaths, perRevMap, isLocalSquash)
} else {
upc.unflushedPaths = unflushedPathsMap{mdInfo.revision: perRevMap}
}
upc.queue = nil
if upc.ready != nil {
close(upc.ready)
upc.ready = nil
}
upc.state = upcInitialized
return true
} | go | func (upc *unflushedPathCache) reinitializeWithResolution(
mdInfo unflushedPathMDInfo, perRevMap unflushedPathsPerRevMap,
isLocalSquash bool) bool {
upc.lock.Lock()
defer upc.lock.Unlock()
if perRevMap == nil {
switch upc.state {
case upcInitialized:
// Initialization started since the perRevMap was created,
// so try again.
return false
case upcInitializing:
// Save this reinit for later.
upc.queue = append(upc.queue, upcQueuedOp{
op: upcOpReinit,
info: mdInfo,
rev: mdInfo.revision,
isLocalSquash: isLocalSquash,
})
return true
default:
// We can't initialize with a nil revision map.
return true
}
}
if upc.unflushedPaths != nil {
reinitUpcCache(
mdInfo.revision, upc.unflushedPaths, perRevMap, isLocalSquash)
} else {
upc.unflushedPaths = unflushedPathsMap{mdInfo.revision: perRevMap}
}
upc.queue = nil
if upc.ready != nil {
close(upc.ready)
upc.ready = nil
}
upc.state = upcInitialized
return true
} | [
"func",
"(",
"upc",
"*",
"unflushedPathCache",
")",
"reinitializeWithResolution",
"(",
"mdInfo",
"unflushedPathMDInfo",
",",
"perRevMap",
"unflushedPathsPerRevMap",
",",
"isLocalSquash",
"bool",
")",
"bool",
"{",
"upc",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
... | // reinitializeWithResolution returns true when successful, and false
// if it needs to be retried after the per-revision map is recomputed. | [
"reinitializeWithResolution",
"returns",
"true",
"when",
"successful",
"and",
"false",
"if",
"it",
"needs",
"to",
"be",
"retried",
"after",
"the",
"per",
"-",
"revision",
"map",
"is",
"recomputed",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/unflushed_path_cache.go#L457-L497 |
160,914 | keybase/client | go/chat/attachments/store.go | NewS3Store | func NewS3Store(logger logger.Logger, env *libkb.Env, runtimeDir string) *S3Store {
return &S3Store{
DebugLabeler: utils.NewDebugLabeler(logger, "Attachments.Store", false),
s3c: &s3.AWS{},
stash: NewFileStash(runtimeDir),
env: env,
}
} | go | func NewS3Store(logger logger.Logger, env *libkb.Env, runtimeDir string) *S3Store {
return &S3Store{
DebugLabeler: utils.NewDebugLabeler(logger, "Attachments.Store", false),
s3c: &s3.AWS{},
stash: NewFileStash(runtimeDir),
env: env,
}
} | [
"func",
"NewS3Store",
"(",
"logger",
"logger",
".",
"Logger",
",",
"env",
"*",
"libkb",
".",
"Env",
",",
"runtimeDir",
"string",
")",
"*",
"S3Store",
"{",
"return",
"&",
"S3Store",
"{",
"DebugLabeler",
":",
"utils",
".",
"NewDebugLabeler",
"(",
"logger",
... | // NewS3Store creates a standard Store that uses a real
// S3 connection. | [
"NewS3Store",
"creates",
"a",
"standard",
"Store",
"that",
"uses",
"a",
"real",
"S3",
"connection",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/store.go#L107-L114 |
160,915 | keybase/client | go/chat/attachments/store.go | DownloadAsset | func (a *S3Store) DownloadAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset,
w io.Writer, signer s3.Signer, progress types.ProgressReporter) error {
if asset.Key == nil || asset.VerifyKey == nil || asset.EncHash == nil {
return fmt.Errorf("unencrypted attachments not supported: asset: %#v", asset)
}
body, err := a.GetAssetReader(ctx, params, asset, signer)
defer func() {
if body != nil {
body.Close()
}
}()
if err != nil {
return err
}
a.Debug(ctx, "DownloadAsset: downloading %s from s3", asset.Path)
return a.DecryptAsset(ctx, w, body, asset, progress)
} | go | func (a *S3Store) DownloadAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset,
w io.Writer, signer s3.Signer, progress types.ProgressReporter) error {
if asset.Key == nil || asset.VerifyKey == nil || asset.EncHash == nil {
return fmt.Errorf("unencrypted attachments not supported: asset: %#v", asset)
}
body, err := a.GetAssetReader(ctx, params, asset, signer)
defer func() {
if body != nil {
body.Close()
}
}()
if err != nil {
return err
}
a.Debug(ctx, "DownloadAsset: downloading %s from s3", asset.Path)
return a.DecryptAsset(ctx, w, body, asset, progress)
} | [
"func",
"(",
"a",
"*",
"S3Store",
")",
"DownloadAsset",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"chat1",
".",
"S3Params",
",",
"asset",
"chat1",
".",
"Asset",
",",
"w",
"io",
".",
"Writer",
",",
"signer",
"s3",
".",
"Signer",
",",
"prog... | // DownloadAsset gets an object from S3 as described in asset. | [
"DownloadAsset",
"gets",
"an",
"object",
"from",
"S3",
"as",
"described",
"in",
"asset",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/store.go#L284-L300 |
160,916 | keybase/client | go/client/cmd_rekey_devel.go | NewCmdRekey | func NewCmdRekey(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "rekey",
Usage: "Rekey status and actions",
ArgumentHelp: "[status, paper, trigger]",
Subcommands: []cli.Command{
NewCmdRekeyStatus(cl, g),
NewCmdRekeyPaper(cl, g),
NewCmdRekeyTrigger(cl, g),
},
}
} | go | func NewCmdRekey(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "rekey",
Usage: "Rekey status and actions",
ArgumentHelp: "[status, paper, trigger]",
Subcommands: []cli.Command{
NewCmdRekeyStatus(cl, g),
NewCmdRekeyPaper(cl, g),
NewCmdRekeyTrigger(cl, g),
},
}
} | [
"func",
"NewCmdRekey",
"(",
"cl",
"*",
"libcmdline",
".",
"CommandLine",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",... | // These are the devel rekey commands | [
"These",
"are",
"the",
"devel",
"rekey",
"commands"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_rekey_devel.go#L15-L26 |
160,917 | keybase/client | go/engine/track_token.go | NewTrackToken | func NewTrackToken(g *libkb.GlobalContext, arg *TrackTokenArg) *TrackToken {
if arg.Options.SigVersion == nil || libkb.SigVersion(*arg.Options.SigVersion) == libkb.KeybaseNullSigVersion {
tmp := keybase1.SigVersion(libkb.GetDefaultSigVersion(g))
arg.Options.SigVersion = &tmp
}
return &TrackToken{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | go | func NewTrackToken(g *libkb.GlobalContext, arg *TrackTokenArg) *TrackToken {
if arg.Options.SigVersion == nil || libkb.SigVersion(*arg.Options.SigVersion) == libkb.KeybaseNullSigVersion {
tmp := keybase1.SigVersion(libkb.GetDefaultSigVersion(g))
arg.Options.SigVersion = &tmp
}
return &TrackToken{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewTrackToken",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"arg",
"*",
"TrackTokenArg",
")",
"*",
"TrackToken",
"{",
"if",
"arg",
".",
"Options",
".",
"SigVersion",
"==",
"nil",
"||",
"libkb",
".",
"SigVersion",
"(",
"*",
"arg",
".",
"... | // NewTrackToken creates a TrackToken engine. | [
"NewTrackToken",
"creates",
"a",
"TrackToken",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/track_token.go#L31-L41 |
160,918 | keybase/client | go/libkb/upak_loader.go | NewCachedUPAKLoader | func NewCachedUPAKLoader(g *GlobalContext, f time.Duration) *CachedUPAKLoader {
c, err := lru.New(g.Env.GetUPAKCacheSize())
if err != nil {
panic(fmt.Sprintf("could not create lru cache (size = %d)", g.Env.GetUPAKCacheSize()))
}
return &CachedUPAKLoader{
Contextified: NewContextified(g),
Freshness: f,
cache: c,
noCache: false,
}
} | go | func NewCachedUPAKLoader(g *GlobalContext, f time.Duration) *CachedUPAKLoader {
c, err := lru.New(g.Env.GetUPAKCacheSize())
if err != nil {
panic(fmt.Sprintf("could not create lru cache (size = %d)", g.Env.GetUPAKCacheSize()))
}
return &CachedUPAKLoader{
Contextified: NewContextified(g),
Freshness: f,
cache: c,
noCache: false,
}
} | [
"func",
"NewCachedUPAKLoader",
"(",
"g",
"*",
"GlobalContext",
",",
"f",
"time",
".",
"Duration",
")",
"*",
"CachedUPAKLoader",
"{",
"c",
",",
"err",
":=",
"lru",
".",
"New",
"(",
"g",
".",
"Env",
".",
"GetUPAKCacheSize",
"(",
")",
")",
"\n",
"if",
"... | // NewCachedUPAKLoader constructs a new CachedUPAKLoader | [
"NewCachedUPAKLoader",
"constructs",
"a",
"new",
"CachedUPAKLoader"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L56-L67 |
160,919 | keybase/client | go/libkb/upak_loader.go | NewUncachedUPAKLoader | func NewUncachedUPAKLoader(g *GlobalContext) UPAKLoader {
return &CachedUPAKLoader{
Contextified: NewContextified(g),
Freshness: time.Duration(0),
noCache: true,
}
} | go | func NewUncachedUPAKLoader(g *GlobalContext) UPAKLoader {
return &CachedUPAKLoader{
Contextified: NewContextified(g),
Freshness: time.Duration(0),
noCache: true,
}
} | [
"func",
"NewUncachedUPAKLoader",
"(",
"g",
"*",
"GlobalContext",
")",
"UPAKLoader",
"{",
"return",
"&",
"CachedUPAKLoader",
"{",
"Contextified",
":",
"NewContextified",
"(",
"g",
")",
",",
"Freshness",
":",
"time",
".",
"Duration",
"(",
"0",
")",
",",
"noCac... | // NewUncachedUPAKLoader creates a UPAK loader that doesn't do any caching.
// It uses the implementation of CachedUPAKLoader but disables all caching. | [
"NewUncachedUPAKLoader",
"creates",
"a",
"UPAK",
"loader",
"that",
"doesn",
"t",
"do",
"any",
"caching",
".",
"It",
"uses",
"the",
"implementation",
"of",
"CachedUPAKLoader",
"but",
"disables",
"all",
"caching",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L88-L94 |
160,920 | keybase/client | go/libkb/upak_loader.go | Load | func (u *CachedUPAKLoader) Load(arg LoadUserArg) (*keybase1.UserPlusAllKeys, *User, error) {
ret, user, err := u.loadWithInfo(arg, nil, nil, true)
// NOTE -- it's OK to return an error and a user, since certain code paths
// want both (see note in loadWithInfo).
var converted *keybase1.UserPlusAllKeys
if ret != nil {
tmp := keybase1.UPAKFromUPKV2AI(*ret)
converted = &tmp
}
return converted, user, err
} | go | func (u *CachedUPAKLoader) Load(arg LoadUserArg) (*keybase1.UserPlusAllKeys, *User, error) {
ret, user, err := u.loadWithInfo(arg, nil, nil, true)
// NOTE -- it's OK to return an error and a user, since certain code paths
// want both (see note in loadWithInfo).
var converted *keybase1.UserPlusAllKeys
if ret != nil {
tmp := keybase1.UPAKFromUPKV2AI(*ret)
converted = &tmp
}
return converted, user, err
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"Load",
"(",
"arg",
"LoadUserArg",
")",
"(",
"*",
"keybase1",
".",
"UserPlusAllKeys",
",",
"*",
"User",
",",
"error",
")",
"{",
"ret",
",",
"user",
",",
"err",
":=",
"u",
".",
"loadWithInfo",
"(",
"arg"... | // Load a UserPlusKeysV2AllIncarnations from the local cache, falls back to
// LoadUser, and cache the user. Can only perform lookups by UID. Will return a
// non-nil UserPlusKeysV2AllIncarnations, or a non-nil error, but never both
// non-nil, nor never both nil. If we had to do a full LoadUser as part of the
// request, it's returned too. Convert to UserPlusAllKeys on the way out, for
// backwards compatibility. | [
"Load",
"a",
"UserPlusKeysV2AllIncarnations",
"from",
"the",
"local",
"cache",
"falls",
"back",
"to",
"LoadUser",
"and",
"cache",
"the",
"user",
".",
"Can",
"only",
"perform",
"lookups",
"by",
"UID",
".",
"Will",
"return",
"a",
"non",
"-",
"nil",
"UserPlusKe... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L509-L521 |
160,921 | keybase/client | go/libkb/upak_loader.go | LoadV2 | func (u *CachedUPAKLoader) LoadV2(arg LoadUserArg) (*keybase1.UserPlusKeysV2AllIncarnations, *User, error) {
m, tbs := arg.m.WithTimeBuckets()
arg.m = m
defer tbs.Record("CachedUPAKLoader.LoadV2")()
return u.loadWithInfo(arg, nil, nil, true)
} | go | func (u *CachedUPAKLoader) LoadV2(arg LoadUserArg) (*keybase1.UserPlusKeysV2AllIncarnations, *User, error) {
m, tbs := arg.m.WithTimeBuckets()
arg.m = m
defer tbs.Record("CachedUPAKLoader.LoadV2")()
return u.loadWithInfo(arg, nil, nil, true)
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"LoadV2",
"(",
"arg",
"LoadUserArg",
")",
"(",
"*",
"keybase1",
".",
"UserPlusKeysV2AllIncarnations",
",",
"*",
"User",
",",
"error",
")",
"{",
"m",
",",
"tbs",
":=",
"arg",
".",
"m",
".",
"WithTimeBuckets"... | // Load a UserPlusKeysV2AllIncarnations from the local cache, falls back to
// LoadUser, and cache the user. Can only perform lookups by UID. Will return a
// non-nil UserPlusKeysV2AllIncarnations, or a non-nil error, but never both
// non-nil, nor never both nil. If we had to do a full LoadUser as part of the
// request, it's returned too. | [
"Load",
"a",
"UserPlusKeysV2AllIncarnations",
"from",
"the",
"local",
"cache",
"falls",
"back",
"to",
"LoadUser",
"and",
"cache",
"the",
"user",
".",
"Can",
"only",
"perform",
"lookups",
"by",
"UID",
".",
"Will",
"return",
"a",
"non",
"-",
"nil",
"UserPlusKe... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L528-L533 |
160,922 | keybase/client | go/libkb/upak_loader.go | LoadKeyV2 | func (u *CachedUPAKLoader) LoadKeyV2(ctx context.Context, uid keybase1.UID, kid keybase1.KID) (ret *keybase1.UserPlusKeysV2,
upak *keybase1.UserPlusKeysV2AllIncarnations, key *keybase1.PublicKeyV2NaCl, err error) {
ctx = WithLogTag(ctx, "LK") // Load key
defer u.G().CVTraceTimed(ctx, VLog0, fmt.Sprintf("LoadKeyV2 uid:%s,kid:%s", uid, kid), func() error { return err })()
ctx, tbs := u.G().CTimeBuckets(ctx)
defer tbs.Record("CachedUPAKLoader.LoadKeyV2")()
if uid.IsNil() {
return nil, nil, nil, NoUIDError{}
}
argBase := NewLoadUserArg(u.G()).WithUID(uid).WithPublicKeyOptional().WithNetContext(ctx)
// Make the retry mechanism increasingly aggressive. See CORE-8851.
// It should be that a ForcePoll is good enough, but in some rare cases,
// people have cached values for previous pre-reset user incarnations that
// were incorrect. So clobber over that if it comes to it.
attempts := []LoadUserArg{
argBase,
argBase.WithForcePoll(true),
argBase.WithForceReload(),
}
for i, arg := range attempts {
if i > 0 {
u.G().VDL.CLogf(ctx, VLog0, "| reloading with arg: %s", arg.String())
}
upak, _, err := u.LoadV2(arg)
if err != nil {
return nil, nil, nil, err
}
if upak == nil {
return nil, nil, nil, fmt.Errorf("Nil user, nil error from LoadUser")
}
ret, key := upak.FindKID(kid)
if key != nil {
u.G().VDL.CLogf(ctx, VLog1, "- found kid in UPAK: %v", ret.Uid)
return ret, upak, key, nil
}
}
return nil, nil, nil, NotFoundError{Msg: "Not found: Key for user"}
} | go | func (u *CachedUPAKLoader) LoadKeyV2(ctx context.Context, uid keybase1.UID, kid keybase1.KID) (ret *keybase1.UserPlusKeysV2,
upak *keybase1.UserPlusKeysV2AllIncarnations, key *keybase1.PublicKeyV2NaCl, err error) {
ctx = WithLogTag(ctx, "LK") // Load key
defer u.G().CVTraceTimed(ctx, VLog0, fmt.Sprintf("LoadKeyV2 uid:%s,kid:%s", uid, kid), func() error { return err })()
ctx, tbs := u.G().CTimeBuckets(ctx)
defer tbs.Record("CachedUPAKLoader.LoadKeyV2")()
if uid.IsNil() {
return nil, nil, nil, NoUIDError{}
}
argBase := NewLoadUserArg(u.G()).WithUID(uid).WithPublicKeyOptional().WithNetContext(ctx)
// Make the retry mechanism increasingly aggressive. See CORE-8851.
// It should be that a ForcePoll is good enough, but in some rare cases,
// people have cached values for previous pre-reset user incarnations that
// were incorrect. So clobber over that if it comes to it.
attempts := []LoadUserArg{
argBase,
argBase.WithForcePoll(true),
argBase.WithForceReload(),
}
for i, arg := range attempts {
if i > 0 {
u.G().VDL.CLogf(ctx, VLog0, "| reloading with arg: %s", arg.String())
}
upak, _, err := u.LoadV2(arg)
if err != nil {
return nil, nil, nil, err
}
if upak == nil {
return nil, nil, nil, fmt.Errorf("Nil user, nil error from LoadUser")
}
ret, key := upak.FindKID(kid)
if key != nil {
u.G().VDL.CLogf(ctx, VLog1, "- found kid in UPAK: %v", ret.Uid)
return ret, upak, key, nil
}
}
return nil, nil, nil, NotFoundError{Msg: "Not found: Key for user"}
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"LoadKeyV2",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
",",
"kid",
"keybase1",
".",
"KID",
")",
"(",
"ret",
"*",
"keybase1",
".",
"UserPlusKeysV2",
",",
"upak",
"*",
"keyb... | // LoadKeyV2 looks through all incarnations for the user and returns the incarnation with the given
// KID, as well as the Key data associated with that KID. It picks the latest such
// incarnation if there are multiple. | [
"LoadKeyV2",
"looks",
"through",
"all",
"incarnations",
"for",
"the",
"user",
"and",
"returns",
"the",
"incarnation",
"with",
"the",
"given",
"KID",
"as",
"well",
"as",
"the",
"Key",
"data",
"associated",
"with",
"that",
"KID",
".",
"It",
"picks",
"the",
"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L589-L633 |
160,923 | keybase/client | go/libkb/upak_loader.go | LoadDeviceKey | func (u *CachedUPAKLoader) LoadDeviceKey(ctx context.Context, uid keybase1.UID, deviceID keybase1.DeviceID) (upakv1 *keybase1.UserPlusAllKeys, deviceKey *keybase1.PublicKey, revoked *keybase1.RevokedKey, err error) {
var info CachedUserLoadInfo
larg := NewLoadUserByUIDArg(ctx, u.G(), uid)
upakV2, _, err := u.loadWithInfo(larg, &info, nil, false)
if err != nil {
return nil, nil, nil, err
}
upakV1 := keybase1.UPAKFromUPKV2AI(*upakV2)
deviceKey, revoked, err = u.extractDeviceKey(upakV1, deviceID)
if err == nil {
// Early success, return
return &upakV1, deviceKey, revoked, err
}
// Try again with a forced load in case the device is very new.
larg = larg.WithForcePoll(true)
upakV2, _, err = u.loadWithInfo(larg, nil, nil, false)
if err != nil {
return nil, nil, nil, err
}
upakV1 = keybase1.UPAKFromUPKV2AI(*upakV2)
deviceKey, revoked, err = u.extractDeviceKey(upakV1, deviceID)
return &upakV1, deviceKey, revoked, err
} | go | func (u *CachedUPAKLoader) LoadDeviceKey(ctx context.Context, uid keybase1.UID, deviceID keybase1.DeviceID) (upakv1 *keybase1.UserPlusAllKeys, deviceKey *keybase1.PublicKey, revoked *keybase1.RevokedKey, err error) {
var info CachedUserLoadInfo
larg := NewLoadUserByUIDArg(ctx, u.G(), uid)
upakV2, _, err := u.loadWithInfo(larg, &info, nil, false)
if err != nil {
return nil, nil, nil, err
}
upakV1 := keybase1.UPAKFromUPKV2AI(*upakV2)
deviceKey, revoked, err = u.extractDeviceKey(upakV1, deviceID)
if err == nil {
// Early success, return
return &upakV1, deviceKey, revoked, err
}
// Try again with a forced load in case the device is very new.
larg = larg.WithForcePoll(true)
upakV2, _, err = u.loadWithInfo(larg, nil, nil, false)
if err != nil {
return nil, nil, nil, err
}
upakV1 = keybase1.UPAKFromUPKV2AI(*upakV2)
deviceKey, revoked, err = u.extractDeviceKey(upakV1, deviceID)
return &upakV1, deviceKey, revoked, err
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"LoadDeviceKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
",",
"deviceID",
"keybase1",
".",
"DeviceID",
")",
"(",
"upakv1",
"*",
"keybase1",
".",
"UserPlusAllKeys",
",",
"dev... | // Load the PublicKey for a user's device from the local cache, falling back to LoadUser, and cache the user.
// If the user exists but the device doesn't, will force a load in case the device is very new. | [
"Load",
"the",
"PublicKey",
"for",
"a",
"user",
"s",
"device",
"from",
"the",
"local",
"cache",
"falling",
"back",
"to",
"LoadUser",
"and",
"cache",
"the",
"user",
".",
"If",
"the",
"user",
"exists",
"but",
"the",
"device",
"doesn",
"t",
"will",
"force",... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L660-L685 |
160,924 | keybase/client | go/libkb/upak_loader.go | LoadUPAKWithDeviceID | func (u *CachedUPAKLoader) LoadUPAKWithDeviceID(ctx context.Context, uid keybase1.UID, deviceID keybase1.DeviceID) (*keybase1.UserPlusKeysV2AllIncarnations, error) {
var info CachedUserLoadInfo
larg := NewLoadUserByUIDArg(ctx, u.G(), uid).WithPublicKeyOptional()
upakV2, _, err := u.loadWithInfo(larg, &info, nil, false)
if err != nil {
return nil, err
}
for _, device := range upakV2.Current.DeviceKeys {
if device.DeviceID.Eq(deviceID) {
// Early success, return
return upakV2, nil
}
}
// Try again with a forced load in case the device is very new.
larg = larg.WithForcePoll(true)
upakV2, _, err = u.loadWithInfo(larg, nil, nil, false)
if err != nil {
return nil, err
}
return upakV2, nil
} | go | func (u *CachedUPAKLoader) LoadUPAKWithDeviceID(ctx context.Context, uid keybase1.UID, deviceID keybase1.DeviceID) (*keybase1.UserPlusKeysV2AllIncarnations, error) {
var info CachedUserLoadInfo
larg := NewLoadUserByUIDArg(ctx, u.G(), uid).WithPublicKeyOptional()
upakV2, _, err := u.loadWithInfo(larg, &info, nil, false)
if err != nil {
return nil, err
}
for _, device := range upakV2.Current.DeviceKeys {
if device.DeviceID.Eq(deviceID) {
// Early success, return
return upakV2, nil
}
}
// Try again with a forced load in case the device is very new.
larg = larg.WithForcePoll(true)
upakV2, _, err = u.loadWithInfo(larg, nil, nil, false)
if err != nil {
return nil, err
}
return upakV2, nil
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"LoadUPAKWithDeviceID",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
",",
"deviceID",
"keybase1",
".",
"DeviceID",
")",
"(",
"*",
"keybase1",
".",
"UserPlusKeysV2AllIncarnations",
",... | // If the user exists but the device doesn't, will force a load in case the device is very new. | [
"If",
"the",
"user",
"exists",
"but",
"the",
"device",
"doesn",
"t",
"will",
"force",
"a",
"load",
"in",
"case",
"the",
"device",
"is",
"very",
"new",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L688-L710 |
160,925 | keybase/client | go/libkb/upak_loader.go | LookupUsername | func (u *CachedUPAKLoader) LookupUsername(ctx context.Context, uid keybase1.UID) (NormalizedUsername, error) {
var empty NormalizedUsername
uids := []keybase1.UID{uid}
namePkgs, err := u.G().UIDMapper.MapUIDsToUsernamePackages(ctx, u.G(), uids, 0, 0, false)
if err != nil {
return empty, err
}
if len(namePkgs) == 0 {
return empty, UserNotFoundError{UID: uid, Msg: "in CachedUPAKLoader"}
}
if u.TestDeadlocker != nil {
u.TestDeadlocker()
}
return namePkgs[0].NormalizedUsername, nil
} | go | func (u *CachedUPAKLoader) LookupUsername(ctx context.Context, uid keybase1.UID) (NormalizedUsername, error) {
var empty NormalizedUsername
uids := []keybase1.UID{uid}
namePkgs, err := u.G().UIDMapper.MapUIDsToUsernamePackages(ctx, u.G(), uids, 0, 0, false)
if err != nil {
return empty, err
}
if len(namePkgs) == 0 {
return empty, UserNotFoundError{UID: uid, Msg: "in CachedUPAKLoader"}
}
if u.TestDeadlocker != nil {
u.TestDeadlocker()
}
return namePkgs[0].NormalizedUsername, nil
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"LookupUsername",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
")",
"(",
"NormalizedUsername",
",",
"error",
")",
"{",
"var",
"empty",
"NormalizedUsername",
"\n",
"uids",
":=",
"... | // LookupUsername uses the UIDMapper to find a username for uid. | [
"LookupUsername",
"uses",
"the",
"UIDMapper",
"to",
"find",
"a",
"username",
"for",
"uid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L713-L729 |
160,926 | keybase/client | go/libkb/upak_loader.go | LookupUsernameUPAK | func (u *CachedUPAKLoader) LookupUsernameUPAK(ctx context.Context, uid keybase1.UID) (NormalizedUsername, error) {
var info CachedUserLoadInfo
arg := NewLoadUserByUIDArg(ctx, u.G(), uid).WithStaleOK(true).WithPublicKeyOptional()
var ret NormalizedUsername
_, _, err := u.loadWithInfo(arg, &info, func(upak *keybase1.UserPlusKeysV2AllIncarnations) error {
if upak == nil {
return UserNotFoundError{UID: uid, Msg: "in CachedUPAKLoader"}
}
ret = NewNormalizedUsername(upak.Current.Username)
return nil
}, false)
return ret, err
} | go | func (u *CachedUPAKLoader) LookupUsernameUPAK(ctx context.Context, uid keybase1.UID) (NormalizedUsername, error) {
var info CachedUserLoadInfo
arg := NewLoadUserByUIDArg(ctx, u.G(), uid).WithStaleOK(true).WithPublicKeyOptional()
var ret NormalizedUsername
_, _, err := u.loadWithInfo(arg, &info, func(upak *keybase1.UserPlusKeysV2AllIncarnations) error {
if upak == nil {
return UserNotFoundError{UID: uid, Msg: "in CachedUPAKLoader"}
}
ret = NewNormalizedUsername(upak.Current.Username)
return nil
}, false)
return ret, err
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"LookupUsernameUPAK",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
")",
"(",
"NormalizedUsername",
",",
"error",
")",
"{",
"var",
"info",
"CachedUserLoadInfo",
"\n",
"arg",
":=",
... | // LookupUsernameUPAK uses the upak loader to find a username for uid. | [
"LookupUsernameUPAK",
"uses",
"the",
"upak",
"loader",
"to",
"find",
"a",
"username",
"for",
"uid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L732-L744 |
160,927 | keybase/client | go/libkb/upak_loader.go | LookupUID | func (u *CachedUPAKLoader) LookupUID(ctx context.Context, un NormalizedUsername) (keybase1.UID, error) {
m := NewMetaContext(ctx, u.G())
rres := u.G().Resolver.Resolve(m, un.String())
if err := rres.GetError(); err != nil {
return keybase1.UID(""), err
}
un2, err := u.LookupUsername(ctx, rres.GetUID())
if err != nil {
return keybase1.UID(""), err
}
if !un.Eq(un2) {
m.Warning("Unexpected mismatched usernames (uid=%s): %s != %s", rres.GetUID(), un.String(), un2.String())
return keybase1.UID(""), NewBadUsernameError(un.String())
}
return rres.GetUID(), nil
} | go | func (u *CachedUPAKLoader) LookupUID(ctx context.Context, un NormalizedUsername) (keybase1.UID, error) {
m := NewMetaContext(ctx, u.G())
rres := u.G().Resolver.Resolve(m, un.String())
if err := rres.GetError(); err != nil {
return keybase1.UID(""), err
}
un2, err := u.LookupUsername(ctx, rres.GetUID())
if err != nil {
return keybase1.UID(""), err
}
if !un.Eq(un2) {
m.Warning("Unexpected mismatched usernames (uid=%s): %s != %s", rres.GetUID(), un.String(), un2.String())
return keybase1.UID(""), NewBadUsernameError(un.String())
}
return rres.GetUID(), nil
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"LookupUID",
"(",
"ctx",
"context",
".",
"Context",
",",
"un",
"NormalizedUsername",
")",
"(",
"keybase1",
".",
"UID",
",",
"error",
")",
"{",
"m",
":=",
"NewMetaContext",
"(",
"ctx",
",",
"u",
".",
"G",
... | // LookupUID is a verified map of username -> UID. IT calls into the resolver, which gives un untrusted
// UID, but verifies with the UPAK loader that the mapping UID -> username is correct. | [
"LookupUID",
"is",
"a",
"verified",
"map",
"of",
"username",
"-",
">",
"UID",
".",
"IT",
"calls",
"into",
"the",
"resolver",
"which",
"gives",
"un",
"untrusted",
"UID",
"but",
"verifies",
"with",
"the",
"UPAK",
"loader",
"that",
"the",
"mapping",
"UID",
... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L748-L763 |
160,928 | keybase/client | go/libkb/upak_loader.go | deleteV1UPAK | func (u *CachedUPAKLoader) deleteV1UPAK(uid keybase1.UID) {
err := u.G().LocalDb.Delete(culDBKeyV1(uid))
if err != nil {
u.G().Log.Warning("Failed to remove %s v1 object from disk cache: %s", uid, err)
}
} | go | func (u *CachedUPAKLoader) deleteV1UPAK(uid keybase1.UID) {
err := u.G().LocalDb.Delete(culDBKeyV1(uid))
if err != nil {
u.G().Log.Warning("Failed to remove %s v1 object from disk cache: %s", uid, err)
}
} | [
"func",
"(",
"u",
"*",
"CachedUPAKLoader",
")",
"deleteV1UPAK",
"(",
"uid",
"keybase1",
".",
"UID",
")",
"{",
"err",
":=",
"u",
".",
"G",
"(",
")",
".",
"LocalDb",
".",
"Delete",
"(",
"culDBKeyV1",
"(",
"uid",
")",
")",
"\n",
"if",
"err",
"!=",
"... | // v1 UPAKs are all legacy and need to be gradually cleaned from cache. | [
"v1",
"UPAKs",
"are",
"all",
"legacy",
"and",
"need",
"to",
"be",
"gradually",
"cleaned",
"from",
"cache",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/upak_loader.go#L881-L886 |
160,929 | keybase/client | go/protocol/keybase1/user.go | LoadUser | func (c UserClient) LoadUser(ctx context.Context, __arg LoadUserArg) (res User, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.loadUser", []interface{}{__arg}, &res)
return
} | go | func (c UserClient) LoadUser(ctx context.Context, __arg LoadUserArg) (res User, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.loadUser", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"UserClient",
")",
"LoadUser",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"LoadUserArg",
")",
"(",
"res",
"User",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",... | // Load a user from the server. | [
"Load",
"a",
"user",
"from",
"the",
"server",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/user.go#L949-L952 |
160,930 | keybase/client | go/protocol/keybase1/user.go | LoadUserPlusKeys | func (c UserClient) LoadUserPlusKeys(ctx context.Context, __arg LoadUserPlusKeysArg) (res UserPlusKeys, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.loadUserPlusKeys", []interface{}{__arg}, &res)
return
} | go | func (c UserClient) LoadUserPlusKeys(ctx context.Context, __arg LoadUserPlusKeysArg) (res UserPlusKeys, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.loadUserPlusKeys", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"UserClient",
")",
"LoadUserPlusKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"LoadUserPlusKeysArg",
")",
"(",
"res",
"UserPlusKeys",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
"... | // Load a user + device keys from the server. | [
"Load",
"a",
"user",
"+",
"device",
"keys",
"from",
"the",
"server",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/user.go#L960-L963 |
160,931 | keybase/client | go/protocol/keybase1/user.go | LoadPublicKeys | func (c UserClient) LoadPublicKeys(ctx context.Context, __arg LoadPublicKeysArg) (res []PublicKey, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.loadPublicKeys", []interface{}{__arg}, &res)
return
} | go | func (c UserClient) LoadPublicKeys(ctx context.Context, __arg LoadPublicKeysArg) (res []PublicKey, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.loadPublicKeys", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"UserClient",
")",
"LoadPublicKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"LoadPublicKeysArg",
")",
"(",
"res",
"[",
"]",
"PublicKey",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ct... | // Load public keys for a user. | [
"Load",
"public",
"keys",
"for",
"a",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/user.go#L971-L974 |
160,932 | keybase/client | go/protocol/keybase1/user.go | ListTracking | func (c UserClient) ListTracking(ctx context.Context, __arg ListTrackingArg) (res []UserSummary, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.listTracking", []interface{}{__arg}, &res)
return
} | go | func (c UserClient) ListTracking(ctx context.Context, __arg ListTrackingArg) (res []UserSummary, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.listTracking", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"UserClient",
")",
"ListTracking",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"ListTrackingArg",
")",
"(",
"res",
"[",
"]",
"UserSummary",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx"... | // The list-tracking functions get verified data from the tracking statements
// in the user's sigchain.
//
// If assertion is empty, it will use the current logged in user. | [
"The",
"list",
"-",
"tracking",
"functions",
"get",
"verified",
"data",
"from",
"the",
"tracking",
"statements",
"in",
"the",
"user",
"s",
"sigchain",
".",
"If",
"assertion",
"is",
"empty",
"it",
"will",
"use",
"the",
"current",
"logged",
"in",
"user",
"."... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/user.go#L994-L997 |
160,933 | keybase/client | go/protocol/keybase1/user.go | GetUPAK | func (c UserClient) GetUPAK(ctx context.Context, uid UID) (res UPAKVersioned, err error) {
__arg := GetUPAKArg{Uid: uid}
err = c.Cli.Call(ctx, "keybase.1.user.getUPAK", []interface{}{__arg}, &res)
return
} | go | func (c UserClient) GetUPAK(ctx context.Context, uid UID) (res UPAKVersioned, err error) {
__arg := GetUPAKArg{Uid: uid}
err = c.Cli.Call(ctx, "keybase.1.user.getUPAK", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"UserClient",
")",
"GetUPAK",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"UID",
")",
"(",
"res",
"UPAKVersioned",
",",
"err",
"error",
")",
"{",
"__arg",
":=",
"GetUPAKArg",
"{",
"Uid",
":",
"uid",
"}",
"\n",
"err",
"=",
"... | // getUPAK returns a UPAK. Used mainly for debugging. | [
"getUPAK",
"returns",
"a",
"UPAK",
".",
"Used",
"mainly",
"for",
"debugging",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/user.go#L1033-L1037 |
160,934 | keybase/client | go/protocol/keybase1/user.go | GetUPAKLite | func (c UserClient) GetUPAKLite(ctx context.Context, uid UID) (res UPKLiteV1AllIncarnations, err error) {
__arg := GetUPAKLiteArg{Uid: uid}
err = c.Cli.Call(ctx, "keybase.1.user.getUPAKLite", []interface{}{__arg}, &res)
return
} | go | func (c UserClient) GetUPAKLite(ctx context.Context, uid UID) (res UPKLiteV1AllIncarnations, err error) {
__arg := GetUPAKLiteArg{Uid: uid}
err = c.Cli.Call(ctx, "keybase.1.user.getUPAKLite", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"UserClient",
")",
"GetUPAKLite",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"UID",
")",
"(",
"res",
"UPKLiteV1AllIncarnations",
",",
"err",
"error",
")",
"{",
"__arg",
":=",
"GetUPAKLiteArg",
"{",
"Uid",
":",
"uid",
"}",
"\n",
... | // getUPAKLite returns a UPKLiteV1AllIncarnations. Used mainly for debugging. | [
"getUPAKLite",
"returns",
"a",
"UPKLiteV1AllIncarnations",
".",
"Used",
"mainly",
"for",
"debugging",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/user.go#L1040-L1044 |
160,935 | keybase/client | go/protocol/keybase1/user.go | FindNextMerkleRootAfterReset | func (c UserClient) FindNextMerkleRootAfterReset(ctx context.Context, __arg FindNextMerkleRootAfterResetArg) (res NextMerkleRootRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.findNextMerkleRootAfterReset", []interface{}{__arg}, &res)
return
} | go | func (c UserClient) FindNextMerkleRootAfterReset(ctx context.Context, __arg FindNextMerkleRootAfterResetArg) (res NextMerkleRootRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.user.findNextMerkleRootAfterReset", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"UserClient",
")",
"FindNextMerkleRootAfterReset",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"FindNextMerkleRootAfterResetArg",
")",
"(",
"res",
"NextMerkleRootRes",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
... | // FindNextMerkleRootAfterReset finds the first Merkle root that contains the UID reset
// at resetSeqno. You should pass it prev, which was the last known Merkle root at the time of
// the reset. Usually, we'll just turn up the next Merkle root, but not always. | [
"FindNextMerkleRootAfterReset",
"finds",
"the",
"first",
"Merkle",
"root",
"that",
"contains",
"the",
"UID",
"reset",
"at",
"resetSeqno",
".",
"You",
"should",
"pass",
"it",
"prev",
"which",
"was",
"the",
"last",
"known",
"Merkle",
"root",
"at",
"the",
"time",... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/user.go#L1068-L1071 |
160,936 | keybase/client | go/stellar/autoclaim.go | Kick | func (r *AutoClaimRunner) Kick(mctx libkb.MetaContext, trigger gregor.MsgID) {
mctx.Debug("AutoClaimRunner.Kick(trigger:%v)", trigger)
var onced bool
r.startOnce.Do(func() {
onced = true
go r.loop(libkb.NewMetaContextBackground(mctx.G()), trigger)
})
if !onced {
select {
case r.kickCh <- trigger:
default:
}
}
} | go | func (r *AutoClaimRunner) Kick(mctx libkb.MetaContext, trigger gregor.MsgID) {
mctx.Debug("AutoClaimRunner.Kick(trigger:%v)", trigger)
var onced bool
r.startOnce.Do(func() {
onced = true
go r.loop(libkb.NewMetaContextBackground(mctx.G()), trigger)
})
if !onced {
select {
case r.kickCh <- trigger:
default:
}
}
} | [
"func",
"(",
"r",
"*",
"AutoClaimRunner",
")",
"Kick",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"trigger",
"gregor",
".",
"MsgID",
")",
"{",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"trigger",
")",
"\n",
"var",
"onced",
"bool",
"\n",
"r",
... | // Kick the processor into gear.
// It will run until all relays in the queue are claimed.
// And then dismiss the gregor message.
// `trigger` is optional, and is of the gregor message that caused the kick. | [
"Kick",
"the",
"processor",
"into",
"gear",
".",
"It",
"will",
"run",
"until",
"all",
"relays",
"in",
"the",
"queue",
"are",
"claimed",
".",
"And",
"then",
"dismiss",
"the",
"gregor",
"message",
".",
"trigger",
"is",
"optional",
"and",
"is",
"of",
"the",... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/autoclaim.go#L34-L47 |
160,937 | keybase/client | go/engine/account_reset.go | NewAccountReset | func NewAccountReset(g *libkb.GlobalContext, usernameOrEmail string) *AccountReset {
return &AccountReset{
Contextified: libkb.NewContextified(g),
usernameOrEmail: usernameOrEmail,
}
} | go | func NewAccountReset(g *libkb.GlobalContext, usernameOrEmail string) *AccountReset {
return &AccountReset{
Contextified: libkb.NewContextified(g),
usernameOrEmail: usernameOrEmail,
}
} | [
"func",
"NewAccountReset",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"usernameOrEmail",
"string",
")",
"*",
"AccountReset",
"{",
"return",
"&",
"AccountReset",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"usernameOrE... | // NewAccountReset creates a AccountReset engine. | [
"NewAccountReset",
"creates",
"a",
"AccountReset",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/account_reset.go#L25-L30 |
160,938 | keybase/client | go/client/files.go | Close | func (b *StdinSource) Close() error {
var err error
if b.open {
err = drain(os.Stdin)
}
b.open = false
return err
} | go | func (b *StdinSource) Close() error {
var err error
if b.open {
err = drain(os.Stdin)
}
b.open = false
return err
} | [
"func",
"(",
"b",
"*",
"StdinSource",
")",
"Close",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"if",
"b",
".",
"open",
"{",
"err",
"=",
"drain",
"(",
"os",
".",
"Stdin",
")",
"\n",
"}",
"\n",
"b",
".",
"open",
"=",
"false",
"\n",
"r... | // Close a source, but consume all leftover input before so doing. | [
"Close",
"a",
"source",
"but",
"consume",
"all",
"leftover",
"input",
"before",
"so",
"doing",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/files.go#L84-L91 |
160,939 | keybase/client | go/client/files.go | isValidFile | func isValidFile(file *os.File) error {
finfo, err := file.Stat()
if err != nil {
return err
}
if mode := finfo.Mode(); mode.IsDir() {
return fmt.Errorf("A directory is not a valid file")
}
return nil
} | go | func isValidFile(file *os.File) error {
finfo, err := file.Stat()
if err != nil {
return err
}
if mode := finfo.Mode(); mode.IsDir() {
return fmt.Errorf("A directory is not a valid file")
}
return nil
} | [
"func",
"isValidFile",
"(",
"file",
"*",
"os",
".",
"File",
")",
"error",
"{",
"finfo",
",",
"err",
":=",
"file",
".",
"Stat",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"mode",
":=",
"finfo",
".",
"M... | // isValidFile verifies the file in question is not actually a directory. | [
"isValidFile",
"verifies",
"the",
"file",
"in",
"question",
"is",
"not",
"actually",
"a",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/files.go#L117-L126 |
160,940 | keybase/client | go/libkb/secret_store_external.go | SetGlobalExternalKeyStore | func SetGlobalExternalKeyStore(s UnsafeExternalKeyStore) {
externalKeyStoreMu.Lock()
defer externalKeyStoreMu.Unlock()
externalKeyStore = TypeSafeExternalKeyStoreProxy{s}
externalKeyStoreInitialized = false
} | go | func SetGlobalExternalKeyStore(s UnsafeExternalKeyStore) {
externalKeyStoreMu.Lock()
defer externalKeyStoreMu.Unlock()
externalKeyStore = TypeSafeExternalKeyStoreProxy{s}
externalKeyStoreInitialized = false
} | [
"func",
"SetGlobalExternalKeyStore",
"(",
"s",
"UnsafeExternalKeyStore",
")",
"{",
"externalKeyStoreMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"externalKeyStoreMu",
".",
"Unlock",
"(",
")",
"\n",
"externalKeyStore",
"=",
"TypeSafeExternalKeyStoreProxy",
"{",
"s",
"}... | // SetGlobalExternalKeyStore is called by Android to register Android's KeyStore with Go | [
"SetGlobalExternalKeyStore",
"is",
"called",
"by",
"Android",
"to",
"register",
"Android",
"s",
"KeyStore",
"with",
"Go"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/secret_store_external.go#L72-L77 |
160,941 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | ToWriterMetadataV3 | func (wmdV2 *WriterMetadataV2) ToWriterMetadataV3() WriterMetadataV3 {
var wmdV3 WriterMetadataV3
wmdV3.Writers = make([]keybase1.UserOrTeamID, len(wmdV2.Writers))
copy(wmdV3.Writers, wmdV2.Writers)
wmdV3.UnresolvedWriters = make([]keybase1.SocialAssertion, len(wmdV2.Extra.UnresolvedWriters))
copy(wmdV3.UnresolvedWriters, wmdV2.Extra.UnresolvedWriters)
wmdV3.ID = wmdV2.ID
wmdV3.BID = wmdV2.BID
wmdV3.WFlags = wmdV2.WFlags
wmdV3.DiskUsage = wmdV2.DiskUsage
wmdV3.MDDiskUsage = wmdV2.MDDiskUsage
wmdV3.RefBytes = wmdV2.RefBytes
wmdV3.UnrefBytes = wmdV2.UnrefBytes
wmdV3.MDRefBytes = wmdV2.MDRefBytes
if wmdV2.ID.Type() == tlf.Public {
wmdV3.LatestKeyGen = PublicKeyGen
} else {
wmdV3.LatestKeyGen = wmdV2.WKeys.LatestKeyGeneration()
}
return wmdV3
} | go | func (wmdV2 *WriterMetadataV2) ToWriterMetadataV3() WriterMetadataV3 {
var wmdV3 WriterMetadataV3
wmdV3.Writers = make([]keybase1.UserOrTeamID, len(wmdV2.Writers))
copy(wmdV3.Writers, wmdV2.Writers)
wmdV3.UnresolvedWriters = make([]keybase1.SocialAssertion, len(wmdV2.Extra.UnresolvedWriters))
copy(wmdV3.UnresolvedWriters, wmdV2.Extra.UnresolvedWriters)
wmdV3.ID = wmdV2.ID
wmdV3.BID = wmdV2.BID
wmdV3.WFlags = wmdV2.WFlags
wmdV3.DiskUsage = wmdV2.DiskUsage
wmdV3.MDDiskUsage = wmdV2.MDDiskUsage
wmdV3.RefBytes = wmdV2.RefBytes
wmdV3.UnrefBytes = wmdV2.UnrefBytes
wmdV3.MDRefBytes = wmdV2.MDRefBytes
if wmdV2.ID.Type() == tlf.Public {
wmdV3.LatestKeyGen = PublicKeyGen
} else {
wmdV3.LatestKeyGen = wmdV2.WKeys.LatestKeyGeneration()
}
return wmdV3
} | [
"func",
"(",
"wmdV2",
"*",
"WriterMetadataV2",
")",
"ToWriterMetadataV3",
"(",
")",
"WriterMetadataV3",
"{",
"var",
"wmdV3",
"WriterMetadataV3",
"\n",
"wmdV3",
".",
"Writers",
"=",
"make",
"(",
"[",
"]",
"keybase1",
".",
"UserOrTeamID",
",",
"len",
"(",
"wmd... | // ToWriterMetadataV3 converts the WriterMetadataV2 to a
// WriterMetadataV3. | [
"ToWriterMetadataV3",
"converts",
"the",
"WriterMetadataV2",
"to",
"a",
"WriterMetadataV3",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L66-L89 |
160,942 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | KeyGenerationsToUpdate | func (md *RootMetadataV2) KeyGenerationsToUpdate() (KeyGen, KeyGen) {
latest := md.LatestKeyGeneration()
if latest < FirstValidKeyGen {
return 0, 0
}
// We keep track of all known key generations.
return FirstValidKeyGen, latest + 1
} | go | func (md *RootMetadataV2) KeyGenerationsToUpdate() (KeyGen, KeyGen) {
latest := md.LatestKeyGeneration()
if latest < FirstValidKeyGen {
return 0, 0
}
// We keep track of all known key generations.
return FirstValidKeyGen, latest + 1
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"KeyGenerationsToUpdate",
"(",
")",
"(",
"KeyGen",
",",
"KeyGen",
")",
"{",
"latest",
":=",
"md",
".",
"LatestKeyGeneration",
"(",
")",
"\n",
"if",
"latest",
"<",
"FirstValidKeyGen",
"{",
"return",
"0",
",",
... | // KeyGenerationsToUpdate implements the RootMetadata interface
// for RootMetadataV2. | [
"KeyGenerationsToUpdate",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L206-L213 |
160,943 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | IsValidRekeyRequest | func (md *RootMetadataV2) IsValidRekeyRequest(
codec kbfscodec.Codec, prevBareMd RootMetadata,
user keybase1.UID, _, _ ExtraMetadata) (bool, error) {
if !md.IsWriterMetadataCopiedSet() {
// Not a copy.
return false, nil
}
prevMd, ok := prevBareMd.(*RootMetadataV2)
if !ok {
// Not the same type so not a copy.
return false, nil
}
writerEqual, err := kbfscodec.Equal(
codec, md.WriterMetadataV2, prevMd.WriterMetadataV2)
if err != nil {
return false, err
}
if !writerEqual {
// Copy mismatch.
return false, nil
}
writerSigInfoEqual, err := kbfscodec.Equal(codec,
md.WriterMetadataSigInfo, prevMd.WriterMetadataSigInfo)
if err != nil {
return false, err
}
if !writerSigInfoEqual {
// Signature/public key mismatch.
return false, nil
}
onlyUserRKeysChanged, err := md.haveOnlyUserRKeysChanged(
codec, prevMd, user)
if err != nil {
return false, err
}
if !onlyUserRKeysChanged {
// Keys outside of this user's reader key set have changed.
return false, nil
}
return true, nil
} | go | func (md *RootMetadataV2) IsValidRekeyRequest(
codec kbfscodec.Codec, prevBareMd RootMetadata,
user keybase1.UID, _, _ ExtraMetadata) (bool, error) {
if !md.IsWriterMetadataCopiedSet() {
// Not a copy.
return false, nil
}
prevMd, ok := prevBareMd.(*RootMetadataV2)
if !ok {
// Not the same type so not a copy.
return false, nil
}
writerEqual, err := kbfscodec.Equal(
codec, md.WriterMetadataV2, prevMd.WriterMetadataV2)
if err != nil {
return false, err
}
if !writerEqual {
// Copy mismatch.
return false, nil
}
writerSigInfoEqual, err := kbfscodec.Equal(codec,
md.WriterMetadataSigInfo, prevMd.WriterMetadataSigInfo)
if err != nil {
return false, err
}
if !writerSigInfoEqual {
// Signature/public key mismatch.
return false, nil
}
onlyUserRKeysChanged, err := md.haveOnlyUserRKeysChanged(
codec, prevMd, user)
if err != nil {
return false, err
}
if !onlyUserRKeysChanged {
// Keys outside of this user's reader key set have changed.
return false, nil
}
return true, nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"IsValidRekeyRequest",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"prevBareMd",
"RootMetadata",
",",
"user",
"keybase1",
".",
"UID",
",",
"_",
",",
"_",
"ExtraMetadata",
")",
"(",
"bool",
",",
"error",
")",... | // IsValidRekeyRequest implements the RootMetadata interface for RootMetadataV2. | [
"IsValidRekeyRequest",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L254-L294 |
160,944 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | IsWriter | func (md *RootMetadataV2) IsWriter(
_ context.Context, user keybase1.UID, deviceKey kbfscrypto.CryptPublicKey,
_ kbfscrypto.VerifyingKey, _ TeamMembershipChecker, _ ExtraMetadata,
_ keybase1.OfflineAvailability) (bool, error) {
if md.ID.Type() != tlf.Private {
for _, w := range md.Writers {
if w == user.AsUserOrTeam() {
return true, nil
}
}
return false, nil
}
return md.WKeys.IsWriter(user, deviceKey), nil
} | go | func (md *RootMetadataV2) IsWriter(
_ context.Context, user keybase1.UID, deviceKey kbfscrypto.CryptPublicKey,
_ kbfscrypto.VerifyingKey, _ TeamMembershipChecker, _ ExtraMetadata,
_ keybase1.OfflineAvailability) (bool, error) {
if md.ID.Type() != tlf.Private {
for _, w := range md.Writers {
if w == user.AsUserOrTeam() {
return true, nil
}
}
return false, nil
}
return md.WKeys.IsWriter(user, deviceKey), nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"IsWriter",
"(",
"_",
"context",
".",
"Context",
",",
"user",
"keybase1",
".",
"UID",
",",
"deviceKey",
"kbfscrypto",
".",
"CryptPublicKey",
",",
"_",
"kbfscrypto",
".",
"VerifyingKey",
",",
"_",
"TeamMembership... | // IsWriter implements the RootMetadata interface for RootMetadataV2. | [
"IsWriter",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L320-L333 |
160,945 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | IsReader | func (md *RootMetadataV2) IsReader(
_ context.Context, user keybase1.UID, deviceKey kbfscrypto.CryptPublicKey,
_ TeamMembershipChecker, _ ExtraMetadata,
_ keybase1.OfflineAvailability) (bool, error) {
switch md.ID.Type() {
case tlf.Public:
return true, nil
case tlf.Private:
return md.RKeys.IsReader(user, deviceKey), nil
case tlf.SingleTeam:
// There are no read-only users of single-team TLFs.
return false, nil
default:
panic(fmt.Sprintf("Unexpected TLF type: %s", md.ID.Type()))
}
} | go | func (md *RootMetadataV2) IsReader(
_ context.Context, user keybase1.UID, deviceKey kbfscrypto.CryptPublicKey,
_ TeamMembershipChecker, _ ExtraMetadata,
_ keybase1.OfflineAvailability) (bool, error) {
switch md.ID.Type() {
case tlf.Public:
return true, nil
case tlf.Private:
return md.RKeys.IsReader(user, deviceKey), nil
case tlf.SingleTeam:
// There are no read-only users of single-team TLFs.
return false, nil
default:
panic(fmt.Sprintf("Unexpected TLF type: %s", md.ID.Type()))
}
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"IsReader",
"(",
"_",
"context",
".",
"Context",
",",
"user",
"keybase1",
".",
"UID",
",",
"deviceKey",
"kbfscrypto",
".",
"CryptPublicKey",
",",
"_",
"TeamMembershipChecker",
",",
"_",
"ExtraMetadata",
",",
"_"... | // IsReader implements the RootMetadata interface for RootMetadataV2. | [
"IsReader",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L336-L351 |
160,946 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | DeepCopy | func (md *RootMetadataV2) DeepCopy(
codec kbfscodec.Codec) (MutableRootMetadata, error) {
return md.deepCopy(codec)
} | go | func (md *RootMetadataV2) DeepCopy(
codec kbfscodec.Codec) (MutableRootMetadata, error) {
return md.deepCopy(codec)
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"DeepCopy",
"(",
"codec",
"kbfscodec",
".",
"Codec",
")",
"(",
"MutableRootMetadata",
",",
"error",
")",
"{",
"return",
"md",
".",
"deepCopy",
"(",
"codec",
")",
"\n",
"}"
] | // DeepCopy implements the RootMetadata interface for RootMetadataV2. | [
"DeepCopy",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L363-L366 |
160,947 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | MakeSuccessorCopy | func (md *RootMetadataV2) MakeSuccessorCopy(
codec kbfscodec.Codec, extra ExtraMetadata, latestMDVer MetadataVer,
tlfCryptKeyGetter func() ([]kbfscrypto.TLFCryptKey, error),
isReadableAndWriter bool) (
MutableRootMetadata, ExtraMetadata, error) {
if !isReadableAndWriter || (latestMDVer < SegregatedKeyBundlesVer) {
// Continue with the current version. If we're just a reader,
// or can't decrypt the MD, we have to continue with v2
// because we can't just copy a v2 signature into a v3 MD
// blindly.
mdCopy, err := md.makeSuccessorCopyV2(
codec, isReadableAndWriter)
if err != nil {
return nil, nil, err
}
return mdCopy, nil, nil
}
// Upconvert to the new version.
return md.makeSuccessorCopyV3(codec, tlfCryptKeyGetter)
} | go | func (md *RootMetadataV2) MakeSuccessorCopy(
codec kbfscodec.Codec, extra ExtraMetadata, latestMDVer MetadataVer,
tlfCryptKeyGetter func() ([]kbfscrypto.TLFCryptKey, error),
isReadableAndWriter bool) (
MutableRootMetadata, ExtraMetadata, error) {
if !isReadableAndWriter || (latestMDVer < SegregatedKeyBundlesVer) {
// Continue with the current version. If we're just a reader,
// or can't decrypt the MD, we have to continue with v2
// because we can't just copy a v2 signature into a v3 MD
// blindly.
mdCopy, err := md.makeSuccessorCopyV2(
codec, isReadableAndWriter)
if err != nil {
return nil, nil, err
}
return mdCopy, nil, nil
}
// Upconvert to the new version.
return md.makeSuccessorCopyV3(codec, tlfCryptKeyGetter)
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"MakeSuccessorCopy",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"extra",
"ExtraMetadata",
",",
"latestMDVer",
"MetadataVer",
",",
"tlfCryptKeyGetter",
"func",
"(",
")",
"(",
"[",
"]",
"kbfscrypto",
".",
"TLFCry... | // MakeSuccessorCopy implements the ImmutableRootMetadata interface for RootMetadataV2. | [
"MakeSuccessorCopy",
"implements",
"the",
"ImmutableRootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L369-L390 |
160,948 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | MakeBareTlfHandle | func (md *RootMetadataV2) MakeBareTlfHandle(_ ExtraMetadata) (
tlf.Handle, error) {
var writers, readers []keybase1.UserOrTeamID
if md.ID.Type() == tlf.Private {
if len(md.WKeys) == 0 {
return tlf.Handle{}, errors.New("No writer key generations; need rekey?")
}
if len(md.RKeys) == 0 {
return tlf.Handle{}, errors.New("No reader key generations; need rekey?")
}
wkb := md.WKeys[len(md.WKeys)-1]
rkb := md.RKeys[len(md.RKeys)-1]
writers = make([]keybase1.UserOrTeamID, 0, len(wkb.WKeys))
readers = make([]keybase1.UserOrTeamID, 0, len(rkb.RKeys))
for w := range wkb.WKeys {
writers = append(writers, w.AsUserOrTeam())
}
for r := range rkb.RKeys {
// TODO: Return an error instead if r is
// PublicUID. Maybe return an error if r is in
// WKeys also. Or do all this in
// MakeBareTlfHandle.
if _, ok := wkb.WKeys[r]; !ok &&
r != keybase1.PublicUID {
readers = append(readers, r.AsUserOrTeam())
}
}
} else {
writers = md.Writers
if md.ID.Type() == tlf.Public {
readers = []keybase1.UserOrTeamID{keybase1.PublicUID.AsUserOrTeam()}
}
}
return tlf.MakeHandle(
writers, readers,
md.Extra.UnresolvedWriters, md.UnresolvedReaders,
md.TlfHandleExtensions())
} | go | func (md *RootMetadataV2) MakeBareTlfHandle(_ ExtraMetadata) (
tlf.Handle, error) {
var writers, readers []keybase1.UserOrTeamID
if md.ID.Type() == tlf.Private {
if len(md.WKeys) == 0 {
return tlf.Handle{}, errors.New("No writer key generations; need rekey?")
}
if len(md.RKeys) == 0 {
return tlf.Handle{}, errors.New("No reader key generations; need rekey?")
}
wkb := md.WKeys[len(md.WKeys)-1]
rkb := md.RKeys[len(md.RKeys)-1]
writers = make([]keybase1.UserOrTeamID, 0, len(wkb.WKeys))
readers = make([]keybase1.UserOrTeamID, 0, len(rkb.RKeys))
for w := range wkb.WKeys {
writers = append(writers, w.AsUserOrTeam())
}
for r := range rkb.RKeys {
// TODO: Return an error instead if r is
// PublicUID. Maybe return an error if r is in
// WKeys also. Or do all this in
// MakeBareTlfHandle.
if _, ok := wkb.WKeys[r]; !ok &&
r != keybase1.PublicUID {
readers = append(readers, r.AsUserOrTeam())
}
}
} else {
writers = md.Writers
if md.ID.Type() == tlf.Public {
readers = []keybase1.UserOrTeamID{keybase1.PublicUID.AsUserOrTeam()}
}
}
return tlf.MakeHandle(
writers, readers,
md.Extra.UnresolvedWriters, md.UnresolvedReaders,
md.TlfHandleExtensions())
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"MakeBareTlfHandle",
"(",
"_",
"ExtraMetadata",
")",
"(",
"tlf",
".",
"Handle",
",",
"error",
")",
"{",
"var",
"writers",
",",
"readers",
"[",
"]",
"keybase1",
".",
"UserOrTeamID",
"\n",
"if",
"md",
".",
"... | // MakeBareTlfHandle implements the RootMetadata interface for RootMetadataV2. | [
"MakeBareTlfHandle",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L574-L614 |
160,949 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | TlfHandleExtensions | func (md *RootMetadataV2) TlfHandleExtensions() (
extensions []tlf.HandleExtension) {
if md.ConflictInfo != nil {
extensions = append(extensions, *md.ConflictInfo)
}
if md.FinalizedInfo != nil {
extensions = append(extensions, *md.FinalizedInfo)
}
return extensions
} | go | func (md *RootMetadataV2) TlfHandleExtensions() (
extensions []tlf.HandleExtension) {
if md.ConflictInfo != nil {
extensions = append(extensions, *md.ConflictInfo)
}
if md.FinalizedInfo != nil {
extensions = append(extensions, *md.FinalizedInfo)
}
return extensions
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"TlfHandleExtensions",
"(",
")",
"(",
"extensions",
"[",
"]",
"tlf",
".",
"HandleExtension",
")",
"{",
"if",
"md",
".",
"ConflictInfo",
"!=",
"nil",
"{",
"extensions",
"=",
"append",
"(",
"extensions",
",",
... | // TlfHandleExtensions implements the RootMetadata interface for RootMetadataV2. | [
"TlfHandleExtensions",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L617-L626 |
160,950 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | PromoteReaders | func (md *RootMetadataV2) PromoteReaders(
readersToPromote map[keybase1.UID]bool,
_ ExtraMetadata) error {
if md.TlfID().Type() != tlf.Private {
return InvalidNonPrivateTLFOperation{md.TlfID(), "PromoteReaders", md.Version()}
}
for i, rkb := range md.RKeys {
for reader := range readersToPromote {
dkim, ok := rkb.RKeys[reader]
if !ok {
return fmt.Errorf("Could not find %s in key gen %d",
reader, FirstValidKeyGen+KeyGen(i))
}
// TODO: This may be incorrect, since dkim may
// contain negative EPubKey indices, and the
// upconversion code assumes that writers will
// only contain non-negative EPubKey indices.
//
// See KBFS-1719.
md.WKeys[i].WKeys[reader] = dkim
delete(rkb.RKeys, reader)
}
}
return nil
} | go | func (md *RootMetadataV2) PromoteReaders(
readersToPromote map[keybase1.UID]bool,
_ ExtraMetadata) error {
if md.TlfID().Type() != tlf.Private {
return InvalidNonPrivateTLFOperation{md.TlfID(), "PromoteReaders", md.Version()}
}
for i, rkb := range md.RKeys {
for reader := range readersToPromote {
dkim, ok := rkb.RKeys[reader]
if !ok {
return fmt.Errorf("Could not find %s in key gen %d",
reader, FirstValidKeyGen+KeyGen(i))
}
// TODO: This may be incorrect, since dkim may
// contain negative EPubKey indices, and the
// upconversion code assumes that writers will
// only contain non-negative EPubKey indices.
//
// See KBFS-1719.
md.WKeys[i].WKeys[reader] = dkim
delete(rkb.RKeys, reader)
}
}
return nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"PromoteReaders",
"(",
"readersToPromote",
"map",
"[",
"keybase1",
".",
"UID",
"]",
"bool",
",",
"_",
"ExtraMetadata",
")",
"error",
"{",
"if",
"md",
".",
"TlfID",
"(",
")",
".",
"Type",
"(",
")",
"!=",
... | // PromoteReaders implements the RootMetadata interface for
// RootMetadataV2. | [
"PromoteReaders",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L630-L656 |
160,951 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | RevokeRemovedDevices | func (md *RootMetadataV2) RevokeRemovedDevices(
updatedWriterKeys, updatedReaderKeys UserDevicePublicKeys,
_ ExtraMetadata) (ServerHalfRemovalInfo, error) {
if md.TlfID().Type() != tlf.Private {
return nil, InvalidNonPrivateTLFOperation{
md.TlfID(), "RevokeRemovedDevices", md.Version()}
}
var wRemovalInfo ServerHalfRemovalInfo
for _, wkb := range md.WKeys {
removalInfo := wkb.WKeys.RemoveDevicesNotIn(updatedWriterKeys)
if wRemovalInfo == nil {
wRemovalInfo = removalInfo
} else {
err := wRemovalInfo.AddGeneration(removalInfo)
if err != nil {
return nil, err
}
}
}
var rRemovalInfo ServerHalfRemovalInfo
for _, rkb := range md.RKeys {
removalInfo := rkb.RKeys.RemoveDevicesNotIn(updatedReaderKeys)
if rRemovalInfo == nil {
rRemovalInfo = removalInfo
} else {
err := rRemovalInfo.AddGeneration(removalInfo)
if err != nil {
return nil, err
}
}
}
return wRemovalInfo.MergeUsers(rRemovalInfo)
} | go | func (md *RootMetadataV2) RevokeRemovedDevices(
updatedWriterKeys, updatedReaderKeys UserDevicePublicKeys,
_ ExtraMetadata) (ServerHalfRemovalInfo, error) {
if md.TlfID().Type() != tlf.Private {
return nil, InvalidNonPrivateTLFOperation{
md.TlfID(), "RevokeRemovedDevices", md.Version()}
}
var wRemovalInfo ServerHalfRemovalInfo
for _, wkb := range md.WKeys {
removalInfo := wkb.WKeys.RemoveDevicesNotIn(updatedWriterKeys)
if wRemovalInfo == nil {
wRemovalInfo = removalInfo
} else {
err := wRemovalInfo.AddGeneration(removalInfo)
if err != nil {
return nil, err
}
}
}
var rRemovalInfo ServerHalfRemovalInfo
for _, rkb := range md.RKeys {
removalInfo := rkb.RKeys.RemoveDevicesNotIn(updatedReaderKeys)
if rRemovalInfo == nil {
rRemovalInfo = removalInfo
} else {
err := rRemovalInfo.AddGeneration(removalInfo)
if err != nil {
return nil, err
}
}
}
return wRemovalInfo.MergeUsers(rRemovalInfo)
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"RevokeRemovedDevices",
"(",
"updatedWriterKeys",
",",
"updatedReaderKeys",
"UserDevicePublicKeys",
",",
"_",
"ExtraMetadata",
")",
"(",
"ServerHalfRemovalInfo",
",",
"error",
")",
"{",
"if",
"md",
".",
"TlfID",
"(",
... | // RevokeRemovedDevices implements the RootMetadata interface for
// RootMetadataV2. | [
"RevokeRemovedDevices",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L660-L695 |
160,952 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | getTLFKeyBundles | func (md *RootMetadataV2) getTLFKeyBundles(keyGen KeyGen) (
*TLFWriterKeyBundleV2, *TLFReaderKeyBundleV2, error) {
if md.ID.Type() != tlf.Private {
return nil, nil, InvalidNonPrivateTLFOperation{md.ID, "getTLFKeyBundles", md.Version()}
}
if keyGen < FirstValidKeyGen {
return nil, nil, InvalidKeyGenerationError{md.ID, keyGen}
}
i := int(keyGen - FirstValidKeyGen)
if i >= len(md.WKeys) || i >= len(md.RKeys) {
return nil, nil, NewKeyGenerationError{md.ID, keyGen}
}
return &md.WKeys[i], &md.RKeys[i], nil
} | go | func (md *RootMetadataV2) getTLFKeyBundles(keyGen KeyGen) (
*TLFWriterKeyBundleV2, *TLFReaderKeyBundleV2, error) {
if md.ID.Type() != tlf.Private {
return nil, nil, InvalidNonPrivateTLFOperation{md.ID, "getTLFKeyBundles", md.Version()}
}
if keyGen < FirstValidKeyGen {
return nil, nil, InvalidKeyGenerationError{md.ID, keyGen}
}
i := int(keyGen - FirstValidKeyGen)
if i >= len(md.WKeys) || i >= len(md.RKeys) {
return nil, nil, NewKeyGenerationError{md.ID, keyGen}
}
return &md.WKeys[i], &md.RKeys[i], nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"getTLFKeyBundles",
"(",
"keyGen",
"KeyGen",
")",
"(",
"*",
"TLFWriterKeyBundleV2",
",",
"*",
"TLFReaderKeyBundleV2",
",",
"error",
")",
"{",
"if",
"md",
".",
"ID",
".",
"Type",
"(",
")",
"!=",
"tlf",
".",
... | // getTLFKeyBundles returns the bundles for a given key generation.
// Note that it is legal a writer or a reader to have no keys in their
// bundle, if they only have a Keybase username with no device keys
// yet. | [
"getTLFKeyBundles",
"returns",
"the",
"bundles",
"for",
"a",
"given",
"key",
"generation",
".",
"Note",
"that",
"it",
"is",
"legal",
"a",
"writer",
"or",
"a",
"reader",
"to",
"have",
"no",
"keys",
"in",
"their",
"bundle",
"if",
"they",
"only",
"have",
"a... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L701-L715 |
160,953 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | GetUserDevicePublicKeys | func (md *RootMetadataV2) GetUserDevicePublicKeys(_ ExtraMetadata) (
writerDeviceKeys, readerDeviceKeys UserDevicePublicKeys, err error) {
if md.TlfID().Type() != tlf.Private {
return nil, nil, InvalidNonPrivateTLFOperation{
md.TlfID(), "GetUserDevicePublicKeys", md.Version()}
}
if len(md.WKeys) == 0 || len(md.RKeys) == 0 {
return nil, nil, errors.New(
"GetUserDevicePublicKeys called with no key generations (V2)")
}
wUDKIM := md.WKeys[len(md.WKeys)-1]
rUDKIM := md.RKeys[len(md.RKeys)-1]
return wUDKIM.WKeys.ToPublicKeys(), rUDKIM.RKeys.ToPublicKeys(), nil
} | go | func (md *RootMetadataV2) GetUserDevicePublicKeys(_ ExtraMetadata) (
writerDeviceKeys, readerDeviceKeys UserDevicePublicKeys, err error) {
if md.TlfID().Type() != tlf.Private {
return nil, nil, InvalidNonPrivateTLFOperation{
md.TlfID(), "GetUserDevicePublicKeys", md.Version()}
}
if len(md.WKeys) == 0 || len(md.RKeys) == 0 {
return nil, nil, errors.New(
"GetUserDevicePublicKeys called with no key generations (V2)")
}
wUDKIM := md.WKeys[len(md.WKeys)-1]
rUDKIM := md.RKeys[len(md.RKeys)-1]
return wUDKIM.WKeys.ToPublicKeys(), rUDKIM.RKeys.ToPublicKeys(), nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"GetUserDevicePublicKeys",
"(",
"_",
"ExtraMetadata",
")",
"(",
"writerDeviceKeys",
",",
"readerDeviceKeys",
"UserDevicePublicKeys",
",",
"err",
"error",
")",
"{",
"if",
"md",
".",
"TlfID",
"(",
")",
".",
"Type",
... | // GetUserDevicePublicKeys implements the RootMetadata interface
// for RootMetadataV2. | [
"GetUserDevicePublicKeys",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L719-L735 |
160,954 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | GetTLFCryptKeyParams | func (md *RootMetadataV2) GetTLFCryptKeyParams(
keyGen KeyGen, user keybase1.UID, key kbfscrypto.CryptPublicKey,
_ ExtraMetadata) (
kbfscrypto.TLFEphemeralPublicKey, kbfscrypto.EncryptedTLFCryptKeyClientHalf,
kbfscrypto.TLFCryptKeyServerHalfID, bool, error) {
wkb, rkb, err := md.getTLFKeyBundles(keyGen)
if err != nil {
return kbfscrypto.TLFEphemeralPublicKey{},
kbfscrypto.EncryptedTLFCryptKeyClientHalf{},
kbfscrypto.TLFCryptKeyServerHalfID{}, false, err
}
dkim := wkb.WKeys[user]
if dkim == nil {
dkim = rkb.RKeys[user]
if dkim == nil {
return kbfscrypto.TLFEphemeralPublicKey{},
kbfscrypto.EncryptedTLFCryptKeyClientHalf{},
kbfscrypto.TLFCryptKeyServerHalfID{}, false, nil
}
}
info, ok := dkim[key.KID()]
if !ok {
return kbfscrypto.TLFEphemeralPublicKey{},
kbfscrypto.EncryptedTLFCryptKeyClientHalf{},
kbfscrypto.TLFCryptKeyServerHalfID{}, false, nil
}
_, _, ePubKey, err := GetEphemeralPublicKeyInfoV2(info, *wkb, *rkb)
if err != nil {
return kbfscrypto.TLFEphemeralPublicKey{},
kbfscrypto.EncryptedTLFCryptKeyClientHalf{},
kbfscrypto.TLFCryptKeyServerHalfID{}, false, err
}
return ePubKey, info.ClientHalf, info.ServerHalfID, true, nil
} | go | func (md *RootMetadataV2) GetTLFCryptKeyParams(
keyGen KeyGen, user keybase1.UID, key kbfscrypto.CryptPublicKey,
_ ExtraMetadata) (
kbfscrypto.TLFEphemeralPublicKey, kbfscrypto.EncryptedTLFCryptKeyClientHalf,
kbfscrypto.TLFCryptKeyServerHalfID, bool, error) {
wkb, rkb, err := md.getTLFKeyBundles(keyGen)
if err != nil {
return kbfscrypto.TLFEphemeralPublicKey{},
kbfscrypto.EncryptedTLFCryptKeyClientHalf{},
kbfscrypto.TLFCryptKeyServerHalfID{}, false, err
}
dkim := wkb.WKeys[user]
if dkim == nil {
dkim = rkb.RKeys[user]
if dkim == nil {
return kbfscrypto.TLFEphemeralPublicKey{},
kbfscrypto.EncryptedTLFCryptKeyClientHalf{},
kbfscrypto.TLFCryptKeyServerHalfID{}, false, nil
}
}
info, ok := dkim[key.KID()]
if !ok {
return kbfscrypto.TLFEphemeralPublicKey{},
kbfscrypto.EncryptedTLFCryptKeyClientHalf{},
kbfscrypto.TLFCryptKeyServerHalfID{}, false, nil
}
_, _, ePubKey, err := GetEphemeralPublicKeyInfoV2(info, *wkb, *rkb)
if err != nil {
return kbfscrypto.TLFEphemeralPublicKey{},
kbfscrypto.EncryptedTLFCryptKeyClientHalf{},
kbfscrypto.TLFCryptKeyServerHalfID{}, false, err
}
return ePubKey, info.ClientHalf, info.ServerHalfID, true, nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"GetTLFCryptKeyParams",
"(",
"keyGen",
"KeyGen",
",",
"user",
"keybase1",
".",
"UID",
",",
"key",
"kbfscrypto",
".",
"CryptPublicKey",
",",
"_",
"ExtraMetadata",
")",
"(",
"kbfscrypto",
".",
"TLFEphemeralPublicKey",... | // GetTLFCryptKeyParams implements the RootMetadata interface for RootMetadataV2. | [
"GetTLFCryptKeyParams",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L738-L774 |
160,955 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | IsValidAndSigned | func (md *RootMetadataV2) IsValidAndSigned(
_ context.Context, codec kbfscodec.Codec,
_ TeamMembershipChecker, extra ExtraMetadata,
_ kbfscrypto.VerifyingKey, _ keybase1.OfflineAvailability) error {
// Optimization -- if the WriterMetadata signature is nil, it
// will fail verification.
if md.WriterMetadataSigInfo.IsNil() {
return errors.New("Missing WriterMetadata signature")
}
if md.IsFinal() {
if md.Revision < RevisionInitial+1 {
return fmt.Errorf("Invalid final revision %d", md.Revision)
}
if md.Revision == (RevisionInitial + 1) {
if md.PrevRoot != (ID{}) {
return fmt.Errorf("Invalid PrevRoot %s for initial final revision", md.PrevRoot)
}
} else {
if md.PrevRoot == (ID{}) {
return errors.New("No PrevRoot for non-initial final revision")
}
}
} else {
if md.Revision < RevisionInitial {
return fmt.Errorf("Invalid revision %d", md.Revision)
}
if md.Revision == RevisionInitial {
if md.PrevRoot != (ID{}) {
return fmt.Errorf("Invalid PrevRoot %s for initial revision", md.PrevRoot)
}
} else {
if md.PrevRoot == (ID{}) {
return errors.New("No PrevRoot for non-initial revision")
}
}
}
if len(md.SerializedPrivateMetadata) == 0 {
return errors.New("No private metadata")
}
if (md.MergedStatus() == Merged) != (md.BID() == NullBranchID) {
return fmt.Errorf("Branch ID %s doesn't match merged status %s",
md.BID(), md.MergedStatus())
}
handle, err := md.MakeBareTlfHandle(extra)
if err != nil {
return err
}
// Make sure the last writer is valid. TODO(KBFS-2185): for a
// team TLF, check that the writer is part of the team.
writer := md.LastModifyingWriter()
if !handle.IsWriter(writer.AsUserOrTeam()) {
return fmt.Errorf("Invalid modifying writer %s", writer)
}
// Make sure the last modifier is valid.
user := md.LastModifyingUser
if !handle.IsReader(user.AsUserOrTeam()) {
return fmt.Errorf("Invalid modifying user %s", user)
}
// Verify signature. We have to re-marshal the WriterMetadata,
// since it's embedded.
buf, err := codec.Encode(md.WriterMetadataV2)
if err != nil {
return err
}
err = kbfscrypto.Verify(buf, md.WriterMetadataSigInfo)
if err != nil {
return fmt.Errorf("Could not verify writer metadata: %v", err)
}
return nil
} | go | func (md *RootMetadataV2) IsValidAndSigned(
_ context.Context, codec kbfscodec.Codec,
_ TeamMembershipChecker, extra ExtraMetadata,
_ kbfscrypto.VerifyingKey, _ keybase1.OfflineAvailability) error {
// Optimization -- if the WriterMetadata signature is nil, it
// will fail verification.
if md.WriterMetadataSigInfo.IsNil() {
return errors.New("Missing WriterMetadata signature")
}
if md.IsFinal() {
if md.Revision < RevisionInitial+1 {
return fmt.Errorf("Invalid final revision %d", md.Revision)
}
if md.Revision == (RevisionInitial + 1) {
if md.PrevRoot != (ID{}) {
return fmt.Errorf("Invalid PrevRoot %s for initial final revision", md.PrevRoot)
}
} else {
if md.PrevRoot == (ID{}) {
return errors.New("No PrevRoot for non-initial final revision")
}
}
} else {
if md.Revision < RevisionInitial {
return fmt.Errorf("Invalid revision %d", md.Revision)
}
if md.Revision == RevisionInitial {
if md.PrevRoot != (ID{}) {
return fmt.Errorf("Invalid PrevRoot %s for initial revision", md.PrevRoot)
}
} else {
if md.PrevRoot == (ID{}) {
return errors.New("No PrevRoot for non-initial revision")
}
}
}
if len(md.SerializedPrivateMetadata) == 0 {
return errors.New("No private metadata")
}
if (md.MergedStatus() == Merged) != (md.BID() == NullBranchID) {
return fmt.Errorf("Branch ID %s doesn't match merged status %s",
md.BID(), md.MergedStatus())
}
handle, err := md.MakeBareTlfHandle(extra)
if err != nil {
return err
}
// Make sure the last writer is valid. TODO(KBFS-2185): for a
// team TLF, check that the writer is part of the team.
writer := md.LastModifyingWriter()
if !handle.IsWriter(writer.AsUserOrTeam()) {
return fmt.Errorf("Invalid modifying writer %s", writer)
}
// Make sure the last modifier is valid.
user := md.LastModifyingUser
if !handle.IsReader(user.AsUserOrTeam()) {
return fmt.Errorf("Invalid modifying user %s", user)
}
// Verify signature. We have to re-marshal the WriterMetadata,
// since it's embedded.
buf, err := codec.Encode(md.WriterMetadataV2)
if err != nil {
return err
}
err = kbfscrypto.Verify(buf, md.WriterMetadataSigInfo)
if err != nil {
return fmt.Errorf("Could not verify writer metadata: %v", err)
}
return nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"IsValidAndSigned",
"(",
"_",
"context",
".",
"Context",
",",
"codec",
"kbfscodec",
".",
"Codec",
",",
"_",
"TeamMembershipChecker",
",",
"extra",
"ExtraMetadata",
",",
"_",
"kbfscrypto",
".",
"VerifyingKey",
",",... | // IsValidAndSigned implements the RootMetadata interface for RootMetadataV2. | [
"IsValidAndSigned",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L777-L857 |
160,956 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | IsLastModifiedBy | func (md *RootMetadataV2) IsLastModifiedBy(
uid keybase1.UID, key kbfscrypto.VerifyingKey) error {
// Verify the user and device are the writer.
writer := md.LastModifyingWriter()
if !md.IsWriterMetadataCopiedSet() {
if writer != uid {
return fmt.Errorf("Last writer %s != %s", writer, uid)
}
if md.WriterMetadataSigInfo.VerifyingKey != key {
return fmt.Errorf(
"Last writer verifying key %v != %v",
md.WriterMetadataSigInfo.VerifyingKey, key)
}
}
// Verify the user and device are the last modifier.
user := md.GetLastModifyingUser()
if user != uid {
return fmt.Errorf("Last modifier %s != %s", user, uid)
}
return nil
} | go | func (md *RootMetadataV2) IsLastModifiedBy(
uid keybase1.UID, key kbfscrypto.VerifyingKey) error {
// Verify the user and device are the writer.
writer := md.LastModifyingWriter()
if !md.IsWriterMetadataCopiedSet() {
if writer != uid {
return fmt.Errorf("Last writer %s != %s", writer, uid)
}
if md.WriterMetadataSigInfo.VerifyingKey != key {
return fmt.Errorf(
"Last writer verifying key %v != %v",
md.WriterMetadataSigInfo.VerifyingKey, key)
}
}
// Verify the user and device are the last modifier.
user := md.GetLastModifyingUser()
if user != uid {
return fmt.Errorf("Last modifier %s != %s", user, uid)
}
return nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"IsLastModifiedBy",
"(",
"uid",
"keybase1",
".",
"UID",
",",
"key",
"kbfscrypto",
".",
"VerifyingKey",
")",
"error",
"{",
"// Verify the user and device are the writer.",
"writer",
":=",
"md",
".",
"LastModifyingWriter"... | // IsLastModifiedBy implements the RootMetadata interface for
// RootMetadataV2. | [
"IsLastModifiedBy",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L861-L883 |
160,957 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | GetSerializedWriterMetadata | func (md *RootMetadataV2) GetSerializedWriterMetadata(
codec kbfscodec.Codec) ([]byte, error) {
return codec.Encode(md.WriterMetadataV2)
} | go | func (md *RootMetadataV2) GetSerializedWriterMetadata(
codec kbfscodec.Codec) ([]byte, error) {
return codec.Encode(md.WriterMetadataV2)
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"GetSerializedWriterMetadata",
"(",
"codec",
"kbfscodec",
".",
"Codec",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"codec",
".",
"Encode",
"(",
"md",
".",
"WriterMetadataV2",
")",
"\n",
"}... | // GetSerializedWriterMetadata implements the RootMetadata interface for RootMetadataV2. | [
"GetSerializedWriterMetadata",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1026-L1029 |
160,958 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | SetLastModifyingWriter | func (md *RootMetadataV2) SetLastModifyingWriter(user keybase1.UID) {
md.WriterMetadataV2.LastModifyingWriter = user
} | go | func (md *RootMetadataV2) SetLastModifyingWriter(user keybase1.UID) {
md.WriterMetadataV2.LastModifyingWriter = user
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"SetLastModifyingWriter",
"(",
"user",
"keybase1",
".",
"UID",
")",
"{",
"md",
".",
"WriterMetadataV2",
".",
"LastModifyingWriter",
"=",
"user",
"\n",
"}"
] | // SetLastModifyingWriter implements the MutableRootMetadata interface for RootMetadataV2. | [
"SetLastModifyingWriter",
"implements",
"the",
"MutableRootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1049-L1051 |
160,959 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | SetUnresolvedWriters | func (md *RootMetadataV2) SetUnresolvedWriters(writers []keybase1.SocialAssertion) {
md.Extra.UnresolvedWriters = writers
} | go | func (md *RootMetadataV2) SetUnresolvedWriters(writers []keybase1.SocialAssertion) {
md.Extra.UnresolvedWriters = writers
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"SetUnresolvedWriters",
"(",
"writers",
"[",
"]",
"keybase1",
".",
"SocialAssertion",
")",
"{",
"md",
".",
"Extra",
".",
"UnresolvedWriters",
"=",
"writers",
"\n",
"}"
] | // SetUnresolvedWriters implements the MutableRootMetadata interface for RootMetadataV2. | [
"SetUnresolvedWriters",
"implements",
"the",
"MutableRootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1084-L1086 |
160,960 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | ClearForV4Migration | func (md *RootMetadataV2) ClearForV4Migration() {
md.WKeys = nil
md.RKeys = nil
md.Extra.UnresolvedWriters = nil
md.UnresolvedReaders = nil
} | go | func (md *RootMetadataV2) ClearForV4Migration() {
md.WKeys = nil
md.RKeys = nil
md.Extra.UnresolvedWriters = nil
md.UnresolvedReaders = nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"ClearForV4Migration",
"(",
")",
"{",
"md",
".",
"WKeys",
"=",
"nil",
"\n",
"md",
".",
"RKeys",
"=",
"nil",
"\n",
"md",
".",
"Extra",
".",
"UnresolvedWriters",
"=",
"nil",
"\n",
"md",
".",
"UnresolvedReade... | // ClearForV4Migration implements the MutableRootMetadata interface
// for RootMetadataV2. | [
"ClearForV4Migration",
"implements",
"the",
"MutableRootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1105-L1110 |
160,961 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | Version | func (md *RootMetadataV2) Version() MetadataVer {
// Only folders with unresolved assertions or conflict info get the
// new version.
if len(md.Extra.UnresolvedWriters) > 0 || len(md.UnresolvedReaders) > 0 ||
md.ConflictInfo != nil ||
md.FinalizedInfo != nil {
return InitialExtraMetadataVer
}
// Let other types of MD objects use the older version since they
// are still compatible with older clients.
return PreExtraMetadataVer
} | go | func (md *RootMetadataV2) Version() MetadataVer {
// Only folders with unresolved assertions or conflict info get the
// new version.
if len(md.Extra.UnresolvedWriters) > 0 || len(md.UnresolvedReaders) > 0 ||
md.ConflictInfo != nil ||
md.FinalizedInfo != nil {
return InitialExtraMetadataVer
}
// Let other types of MD objects use the older version since they
// are still compatible with older clients.
return PreExtraMetadataVer
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"Version",
"(",
")",
"MetadataVer",
"{",
"// Only folders with unresolved assertions or conflict info get the",
"// new version.",
"if",
"len",
"(",
"md",
".",
"Extra",
".",
"UnresolvedWriters",
")",
">",
"0",
"||",
"le... | // Version implements the MutableRootMetadata interface for RootMetadataV2. | [
"Version",
"implements",
"the",
"MutableRootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1123-L1134 |
160,962 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | GetCurrentTLFPublicKey | func (md *RootMetadataV2) GetCurrentTLFPublicKey(
_ ExtraMetadata) (kbfscrypto.TLFPublicKey, error) {
if len(md.WKeys) == 0 {
return kbfscrypto.TLFPublicKey{}, errors.New(
"No key generations in GetCurrentTLFPublicKey")
}
return md.WKeys[len(md.WKeys)-1].TLFPublicKey, nil
} | go | func (md *RootMetadataV2) GetCurrentTLFPublicKey(
_ ExtraMetadata) (kbfscrypto.TLFPublicKey, error) {
if len(md.WKeys) == 0 {
return kbfscrypto.TLFPublicKey{}, errors.New(
"No key generations in GetCurrentTLFPublicKey")
}
return md.WKeys[len(md.WKeys)-1].TLFPublicKey, nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"GetCurrentTLFPublicKey",
"(",
"_",
"ExtraMetadata",
")",
"(",
"kbfscrypto",
".",
"TLFPublicKey",
",",
"error",
")",
"{",
"if",
"len",
"(",
"md",
".",
"WKeys",
")",
"==",
"0",
"{",
"return",
"kbfscrypto",
".... | // GetCurrentTLFPublicKey implements the RootMetadata interface
// for RootMetadataV2. | [
"GetCurrentTLFPublicKey",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1138-L1145 |
160,963 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | GetUnresolvedParticipants | func (md *RootMetadataV2) GetUnresolvedParticipants() []keybase1.SocialAssertion {
writers := md.WriterMetadataV2.Extra.UnresolvedWriters
readers := md.UnresolvedReaders
users := make([]keybase1.SocialAssertion, 0, len(writers)+len(readers))
users = append(users, writers...)
users = append(users, readers...)
return users
} | go | func (md *RootMetadataV2) GetUnresolvedParticipants() []keybase1.SocialAssertion {
writers := md.WriterMetadataV2.Extra.UnresolvedWriters
readers := md.UnresolvedReaders
users := make([]keybase1.SocialAssertion, 0, len(writers)+len(readers))
users = append(users, writers...)
users = append(users, readers...)
return users
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"GetUnresolvedParticipants",
"(",
")",
"[",
"]",
"keybase1",
".",
"SocialAssertion",
"{",
"writers",
":=",
"md",
".",
"WriterMetadataV2",
".",
"Extra",
".",
"UnresolvedWriters",
"\n",
"readers",
":=",
"md",
".",
... | // GetUnresolvedParticipants implements the RootMetadata interface
// for RootMetadataV2. | [
"GetUnresolvedParticipants",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1149-L1156 |
160,964 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | AddKeyGeneration | func (md *RootMetadataV2) AddKeyGeneration(
codec kbfscodec.Codec, extra ExtraMetadata,
updatedWriterKeys, updatedReaderKeys UserDevicePublicKeys,
ePubKey kbfscrypto.TLFEphemeralPublicKey,
ePrivKey kbfscrypto.TLFEphemeralPrivateKey,
pubKey kbfscrypto.TLFPublicKey,
currCryptKey, nextCryptKey kbfscrypto.TLFCryptKey) (
nextExtra ExtraMetadata,
serverHalves UserDeviceKeyServerHalves, err error) {
if md.TlfID().Type() != tlf.Private {
return nil, nil, InvalidNonPrivateTLFOperation{
md.TlfID(), "AddKeyGeneration", md.Version()}
}
if len(updatedWriterKeys) == 0 {
return nil, nil, errors.New(
"updatedWriterKeys unexpectedly non-empty")
}
if currCryptKey != (kbfscrypto.TLFCryptKey{}) {
return nil, nil, errors.New("currCryptKey unexpectedly non-zero")
}
if len(md.WKeys) != len(md.RKeys) {
return nil, nil, fmt.Errorf(
"Have %d writer key gens, but %d reader key gens",
len(md.WKeys), len(md.RKeys))
}
if len(md.WKeys) > 0 {
existingWriterKeys :=
md.WKeys[len(md.WKeys)-1].WKeys.ToPublicKeys()
if !existingWriterKeys.Equals(updatedWriterKeys) {
return nil, nil, fmt.Errorf(
"existingWriterKeys=%+v != updatedWriterKeys=%+v",
existingWriterKeys, updatedWriterKeys)
}
existingReaderKeys :=
md.RKeys[len(md.RKeys)-1].RKeys.ToPublicKeys()
if !existingReaderKeys.Equals(updatedReaderKeys) {
return nil, nil, fmt.Errorf(
"existingReaderKeys=%+v != updatedReaderKeys=%+v",
existingReaderKeys, updatedReaderKeys)
}
}
newWriterKeys := TLFWriterKeyBundleV2{
WKeys: make(UserDeviceKeyInfoMapV2),
TLFPublicKey: pubKey,
}
md.WKeys = append(md.WKeys, newWriterKeys)
newReaderKeys := TLFReaderKeyBundleV2{
RKeys: make(UserDeviceKeyInfoMapV2),
}
md.RKeys = append(md.RKeys, newReaderKeys)
serverHalves, err = md.updateKeyGeneration(
md.LatestKeyGeneration(), updatedWriterKeys,
updatedReaderKeys, ePubKey, ePrivKey, nextCryptKey)
if err != nil {
return nil, nil, err
}
return nil, serverHalves, nil
} | go | func (md *RootMetadataV2) AddKeyGeneration(
codec kbfscodec.Codec, extra ExtraMetadata,
updatedWriterKeys, updatedReaderKeys UserDevicePublicKeys,
ePubKey kbfscrypto.TLFEphemeralPublicKey,
ePrivKey kbfscrypto.TLFEphemeralPrivateKey,
pubKey kbfscrypto.TLFPublicKey,
currCryptKey, nextCryptKey kbfscrypto.TLFCryptKey) (
nextExtra ExtraMetadata,
serverHalves UserDeviceKeyServerHalves, err error) {
if md.TlfID().Type() != tlf.Private {
return nil, nil, InvalidNonPrivateTLFOperation{
md.TlfID(), "AddKeyGeneration", md.Version()}
}
if len(updatedWriterKeys) == 0 {
return nil, nil, errors.New(
"updatedWriterKeys unexpectedly non-empty")
}
if currCryptKey != (kbfscrypto.TLFCryptKey{}) {
return nil, nil, errors.New("currCryptKey unexpectedly non-zero")
}
if len(md.WKeys) != len(md.RKeys) {
return nil, nil, fmt.Errorf(
"Have %d writer key gens, but %d reader key gens",
len(md.WKeys), len(md.RKeys))
}
if len(md.WKeys) > 0 {
existingWriterKeys :=
md.WKeys[len(md.WKeys)-1].WKeys.ToPublicKeys()
if !existingWriterKeys.Equals(updatedWriterKeys) {
return nil, nil, fmt.Errorf(
"existingWriterKeys=%+v != updatedWriterKeys=%+v",
existingWriterKeys, updatedWriterKeys)
}
existingReaderKeys :=
md.RKeys[len(md.RKeys)-1].RKeys.ToPublicKeys()
if !existingReaderKeys.Equals(updatedReaderKeys) {
return nil, nil, fmt.Errorf(
"existingReaderKeys=%+v != updatedReaderKeys=%+v",
existingReaderKeys, updatedReaderKeys)
}
}
newWriterKeys := TLFWriterKeyBundleV2{
WKeys: make(UserDeviceKeyInfoMapV2),
TLFPublicKey: pubKey,
}
md.WKeys = append(md.WKeys, newWriterKeys)
newReaderKeys := TLFReaderKeyBundleV2{
RKeys: make(UserDeviceKeyInfoMapV2),
}
md.RKeys = append(md.RKeys, newReaderKeys)
serverHalves, err = md.updateKeyGeneration(
md.LatestKeyGeneration(), updatedWriterKeys,
updatedReaderKeys, ePubKey, ePrivKey, nextCryptKey)
if err != nil {
return nil, nil, err
}
return nil, serverHalves, nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"AddKeyGeneration",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"extra",
"ExtraMetadata",
",",
"updatedWriterKeys",
",",
"updatedReaderKeys",
"UserDevicePublicKeys",
",",
"ePubKey",
"kbfscrypto",
".",
"TLFEphemeralPubli... | // AddKeyGeneration implements the MutableRootMetadata interface
// for RootMetadataV2. | [
"AddKeyGeneration",
"implements",
"the",
"MutableRootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1242-L1308 |
160,965 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | UpdateKeyBundles | func (md *RootMetadataV2) UpdateKeyBundles(codec kbfscodec.Codec,
_ ExtraMetadata,
updatedWriterKeys, updatedReaderKeys UserDevicePublicKeys,
ePubKey kbfscrypto.TLFEphemeralPublicKey,
ePrivKey kbfscrypto.TLFEphemeralPrivateKey,
tlfCryptKeys []kbfscrypto.TLFCryptKey) (
[]UserDeviceKeyServerHalves, error) {
if md.TlfID().Type() != tlf.Private {
return nil, InvalidNonPrivateTLFOperation{
md.TlfID(), "UpdateKeyBundles", md.Version()}
}
expectedTLFCryptKeyCount := int(
md.LatestKeyGeneration() - FirstValidKeyGen + 1)
if len(tlfCryptKeys) != expectedTLFCryptKeyCount {
return nil, fmt.Errorf(
"(MDv2) Expected %d TLF crypt keys, got %d",
expectedTLFCryptKeyCount, len(tlfCryptKeys))
}
serverHalves := make([]UserDeviceKeyServerHalves, len(tlfCryptKeys))
if len(updatedWriterKeys) == 0 {
// Reader rekey case.
for keyGen := FirstValidKeyGen; keyGen <= md.LatestKeyGeneration(); keyGen++ {
serverHalvesGen, err :=
md.updateKeyGenerationForReaderRekey(codec,
keyGen, updatedReaderKeys,
ePubKey, ePrivKey,
tlfCryptKeys[keyGen-FirstValidKeyGen])
if err != nil {
return nil, err
}
serverHalves[keyGen-FirstValidKeyGen] = serverHalvesGen
}
return serverHalves, nil
}
// Usual rekey case.
for keyGen := FirstValidKeyGen; keyGen <= md.LatestKeyGeneration(); keyGen++ {
serverHalvesGen, err := md.updateKeyGeneration(
keyGen, updatedWriterKeys, updatedReaderKeys,
ePubKey, ePrivKey,
tlfCryptKeys[keyGen-FirstValidKeyGen])
if err != nil {
return nil, err
}
serverHalves[keyGen-FirstValidKeyGen] = serverHalvesGen
}
return serverHalves, nil
} | go | func (md *RootMetadataV2) UpdateKeyBundles(codec kbfscodec.Codec,
_ ExtraMetadata,
updatedWriterKeys, updatedReaderKeys UserDevicePublicKeys,
ePubKey kbfscrypto.TLFEphemeralPublicKey,
ePrivKey kbfscrypto.TLFEphemeralPrivateKey,
tlfCryptKeys []kbfscrypto.TLFCryptKey) (
[]UserDeviceKeyServerHalves, error) {
if md.TlfID().Type() != tlf.Private {
return nil, InvalidNonPrivateTLFOperation{
md.TlfID(), "UpdateKeyBundles", md.Version()}
}
expectedTLFCryptKeyCount := int(
md.LatestKeyGeneration() - FirstValidKeyGen + 1)
if len(tlfCryptKeys) != expectedTLFCryptKeyCount {
return nil, fmt.Errorf(
"(MDv2) Expected %d TLF crypt keys, got %d",
expectedTLFCryptKeyCount, len(tlfCryptKeys))
}
serverHalves := make([]UserDeviceKeyServerHalves, len(tlfCryptKeys))
if len(updatedWriterKeys) == 0 {
// Reader rekey case.
for keyGen := FirstValidKeyGen; keyGen <= md.LatestKeyGeneration(); keyGen++ {
serverHalvesGen, err :=
md.updateKeyGenerationForReaderRekey(codec,
keyGen, updatedReaderKeys,
ePubKey, ePrivKey,
tlfCryptKeys[keyGen-FirstValidKeyGen])
if err != nil {
return nil, err
}
serverHalves[keyGen-FirstValidKeyGen] = serverHalvesGen
}
return serverHalves, nil
}
// Usual rekey case.
for keyGen := FirstValidKeyGen; keyGen <= md.LatestKeyGeneration(); keyGen++ {
serverHalvesGen, err := md.updateKeyGeneration(
keyGen, updatedWriterKeys, updatedReaderKeys,
ePubKey, ePrivKey,
tlfCryptKeys[keyGen-FirstValidKeyGen])
if err != nil {
return nil, err
}
serverHalves[keyGen-FirstValidKeyGen] = serverHalvesGen
}
return serverHalves, nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"UpdateKeyBundles",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"_",
"ExtraMetadata",
",",
"updatedWriterKeys",
",",
"updatedReaderKeys",
"UserDevicePublicKeys",
",",
"ePubKey",
"kbfscrypto",
".",
"TLFEphemeralPublicKey... | // UpdateKeyBundles implements the MutableRootMetadata interface
// for RootMetadataV2. | [
"UpdateKeyBundles",
"implements",
"the",
"MutableRootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1318-L1373 |
160,966 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | FinalizeRekey | func (md *RootMetadataV2) FinalizeRekey(
_ kbfscodec.Codec, _ ExtraMetadata) error {
// Nothing to do.
return nil
} | go | func (md *RootMetadataV2) FinalizeRekey(
_ kbfscodec.Codec, _ ExtraMetadata) error {
// Nothing to do.
return nil
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"FinalizeRekey",
"(",
"_",
"kbfscodec",
".",
"Codec",
",",
"_",
"ExtraMetadata",
")",
"error",
"{",
"// Nothing to do.",
"return",
"nil",
"\n",
"}"
] | // FinalizeRekey implements the MutableRootMetadata interface for RootMetadataV2. | [
"FinalizeRekey",
"implements",
"the",
"MutableRootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1388-L1392 |
160,967 | keybase/client | go/kbfs/kbfsmd/root_metadata_v2.go | GetHistoricTLFCryptKey | func (md *RootMetadataV2) GetHistoricTLFCryptKey(
_ kbfscodec.Codec, _ KeyGen, _ kbfscrypto.TLFCryptKey, _ ExtraMetadata) (
kbfscrypto.TLFCryptKey, error) {
return kbfscrypto.TLFCryptKey{}, errors.New(
"TLF crypt key not symmetrically encrypted")
} | go | func (md *RootMetadataV2) GetHistoricTLFCryptKey(
_ kbfscodec.Codec, _ KeyGen, _ kbfscrypto.TLFCryptKey, _ ExtraMetadata) (
kbfscrypto.TLFCryptKey, error) {
return kbfscrypto.TLFCryptKey{}, errors.New(
"TLF crypt key not symmetrically encrypted")
} | [
"func",
"(",
"md",
"*",
"RootMetadataV2",
")",
"GetHistoricTLFCryptKey",
"(",
"_",
"kbfscodec",
".",
"Codec",
",",
"_",
"KeyGen",
",",
"_",
"kbfscrypto",
".",
"TLFCryptKey",
",",
"_",
"ExtraMetadata",
")",
"(",
"kbfscrypto",
".",
"TLFCryptKey",
",",
"error",... | // GetHistoricTLFCryptKey implements the RootMetadata interface for RootMetadataV2. | [
"GetHistoricTLFCryptKey",
"implements",
"the",
"RootMetadata",
"interface",
"for",
"RootMetadataV2",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata_v2.go#L1401-L1406 |
160,968 | keybase/client | go/libkb/sig_chain.go | GetExpectedNextHighSkip | func (sc SigChain) GetExpectedNextHighSkip(mctx MetaContext, uid keybase1.UID) (HighSkip, error) {
if sc.localChainNextHighSkipOverride != nil {
return *sc.localChainNextHighSkipOverride, nil
}
if len(sc.chainLinks) == 0 {
return NewInitialHighSkip(), nil
}
return sc.GetLastLink().ExpectedNextHighSkip(mctx, uid)
} | go | func (sc SigChain) GetExpectedNextHighSkip(mctx MetaContext, uid keybase1.UID) (HighSkip, error) {
if sc.localChainNextHighSkipOverride != nil {
return *sc.localChainNextHighSkipOverride, nil
}
if len(sc.chainLinks) == 0 {
return NewInitialHighSkip(), nil
}
return sc.GetLastLink().ExpectedNextHighSkip(mctx, uid)
} | [
"func",
"(",
"sc",
"SigChain",
")",
"GetExpectedNextHighSkip",
"(",
"mctx",
"MetaContext",
",",
"uid",
"keybase1",
".",
"UID",
")",
"(",
"HighSkip",
",",
"error",
")",
"{",
"if",
"sc",
".",
"localChainNextHighSkipOverride",
"!=",
"nil",
"{",
"return",
"*",
... | // GetExpectedNextHighSkip returns the HighSkip expected for a new link to be
// added to the chain. It can only be called after VerifyChain is completed. | [
"GetExpectedNextHighSkip",
"returns",
"the",
"HighSkip",
"expected",
"for",
"a",
"new",
"link",
"to",
"be",
"added",
"to",
"the",
"chain",
".",
"It",
"can",
"only",
"be",
"called",
"after",
"VerifyChain",
"is",
"completed",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sig_chain.go#L468-L476 |
160,969 | keybase/client | go/libkb/sig_chain.go | GetCurrentSubchain | func (sc *SigChain) GetCurrentSubchain(m MetaContext, eldest keybase1.KID) (ChainLinks, error) {
return cropToRightmostSubchain(m, sc.chainLinks, eldest, sc.uid)
} | go | func (sc *SigChain) GetCurrentSubchain(m MetaContext, eldest keybase1.KID) (ChainLinks, error) {
return cropToRightmostSubchain(m, sc.chainLinks, eldest, sc.uid)
} | [
"func",
"(",
"sc",
"*",
"SigChain",
")",
"GetCurrentSubchain",
"(",
"m",
"MetaContext",
",",
"eldest",
"keybase1",
".",
"KID",
")",
"(",
"ChainLinks",
",",
"error",
")",
"{",
"return",
"cropToRightmostSubchain",
"(",
"m",
",",
"sc",
".",
"chainLinks",
",",... | // GetCurrentSubchain takes the given sigchain and walks backward until it
// finds the start of the current subchain, returning all the links in the
// subchain. See isSubchainStart for the details of the logic here. | [
"GetCurrentSubchain",
"takes",
"the",
"given",
"sigchain",
"and",
"walks",
"backward",
"until",
"it",
"finds",
"the",
"start",
"of",
"the",
"current",
"subchain",
"returning",
"all",
"the",
"links",
"in",
"the",
"subchain",
".",
"See",
"isSubchainStart",
"for",
... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sig_chain.go#L568-L570 |
160,970 | keybase/client | go/libkb/sig_chain.go | cropToRightmostSubchain | func cropToRightmostSubchain(m MetaContext, links []*ChainLink, eldest keybase1.KID, uid keybase1.UID) (ChainLinks, error) {
// Check for a totally empty chain (that is, a totally new account).
if len(links) == 0 {
return nil, nil
}
// Confirm that the last link is not stubbed. This would prevent us from
// reading the eldest_kid, so the server should never do it.
lastLink := links[len(links)-1]
if lastLink.IsStubbed() {
return nil, errors.New("the last chain link is unexpectedly stubbed in GetCurrentSunchain")
}
// Check whether the eldest KID doesn't match the latest link. That means
// the account has just been reset, and so as with a new account, there is
// no current subchain.
if !lastLink.ToEldestKID().Equal(eldest) {
return nil, nil
}
// The usual case: The eldest kid we're looking for matches the latest
// link, and we need to loop backwards through every pair of links we have.
// If we find a subchain start, return that subslice of links.
for i := len(links) - 1; i > 0; i-- {
curr := links[i]
prev := links[i-1]
isStart, err := isSubchainStart(m, curr, prev, uid)
if err != nil {
return nil, err
}
if isStart {
return links[i:], nil
}
}
// If we didn't find a start anywhere in the middle of the chain, then this
// user has no resets, and we'll return the whole chain. Sanity check that
// we actually loaded everything back to seqno 1. (Anything else would be
// some kind of bug in chain loading.)
if links[0].GetSeqno() != 1 {
return nil, errors.New("chain ended unexpectedly before seqno 1 in GetCurrentSubchain")
}
// In this last case, we're returning the whole chain.
return links, nil
} | go | func cropToRightmostSubchain(m MetaContext, links []*ChainLink, eldest keybase1.KID, uid keybase1.UID) (ChainLinks, error) {
// Check for a totally empty chain (that is, a totally new account).
if len(links) == 0 {
return nil, nil
}
// Confirm that the last link is not stubbed. This would prevent us from
// reading the eldest_kid, so the server should never do it.
lastLink := links[len(links)-1]
if lastLink.IsStubbed() {
return nil, errors.New("the last chain link is unexpectedly stubbed in GetCurrentSunchain")
}
// Check whether the eldest KID doesn't match the latest link. That means
// the account has just been reset, and so as with a new account, there is
// no current subchain.
if !lastLink.ToEldestKID().Equal(eldest) {
return nil, nil
}
// The usual case: The eldest kid we're looking for matches the latest
// link, and we need to loop backwards through every pair of links we have.
// If we find a subchain start, return that subslice of links.
for i := len(links) - 1; i > 0; i-- {
curr := links[i]
prev := links[i-1]
isStart, err := isSubchainStart(m, curr, prev, uid)
if err != nil {
return nil, err
}
if isStart {
return links[i:], nil
}
}
// If we didn't find a start anywhere in the middle of the chain, then this
// user has no resets, and we'll return the whole chain. Sanity check that
// we actually loaded everything back to seqno 1. (Anything else would be
// some kind of bug in chain loading.)
if links[0].GetSeqno() != 1 {
return nil, errors.New("chain ended unexpectedly before seqno 1 in GetCurrentSubchain")
}
// In this last case, we're returning the whole chain.
return links, nil
} | [
"func",
"cropToRightmostSubchain",
"(",
"m",
"MetaContext",
",",
"links",
"[",
"]",
"*",
"ChainLink",
",",
"eldest",
"keybase1",
".",
"KID",
",",
"uid",
"keybase1",
".",
"UID",
")",
"(",
"ChainLinks",
",",
"error",
")",
"{",
"// Check for a totally empty chain... | // cropToRightmostSubchain takes the given set of chain links, and then limits the tail
// of the chain to just those that correspond to the eldest key given by `eldest`. | [
"cropToRightmostSubchain",
"takes",
"the",
"given",
"set",
"of",
"chain",
"links",
"and",
"then",
"limits",
"the",
"tail",
"of",
"the",
"chain",
"to",
"just",
"those",
"that",
"correspond",
"to",
"the",
"eldest",
"key",
"given",
"by",
"eldest",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sig_chain.go#L574-L615 |
160,971 | keybase/client | go/libkb/sig_chain.go | Dump | func (sc *SigChain) Dump(w io.Writer) {
fmt.Fprintf(w, "sigchain dump\n")
for i, l := range sc.chainLinks {
fmt.Fprintf(w, "link %d: %+v\n", i, l)
}
fmt.Fprintf(w, "last known seqno: %d\n", sc.GetLastKnownSeqno())
fmt.Fprintf(w, "last known id: %s\n", sc.GetLastKnownID())
} | go | func (sc *SigChain) Dump(w io.Writer) {
fmt.Fprintf(w, "sigchain dump\n")
for i, l := range sc.chainLinks {
fmt.Fprintf(w, "link %d: %+v\n", i, l)
}
fmt.Fprintf(w, "last known seqno: %d\n", sc.GetLastKnownSeqno())
fmt.Fprintf(w, "last known id: %s\n", sc.GetLastKnownID())
} | [
"func",
"(",
"sc",
"*",
"SigChain",
")",
"Dump",
"(",
"w",
"io",
".",
"Writer",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"for",
"i",
",",
"l",
":=",
"range",
"sc",
".",
"chainLinks",
"{",
"fmt",
".",
"Fpri... | // Dump prints the sigchain to the writer arg. | [
"Dump",
"prints",
"the",
"sigchain",
"to",
"the",
"writer",
"arg",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sig_chain.go#L670-L677 |
160,972 | keybase/client | go/libkb/sig_chain.go | GetLinkFromSigIDQuery | func (sc *SigChain) GetLinkFromSigIDQuery(query string) *ChainLink {
for _, link := range sc.chainLinks {
if link.GetSigID().Match(query, false) {
return link
}
}
return nil
} | go | func (sc *SigChain) GetLinkFromSigIDQuery(query string) *ChainLink {
for _, link := range sc.chainLinks {
if link.GetSigID().Match(query, false) {
return link
}
}
return nil
} | [
"func",
"(",
"sc",
"*",
"SigChain",
")",
"GetLinkFromSigIDQuery",
"(",
"query",
"string",
")",
"*",
"ChainLink",
"{",
"for",
"_",
",",
"link",
":=",
"range",
"sc",
".",
"chainLinks",
"{",
"if",
"link",
".",
"GetSigID",
"(",
")",
".",
"Match",
"(",
"q... | // GetLinkFromSigIDQuery will return true if it finds a ChainLink
// with a SigID that starts with query. | [
"GetLinkFromSigIDQuery",
"will",
"return",
"true",
"if",
"it",
"finds",
"a",
"ChainLink",
"with",
"a",
"SigID",
"that",
"starts",
"with",
"query",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sig_chain.go#L1003-L1010 |
160,973 | keybase/client | go/libkb/sig_chain.go | Store | func (l *SigChainLoader) Store() (err error) {
err = l.StoreTail()
if err == nil {
err = l.chain.Store(l.M())
}
return
} | go | func (l *SigChainLoader) Store() (err error) {
err = l.StoreTail()
if err == nil {
err = l.chain.Store(l.M())
}
return
} | [
"func",
"(",
"l",
"*",
"SigChainLoader",
")",
"Store",
"(",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"l",
".",
"StoreTail",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"err",
"=",
"l",
".",
"chain",
".",
"Store",
"(",
"l",
".",
"M",... | // Store a SigChain to local storage as a result of having loaded it.
// We eagerly write loaded chain links to storage if they verify properly. | [
"Store",
"a",
"SigChain",
"to",
"local",
"storage",
"as",
"a",
"result",
"of",
"having",
"loaded",
"it",
".",
"We",
"eagerly",
"write",
"loaded",
"chain",
"links",
"to",
"storage",
"if",
"they",
"verify",
"properly",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sig_chain.go#L1383-L1389 |
160,974 | keybase/client | go/kbfs/tlf/handle.go | MakeHandle | func MakeHandle(
writers, readers []keybase1.UserOrTeamID,
unresolvedWriters, unresolvedReaders []keybase1.SocialAssertion,
extensions []HandleExtension) (Handle, error) {
if len(writers) == 0 {
return Handle{}, errNoWriters
}
if writers[0].IsTeamOrSubteam() {
// Right now we only support single-team private TLFs.
if len(writers) > 1 || len(unresolvedWriters) != 0 {
return Handle{}, errInvalidWriter
} else if len(readers) != 0 || len(unresolvedReaders) != 0 {
return Handle{}, errInvalidReader
}
}
for i, w := range writers {
if w == keybase1.PUBLIC_UID {
return Handle{}, errInvalidWriter
} else if i > 0 && w.IsTeamOrSubteam() {
return Handle{}, errInvalidWriter
}
}
// If we have more than one reader, none of them should be the
// public UID. And no readers should be a team.
checkPublic := (len(readers) + len(unresolvedReaders)) > 1
for _, r := range readers {
if checkPublic && r == keybase1.PUBLIC_UID {
return Handle{}, errInvalidReader
} else if r.IsTeamOrSubteam() {
return Handle{}, errInvalidReader
}
}
// TODO: Check for overlap between readers and writers, and
// for duplicates.
writersCopy := make([]keybase1.UserOrTeamID, len(writers))
copy(writersCopy, writers)
sort.Sort(UIDList(writersCopy))
var readersCopy []keybase1.UserOrTeamID
if len(readers) > 0 {
readersCopy = make([]keybase1.UserOrTeamID, len(readers))
copy(readersCopy, readers)
sort.Sort(UIDList(readersCopy))
}
var unresolvedWritersCopy []keybase1.SocialAssertion
if len(unresolvedWriters) > 0 {
unresolvedWritersCopy = make([]keybase1.SocialAssertion, len(unresolvedWriters))
copy(unresolvedWritersCopy, unresolvedWriters)
sort.Sort(SocialAssertionList(unresolvedWritersCopy))
}
var unresolvedReadersCopy []keybase1.SocialAssertion
if len(unresolvedReaders) > 0 {
unresolvedReadersCopy = make([]keybase1.SocialAssertion, len(unresolvedReaders))
copy(unresolvedReadersCopy, unresolvedReaders)
sort.Sort(SocialAssertionList(unresolvedReadersCopy))
}
conflictInfo, finalizedInfo := HandleExtensionList(extensions).Splat()
return Handle{
Writers: writersCopy,
Readers: readersCopy,
UnresolvedWriters: unresolvedWritersCopy,
UnresolvedReaders: unresolvedReadersCopy,
ConflictInfo: conflictInfo,
FinalizedInfo: finalizedInfo,
sorted: true,
}, nil
} | go | func MakeHandle(
writers, readers []keybase1.UserOrTeamID,
unresolvedWriters, unresolvedReaders []keybase1.SocialAssertion,
extensions []HandleExtension) (Handle, error) {
if len(writers) == 0 {
return Handle{}, errNoWriters
}
if writers[0].IsTeamOrSubteam() {
// Right now we only support single-team private TLFs.
if len(writers) > 1 || len(unresolvedWriters) != 0 {
return Handle{}, errInvalidWriter
} else if len(readers) != 0 || len(unresolvedReaders) != 0 {
return Handle{}, errInvalidReader
}
}
for i, w := range writers {
if w == keybase1.PUBLIC_UID {
return Handle{}, errInvalidWriter
} else if i > 0 && w.IsTeamOrSubteam() {
return Handle{}, errInvalidWriter
}
}
// If we have more than one reader, none of them should be the
// public UID. And no readers should be a team.
checkPublic := (len(readers) + len(unresolvedReaders)) > 1
for _, r := range readers {
if checkPublic && r == keybase1.PUBLIC_UID {
return Handle{}, errInvalidReader
} else if r.IsTeamOrSubteam() {
return Handle{}, errInvalidReader
}
}
// TODO: Check for overlap between readers and writers, and
// for duplicates.
writersCopy := make([]keybase1.UserOrTeamID, len(writers))
copy(writersCopy, writers)
sort.Sort(UIDList(writersCopy))
var readersCopy []keybase1.UserOrTeamID
if len(readers) > 0 {
readersCopy = make([]keybase1.UserOrTeamID, len(readers))
copy(readersCopy, readers)
sort.Sort(UIDList(readersCopy))
}
var unresolvedWritersCopy []keybase1.SocialAssertion
if len(unresolvedWriters) > 0 {
unresolvedWritersCopy = make([]keybase1.SocialAssertion, len(unresolvedWriters))
copy(unresolvedWritersCopy, unresolvedWriters)
sort.Sort(SocialAssertionList(unresolvedWritersCopy))
}
var unresolvedReadersCopy []keybase1.SocialAssertion
if len(unresolvedReaders) > 0 {
unresolvedReadersCopy = make([]keybase1.SocialAssertion, len(unresolvedReaders))
copy(unresolvedReadersCopy, unresolvedReaders)
sort.Sort(SocialAssertionList(unresolvedReadersCopy))
}
conflictInfo, finalizedInfo := HandleExtensionList(extensions).Splat()
return Handle{
Writers: writersCopy,
Readers: readersCopy,
UnresolvedWriters: unresolvedWritersCopy,
UnresolvedReaders: unresolvedReadersCopy,
ConflictInfo: conflictInfo,
FinalizedInfo: finalizedInfo,
sorted: true,
}, nil
} | [
"func",
"MakeHandle",
"(",
"writers",
",",
"readers",
"[",
"]",
"keybase1",
".",
"UserOrTeamID",
",",
"unresolvedWriters",
",",
"unresolvedReaders",
"[",
"]",
"keybase1",
".",
"SocialAssertion",
",",
"extensions",
"[",
"]",
"HandleExtension",
")",
"(",
"Handle",... | // MakeHandle creates a Handle from the given list of
// readers and writers. If the given reader list contains just
// keybase1.PUBLIC_UID, then the returned handle will be for a public
// folder. Otherwise, it will be private. PUBLIC_UID shouldn't be in
// any list in any other case. | [
"MakeHandle",
"creates",
"a",
"Handle",
"from",
"the",
"given",
"list",
"of",
"readers",
"and",
"writers",
".",
"If",
"the",
"given",
"reader",
"list",
"contains",
"just",
"keybase1",
".",
"PUBLIC_UID",
"then",
"the",
"returned",
"handle",
"will",
"be",
"for... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L93-L168 |
160,975 | keybase/client | go/kbfs/tlf/handle.go | Type | func (h Handle) Type() Type {
if len(h.Readers) == 1 &&
h.Readers[0].Equal(keybase1.PublicUID.AsUserOrTeam()) {
return Public
} else if len(h.Writers) == 1 && h.Writers[0].IsTeamOrSubteam() {
return SingleTeam
}
return Private
} | go | func (h Handle) Type() Type {
if len(h.Readers) == 1 &&
h.Readers[0].Equal(keybase1.PublicUID.AsUserOrTeam()) {
return Public
} else if len(h.Writers) == 1 && h.Writers[0].IsTeamOrSubteam() {
return SingleTeam
}
return Private
} | [
"func",
"(",
"h",
"Handle",
")",
"Type",
"(",
")",
"Type",
"{",
"if",
"len",
"(",
"h",
".",
"Readers",
")",
"==",
"1",
"&&",
"h",
".",
"Readers",
"[",
"0",
"]",
".",
"Equal",
"(",
"keybase1",
".",
"PublicUID",
".",
"AsUserOrTeam",
"(",
")",
")"... | // Type returns the type of TLF this Handle represents. | [
"Type",
"returns",
"the",
"type",
"of",
"TLF",
"this",
"Handle",
"represents",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L184-L192 |
160,976 | keybase/client | go/kbfs/tlf/handle.go | TypeForKeying | func (h Handle) TypeForKeying() KeyingType {
if h.IsBackedByTeam() {
return TeamKeying
}
return h.Type().ToKeyingType()
} | go | func (h Handle) TypeForKeying() KeyingType {
if h.IsBackedByTeam() {
return TeamKeying
}
return h.Type().ToKeyingType()
} | [
"func",
"(",
"h",
"Handle",
")",
"TypeForKeying",
"(",
")",
"KeyingType",
"{",
"if",
"h",
".",
"IsBackedByTeam",
"(",
")",
"{",
"return",
"TeamKeying",
"\n",
"}",
"\n",
"return",
"h",
".",
"Type",
"(",
")",
".",
"ToKeyingType",
"(",
")",
"\n",
"}"
] | // TypeForKeying returns the keying type for the handle h. | [
"TypeForKeying",
"returns",
"the",
"keying",
"type",
"for",
"the",
"handle",
"h",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L195-L200 |
160,977 | keybase/client | go/kbfs/tlf/handle.go | IsWriter | func (h Handle) IsWriter(user keybase1.UserOrTeamID) bool {
if h.TypeForKeying() == TeamKeying {
panic("Can't call Handle.IsWriter() for a single team TLF")
}
return h.findUserInList(user, h.Writers)
} | go | func (h Handle) IsWriter(user keybase1.UserOrTeamID) bool {
if h.TypeForKeying() == TeamKeying {
panic("Can't call Handle.IsWriter() for a single team TLF")
}
return h.findUserInList(user, h.Writers)
} | [
"func",
"(",
"h",
"Handle",
")",
"IsWriter",
"(",
"user",
"keybase1",
".",
"UserOrTeamID",
")",
"bool",
"{",
"if",
"h",
".",
"TypeForKeying",
"(",
")",
"==",
"TeamKeying",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"h",
".",
"fi... | // IsWriter returns whether or not the given user is a writer for the
// top-level folder represented by this Handle. | [
"IsWriter",
"returns",
"whether",
"or",
"not",
"the",
"given",
"user",
"is",
"a",
"writer",
"for",
"the",
"top",
"-",
"level",
"folder",
"represented",
"by",
"this",
"Handle",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L214-L219 |
160,978 | keybase/client | go/kbfs/tlf/handle.go | IsReader | func (h Handle) IsReader(user keybase1.UserOrTeamID) bool {
if h.TypeForKeying() == TeamKeying {
panic("Can't call Handle.IsReader() for a single team TLF")
}
return h.TypeForKeying() == PublicKeying ||
h.findUserInList(user, h.Readers) ||
h.IsWriter(user)
} | go | func (h Handle) IsReader(user keybase1.UserOrTeamID) bool {
if h.TypeForKeying() == TeamKeying {
panic("Can't call Handle.IsReader() for a single team TLF")
}
return h.TypeForKeying() == PublicKeying ||
h.findUserInList(user, h.Readers) ||
h.IsWriter(user)
} | [
"func",
"(",
"h",
"Handle",
")",
"IsReader",
"(",
"user",
"keybase1",
".",
"UserOrTeamID",
")",
"bool",
"{",
"if",
"h",
".",
"TypeForKeying",
"(",
")",
"==",
"TeamKeying",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"h",
".",
"Ty... | // IsReader returns whether or not the given user is a reader for the
// top-level folder represented by this Handle. | [
"IsReader",
"returns",
"whether",
"or",
"not",
"the",
"given",
"user",
"is",
"a",
"reader",
"for",
"the",
"top",
"-",
"level",
"folder",
"represented",
"by",
"this",
"Handle",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L223-L230 |
160,979 | keybase/client | go/kbfs/tlf/handle.go | ResolvedUsers | func (h Handle) ResolvedUsers() []keybase1.UserOrTeamID {
var resolvedUsers []keybase1.UserOrTeamID
resolvedUsers = append(resolvedUsers, h.Writers...)
if h.TypeForKeying() == PrivateKeying {
resolvedUsers = append(resolvedUsers, h.Readers...)
}
return resolvedUsers
} | go | func (h Handle) ResolvedUsers() []keybase1.UserOrTeamID {
var resolvedUsers []keybase1.UserOrTeamID
resolvedUsers = append(resolvedUsers, h.Writers...)
if h.TypeForKeying() == PrivateKeying {
resolvedUsers = append(resolvedUsers, h.Readers...)
}
return resolvedUsers
} | [
"func",
"(",
"h",
"Handle",
")",
"ResolvedUsers",
"(",
")",
"[",
"]",
"keybase1",
".",
"UserOrTeamID",
"{",
"var",
"resolvedUsers",
"[",
"]",
"keybase1",
".",
"UserOrTeamID",
"\n",
"resolvedUsers",
"=",
"append",
"(",
"resolvedUsers",
",",
"h",
".",
"Write... | // ResolvedUsers returns the concatenation of h.Writers and h.Readers,
// except if the handle is public, the returned list won't contain
// PUBLIC_UID. | [
"ResolvedUsers",
"returns",
"the",
"concatenation",
"of",
"h",
".",
"Writers",
"and",
"h",
".",
"Readers",
"except",
"if",
"the",
"handle",
"is",
"public",
"the",
"returned",
"list",
"won",
"t",
"contain",
"PUBLIC_UID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L235-L242 |
160,980 | keybase/client | go/kbfs/tlf/handle.go | HasUnresolvedUsers | func (h Handle) HasUnresolvedUsers() bool {
return len(h.UnresolvedWriters) > 0 || len(h.UnresolvedReaders) > 0
} | go | func (h Handle) HasUnresolvedUsers() bool {
return len(h.UnresolvedWriters) > 0 || len(h.UnresolvedReaders) > 0
} | [
"func",
"(",
"h",
"Handle",
")",
"HasUnresolvedUsers",
"(",
")",
"bool",
"{",
"return",
"len",
"(",
"h",
".",
"UnresolvedWriters",
")",
">",
"0",
"||",
"len",
"(",
"h",
".",
"UnresolvedReaders",
")",
">",
"0",
"\n",
"}"
] | // HasUnresolvedUsers returns true if this handle has any unresolved
// writers or readers. | [
"HasUnresolvedUsers",
"returns",
"true",
"if",
"this",
"handle",
"has",
"any",
"unresolved",
"writers",
"or",
"readers",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L246-L248 |
160,981 | keybase/client | go/kbfs/tlf/handle.go | UnresolvedUsers | func (h Handle) UnresolvedUsers() []keybase1.SocialAssertion {
var unresolvedUsers []keybase1.SocialAssertion
unresolvedUsers = append(unresolvedUsers, h.UnresolvedWriters...)
unresolvedUsers = append(unresolvedUsers, h.UnresolvedReaders...)
return unresolvedUsers
} | go | func (h Handle) UnresolvedUsers() []keybase1.SocialAssertion {
var unresolvedUsers []keybase1.SocialAssertion
unresolvedUsers = append(unresolvedUsers, h.UnresolvedWriters...)
unresolvedUsers = append(unresolvedUsers, h.UnresolvedReaders...)
return unresolvedUsers
} | [
"func",
"(",
"h",
"Handle",
")",
"UnresolvedUsers",
"(",
")",
"[",
"]",
"keybase1",
".",
"SocialAssertion",
"{",
"var",
"unresolvedUsers",
"[",
"]",
"keybase1",
".",
"SocialAssertion",
"\n",
"unresolvedUsers",
"=",
"append",
"(",
"unresolvedUsers",
",",
"h",
... | // UnresolvedUsers returns the concatenation of h.UnresolvedWriters
// and h.UnresolvedReaders. | [
"UnresolvedUsers",
"returns",
"the",
"concatenation",
"of",
"h",
".",
"UnresolvedWriters",
"and",
"h",
".",
"UnresolvedReaders",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L252-L257 |
160,982 | keybase/client | go/kbfs/tlf/handle.go | ResolveAssertions | func (h Handle) ResolveAssertions(
assertions map[keybase1.SocialAssertion]keybase1.UID) Handle {
if len(assertions) == 0 || (len(h.UnresolvedWriters) == 0 && len(h.UnresolvedReaders) == 0) || h.IsFinal() {
return h
}
var resolvedWriters, resolvedReaders map[keybase1.UserOrTeamID]bool
resolvedWriters, h.UnresolvedWriters = resolveAssertions(assertions, h.UnresolvedWriters, h.Writers)
resolvedReaders, h.UnresolvedReaders = resolveAssertions(assertions, h.UnresolvedReaders, h.Readers)
h.Writers = uidSetToSlice(resolvedWriters)
for _, u := range h.Writers {
delete(resolvedReaders, u)
}
h.Readers = uidSetToSlice(resolvedReaders)
sort.Sort(UIDList(h.Writers))
sort.Sort(UIDList(h.Readers))
sort.Sort(SocialAssertionList(h.UnresolvedWriters))
sort.Sort(SocialAssertionList(h.UnresolvedReaders))
h.sorted = true
return h
} | go | func (h Handle) ResolveAssertions(
assertions map[keybase1.SocialAssertion]keybase1.UID) Handle {
if len(assertions) == 0 || (len(h.UnresolvedWriters) == 0 && len(h.UnresolvedReaders) == 0) || h.IsFinal() {
return h
}
var resolvedWriters, resolvedReaders map[keybase1.UserOrTeamID]bool
resolvedWriters, h.UnresolvedWriters = resolveAssertions(assertions, h.UnresolvedWriters, h.Writers)
resolvedReaders, h.UnresolvedReaders = resolveAssertions(assertions, h.UnresolvedReaders, h.Readers)
h.Writers = uidSetToSlice(resolvedWriters)
for _, u := range h.Writers {
delete(resolvedReaders, u)
}
h.Readers = uidSetToSlice(resolvedReaders)
sort.Sort(UIDList(h.Writers))
sort.Sort(UIDList(h.Readers))
sort.Sort(SocialAssertionList(h.UnresolvedWriters))
sort.Sort(SocialAssertionList(h.UnresolvedReaders))
h.sorted = true
return h
} | [
"func",
"(",
"h",
"Handle",
")",
"ResolveAssertions",
"(",
"assertions",
"map",
"[",
"keybase1",
".",
"SocialAssertion",
"]",
"keybase1",
".",
"UID",
")",
"Handle",
"{",
"if",
"len",
"(",
"assertions",
")",
"==",
"0",
"||",
"(",
"len",
"(",
"h",
".",
... | // ResolveAssertions creates a new Handle given an existing one with
// while resolving the passed assertions. | [
"ResolveAssertions",
"creates",
"a",
"new",
"Handle",
"given",
"an",
"existing",
"one",
"with",
"while",
"resolving",
"the",
"passed",
"assertions",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L307-L326 |
160,983 | keybase/client | go/kbfs/tlf/handle.go | Extensions | func (h Handle) Extensions() (extensions []HandleExtension) {
if h.ConflictInfo != nil {
extensions = append(extensions, *h.ConflictInfo)
}
if h.FinalizedInfo != nil {
extensions = append(extensions, *h.FinalizedInfo)
}
return extensions
} | go | func (h Handle) Extensions() (extensions []HandleExtension) {
if h.ConflictInfo != nil {
extensions = append(extensions, *h.ConflictInfo)
}
if h.FinalizedInfo != nil {
extensions = append(extensions, *h.FinalizedInfo)
}
return extensions
} | [
"func",
"(",
"h",
"Handle",
")",
"Extensions",
"(",
")",
"(",
"extensions",
"[",
"]",
"HandleExtension",
")",
"{",
"if",
"h",
".",
"ConflictInfo",
"!=",
"nil",
"{",
"extensions",
"=",
"append",
"(",
"extensions",
",",
"*",
"h",
".",
"ConflictInfo",
")"... | // Extensions returns a list of extensions for the given handle. | [
"Extensions",
"returns",
"a",
"list",
"of",
"extensions",
"for",
"the",
"given",
"handle",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L329-L337 |
160,984 | keybase/client | go/kbfs/tlf/handle.go | DeepEqual | func (h *Handle) DeepEqual(other Handle) bool {
if len(h.Writers) != len(other.Writers) {
return false
}
if len(h.UnresolvedWriters) != len(other.UnresolvedWriters) {
return false
}
if len(h.Readers) != len(other.Readers) {
return false
}
if len(h.UnresolvedReaders) != len(other.UnresolvedReaders) {
return false
}
if !h.sorted {
sort.Sort(UIDList(h.Writers))
sort.Sort(UIDList(h.Readers))
sort.Sort(SocialAssertionList(h.UnresolvedWriters))
sort.Sort(SocialAssertionList(h.UnresolvedReaders))
h.sorted = true
}
if !other.sorted {
sort.Sort(UIDList(other.Writers))
sort.Sort(UIDList(other.Readers))
sort.Sort(SocialAssertionList(other.UnresolvedWriters))
sort.Sort(SocialAssertionList(other.UnresolvedReaders))
}
for i, v := range h.Writers {
if other.Writers[i] != v {
return false
}
}
for i, v := range h.UnresolvedWriters {
if other.UnresolvedWriters[i] != v {
return false
}
}
for i, v := range h.Readers {
if other.Readers[i] != v {
return false
}
}
for i, v := range h.UnresolvedReaders {
if other.UnresolvedReaders[i] != v {
return false
}
}
if h.IsConflict() != other.IsConflict() {
return false
}
if h.IsFinal() != other.IsFinal() {
return false
}
if h.ConflictInfo != nil &&
h.ConflictInfo.String() != other.ConflictInfo.String() {
return false
}
if h.FinalizedInfo != nil &&
h.FinalizedInfo.String() != other.FinalizedInfo.String() {
return false
}
return true
} | go | func (h *Handle) DeepEqual(other Handle) bool {
if len(h.Writers) != len(other.Writers) {
return false
}
if len(h.UnresolvedWriters) != len(other.UnresolvedWriters) {
return false
}
if len(h.Readers) != len(other.Readers) {
return false
}
if len(h.UnresolvedReaders) != len(other.UnresolvedReaders) {
return false
}
if !h.sorted {
sort.Sort(UIDList(h.Writers))
sort.Sort(UIDList(h.Readers))
sort.Sort(SocialAssertionList(h.UnresolvedWriters))
sort.Sort(SocialAssertionList(h.UnresolvedReaders))
h.sorted = true
}
if !other.sorted {
sort.Sort(UIDList(other.Writers))
sort.Sort(UIDList(other.Readers))
sort.Sort(SocialAssertionList(other.UnresolvedWriters))
sort.Sort(SocialAssertionList(other.UnresolvedReaders))
}
for i, v := range h.Writers {
if other.Writers[i] != v {
return false
}
}
for i, v := range h.UnresolvedWriters {
if other.UnresolvedWriters[i] != v {
return false
}
}
for i, v := range h.Readers {
if other.Readers[i] != v {
return false
}
}
for i, v := range h.UnresolvedReaders {
if other.UnresolvedReaders[i] != v {
return false
}
}
if h.IsConflict() != other.IsConflict() {
return false
}
if h.IsFinal() != other.IsFinal() {
return false
}
if h.ConflictInfo != nil &&
h.ConflictInfo.String() != other.ConflictInfo.String() {
return false
}
if h.FinalizedInfo != nil &&
h.FinalizedInfo.String() != other.FinalizedInfo.String() {
return false
}
return true
} | [
"func",
"(",
"h",
"*",
"Handle",
")",
"DeepEqual",
"(",
"other",
"Handle",
")",
"bool",
"{",
"if",
"len",
"(",
"h",
".",
"Writers",
")",
"!=",
"len",
"(",
"other",
".",
"Writers",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"len",
"(",
... | // DeepEqual returns true if the handle is equal to another handle.
// This can mutate the Handle in that it might sort its Writers,
// Readers, UnresolvedWriters, and UnresolvedReaders. | [
"DeepEqual",
"returns",
"true",
"if",
"the",
"handle",
"is",
"equal",
"to",
"another",
"handle",
".",
"This",
"can",
"mutate",
"the",
"Handle",
"in",
"that",
"it",
"might",
"sort",
"its",
"Writers",
"Readers",
"UnresolvedWriters",
"and",
"UnresolvedReaders",
"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L352-L416 |
160,985 | keybase/client | go/kbfs/tlf/handle.go | checkUIDEquality | func checkUIDEquality(a, b []keybase1.UserOrTeamID) bool {
aMap := make(map[keybase1.UserOrTeamID]bool)
for _, u := range a {
aMap[u] = true
}
for _, u := range b {
if !aMap[u] {
return false
}
delete(aMap, u)
}
return len(aMap) == 0
} | go | func checkUIDEquality(a, b []keybase1.UserOrTeamID) bool {
aMap := make(map[keybase1.UserOrTeamID]bool)
for _, u := range a {
aMap[u] = true
}
for _, u := range b {
if !aMap[u] {
return false
}
delete(aMap, u)
}
return len(aMap) == 0
} | [
"func",
"checkUIDEquality",
"(",
"a",
",",
"b",
"[",
"]",
"keybase1",
".",
"UserOrTeamID",
")",
"bool",
"{",
"aMap",
":=",
"make",
"(",
"map",
"[",
"keybase1",
".",
"UserOrTeamID",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"u",
":=",
"range",
"a",
"... | // checkUIDEquality returns true if `a` and `b` contain the same IDs,
// regardless of order. However, if `a` contains duplicates, this
// function may return an incorrect value. | [
"checkUIDEquality",
"returns",
"true",
"if",
"a",
"and",
"b",
"contain",
"the",
"same",
"IDs",
"regardless",
"of",
"order",
".",
"However",
"if",
"a",
"contains",
"duplicates",
"this",
"function",
"may",
"return",
"an",
"incorrect",
"value",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L421-L433 |
160,986 | keybase/client | go/kbfs/tlf/handle.go | ResolvedUsersEqual | func (h *Handle) ResolvedUsersEqual(
writers []keybase1.UserOrTeamID, readers []keybase1.UserOrTeamID) bool {
return checkUIDEquality(h.Writers, writers) &&
checkUIDEquality(h.Readers, readers)
} | go | func (h *Handle) ResolvedUsersEqual(
writers []keybase1.UserOrTeamID, readers []keybase1.UserOrTeamID) bool {
return checkUIDEquality(h.Writers, writers) &&
checkUIDEquality(h.Readers, readers)
} | [
"func",
"(",
"h",
"*",
"Handle",
")",
"ResolvedUsersEqual",
"(",
"writers",
"[",
"]",
"keybase1",
".",
"UserOrTeamID",
",",
"readers",
"[",
"]",
"keybase1",
".",
"UserOrTeamID",
")",
"bool",
"{",
"return",
"checkUIDEquality",
"(",
"h",
".",
"Writers",
",",... | // ResolvedUsersEqual checks whether the resolved users of this TLF
// matches the provided lists of writers and readers. | [
"ResolvedUsersEqual",
"checks",
"whether",
"the",
"resolved",
"users",
"of",
"this",
"TLF",
"matches",
"the",
"provided",
"lists",
"of",
"writers",
"and",
"readers",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle.go#L437-L441 |
160,987 | keybase/client | go/kbfs/libgit/util.go | commonTime | func commonTime(
ctx context.Context, mdserver libkbfs.MDServer, clock libkbfs.Clock,
log logger.Logger) time.Time {
offset, haveOffset := mdserver.OffsetFromServerTime()
if !haveOffset {
log.CDebugf(ctx, "No offset, cannot use common time; "+
"falling back to local time")
return clock.Now()
}
return clock.Now().Add(-offset)
} | go | func commonTime(
ctx context.Context, mdserver libkbfs.MDServer, clock libkbfs.Clock,
log logger.Logger) time.Time {
offset, haveOffset := mdserver.OffsetFromServerTime()
if !haveOffset {
log.CDebugf(ctx, "No offset, cannot use common time; "+
"falling back to local time")
return clock.Now()
}
return clock.Now().Add(-offset)
} | [
"func",
"commonTime",
"(",
"ctx",
"context",
".",
"Context",
",",
"mdserver",
"libkbfs",
".",
"MDServer",
",",
"clock",
"libkbfs",
".",
"Clock",
",",
"log",
"logger",
".",
"Logger",
")",
"time",
".",
"Time",
"{",
"offset",
",",
"haveOffset",
":=",
"mdser... | // commonTime computes the current time according to our estimate of
// the mdserver's time. It's a very crude way of normalizing the
// local clock. | [
"commonTime",
"computes",
"the",
"current",
"time",
"according",
"to",
"our",
"estimate",
"of",
"the",
"mdserver",
"s",
"time",
".",
"It",
"s",
"a",
"very",
"crude",
"way",
"of",
"normalizing",
"the",
"local",
"clock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/util.go#L24-L34 |
160,988 | keybase/client | go/kbfs/libgit/util.go | canDoWork | func canDoWork(
ctx context.Context, mdserver libkbfs.MDServer, clock libkbfs.Clock,
fs *libfs.FS, workingFileName string, workLimit time.Duration,
log logger.Logger) (bool, error) {
fi, err := fs.Stat(workingFileName)
currCommonTime := commonTime(ctx, mdserver, clock, log)
switch {
case os.IsNotExist(err):
log.CDebugf(ctx, "Creating new working file %s", workingFileName)
f, err := fs.Create(workingFileName)
if err != nil {
return false, err
}
err = f.Close()
if err != nil {
return false, err
}
case err != nil:
return false, err
default: // err == nil
modCommonTime := fi.ModTime()
if modCommonTime.Add(workTimeLimit).After(currCommonTime) {
log.CDebugf(ctx, "Other worker is still working; "+
"modCommonTime=%s, currCommonTime=%s, workTimeLimit=%s",
modCommonTime, currCommonTime, workTimeLimit)
// The other GC is still running within the time
// limit.
return false, nil
}
log.CDebugf(ctx, "Other GC expired; "+
"modCommonTime=%s, currCommonTime=%s, workTimeLimit=%s",
modCommonTime, currCommonTime, workTimeLimit)
}
log.CDebugf(ctx, "Setting work common time to %s", currCommonTime)
err = fs.Chtimes(workingFileName, time.Time{}, currCommonTime)
if err != nil {
return false, err
}
return true, nil
} | go | func canDoWork(
ctx context.Context, mdserver libkbfs.MDServer, clock libkbfs.Clock,
fs *libfs.FS, workingFileName string, workLimit time.Duration,
log logger.Logger) (bool, error) {
fi, err := fs.Stat(workingFileName)
currCommonTime := commonTime(ctx, mdserver, clock, log)
switch {
case os.IsNotExist(err):
log.CDebugf(ctx, "Creating new working file %s", workingFileName)
f, err := fs.Create(workingFileName)
if err != nil {
return false, err
}
err = f.Close()
if err != nil {
return false, err
}
case err != nil:
return false, err
default: // err == nil
modCommonTime := fi.ModTime()
if modCommonTime.Add(workTimeLimit).After(currCommonTime) {
log.CDebugf(ctx, "Other worker is still working; "+
"modCommonTime=%s, currCommonTime=%s, workTimeLimit=%s",
modCommonTime, currCommonTime, workTimeLimit)
// The other GC is still running within the time
// limit.
return false, nil
}
log.CDebugf(ctx, "Other GC expired; "+
"modCommonTime=%s, currCommonTime=%s, workTimeLimit=%s",
modCommonTime, currCommonTime, workTimeLimit)
}
log.CDebugf(ctx, "Setting work common time to %s", currCommonTime)
err = fs.Chtimes(workingFileName, time.Time{}, currCommonTime)
if err != nil {
return false, err
}
return true, nil
} | [
"func",
"canDoWork",
"(",
"ctx",
"context",
".",
"Context",
",",
"mdserver",
"libkbfs",
".",
"MDServer",
",",
"clock",
"libkbfs",
".",
"Clock",
",",
"fs",
"*",
"libfs",
".",
"FS",
",",
"workingFileName",
"string",
",",
"workLimit",
"time",
".",
"Duration",... | // canDoWork creates a file that marks the start of some long-term
// work by this node. It should be called while a lock is taken on
// the server. It returns true if the caller should start doing the
// work. | [
"canDoWork",
"creates",
"a",
"file",
"that",
"marks",
"the",
"start",
"of",
"some",
"long",
"-",
"term",
"work",
"by",
"this",
"node",
".",
"It",
"should",
"be",
"called",
"while",
"a",
"lock",
"is",
"taken",
"on",
"the",
"server",
".",
"It",
"returns"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/util.go#L40-L80 |
160,989 | keybase/client | go/kbfs/fsrpc/fs.go | NewFS | func NewFS(config libkbfs.Config, log logger.Logger) keybase1.FsInterface {
return &fs{config: config, log: log}
} | go | func NewFS(config libkbfs.Config, log logger.Logger) keybase1.FsInterface {
return &fs{config: config, log: log}
} | [
"func",
"NewFS",
"(",
"config",
"libkbfs",
".",
"Config",
",",
"log",
"logger",
".",
"Logger",
")",
"keybase1",
".",
"FsInterface",
"{",
"return",
"&",
"fs",
"{",
"config",
":",
"config",
",",
"log",
":",
"log",
"}",
"\n",
"}"
] | // NewFS returns a new FS protocol implementation | [
"NewFS",
"returns",
"a",
"new",
"FS",
"protocol",
"implementation"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/fsrpc/fs.go#L23-L25 |
160,990 | keybase/client | go/kbfs/fsrpc/fs.go | List | func (f *fs) List(ctx context.Context, arg keybase1.ListArg) (keybase1.ListResult, error) {
f.log.CDebugf(ctx, "Listing %q", arg.Path)
kbfsPath, err := NewPath(arg.Path)
if err != nil {
return keybase1.ListResult{}, err
}
var result keybase1.ListResult
switch kbfsPath.PathType {
case RootPathType:
result, err = f.root(ctx)
case KeybasePathType:
result, err = f.keybase(ctx)
case KeybaseChildPathType:
result, err = f.favorites(ctx, kbfsPath)
default:
result, err = f.tlf(ctx, kbfsPath)
}
if err != nil {
f.log.CErrorf(ctx, "Error listing path %q: %s", arg.Path, err)
}
return result, err
} | go | func (f *fs) List(ctx context.Context, arg keybase1.ListArg) (keybase1.ListResult, error) {
f.log.CDebugf(ctx, "Listing %q", arg.Path)
kbfsPath, err := NewPath(arg.Path)
if err != nil {
return keybase1.ListResult{}, err
}
var result keybase1.ListResult
switch kbfsPath.PathType {
case RootPathType:
result, err = f.root(ctx)
case KeybasePathType:
result, err = f.keybase(ctx)
case KeybaseChildPathType:
result, err = f.favorites(ctx, kbfsPath)
default:
result, err = f.tlf(ctx, kbfsPath)
}
if err != nil {
f.log.CErrorf(ctx, "Error listing path %q: %s", arg.Path, err)
}
return result, err
} | [
"func",
"(",
"f",
"*",
"fs",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"ListArg",
")",
"(",
"keybase1",
".",
"ListResult",
",",
"error",
")",
"{",
"f",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\""... | // List implements keybase1.FsInterface | [
"List",
"implements",
"keybase1",
".",
"FsInterface"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/fsrpc/fs.go#L103-L126 |
160,991 | keybase/client | go/libkb/secret_store.go | PrimeSecretStore | func PrimeSecretStore(mctx MetaContext, ss SecretStoreAll) (err error) {
defer mctx.TraceTimed("PrimeSecretStore", func() error { return err })()
// Generate test username and test secret
testUsername, err := RandString("test_ss_", 5)
// RandString returns base32 encoded random bytes, make it look like a
// Keybase username. This is not required, though.
testUsername = strings.ToLower(strings.Replace(testUsername, "=", "", -1))
if err != nil {
return err
}
randBytes, err := RandBytes(LKSecLen)
if err != nil {
return err
}
mctx.Debug("PrimeSecretStore: priming secret store with username %q and secret %v", testUsername, randBytes)
testNormUsername := NormalizedUsername(testUsername)
var secretF [LKSecLen]byte
copy(secretF[:], randBytes[:])
testSecret := LKSecFullSecret{f: &secretF}
defer func() {
err2 := ss.ClearSecret(mctx, testNormUsername)
mctx.Debug("PrimeSecretStore: clearing test secret store entry")
if err2 != nil {
mctx.Debug("PrimeSecretStore: clearing secret store entry returned an error: %s", err2)
if err == nil {
err = err2
} else {
mctx.Debug("suppressing store clearing error because something else has errored prior")
}
}
}()
// Try to fetch first, we should get an error back.
_, err = ss.RetrieveSecret(mctx, testNormUsername)
if err == nil {
return errors.New("managed to retrieve secret before storing it")
} else if err != nil {
mctx.Debug("PrimeSecretStore: error when retrieving secret that wasn't stored yet: %q, as expected", err)
}
// Put secret in secret store through `SecretStore` interface.
err = ss.StoreSecret(mctx, testNormUsername, testSecret)
if err != nil {
return fmt.Errorf("error while storing secret: %s", err)
}
// Recreate test store with same username, try to retrieve secret.
retrSecret, err := ss.RetrieveSecret(mctx, testNormUsername)
if err != nil {
return fmt.Errorf("error while retrieving secret: %s", err)
}
mctx.Debug("PrimeSecretStore: retrieved secret: %v", retrSecret.f)
if !retrSecret.Equal(testSecret) {
return errors.New("managed to retrieve test secret but it didn't match the stored one")
}
mctx.Debug("PrimeSecretStore: retrieved secret matched!")
return nil
} | go | func PrimeSecretStore(mctx MetaContext, ss SecretStoreAll) (err error) {
defer mctx.TraceTimed("PrimeSecretStore", func() error { return err })()
// Generate test username and test secret
testUsername, err := RandString("test_ss_", 5)
// RandString returns base32 encoded random bytes, make it look like a
// Keybase username. This is not required, though.
testUsername = strings.ToLower(strings.Replace(testUsername, "=", "", -1))
if err != nil {
return err
}
randBytes, err := RandBytes(LKSecLen)
if err != nil {
return err
}
mctx.Debug("PrimeSecretStore: priming secret store with username %q and secret %v", testUsername, randBytes)
testNormUsername := NormalizedUsername(testUsername)
var secretF [LKSecLen]byte
copy(secretF[:], randBytes[:])
testSecret := LKSecFullSecret{f: &secretF}
defer func() {
err2 := ss.ClearSecret(mctx, testNormUsername)
mctx.Debug("PrimeSecretStore: clearing test secret store entry")
if err2 != nil {
mctx.Debug("PrimeSecretStore: clearing secret store entry returned an error: %s", err2)
if err == nil {
err = err2
} else {
mctx.Debug("suppressing store clearing error because something else has errored prior")
}
}
}()
// Try to fetch first, we should get an error back.
_, err = ss.RetrieveSecret(mctx, testNormUsername)
if err == nil {
return errors.New("managed to retrieve secret before storing it")
} else if err != nil {
mctx.Debug("PrimeSecretStore: error when retrieving secret that wasn't stored yet: %q, as expected", err)
}
// Put secret in secret store through `SecretStore` interface.
err = ss.StoreSecret(mctx, testNormUsername, testSecret)
if err != nil {
return fmt.Errorf("error while storing secret: %s", err)
}
// Recreate test store with same username, try to retrieve secret.
retrSecret, err := ss.RetrieveSecret(mctx, testNormUsername)
if err != nil {
return fmt.Errorf("error while retrieving secret: %s", err)
}
mctx.Debug("PrimeSecretStore: retrieved secret: %v", retrSecret.f)
if !retrSecret.Equal(testSecret) {
return errors.New("managed to retrieve test secret but it didn't match the stored one")
}
mctx.Debug("PrimeSecretStore: retrieved secret matched!")
return nil
} | [
"func",
"PrimeSecretStore",
"(",
"mctx",
"MetaContext",
",",
"ss",
"SecretStoreAll",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"mctx",
".",
"TraceTimed",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\... | // PrimeSecretStore runs a test with current platform's secret store, trying to
// store, retrieve, and then delete a secret with an arbitrary name. This should
// be done before provisioning or logging in | [
"PrimeSecretStore",
"runs",
"a",
"test",
"with",
"current",
"platform",
"s",
"secret",
"store",
"trying",
"to",
"store",
"retrieve",
"and",
"then",
"delete",
"a",
"secret",
"with",
"an",
"arbitrary",
"name",
".",
"This",
"should",
"be",
"done",
"before",
"pr... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/secret_store.go#L314-L374 |
160,992 | keybase/client | go/kbfs/libfuse/fs.go | SetFuseConn | func (f *FS) SetFuseConn(fuse *fs.Server, conn *fuse.Conn) {
f.fuse = fuse
f.conn = conn
} | go | func (f *FS) SetFuseConn(fuse *fs.Server, conn *fuse.Conn) {
f.fuse = fuse
f.conn = conn
} | [
"func",
"(",
"f",
"*",
"FS",
")",
"SetFuseConn",
"(",
"fuse",
"*",
"fs",
".",
"Server",
",",
"conn",
"*",
"fuse",
".",
"Conn",
")",
"{",
"f",
".",
"fuse",
"=",
"fuse",
"\n",
"f",
".",
"conn",
"=",
"conn",
"\n",
"}"
] | // SetFuseConn sets fuse connection for this FS. | [
"SetFuseConn",
"sets",
"fuse",
"connection",
"for",
"this",
"FS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/fs.go#L261-L264 |
160,993 | keybase/client | go/kbfs/libfuse/fs.go | LaunchNotificationProcessor | func (f *FS) LaunchNotificationProcessor(ctx context.Context) {
f.notifications.LaunchProcessor(ctx)
} | go | func (f *FS) LaunchNotificationProcessor(ctx context.Context) {
f.notifications.LaunchProcessor(ctx)
} | [
"func",
"(",
"f",
"*",
"FS",
")",
"LaunchNotificationProcessor",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"f",
".",
"notifications",
".",
"LaunchProcessor",
"(",
"ctx",
")",
"\n",
"}"
] | // LaunchNotificationProcessor launches the notification processor. | [
"LaunchNotificationProcessor",
"launches",
"the",
"notification",
"processor",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/fs.go#L276-L278 |
160,994 | keybase/client | go/kbfs/libfuse/fs.go | WithContext | func (f *FS) WithContext(ctx context.Context) context.Context {
id, errRandomReqID := libkbfs.MakeRandomRequestID()
if errRandomReqID != nil {
f.log.Errorf("Couldn't make request ID: %v", errRandomReqID)
}
// context.WithDeadline uses clock from `time` package, so we are not using
// f.config.Clock() here
start := time.Now()
ctx, err := libcontext.NewContextWithCancellationDelayer(
libcontext.NewContextReplayable(ctx, func(ctx context.Context) context.Context {
ctx = context.WithValue(ctx, libfs.CtxAppIDKey, f)
logTags := make(logger.CtxLogTags)
logTags[CtxIDKey] = CtxOpID
ctx = logger.NewContextWithLogTags(ctx, logTags)
if errRandomReqID == nil {
// Add a unique ID to this context, identifying a particular
// request.
ctx = context.WithValue(ctx, CtxIDKey, id)
}
if runtime.GOOS == "darwin" {
// Timeout operations before they hit the osxfuse time limit,
// so we don't hose the entire mount (Fixed in OSXFUSE 3.2.0).
// The timeout is 60 seconds, but it looks like sometimes it
// tries multiple attempts within that 60 seconds, so let's go
// a little under 60/3 to be safe.
//
// It should be safe to ignore the CancelFunc here because our
// parent context will be canceled by the FUSE serve loop.
ctx, _ = context.WithDeadline(ctx, start.Add(19*time.Second))
}
return ctx
}))
if err != nil {
panic(err) // this should never happen
}
return ctx
} | go | func (f *FS) WithContext(ctx context.Context) context.Context {
id, errRandomReqID := libkbfs.MakeRandomRequestID()
if errRandomReqID != nil {
f.log.Errorf("Couldn't make request ID: %v", errRandomReqID)
}
// context.WithDeadline uses clock from `time` package, so we are not using
// f.config.Clock() here
start := time.Now()
ctx, err := libcontext.NewContextWithCancellationDelayer(
libcontext.NewContextReplayable(ctx, func(ctx context.Context) context.Context {
ctx = context.WithValue(ctx, libfs.CtxAppIDKey, f)
logTags := make(logger.CtxLogTags)
logTags[CtxIDKey] = CtxOpID
ctx = logger.NewContextWithLogTags(ctx, logTags)
if errRandomReqID == nil {
// Add a unique ID to this context, identifying a particular
// request.
ctx = context.WithValue(ctx, CtxIDKey, id)
}
if runtime.GOOS == "darwin" {
// Timeout operations before they hit the osxfuse time limit,
// so we don't hose the entire mount (Fixed in OSXFUSE 3.2.0).
// The timeout is 60 seconds, but it looks like sometimes it
// tries multiple attempts within that 60 seconds, so let's go
// a little under 60/3 to be safe.
//
// It should be safe to ignore the CancelFunc here because our
// parent context will be canceled by the FUSE serve loop.
ctx, _ = context.WithDeadline(ctx, start.Add(19*time.Second))
}
return ctx
}))
if err != nil {
panic(err) // this should never happen
}
return ctx
} | [
"func",
"(",
"f",
"*",
"FS",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"id",
",",
"errRandomReqID",
":=",
"libkbfs",
".",
"MakeRandomRequestID",
"(",
")",
"\n",
"if",
"errRandomReqID",
"!=",
"nil",
"{... | // WithContext adds app- and request-specific values to the context.
// libkbfs.NewContextWithCancellationDelayer is called before returning the
// context to ensure the cancellation is controllable.
//
// It is called by FUSE for normal runs, but may be called explicitly in other
// settings, such as tests. | [
"WithContext",
"adds",
"app",
"-",
"and",
"request",
"-",
"specific",
"values",
"to",
"the",
"context",
".",
"libkbfs",
".",
"NewContextWithCancellationDelayer",
"is",
"called",
"before",
"returning",
"the",
"context",
"to",
"ensure",
"the",
"cancellation",
"is",
... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/fs.go#L286-L329 |
160,995 | keybase/client | go/kbfs/libfuse/fs.go | Serve | func (f *FS) Serve(ctx context.Context) error {
srv := fs.New(f.conn, &fs.Config{
WithContext: func(ctx context.Context, _ fuse.Request) context.Context {
return f.WithContext(ctx)
},
})
f.fuse = srv
f.notifications.LaunchProcessor(ctx)
f.remoteStatus.Init(ctx, f.log, f.config, f)
// Blocks forever, unless an interrupt signal is received
// (handled by libkbfs.Init).
return srv.Serve(f)
} | go | func (f *FS) Serve(ctx context.Context) error {
srv := fs.New(f.conn, &fs.Config{
WithContext: func(ctx context.Context, _ fuse.Request) context.Context {
return f.WithContext(ctx)
},
})
f.fuse = srv
f.notifications.LaunchProcessor(ctx)
f.remoteStatus.Init(ctx, f.log, f.config, f)
// Blocks forever, unless an interrupt signal is received
// (handled by libkbfs.Init).
return srv.Serve(f)
} | [
"func",
"(",
"f",
"*",
"FS",
")",
"Serve",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"srv",
":=",
"fs",
".",
"New",
"(",
"f",
".",
"conn",
",",
"&",
"fs",
".",
"Config",
"{",
"WithContext",
":",
"func",
"(",
"ctx",
"context",
".... | // Serve FS. Will block. | [
"Serve",
"FS",
".",
"Will",
"block",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/fs.go#L332-L345 |
160,996 | keybase/client | go/kbfs/libfuse/fs.go | Statfs | func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
*resp = fuse.StatfsResponse{
Bsize: fuseBlockSize,
Namelen: ^uint32(0),
Frsize: fuseBlockSize,
}
if f.remoteStatus.ExtraFileName() != "" {
f.vlog.CLogf(
ctx, libkb.VLog1,
"Skipping quota usage check while errors are present")
return nil
}
if session, err := idutil.GetCurrentSessionIfPossible(
ctx, f.config.KBPKI(), true); err != nil {
return err
} else if session == (idutil.SessionInfo{}) {
// If user is not logged in, don't bother getting quota info. Otherwise
// reading a public TLF while logged out can fail on macOS.
return nil
}
_, usageBytes, _, limitBytes, err := f.quotaUsage.Get(
ctx, quotaUsageStaleTolerance/2, quotaUsageStaleTolerance)
if err != nil {
f.vlog.CLogf(ctx, libkb.VLog1, "Getting quota usage error: %v", err)
return err
}
total := getNumBlocksFromSize(uint64(limitBytes))
used := getNumBlocksFromSize(uint64(usageBytes))
resp.Blocks = total
resp.Bavail = total - used
resp.Bfree = total - used
return nil
} | go | func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
*resp = fuse.StatfsResponse{
Bsize: fuseBlockSize,
Namelen: ^uint32(0),
Frsize: fuseBlockSize,
}
if f.remoteStatus.ExtraFileName() != "" {
f.vlog.CLogf(
ctx, libkb.VLog1,
"Skipping quota usage check while errors are present")
return nil
}
if session, err := idutil.GetCurrentSessionIfPossible(
ctx, f.config.KBPKI(), true); err != nil {
return err
} else if session == (idutil.SessionInfo{}) {
// If user is not logged in, don't bother getting quota info. Otherwise
// reading a public TLF while logged out can fail on macOS.
return nil
}
_, usageBytes, _, limitBytes, err := f.quotaUsage.Get(
ctx, quotaUsageStaleTolerance/2, quotaUsageStaleTolerance)
if err != nil {
f.vlog.CLogf(ctx, libkb.VLog1, "Getting quota usage error: %v", err)
return err
}
total := getNumBlocksFromSize(uint64(limitBytes))
used := getNumBlocksFromSize(uint64(usageBytes))
resp.Blocks = total
resp.Bavail = total - used
resp.Bfree = total - used
return nil
} | [
"func",
"(",
"f",
"*",
"FS",
")",
"Statfs",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"StatfsRequest",
",",
"resp",
"*",
"fuse",
".",
"StatfsResponse",
")",
"error",
"{",
"*",
"resp",
"=",
"fuse",
".",
"StatfsResponse",
"{"... | // Statfs implements the fs.FSStatfser interface for FS. | [
"Statfs",
"implements",
"the",
"fs",
".",
"FSStatfser",
"interface",
"for",
"FS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/fs.go#L388-L424 |
160,997 | keybase/client | go/kbfs/libfuse/fs.go | Lookup | func (r *Root) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (_ fs.Node, err error) {
r.log().CDebugf(ctx, "FS Lookup %s", req.Name)
defer func() { err = r.private.fs.processError(ctx, libkbfs.ReadMode, err) }()
specialNode := handleNonTLFSpecialFile(
req.Name, r.private.fs, &resp.EntryValid)
if specialNode != nil {
return specialNode, nil
}
platformNode, err := r.platformLookup(ctx, req, resp)
if platformNode != nil || err != nil {
return platformNode, err
}
switch req.Name {
case PrivateName:
return r.private, nil
case PublicName:
return r.public, nil
}
if req.Name == TeamName {
return r.team, nil
}
// Don't want to pop up errors on special OS files.
if strings.HasPrefix(req.Name, ".") {
return nil, fuse.ENOENT
}
return nil, libkbfs.NoSuchFolderListError{
Name: req.Name,
PrivName: PrivateName,
PubName: PublicName,
}
} | go | func (r *Root) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (_ fs.Node, err error) {
r.log().CDebugf(ctx, "FS Lookup %s", req.Name)
defer func() { err = r.private.fs.processError(ctx, libkbfs.ReadMode, err) }()
specialNode := handleNonTLFSpecialFile(
req.Name, r.private.fs, &resp.EntryValid)
if specialNode != nil {
return specialNode, nil
}
platformNode, err := r.platformLookup(ctx, req, resp)
if platformNode != nil || err != nil {
return platformNode, err
}
switch req.Name {
case PrivateName:
return r.private, nil
case PublicName:
return r.public, nil
}
if req.Name == TeamName {
return r.team, nil
}
// Don't want to pop up errors on special OS files.
if strings.HasPrefix(req.Name, ".") {
return nil, fuse.ENOENT
}
return nil, libkbfs.NoSuchFolderListError{
Name: req.Name,
PrivName: PrivateName,
PubName: PublicName,
}
} | [
"func",
"(",
"r",
"*",
"Root",
")",
"Lookup",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"LookupRequest",
",",
"resp",
"*",
"fuse",
".",
"LookupResponse",
")",
"(",
"_",
"fs",
".",
"Node",
",",
"err",
"error",
")",
"{",
... | // Lookup implements the fs.NodeRequestLookuper interface for Root. | [
"Lookup",
"implements",
"the",
"fs",
".",
"NodeRequestLookuper",
"interface",
"for",
"Root",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/fs.go#L466-L502 |
160,998 | keybase/client | go/kbfs/libfuse/fs.go | Create | func (r *Root) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (_ fs.Node, _ fs.Handle, err error) {
r.log().CDebugf(ctx, "FS Create")
defer func() { err = r.private.fs.processError(ctx, libkbfs.WriteMode, err) }()
if strings.HasPrefix(req.Name, "._") {
// Quietly ignore writes to special macOS files, without
// triggering a notification.
return nil, nil, syscall.ENOENT
}
return nil, nil, libkbfs.NewWriteUnsupportedError(tlfhandle.BuildCanonicalPath(r.PathType(), req.Name))
} | go | func (r *Root) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (_ fs.Node, _ fs.Handle, err error) {
r.log().CDebugf(ctx, "FS Create")
defer func() { err = r.private.fs.processError(ctx, libkbfs.WriteMode, err) }()
if strings.HasPrefix(req.Name, "._") {
// Quietly ignore writes to special macOS files, without
// triggering a notification.
return nil, nil, syscall.ENOENT
}
return nil, nil, libkbfs.NewWriteUnsupportedError(tlfhandle.BuildCanonicalPath(r.PathType(), req.Name))
} | [
"func",
"(",
"r",
"*",
"Root",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"CreateRequest",
",",
"resp",
"*",
"fuse",
".",
"CreateResponse",
")",
"(",
"_",
"fs",
".",
"Node",
",",
"_",
"fs",
".",
"Handle",
... | // Create implements the fs.NodeCreater interface for Root. | [
"Create",
"implements",
"the",
"fs",
".",
"NodeCreater",
"interface",
"for",
"Root",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/fs.go#L512-L521 |
160,999 | keybase/client | go/kbfs/libfuse/fs.go | Mkdir | func (r *Root) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (_ fs.Node, err error) {
r.log().CDebugf(ctx, "FS Mkdir")
defer func() { err = r.private.fs.processError(ctx, libkbfs.WriteMode, err) }()
return nil, libkbfs.NewWriteUnsupportedError(tlfhandle.BuildCanonicalPath(r.PathType(), req.Name))
} | go | func (r *Root) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (_ fs.Node, err error) {
r.log().CDebugf(ctx, "FS Mkdir")
defer func() { err = r.private.fs.processError(ctx, libkbfs.WriteMode, err) }()
return nil, libkbfs.NewWriteUnsupportedError(tlfhandle.BuildCanonicalPath(r.PathType(), req.Name))
} | [
"func",
"(",
"r",
"*",
"Root",
")",
"Mkdir",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"MkdirRequest",
")",
"(",
"_",
"fs",
".",
"Node",
",",
"err",
"error",
")",
"{",
"r",
".",
"log",
"(",
")",
".",
"CDebugf",
"(",
... | // Mkdir implements the fs.NodeMkdirer interface for Root. | [
"Mkdir",
"implements",
"the",
"fs",
".",
"NodeMkdirer",
"interface",
"for",
"Root",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/fs.go#L524-L528 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.