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
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
161,100
keybase/client
go/libkb/assertion.go
MatchProof
func (a AssertionFingerprint) MatchProof(proof Proof) bool { v1, v2 := strings.ToLower(proof.Value), a.Value l1, l2 := len(v1), len(v2) if l2 > l1 { return false } // Match the suffixes of the fingerprint return (v1[(l1-l2):] == v2) }
go
func (a AssertionFingerprint) MatchProof(proof Proof) bool { v1, v2 := strings.ToLower(proof.Value), a.Value l1, l2 := len(v1), len(v2) if l2 > l1 { return false } // Match the suffixes of the fingerprint return (v1[(l1-l2):] == v2) }
[ "func", "(", "a", "AssertionFingerprint", ")", "MatchProof", "(", "proof", "Proof", ")", "bool", "{", "v1", ",", "v2", ":=", "strings", ".", "ToLower", "(", "proof", ".", "Value", ")", ",", "a", ".", "Value", "\n", "l1", ",", "l2", ":=", "len", "(", "v1", ")", ",", "len", "(", "v2", ")", "\n", "if", "l2", ">", "l1", "{", "return", "false", "\n", "}", "\n", "// Match the suffixes of the fingerprint", "return", "(", "v1", "[", "(", "l1", "-", "l2", ")", ":", "]", "==", "v2", ")", "\n", "}" ]
// Fingerprint matching is on the suffixes. If the assertion matches // any suffix of the proof, then we're OK
[ "Fingerprint", "matching", "is", "on", "the", "suffixes", ".", "If", "the", "assertion", "matches", "any", "suffix", "of", "the", "proof", "then", "we", "re", "OK" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/assertion.go#L280-L288
161,101
keybase/client
go/libkb/assertion.go
ParseImplicitTeamDisplayName
func ParseImplicitTeamDisplayName(ctx AssertionContext, s string, isPublic bool) (ret keybase1.ImplicitTeamDisplayName, err error) { // Turn the whole string tolower s = strings.ToLower(s) split1 := strings.SplitN(s, " ", 2) // split1: [assertions, ?conflict] split2 := strings.Split(split1[0], "#") // split2: [writers, ?readers] if len(split2) > 2 { return ret, NewImplicitTeamDisplayNameError("can have at most one '#' separator") } seen := make(map[string]bool) var readers, writers keybase1.ImplicitTeamUserSet writers, err = parseImplicitTeamUserSet(ctx, split2[0], seen) if err != nil { return ret, err } if writers.NumTotalUsers() == 0 { return ret, NewImplicitTeamDisplayNameError("need at least one writer") } if len(split2) == 2 { readers, err = parseImplicitTeamUserSet(ctx, split2[1], seen) if err != nil { return ret, err } } var conflictInfo *keybase1.ImplicitTeamConflictInfo if len(split1) > 1 { suffix := split1[1] if len(suffix) == 0 { return ret, NewImplicitTeamDisplayNameError("empty suffix") } conflictInfo, err = ParseImplicitTeamDisplayNameSuffix(suffix) if err != nil { return ret, err } } ret = keybase1.ImplicitTeamDisplayName{ IsPublic: isPublic, ConflictInfo: conflictInfo, Writers: writers, Readers: readers, } return ret, nil }
go
func ParseImplicitTeamDisplayName(ctx AssertionContext, s string, isPublic bool) (ret keybase1.ImplicitTeamDisplayName, err error) { // Turn the whole string tolower s = strings.ToLower(s) split1 := strings.SplitN(s, " ", 2) // split1: [assertions, ?conflict] split2 := strings.Split(split1[0], "#") // split2: [writers, ?readers] if len(split2) > 2 { return ret, NewImplicitTeamDisplayNameError("can have at most one '#' separator") } seen := make(map[string]bool) var readers, writers keybase1.ImplicitTeamUserSet writers, err = parseImplicitTeamUserSet(ctx, split2[0], seen) if err != nil { return ret, err } if writers.NumTotalUsers() == 0 { return ret, NewImplicitTeamDisplayNameError("need at least one writer") } if len(split2) == 2 { readers, err = parseImplicitTeamUserSet(ctx, split2[1], seen) if err != nil { return ret, err } } var conflictInfo *keybase1.ImplicitTeamConflictInfo if len(split1) > 1 { suffix := split1[1] if len(suffix) == 0 { return ret, NewImplicitTeamDisplayNameError("empty suffix") } conflictInfo, err = ParseImplicitTeamDisplayNameSuffix(suffix) if err != nil { return ret, err } } ret = keybase1.ImplicitTeamDisplayName{ IsPublic: isPublic, ConflictInfo: conflictInfo, Writers: writers, Readers: readers, } return ret, nil }
[ "func", "ParseImplicitTeamDisplayName", "(", "ctx", "AssertionContext", ",", "s", "string", ",", "isPublic", "bool", ")", "(", "ret", "keybase1", ".", "ImplicitTeamDisplayName", ",", "err", "error", ")", "{", "// Turn the whole string tolower", "s", "=", "strings", ".", "ToLower", "(", "s", ")", "\n\n", "split1", ":=", "strings", ".", "SplitN", "(", "s", ",", "\"", "\"", ",", "2", ")", "// split1: [assertions, ?conflict]", "\n", "split2", ":=", "strings", ".", "Split", "(", "split1", "[", "0", "]", ",", "\"", "\"", ")", "// split2: [writers, ?readers]", "\n", "if", "len", "(", "split2", ")", ">", "2", "{", "return", "ret", ",", "NewImplicitTeamDisplayNameError", "(", "\"", "\"", ")", "\n", "}", "\n\n", "seen", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "var", "readers", ",", "writers", "keybase1", ".", "ImplicitTeamUserSet", "\n", "writers", ",", "err", "=", "parseImplicitTeamUserSet", "(", "ctx", ",", "split2", "[", "0", "]", ",", "seen", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ret", ",", "err", "\n", "}", "\n\n", "if", "writers", ".", "NumTotalUsers", "(", ")", "==", "0", "{", "return", "ret", ",", "NewImplicitTeamDisplayNameError", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "split2", ")", "==", "2", "{", "readers", ",", "err", "=", "parseImplicitTeamUserSet", "(", "ctx", ",", "split2", "[", "1", "]", ",", "seen", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ret", ",", "err", "\n", "}", "\n", "}", "\n\n", "var", "conflictInfo", "*", "keybase1", ".", "ImplicitTeamConflictInfo", "\n", "if", "len", "(", "split1", ")", ">", "1", "{", "suffix", ":=", "split1", "[", "1", "]", "\n", "if", "len", "(", "suffix", ")", "==", "0", "{", "return", "ret", ",", "NewImplicitTeamDisplayNameError", "(", "\"", "\"", ")", "\n", "}", "\n", "conflictInfo", ",", "err", "=", "ParseImplicitTeamDisplayNameSuffix", "(", "suffix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ret", ",", "err", "\n", "}", "\n", "}", "\n\n", "ret", "=", "keybase1", ".", "ImplicitTeamDisplayName", "{", "IsPublic", ":", "isPublic", ",", "ConflictInfo", ":", "conflictInfo", ",", "Writers", ":", "writers", ",", "Readers", ":", "readers", ",", "}", "\n", "return", "ret", ",", "nil", "\n", "}" ]
// Parse a name like "mlsteele,malgorithms@twitter#bot (conflicted copy 2017-03-04 #2)"
[ "Parse", "a", "name", "like", "mlsteele", "malgorithms" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/assertion.go#L785-L832
161,102
keybase/client
go/kbfs/data/dir_entry.go
DirEntryMapToDirEntries
func DirEntryMapToDirEntries(entryMap map[string]DirEntry) DirEntries { dirEntries := make(DirEntries, 0, len(entryMap)) for name, entry := range entryMap { dirEntries = append(dirEntries, DirEntryWithName{entry, name}) } return dirEntries }
go
func DirEntryMapToDirEntries(entryMap map[string]DirEntry) DirEntries { dirEntries := make(DirEntries, 0, len(entryMap)) for name, entry := range entryMap { dirEntries = append(dirEntries, DirEntryWithName{entry, name}) } return dirEntries }
[ "func", "DirEntryMapToDirEntries", "(", "entryMap", "map", "[", "string", "]", "DirEntry", ")", "DirEntries", "{", "dirEntries", ":=", "make", "(", "DirEntries", ",", "0", ",", "len", "(", "entryMap", ")", ")", "\n", "for", "name", ",", "entry", ":=", "range", "entryMap", "{", "dirEntries", "=", "append", "(", "dirEntries", ",", "DirEntryWithName", "{", "entry", ",", "name", "}", ")", "\n", "}", "\n", "return", "dirEntries", "\n", "}" ]
// DirEntryMapToDirEntries returns a `DirEntries` slice of all the // entries in the given map.
[ "DirEntryMapToDirEntries", "returns", "a", "DirEntries", "slice", "of", "all", "the", "entries", "in", "the", "given", "map", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_entry.go#L52-L58
161,103
keybase/client
go/kbfs/libkbfs/journal_manager_util.go
GetJournalManager
func GetJournalManager(config Config) (*JournalManager, error) { bserver := config.BlockServer() jbserver, ok := bserver.(journalBlockServer) if !ok { return nil, errors.New("Write journal not enabled") } return jbserver.jManager, nil }
go
func GetJournalManager(config Config) (*JournalManager, error) { bserver := config.BlockServer() jbserver, ok := bserver.(journalBlockServer) if !ok { return nil, errors.New("Write journal not enabled") } return jbserver.jManager, nil }
[ "func", "GetJournalManager", "(", "config", "Config", ")", "(", "*", "JournalManager", ",", "error", ")", "{", "bserver", ":=", "config", ".", "BlockServer", "(", ")", "\n", "jbserver", ",", "ok", ":=", "bserver", ".", "(", "journalBlockServer", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "jbserver", ".", "jManager", ",", "nil", "\n", "}" ]
// GetJournalManager returns the JournalManager tied to a particular // config.
[ "GetJournalManager", "returns", "the", "JournalManager", "tied", "to", "a", "particular", "config", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/journal_manager_util.go#L20-L27
161,104
keybase/client
go/kbfs/libkbfs/journal_manager_util.go
TLFJournalEnabled
func TLFJournalEnabled(config Config, tlfID tlf.ID) bool { if jManager, err := GetJournalManager(config); err == nil { _, err := jManager.JournalStatus(tlfID) return err == nil } return false }
go
func TLFJournalEnabled(config Config, tlfID tlf.ID) bool { if jManager, err := GetJournalManager(config); err == nil { _, err := jManager.JournalStatus(tlfID) return err == nil } return false }
[ "func", "TLFJournalEnabled", "(", "config", "Config", ",", "tlfID", "tlf", ".", "ID", ")", "bool", "{", "if", "jManager", ",", "err", ":=", "GetJournalManager", "(", "config", ")", ";", "err", "==", "nil", "{", "_", ",", "err", ":=", "jManager", ".", "JournalStatus", "(", "tlfID", ")", "\n", "return", "err", "==", "nil", "\n", "}", "\n", "return", "false", "\n", "}" ]
// TLFJournalEnabled returns true if journaling is enabled for the // given TLF.
[ "TLFJournalEnabled", "returns", "true", "if", "journaling", "is", "enabled", "for", "the", "given", "TLF", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/journal_manager_util.go#L31-L37
161,105
keybase/client
go/kbfs/libkbfs/journal_manager_util.go
WaitForTLFJournal
func WaitForTLFJournal(ctx context.Context, config Config, tlfID tlf.ID, log logger.Logger) error { if jManager, err := GetJournalManager(config); err == nil { log.CDebugf(ctx, "Waiting for journal to flush") if err := jManager.Wait(ctx, tlfID); err != nil { return err } } return nil }
go
func WaitForTLFJournal(ctx context.Context, config Config, tlfID tlf.ID, log logger.Logger) error { if jManager, err := GetJournalManager(config); err == nil { log.CDebugf(ctx, "Waiting for journal to flush") if err := jManager.Wait(ctx, tlfID); err != nil { return err } } return nil }
[ "func", "WaitForTLFJournal", "(", "ctx", "context", ".", "Context", ",", "config", "Config", ",", "tlfID", "tlf", ".", "ID", ",", "log", "logger", ".", "Logger", ")", "error", "{", "if", "jManager", ",", "err", ":=", "GetJournalManager", "(", "config", ")", ";", "err", "==", "nil", "{", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ")", "\n", "if", "err", ":=", "jManager", ".", "Wait", "(", "ctx", ",", "tlfID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// WaitForTLFJournal waits for the corresponding journal to flush, if // one exists.
[ "WaitForTLFJournal", "waits", "for", "the", "corresponding", "journal", "to", "flush", "if", "one", "exists", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/journal_manager_util.go#L41-L50
161,106
keybase/client
go/protocol/keybase1/account.go
PassphraseChange
func (c AccountClient) PassphraseChange(ctx context.Context, __arg PassphraseChangeArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.account.passphraseChange", []interface{}{__arg}, nil) return }
go
func (c AccountClient) PassphraseChange(ctx context.Context, __arg PassphraseChangeArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.account.passphraseChange", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "AccountClient", ")", "PassphraseChange", "(", "ctx", "context", ".", "Context", ",", "__arg", "PassphraseChangeArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "nil", ")", "\n", "return", "\n", "}" ]
// Change the passphrase from old to new. If old isn't set, and force is false, // then prompt at the UI for it. If old isn't set and force is true, then // we'll try to force a passphrase change.
[ "Change", "the", "passphrase", "from", "old", "to", "new", ".", "If", "old", "isn", "t", "set", "and", "force", "is", "false", "then", "prompt", "at", "the", "UI", "for", "it", ".", "If", "old", "isn", "t", "set", "and", "force", "is", "true", "then", "we", "ll", "try", "to", "force", "a", "passphrase", "change", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/account.go#L365-L368
161,107
keybase/client
go/protocol/keybase1/account.go
ResetAccount
func (c AccountClient) ResetAccount(ctx context.Context, __arg ResetAccountArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.account.resetAccount", []interface{}{__arg}, nil) return }
go
func (c AccountClient) ResetAccount(ctx context.Context, __arg ResetAccountArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.account.resetAccount", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "AccountClient", ")", "ResetAccount", "(", "ctx", "context", ".", "Context", ",", "__arg", "ResetAccountArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "nil", ")", "\n", "return", "\n", "}" ]
// resetAccount resets the user's account; it's meant only for devel and tests. // passphrase is optional and will be prompted for if not supplied.
[ "resetAccount", "resets", "the", "user", "s", "account", ";", "it", "s", "meant", "only", "for", "devel", "and", "tests", ".", "passphrase", "is", "optional", "and", "will", "be", "prompted", "for", "if", "not", "supplied", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/account.go#L399-L402
161,108
keybase/client
go/protocol/keybase1/account.go
EnterResetPipeline
func (c AccountClient) EnterResetPipeline(ctx context.Context, __arg EnterResetPipelineArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.account.enterResetPipeline", []interface{}{__arg}, nil) return }
go
func (c AccountClient) EnterResetPipeline(ctx context.Context, __arg EnterResetPipelineArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.account.enterResetPipeline", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "AccountClient", ")", "EnterResetPipeline", "(", "ctx", "context", ".", "Context", ",", "__arg", "EnterResetPipelineArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "nil", ")", "\n", "return", "\n", "}" ]
// Start reset process for the user based on their username or email. If // neither are known the user will be prompted for their passphrase to start // the process.
[ "Start", "reset", "process", "for", "the", "user", "based", "on", "their", "username", "or", "email", ".", "If", "neither", "are", "known", "the", "user", "will", "be", "prompted", "for", "their", "passphrase", "to", "start", "the", "process", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/account.go#L428-L431
161,109
keybase/client
go/protocol/keybase1/account.go
CancelReset
func (c AccountClient) CancelReset(ctx context.Context, sessionID int) (err error) { __arg := CancelResetArg{SessionID: sessionID} err = c.Cli.Call(ctx, "keybase.1.account.cancelReset", []interface{}{__arg}, nil) return }
go
func (c AccountClient) CancelReset(ctx context.Context, sessionID int) (err error) { __arg := CancelResetArg{SessionID: sessionID} err = c.Cli.Call(ctx, "keybase.1.account.cancelReset", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "AccountClient", ")", "CancelReset", "(", "ctx", "context", ".", "Context", ",", "sessionID", "int", ")", "(", "err", "error", ")", "{", "__arg", ":=", "CancelResetArg", "{", "SessionID", ":", "sessionID", "}", "\n", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "nil", ")", "\n", "return", "\n", "}" ]
// Aborts the reset process
[ "Aborts", "the", "reset", "process" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/account.go#L434-L438
161,110
keybase/client
go/pvl/registers.go
Ban
func (r *namedRegsStore) Ban(key string) libkb.ProofError { err := r.validateKey(key) if err != nil { return err } _, banned := r.banned[key] if banned { return libkb.NewProofError(keybase1.ProofStatus_INVALID_PVL, "cannot ban already banned register '%v'", key) } _, set := r.m[key] if set { return libkb.NewProofError(keybase1.ProofStatus_INVALID_PVL, "cannot ban already set register '%v'", key) } r.banned[key] = true return nil }
go
func (r *namedRegsStore) Ban(key string) libkb.ProofError { err := r.validateKey(key) if err != nil { return err } _, banned := r.banned[key] if banned { return libkb.NewProofError(keybase1.ProofStatus_INVALID_PVL, "cannot ban already banned register '%v'", key) } _, set := r.m[key] if set { return libkb.NewProofError(keybase1.ProofStatus_INVALID_PVL, "cannot ban already set register '%v'", key) } r.banned[key] = true return nil }
[ "func", "(", "r", "*", "namedRegsStore", ")", "Ban", "(", "key", "string", ")", "libkb", ".", "ProofError", "{", "err", ":=", "r", ".", "validateKey", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "banned", ":=", "r", ".", "banned", "[", "key", "]", "\n", "if", "banned", "{", "return", "libkb", ".", "NewProofError", "(", "keybase1", ".", "ProofStatus_INVALID_PVL", ",", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "_", ",", "set", ":=", "r", ".", "m", "[", "key", "]", "\n", "if", "set", "{", "return", "libkb", ".", "NewProofError", "(", "keybase1", ".", "ProofStatus_INVALID_PVL", ",", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "r", ".", "banned", "[", "key", "]", "=", "true", "\n", "return", "nil", "\n", "}" ]
// Mark a register as unuseable
[ "Mark", "a", "register", "as", "unuseable" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/registers.go#L62-L77
161,111
keybase/client
go/pvl/registers.go
validateKey
func (r *namedRegsStore) validateKey(key string) libkb.ProofError { if !keyRE.MatchString(key) { return libkb.NewProofError(keybase1.ProofStatus_INVALID_PVL, "invalid register name '%v'", key) } return nil }
go
func (r *namedRegsStore) validateKey(key string) libkb.ProofError { if !keyRE.MatchString(key) { return libkb.NewProofError(keybase1.ProofStatus_INVALID_PVL, "invalid register name '%v'", key) } return nil }
[ "func", "(", "r", "*", "namedRegsStore", ")", "validateKey", "(", "key", "string", ")", "libkb", ".", "ProofError", "{", "if", "!", "keyRE", ".", "MatchString", "(", "key", ")", "{", "return", "libkb", ".", "NewProofError", "(", "keybase1", ".", "ProofStatus_INVALID_PVL", ",", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Make sure a key is a simple snake case name. // Does not check whether it's banned.
[ "Make", "sure", "a", "key", "is", "a", "simple", "snake", "case", "name", ".", "Does", "not", "check", "whether", "it", "s", "banned", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/registers.go#L83-L88
161,112
keybase/client
go/client/simplefs_ls.go
Mode
func (d DirentFileInfo) Mode() os.FileMode { switch d.Entry.DirentType { case keybase1.DirentType_FILE: return 0664 case keybase1.DirentType_DIR: return os.ModeDir | 0664 case keybase1.DirentType_SYM: return os.ModeSymlink | 0664 case keybase1.DirentType_EXEC: return 0773 } return 0 }
go
func (d DirentFileInfo) Mode() os.FileMode { switch d.Entry.DirentType { case keybase1.DirentType_FILE: return 0664 case keybase1.DirentType_DIR: return os.ModeDir | 0664 case keybase1.DirentType_SYM: return os.ModeSymlink | 0664 case keybase1.DirentType_EXEC: return 0773 } return 0 }
[ "func", "(", "d", "DirentFileInfo", ")", "Mode", "(", ")", "os", ".", "FileMode", "{", "switch", "d", ".", "Entry", ".", "DirentType", "{", "case", "keybase1", ".", "DirentType_FILE", ":", "return", "0664", "\n", "case", "keybase1", ".", "DirentType_DIR", ":", "return", "os", ".", "ModeDir", "|", "0664", "\n", "case", "keybase1", ".", "DirentType_SYM", ":", "return", "os", ".", "ModeSymlink", "|", "0664", "\n", "case", "keybase1", ".", "DirentType_EXEC", ":", "return", "0773", "\n", "}", "\n", "return", "0", "\n", "}" ]
// Mode returns the file mode bits
[ "Mode", "returns", "the", "file", "mode", "bits" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/simplefs_ls.go#L68-L80
161,113
keybase/client
go/client/simplefs_ls.go
ModTime
func (d DirentFileInfo) ModTime() time.Time { return time.Unix(int64(d.Entry.Time/1000), int64(d.Entry.Time%1000)*1000000) }
go
func (d DirentFileInfo) ModTime() time.Time { return time.Unix(int64(d.Entry.Time/1000), int64(d.Entry.Time%1000)*1000000) }
[ "func", "(", "d", "DirentFileInfo", ")", "ModTime", "(", ")", "time", ".", "Time", "{", "return", "time", ".", "Unix", "(", "int64", "(", "d", ".", "Entry", ".", "Time", "/", "1000", ")", ",", "int64", "(", "d", ".", "Entry", ".", "Time", "%", "1000", ")", "*", "1000000", ")", "\n", "}" ]
// ModTime returns modification time
[ "ModTime", "returns", "modification", "time" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/simplefs_ls.go#L83-L85
161,114
keybase/client
go/client/simplefs_ls.go
parseLsColors
func parseLsColors(lsColors string) { for i := 0; i < len(lsColors); i += 2 { if i == 0 { colorMap["directory"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 2 { colorMap["symlink"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 4 { colorMap["socket"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 6 { colorMap["pipe"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 8 { colorMap["executable"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 10 { colorMap["block"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 12 { colorMap["character"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 14 { colorMap["executable_suid"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 16 { colorMap["executable_sgid"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 18 { colorMap["directory_o+w_sticky"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 20 { colorMap["directory_o+w"] = getColorFromBsdCode(lsColors[i : i+2]) } } }
go
func parseLsColors(lsColors string) { for i := 0; i < len(lsColors); i += 2 { if i == 0 { colorMap["directory"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 2 { colorMap["symlink"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 4 { colorMap["socket"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 6 { colorMap["pipe"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 8 { colorMap["executable"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 10 { colorMap["block"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 12 { colorMap["character"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 14 { colorMap["executable_suid"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 16 { colorMap["executable_sgid"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 18 { colorMap["directory_o+w_sticky"] = getColorFromBsdCode(lsColors[i : i+2]) } else if i == 20 { colorMap["directory_o+w"] = getColorFromBsdCode(lsColors[i : i+2]) } } }
[ "func", "parseLsColors", "(", "lsColors", "string", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "lsColors", ")", ";", "i", "+=", "2", "{", "if", "i", "==", "0", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "2", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "4", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "6", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "8", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "10", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "12", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "14", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "16", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "18", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "else", "if", "i", "==", "20", "{", "colorMap", "[", "\"", "\"", "]", "=", "getColorFromBsdCode", "(", "lsColors", "[", "i", ":", "i", "+", "2", "]", ")", "\n", "}", "\n", "}", "\n", "}" ]
// Given an LSCOLORS string, fill in the appropriate keys and values of the // global colorMap.
[ "Given", "an", "LSCOLORS", "string", "fill", "in", "the", "appropriate", "keys", "and", "values", "of", "the", "global", "colorMap", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/simplefs_ls.go#L230-L267
161,115
keybase/client
go/client/simplefs_ls.go
lessByName
func (listings Listings) lessByName(i, j int) bool { a := listings[i] b := listings[j] aNameLower := strings.ToLower(a.name) bNameLower := strings.ToLower(b.name) if aNameLower != bNameLower { return aNameLower < bNameLower } // If capitalization is the only thing different between the // words, put lower-case first. return a.name >= b.name }
go
func (listings Listings) lessByName(i, j int) bool { a := listings[i] b := listings[j] aNameLower := strings.ToLower(a.name) bNameLower := strings.ToLower(b.name) if aNameLower != bNameLower { return aNameLower < bNameLower } // If capitalization is the only thing different between the // words, put lower-case first. return a.name >= b.name }
[ "func", "(", "listings", "Listings", ")", "lessByName", "(", "i", ",", "j", "int", ")", "bool", "{", "a", ":=", "listings", "[", "i", "]", "\n", "b", ":=", "listings", "[", "j", "]", "\n", "aNameLower", ":=", "strings", ".", "ToLower", "(", "a", ".", "name", ")", "\n", "bNameLower", ":=", "strings", ".", "ToLower", "(", "b", ".", "name", ")", "\n\n", "if", "aNameLower", "!=", "bNameLower", "{", "return", "aNameLower", "<", "bNameLower", "\n", "}", "\n", "// If capitalization is the only thing different between the", "// words, put lower-case first.", "return", "a", ".", "name", ">=", "b", ".", "name", "\n", "}" ]
// Comparison function used for sorting Listings by name.
[ "Comparison", "function", "used", "for", "sorting", "Listings", "by", "name", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/simplefs_ls.go#L498-L510
161,116
keybase/client
go/client/simplefs_ls.go
lessByTime
func (listings Listings) lessByTime(i, j int) bool { a := listings[i] b := listings[j] return a.epochNano >= b.epochNano }
go
func (listings Listings) lessByTime(i, j int) bool { a := listings[i] b := listings[j] return a.epochNano >= b.epochNano }
[ "func", "(", "listings", "Listings", ")", "lessByTime", "(", "i", ",", "j", "int", ")", "bool", "{", "a", ":=", "listings", "[", "i", "]", "\n", "b", ":=", "listings", "[", "j", "]", "\n", "return", "a", ".", "epochNano", ">=", "b", ".", "epochNano", "\n", "}" ]
// Comparison function used for sorting Listings by modification time, from most // recent to oldest.
[ "Comparison", "function", "used", "for", "sorting", "Listings", "by", "modification", "time", "from", "most", "recent", "to", "oldest", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/simplefs_ls.go#L514-L518
161,117
keybase/client
go/client/simplefs_ls.go
lessBySize
func (listings Listings) lessBySize(i, j int) bool { a := listings[i] b := listings[j] aSize, _ := strconv.Atoi(a.size) bSize, _ := strconv.Atoi(b.size) return aSize >= bSize }
go
func (listings Listings) lessBySize(i, j int) bool { a := listings[i] b := listings[j] aSize, _ := strconv.Atoi(a.size) bSize, _ := strconv.Atoi(b.size) return aSize >= bSize }
[ "func", "(", "listings", "Listings", ")", "lessBySize", "(", "i", ",", "j", "int", ")", "bool", "{", "a", ":=", "listings", "[", "i", "]", "\n", "b", ":=", "listings", "[", "j", "]", "\n", "aSize", ",", "_", ":=", "strconv", ".", "Atoi", "(", "a", ".", "size", ")", "\n", "bSize", ",", "_", ":=", "strconv", ".", "Atoi", "(", "b", ".", "size", ")", "\n", "return", "aSize", ">=", "bSize", "\n", "}" ]
// Comparison function used for sorting Listings by size, from largest to // smallest.
[ "Comparison", "function", "used", "for", "sorting", "Listings", "by", "size", "from", "largest", "to", "smallest", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/simplefs_ls.go#L522-L528
161,118
keybase/client
go/client/simplefs_ls.go
sortListings
func sortListings(listings Listings, options ListOptions) { comparisonFunction := listings.lessByName if options.sortTime { comparisonFunction = listings.lessByTime } else if options.sortSize { comparisonFunction = listings.lessBySize } sort.Slice(listings, comparisonFunction) if options.sortReverse { middleIndex := (len(listings) / 2) if len(listings)%2 == 0 { middleIndex-- } for i := 0; i <= middleIndex; i++ { frontIndex := i rearIndex := len(listings) - 1 - i if frontIndex == rearIndex { break } tmp := listings[frontIndex] listings[frontIndex] = listings[rearIndex] listings[rearIndex] = tmp } } }
go
func sortListings(listings Listings, options ListOptions) { comparisonFunction := listings.lessByName if options.sortTime { comparisonFunction = listings.lessByTime } else if options.sortSize { comparisonFunction = listings.lessBySize } sort.Slice(listings, comparisonFunction) if options.sortReverse { middleIndex := (len(listings) / 2) if len(listings)%2 == 0 { middleIndex-- } for i := 0; i <= middleIndex; i++ { frontIndex := i rearIndex := len(listings) - 1 - i if frontIndex == rearIndex { break } tmp := listings[frontIndex] listings[frontIndex] = listings[rearIndex] listings[rearIndex] = tmp } } }
[ "func", "sortListings", "(", "listings", "Listings", ",", "options", "ListOptions", ")", "{", "comparisonFunction", ":=", "listings", ".", "lessByName", "\n", "if", "options", ".", "sortTime", "{", "comparisonFunction", "=", "listings", ".", "lessByTime", "\n", "}", "else", "if", "options", ".", "sortSize", "{", "comparisonFunction", "=", "listings", ".", "lessBySize", "\n", "}", "\n\n", "sort", ".", "Slice", "(", "listings", ",", "comparisonFunction", ")", "\n\n", "if", "options", ".", "sortReverse", "{", "middleIndex", ":=", "(", "len", "(", "listings", ")", "/", "2", ")", "\n", "if", "len", "(", "listings", ")", "%", "2", "==", "0", "{", "middleIndex", "--", "\n", "}", "\n\n", "for", "i", ":=", "0", ";", "i", "<=", "middleIndex", ";", "i", "++", "{", "frontIndex", ":=", "i", "\n", "rearIndex", ":=", "len", "(", "listings", ")", "-", "1", "-", "i", "\n\n", "if", "frontIndex", "==", "rearIndex", "{", "break", "\n", "}", "\n\n", "tmp", ":=", "listings", "[", "frontIndex", "]", "\n", "listings", "[", "frontIndex", "]", "=", "listings", "[", "rearIndex", "]", "\n", "listings", "[", "rearIndex", "]", "=", "tmp", "\n", "}", "\n", "}", "\n", "}" ]
// Sort the given listings, taking into account the current program options.
[ "Sort", "the", "given", "listings", "taking", "into", "account", "the", "current", "program", "options", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/simplefs_ls.go#L531-L560
161,119
keybase/client
go/kbfs/kbfscrypto/signature.go
IsNil
func (s SignatureInfo) IsNil() bool { return s.Version.IsNil() && len(s.Signature) == 0 && s.VerifyingKey.IsNil() }
go
func (s SignatureInfo) IsNil() bool { return s.Version.IsNil() && len(s.Signature) == 0 && s.VerifyingKey.IsNil() }
[ "func", "(", "s", "SignatureInfo", ")", "IsNil", "(", ")", "bool", "{", "return", "s", ".", "Version", ".", "IsNil", "(", ")", "&&", "len", "(", "s", ".", "Signature", ")", "==", "0", "&&", "s", ".", "VerifyingKey", ".", "IsNil", "(", ")", "\n", "}" ]
// IsNil returns true if this SignatureInfo is nil.
[ "IsNil", "returns", "true", "if", "this", "SignatureInfo", "is", "nil", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L47-L49
161,120
keybase/client
go/kbfs/kbfscrypto/signature.go
Equals
func (s SignatureInfo) Equals(other SignatureInfo) bool { if s.Version != other.Version { return false } if !bytes.Equal(s.Signature, other.Signature) { return false } if s.VerifyingKey != other.VerifyingKey { return false } return true }
go
func (s SignatureInfo) Equals(other SignatureInfo) bool { if s.Version != other.Version { return false } if !bytes.Equal(s.Signature, other.Signature) { return false } if s.VerifyingKey != other.VerifyingKey { return false } return true }
[ "func", "(", "s", "SignatureInfo", ")", "Equals", "(", "other", "SignatureInfo", ")", "bool", "{", "if", "s", ".", "Version", "!=", "other", ".", "Version", "{", "return", "false", "\n", "}", "\n", "if", "!", "bytes", ".", "Equal", "(", "s", ".", "Signature", ",", "other", ".", "Signature", ")", "{", "return", "false", "\n", "}", "\n", "if", "s", ".", "VerifyingKey", "!=", "other", ".", "VerifyingKey", "{", "return", "false", "\n", "}", "\n\n", "return", "true", "\n", "}" ]
// Equals returns true if this SignatureInfo matches the given one.
[ "Equals", "returns", "true", "if", "this", "SignatureInfo", "matches", "the", "given", "one", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L52-L64
161,121
keybase/client
go/kbfs/kbfscrypto/signature.go
DeepCopy
func (s SignatureInfo) DeepCopy() SignatureInfo { signature := make([]byte, len(s.Signature)) copy(signature[:], s.Signature[:]) return SignatureInfo{s.Version, signature, s.VerifyingKey} }
go
func (s SignatureInfo) DeepCopy() SignatureInfo { signature := make([]byte, len(s.Signature)) copy(signature[:], s.Signature[:]) return SignatureInfo{s.Version, signature, s.VerifyingKey} }
[ "func", "(", "s", "SignatureInfo", ")", "DeepCopy", "(", ")", "SignatureInfo", "{", "signature", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "s", ".", "Signature", ")", ")", "\n", "copy", "(", "signature", "[", ":", "]", ",", "s", ".", "Signature", "[", ":", "]", ")", "\n", "return", "SignatureInfo", "{", "s", ".", "Version", ",", "signature", ",", "s", ".", "VerifyingKey", "}", "\n", "}" ]
// DeepCopy makes a complete copy of this SignatureInfo.
[ "DeepCopy", "makes", "a", "complete", "copy", "of", "this", "SignatureInfo", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L67-L71
161,122
keybase/client
go/kbfs/kbfscrypto/signature.go
String
func (s SignatureInfo) String() string { return fmt.Sprintf("SignatureInfo{Version: %d, Signature: %s, "+ "VerifyingKey: %s}", s.Version, hex.EncodeToString(s.Signature[:]), &s.VerifyingKey) }
go
func (s SignatureInfo) String() string { return fmt.Sprintf("SignatureInfo{Version: %d, Signature: %s, "+ "VerifyingKey: %s}", s.Version, hex.EncodeToString(s.Signature[:]), &s.VerifyingKey) }
[ "func", "(", "s", "SignatureInfo", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", ",", "s", ".", "Version", ",", "hex", ".", "EncodeToString", "(", "s", ".", "Signature", "[", ":", "]", ")", ",", "&", "s", ".", "VerifyingKey", ")", "\n", "}" ]
// String implements the fmt.Stringer interface for SignatureInfo.
[ "String", "implements", "the", "fmt", ".", "Stringer", "interface", "for", "SignatureInfo", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L74-L78
161,123
keybase/client
go/kbfs/kbfscrypto/signature.go
Sign
func (k SigningKey) Sign(data []byte) SignatureInfo { sig := k.kp.Private.Sign(data) return SignatureInfo{ Version: SigED25519, Signature: sig[:], VerifyingKey: k.GetVerifyingKey(), } }
go
func (k SigningKey) Sign(data []byte) SignatureInfo { sig := k.kp.Private.Sign(data) return SignatureInfo{ Version: SigED25519, Signature: sig[:], VerifyingKey: k.GetVerifyingKey(), } }
[ "func", "(", "k", "SigningKey", ")", "Sign", "(", "data", "[", "]", "byte", ")", "SignatureInfo", "{", "sig", ":=", "k", ".", "kp", ".", "Private", ".", "Sign", "(", "data", ")", "\n", "return", "SignatureInfo", "{", "Version", ":", "SigED25519", ",", "Signature", ":", "sig", "[", ":", "]", ",", "VerifyingKey", ":", "k", ".", "GetVerifyingKey", "(", ")", ",", "}", "\n", "}" ]
// Sign signs the given data and returns a SignatureInfo.
[ "Sign", "signs", "the", "given", "data", "and", "returns", "a", "SignatureInfo", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L91-L98
161,124
keybase/client
go/kbfs/kbfscrypto/signature.go
SignForKBFS
func (k SigningKey) SignForKBFS(data []byte) (SignatureInfo, error) { sigInfo, err := k.kp.SignV2(data, kbcrypto.SignaturePrefixKBFS) if err != nil { return SignatureInfo{}, errors.WithStack(err) } return SignatureInfo{ Version: SigVer(sigInfo.Version), Signature: sigInfo.Sig[:], VerifyingKey: k.GetVerifyingKey(), }, nil }
go
func (k SigningKey) SignForKBFS(data []byte) (SignatureInfo, error) { sigInfo, err := k.kp.SignV2(data, kbcrypto.SignaturePrefixKBFS) if err != nil { return SignatureInfo{}, errors.WithStack(err) } return SignatureInfo{ Version: SigVer(sigInfo.Version), Signature: sigInfo.Sig[:], VerifyingKey: k.GetVerifyingKey(), }, nil }
[ "func", "(", "k", "SigningKey", ")", "SignForKBFS", "(", "data", "[", "]", "byte", ")", "(", "SignatureInfo", ",", "error", ")", "{", "sigInfo", ",", "err", ":=", "k", ".", "kp", ".", "SignV2", "(", "data", ",", "kbcrypto", ".", "SignaturePrefixKBFS", ")", "\n", "if", "err", "!=", "nil", "{", "return", "SignatureInfo", "{", "}", ",", "errors", ".", "WithStack", "(", "err", ")", "\n", "}", "\n", "return", "SignatureInfo", "{", "Version", ":", "SigVer", "(", "sigInfo", ".", "Version", ")", ",", "Signature", ":", "sigInfo", ".", "Sig", "[", ":", "]", ",", "VerifyingKey", ":", "k", ".", "GetVerifyingKey", "(", ")", ",", "}", ",", "nil", "\n", "}" ]
// SignForKBFS signs the given data with the KBFS prefix and returns a SignatureInfo.
[ "SignForKBFS", "signs", "the", "given", "data", "with", "the", "KBFS", "prefix", "and", "returns", "a", "SignatureInfo", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L101-L111
161,125
keybase/client
go/kbfs/kbfscrypto/signature.go
SignToString
func (k SigningKey) SignToString(data []byte) (sig string, err error) { sig, _, err = k.kp.SignToString(data) if err != nil { return "", errors.WithStack(err) } return sig, nil }
go
func (k SigningKey) SignToString(data []byte) (sig string, err error) { sig, _, err = k.kp.SignToString(data) if err != nil { return "", errors.WithStack(err) } return sig, nil }
[ "func", "(", "k", "SigningKey", ")", "SignToString", "(", "data", "[", "]", "byte", ")", "(", "sig", "string", ",", "err", "error", ")", "{", "sig", ",", "_", ",", "err", "=", "k", ".", "kp", ".", "SignToString", "(", "data", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "WithStack", "(", "err", ")", "\n", "}", "\n", "return", "sig", ",", "nil", "\n", "}" ]
// SignToString signs the given data and returns a string.
[ "SignToString", "signs", "the", "given", "data", "and", "returns", "a", "string", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L114-L120
161,126
keybase/client
go/kbfs/kbfscrypto/signature.go
Verify
func Verify(msg []byte, sigInfo SignatureInfo) error { if sigInfo.Version < SigED25519 || sigInfo.Version > SigED25519ForKBFS { return errors.WithStack(UnknownSigVer{sigInfo.Version}) } publicKey := kbcrypto.KIDToNaclSigningKeyPublic( sigInfo.VerifyingKey.KID().ToBytes()) if publicKey == nil { return errors.WithStack(libkb.KeyCannotVerifyError{}) } var naclSignature kbcrypto.NaclSignature if len(sigInfo.Signature) != len(naclSignature) { return errors.WithStack(kbcrypto.VerificationError{}) } copy(naclSignature[:], sigInfo.Signature) if sigInfo.Version == SigED25519ForKBFS { msg = kbcrypto.SignaturePrefixKBFS.Prefix(msg) } if !publicKey.Verify(msg, naclSignature) { return errors.WithStack(kbcrypto.VerificationError{}) } return nil }
go
func Verify(msg []byte, sigInfo SignatureInfo) error { if sigInfo.Version < SigED25519 || sigInfo.Version > SigED25519ForKBFS { return errors.WithStack(UnknownSigVer{sigInfo.Version}) } publicKey := kbcrypto.KIDToNaclSigningKeyPublic( sigInfo.VerifyingKey.KID().ToBytes()) if publicKey == nil { return errors.WithStack(libkb.KeyCannotVerifyError{}) } var naclSignature kbcrypto.NaclSignature if len(sigInfo.Signature) != len(naclSignature) { return errors.WithStack(kbcrypto.VerificationError{}) } copy(naclSignature[:], sigInfo.Signature) if sigInfo.Version == SigED25519ForKBFS { msg = kbcrypto.SignaturePrefixKBFS.Prefix(msg) } if !publicKey.Verify(msg, naclSignature) { return errors.WithStack(kbcrypto.VerificationError{}) } return nil }
[ "func", "Verify", "(", "msg", "[", "]", "byte", ",", "sigInfo", "SignatureInfo", ")", "error", "{", "if", "sigInfo", ".", "Version", "<", "SigED25519", "||", "sigInfo", ".", "Version", ">", "SigED25519ForKBFS", "{", "return", "errors", ".", "WithStack", "(", "UnknownSigVer", "{", "sigInfo", ".", "Version", "}", ")", "\n", "}", "\n\n", "publicKey", ":=", "kbcrypto", ".", "KIDToNaclSigningKeyPublic", "(", "sigInfo", ".", "VerifyingKey", ".", "KID", "(", ")", ".", "ToBytes", "(", ")", ")", "\n", "if", "publicKey", "==", "nil", "{", "return", "errors", ".", "WithStack", "(", "libkb", ".", "KeyCannotVerifyError", "{", "}", ")", "\n", "}", "\n\n", "var", "naclSignature", "kbcrypto", ".", "NaclSignature", "\n", "if", "len", "(", "sigInfo", ".", "Signature", ")", "!=", "len", "(", "naclSignature", ")", "{", "return", "errors", ".", "WithStack", "(", "kbcrypto", ".", "VerificationError", "{", "}", ")", "\n", "}", "\n", "copy", "(", "naclSignature", "[", ":", "]", ",", "sigInfo", ".", "Signature", ")", "\n\n", "if", "sigInfo", ".", "Version", "==", "SigED25519ForKBFS", "{", "msg", "=", "kbcrypto", ".", "SignaturePrefixKBFS", ".", "Prefix", "(", "msg", ")", "\n", "}", "\n\n", "if", "!", "publicKey", ".", "Verify", "(", "msg", ",", "naclSignature", ")", "{", "return", "errors", ".", "WithStack", "(", "kbcrypto", ".", "VerificationError", "{", "}", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Verify verifies the given message against the given SignatureInfo, // and returns nil if it verifies successfully, or an error otherwise.
[ "Verify", "verifies", "the", "given", "message", "against", "the", "given", "SignatureInfo", "and", "returns", "nil", "if", "it", "verifies", "successfully", "or", "an", "error", "otherwise", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L160-L186
161,127
keybase/client
go/kbfs/kbfscrypto/signature.go
Sign
func (s SigningKeySigner) Sign( ctx context.Context, data []byte) (SignatureInfo, error) { return s.Key.Sign(data), nil }
go
func (s SigningKeySigner) Sign( ctx context.Context, data []byte) (SignatureInfo, error) { return s.Key.Sign(data), nil }
[ "func", "(", "s", "SigningKeySigner", ")", "Sign", "(", "ctx", "context", ".", "Context", ",", "data", "[", "]", "byte", ")", "(", "SignatureInfo", ",", "error", ")", "{", "return", "s", ".", "Key", ".", "Sign", "(", "data", ")", ",", "nil", "\n", "}" ]
// Sign implements Signer for SigningKeySigner.
[ "Sign", "implements", "Signer", "for", "SigningKeySigner", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L205-L208
161,128
keybase/client
go/kbfs/kbfscrypto/signature.go
SignForKBFS
func (s SigningKeySigner) SignForKBFS( ctx context.Context, data []byte) (SignatureInfo, error) { return s.Key.SignForKBFS(data) }
go
func (s SigningKeySigner) SignForKBFS( ctx context.Context, data []byte) (SignatureInfo, error) { return s.Key.SignForKBFS(data) }
[ "func", "(", "s", "SigningKeySigner", ")", "SignForKBFS", "(", "ctx", "context", ".", "Context", ",", "data", "[", "]", "byte", ")", "(", "SignatureInfo", ",", "error", ")", "{", "return", "s", ".", "Key", ".", "SignForKBFS", "(", "data", ")", "\n", "}" ]
// SignForKBFS implements Signer for SigningKeySigner.
[ "SignForKBFS", "implements", "Signer", "for", "SigningKeySigner", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L211-L214
161,129
keybase/client
go/kbfs/kbfscrypto/signature.go
SignToString
func (s SigningKeySigner) SignToString( ctx context.Context, data []byte) (sig string, err error) { return s.Key.SignToString(data) }
go
func (s SigningKeySigner) SignToString( ctx context.Context, data []byte) (sig string, err error) { return s.Key.SignToString(data) }
[ "func", "(", "s", "SigningKeySigner", ")", "SignToString", "(", "ctx", "context", ".", "Context", ",", "data", "[", "]", "byte", ")", "(", "sig", "string", ",", "err", "error", ")", "{", "return", "s", ".", "Key", ".", "SignToString", "(", "data", ")", "\n", "}" ]
// SignToString implements Signer for SigningKeySigner.
[ "SignToString", "implements", "Signer", "for", "SigningKeySigner", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/signature.go#L217-L220
161,130
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
DoesCacheHaveSpace
func (cache *diskBlockCacheWrapped) DoesCacheHaveSpace( ctx context.Context, cacheType DiskBlockCacheType) (bool, error) { cache.mtx.RLock() defer cache.mtx.RUnlock() c, err := cache.getCacheLocked(cacheType) if err != nil { return false, err } return c.DoesCacheHaveSpace(ctx), nil }
go
func (cache *diskBlockCacheWrapped) DoesCacheHaveSpace( ctx context.Context, cacheType DiskBlockCacheType) (bool, error) { cache.mtx.RLock() defer cache.mtx.RUnlock() c, err := cache.getCacheLocked(cacheType) if err != nil { return false, err } return c.DoesCacheHaveSpace(ctx), nil }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "DoesCacheHaveSpace", "(", "ctx", "context", ".", "Context", ",", "cacheType", "DiskBlockCacheType", ")", "(", "bool", ",", "error", ")", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "c", ",", "err", ":=", "cache", ".", "getCacheLocked", "(", "cacheType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "c", ".", "DoesCacheHaveSpace", "(", "ctx", ")", ",", "nil", "\n", "}" ]
// DoesCacheHaveSpace implements the DiskBlockCache interface for // diskBlockCacheWrapped.
[ "DoesCacheHaveSpace", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L116-L125
161,131
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
Get
func (cache *diskBlockCacheWrapped) Get( ctx context.Context, tlfID tlf.ID, blockID kbfsblock.ID, preferredCacheType DiskBlockCacheType) ( buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, prefetchStatus PrefetchStatus, err error) { cache.mtx.RLock() defer cache.mtx.RUnlock() primaryCache, secondaryCache := cache.rankCachesLocked(preferredCacheType) // Check both caches if the primary cache doesn't have the block. buf, serverHalf, prefetchStatus, err = primaryCache.Get(ctx, tlfID, blockID) if _, isNoSuchBlockError := errors.Cause(err).(data.NoSuchBlockError); isNoSuchBlockError && secondaryCache != nil { buf, serverHalf, prefetchStatus, err = secondaryCache.Get( ctx, tlfID, blockID) if err != nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, NoPrefetch, err } if preferredCacheType != DiskBlockAnyCache { cache.moveBetweenCachesWithBlockLocked( ctx, tlfID, blockID, buf, serverHalf, prefetchStatus, preferredCacheType) } } return buf, serverHalf, prefetchStatus, err }
go
func (cache *diskBlockCacheWrapped) Get( ctx context.Context, tlfID tlf.ID, blockID kbfsblock.ID, preferredCacheType DiskBlockCacheType) ( buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, prefetchStatus PrefetchStatus, err error) { cache.mtx.RLock() defer cache.mtx.RUnlock() primaryCache, secondaryCache := cache.rankCachesLocked(preferredCacheType) // Check both caches if the primary cache doesn't have the block. buf, serverHalf, prefetchStatus, err = primaryCache.Get(ctx, tlfID, blockID) if _, isNoSuchBlockError := errors.Cause(err).(data.NoSuchBlockError); isNoSuchBlockError && secondaryCache != nil { buf, serverHalf, prefetchStatus, err = secondaryCache.Get( ctx, tlfID, blockID) if err != nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, NoPrefetch, err } if preferredCacheType != DiskBlockAnyCache { cache.moveBetweenCachesWithBlockLocked( ctx, tlfID, blockID, buf, serverHalf, prefetchStatus, preferredCacheType) } } return buf, serverHalf, prefetchStatus, err }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "blockID", "kbfsblock", ".", "ID", ",", "preferredCacheType", "DiskBlockCacheType", ")", "(", "buf", "[", "]", "byte", ",", "serverHalf", "kbfscrypto", ".", "BlockCryptKeyServerHalf", ",", "prefetchStatus", "PrefetchStatus", ",", "err", "error", ")", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "primaryCache", ",", "secondaryCache", ":=", "cache", ".", "rankCachesLocked", "(", "preferredCacheType", ")", "\n", "// Check both caches if the primary cache doesn't have the block.", "buf", ",", "serverHalf", ",", "prefetchStatus", ",", "err", "=", "primaryCache", ".", "Get", "(", "ctx", ",", "tlfID", ",", "blockID", ")", "\n", "if", "_", ",", "isNoSuchBlockError", ":=", "errors", ".", "Cause", "(", "err", ")", ".", "(", "data", ".", "NoSuchBlockError", ")", ";", "isNoSuchBlockError", "&&", "secondaryCache", "!=", "nil", "{", "buf", ",", "serverHalf", ",", "prefetchStatus", ",", "err", "=", "secondaryCache", ".", "Get", "(", "ctx", ",", "tlfID", ",", "blockID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "kbfscrypto", ".", "BlockCryptKeyServerHalf", "{", "}", ",", "NoPrefetch", ",", "err", "\n", "}", "\n", "if", "preferredCacheType", "!=", "DiskBlockAnyCache", "{", "cache", ".", "moveBetweenCachesWithBlockLocked", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "buf", ",", "serverHalf", ",", "prefetchStatus", ",", "preferredCacheType", ")", "\n", "}", "\n", "}", "\n", "return", "buf", ",", "serverHalf", ",", "prefetchStatus", ",", "err", "\n", "}" ]
// Get implements the DiskBlockCache interface for diskBlockCacheWrapped.
[ "Get", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L181-L205
161,132
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
GetMetadata
func (cache *diskBlockCacheWrapped) GetMetadata(ctx context.Context, blockID kbfsblock.ID) (metadata DiskBlockCacheMetadata, err error) { cache.mtx.RLock() defer cache.mtx.RUnlock() if cache.syncCache != nil { md, err := cache.syncCache.GetMetadata(ctx, blockID) switch errors.Cause(err) { case nil: return md, nil case ldberrors.ErrNotFound: default: return md, err } } return cache.workingSetCache.GetMetadata(ctx, blockID) }
go
func (cache *diskBlockCacheWrapped) GetMetadata(ctx context.Context, blockID kbfsblock.ID) (metadata DiskBlockCacheMetadata, err error) { cache.mtx.RLock() defer cache.mtx.RUnlock() if cache.syncCache != nil { md, err := cache.syncCache.GetMetadata(ctx, blockID) switch errors.Cause(err) { case nil: return md, nil case ldberrors.ErrNotFound: default: return md, err } } return cache.workingSetCache.GetMetadata(ctx, blockID) }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "GetMetadata", "(", "ctx", "context", ".", "Context", ",", "blockID", "kbfsblock", ".", "ID", ")", "(", "metadata", "DiskBlockCacheMetadata", ",", "err", "error", ")", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "if", "cache", ".", "syncCache", "!=", "nil", "{", "md", ",", "err", ":=", "cache", ".", "syncCache", ".", "GetMetadata", "(", "ctx", ",", "blockID", ")", "\n", "switch", "errors", ".", "Cause", "(", "err", ")", "{", "case", "nil", ":", "return", "md", ",", "nil", "\n", "case", "ldberrors", ".", "ErrNotFound", ":", "default", ":", "return", "md", ",", "err", "\n", "}", "\n", "}", "\n", "return", "cache", ".", "workingSetCache", ".", "GetMetadata", "(", "ctx", ",", "blockID", ")", "\n", "}" ]
// GetMetadata implements the DiskBlockCache interface for // diskBlockCacheWrapped.
[ "GetMetadata", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L209-L224
161,133
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
GetPrefetchStatus
func (cache *diskBlockCacheWrapped) GetPrefetchStatus( ctx context.Context, tlfID tlf.ID, blockID kbfsblock.ID, cacheType DiskBlockCacheType) (prefetchStatus PrefetchStatus, err error) { cache.mtx.RLock() defer cache.mtx.RUnlock() // Try the sync cache first unless working set cache is required. if cacheType != DiskBlockWorkingSetCache { md, err := cache.syncCache.GetMetadata(ctx, blockID) switch errors.Cause(err) { case nil: return md.PrefetchStatus(), nil case ldberrors.ErrNotFound: if cacheType == DiskBlockSyncCache { // Try moving the block and getting it again. moved := cache.moveBetweenCachesLocked( ctx, tlfID, blockID, cacheType) if moved { md, err := cache.syncCache.GetMetadata(ctx, blockID) if err != nil { return NoPrefetch, err } return md.PrefetchStatus(), nil } return NoPrefetch, err } // Otherwise try the working set cache below. default: return NoPrefetch, err } } md, err := cache.workingSetCache.GetMetadata(ctx, blockID) if err != nil { return NoPrefetch, err } return md.PrefetchStatus(), nil }
go
func (cache *diskBlockCacheWrapped) GetPrefetchStatus( ctx context.Context, tlfID tlf.ID, blockID kbfsblock.ID, cacheType DiskBlockCacheType) (prefetchStatus PrefetchStatus, err error) { cache.mtx.RLock() defer cache.mtx.RUnlock() // Try the sync cache first unless working set cache is required. if cacheType != DiskBlockWorkingSetCache { md, err := cache.syncCache.GetMetadata(ctx, blockID) switch errors.Cause(err) { case nil: return md.PrefetchStatus(), nil case ldberrors.ErrNotFound: if cacheType == DiskBlockSyncCache { // Try moving the block and getting it again. moved := cache.moveBetweenCachesLocked( ctx, tlfID, blockID, cacheType) if moved { md, err := cache.syncCache.GetMetadata(ctx, blockID) if err != nil { return NoPrefetch, err } return md.PrefetchStatus(), nil } return NoPrefetch, err } // Otherwise try the working set cache below. default: return NoPrefetch, err } } md, err := cache.workingSetCache.GetMetadata(ctx, blockID) if err != nil { return NoPrefetch, err } return md.PrefetchStatus(), nil }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "GetPrefetchStatus", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "blockID", "kbfsblock", ".", "ID", ",", "cacheType", "DiskBlockCacheType", ")", "(", "prefetchStatus", "PrefetchStatus", ",", "err", "error", ")", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "// Try the sync cache first unless working set cache is required.", "if", "cacheType", "!=", "DiskBlockWorkingSetCache", "{", "md", ",", "err", ":=", "cache", ".", "syncCache", ".", "GetMetadata", "(", "ctx", ",", "blockID", ")", "\n", "switch", "errors", ".", "Cause", "(", "err", ")", "{", "case", "nil", ":", "return", "md", ".", "PrefetchStatus", "(", ")", ",", "nil", "\n", "case", "ldberrors", ".", "ErrNotFound", ":", "if", "cacheType", "==", "DiskBlockSyncCache", "{", "// Try moving the block and getting it again.", "moved", ":=", "cache", ".", "moveBetweenCachesLocked", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "cacheType", ")", "\n", "if", "moved", "{", "md", ",", "err", ":=", "cache", ".", "syncCache", ".", "GetMetadata", "(", "ctx", ",", "blockID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NoPrefetch", ",", "err", "\n", "}", "\n", "return", "md", ".", "PrefetchStatus", "(", ")", ",", "nil", "\n", "}", "\n", "return", "NoPrefetch", ",", "err", "\n", "}", "\n", "// Otherwise try the working set cache below.", "default", ":", "return", "NoPrefetch", ",", "err", "\n", "}", "\n", "}", "\n\n", "md", ",", "err", ":=", "cache", ".", "workingSetCache", ".", "GetMetadata", "(", "ctx", ",", "blockID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NoPrefetch", ",", "err", "\n", "}", "\n", "return", "md", ".", "PrefetchStatus", "(", ")", ",", "nil", "\n", "}" ]
// GetPefetchStatus implements the DiskBlockCache interface for // diskBlockCacheWrapped.
[ "GetPefetchStatus", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L243-L280
161,134
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
Put
func (cache *diskBlockCacheWrapped) Put(ctx context.Context, tlfID tlf.ID, blockID kbfsblock.ID, buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, cacheType DiskBlockCacheType) error { // This is a write operation but we are only reading the pointers to the // caches. So we use a read lock. cache.mtx.RLock() defer cache.mtx.RUnlock() if cacheType == DiskBlockSyncCache && cache.syncCache != nil { workingSetCache := cache.workingSetCache err := cache.syncCache.Put(ctx, tlfID, blockID, buf, serverHalf) if err == nil { cache.deleteGroup.Add(1) go func() { defer cache.deleteGroup.Done() workingSetCache.Delete(ctx, []kbfsblock.ID{blockID}) }() return nil } // Otherwise drop through and put it into the working set cache. } // No need to put it in the working cache if it's already in the // sync cache. if cache.syncCache != nil { _, _, _, err := cache.syncCache.Get(ctx, tlfID, blockID) if err == nil { return nil } } return cache.workingSetCache.Put(ctx, tlfID, blockID, buf, serverHalf) }
go
func (cache *diskBlockCacheWrapped) Put(ctx context.Context, tlfID tlf.ID, blockID kbfsblock.ID, buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, cacheType DiskBlockCacheType) error { // This is a write operation but we are only reading the pointers to the // caches. So we use a read lock. cache.mtx.RLock() defer cache.mtx.RUnlock() if cacheType == DiskBlockSyncCache && cache.syncCache != nil { workingSetCache := cache.workingSetCache err := cache.syncCache.Put(ctx, tlfID, blockID, buf, serverHalf) if err == nil { cache.deleteGroup.Add(1) go func() { defer cache.deleteGroup.Done() workingSetCache.Delete(ctx, []kbfsblock.ID{blockID}) }() return nil } // Otherwise drop through and put it into the working set cache. } // No need to put it in the working cache if it's already in the // sync cache. if cache.syncCache != nil { _, _, _, err := cache.syncCache.Get(ctx, tlfID, blockID) if err == nil { return nil } } return cache.workingSetCache.Put(ctx, tlfID, blockID, buf, serverHalf) }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "Put", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "blockID", "kbfsblock", ".", "ID", ",", "buf", "[", "]", "byte", ",", "serverHalf", "kbfscrypto", ".", "BlockCryptKeyServerHalf", ",", "cacheType", "DiskBlockCacheType", ")", "error", "{", "// This is a write operation but we are only reading the pointers to the", "// caches. So we use a read lock.", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "if", "cacheType", "==", "DiskBlockSyncCache", "&&", "cache", ".", "syncCache", "!=", "nil", "{", "workingSetCache", ":=", "cache", ".", "workingSetCache", "\n", "err", ":=", "cache", ".", "syncCache", ".", "Put", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "buf", ",", "serverHalf", ")", "\n", "if", "err", "==", "nil", "{", "cache", ".", "deleteGroup", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "defer", "cache", ".", "deleteGroup", ".", "Done", "(", ")", "\n", "workingSetCache", ".", "Delete", "(", "ctx", ",", "[", "]", "kbfsblock", ".", "ID", "{", "blockID", "}", ")", "\n", "}", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "// Otherwise drop through and put it into the working set cache.", "}", "\n", "// No need to put it in the working cache if it's already in the", "// sync cache.", "if", "cache", ".", "syncCache", "!=", "nil", "{", "_", ",", "_", ",", "_", ",", "err", ":=", "cache", ".", "syncCache", ".", "Get", "(", "ctx", ",", "tlfID", ",", "blockID", ")", "\n", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "}", "\n", "return", "cache", ".", "workingSetCache", ".", "Put", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "buf", ",", "serverHalf", ")", "\n", "}" ]
// Put implements the DiskBlockCache interface for diskBlockCacheWrapped.
[ "Put", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L283-L313
161,135
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
Delete
func (cache *diskBlockCacheWrapped) Delete(ctx context.Context, blockIDs []kbfsblock.ID, cacheType DiskBlockCacheType) ( numRemoved int, sizeRemoved int64, err error) { // This is a write operation but we are only reading the pointers to the // caches. So we use a read lock. cache.mtx.RLock() defer cache.mtx.RUnlock() if cacheType == DiskBlockAnyCache || cacheType == DiskBlockSyncCache { numRemoved, sizeRemoved, err = cache.syncCache.Delete(ctx, blockIDs) if err != nil { return 0, 0, err } if cacheType == DiskBlockSyncCache { return numRemoved, sizeRemoved, err } } wsNumRemoved, wsSizeRemoved, err := cache.workingSetCache.Delete( ctx, blockIDs) if err != nil { return 0, 0, err } return wsNumRemoved + numRemoved, wsSizeRemoved + sizeRemoved, nil }
go
func (cache *diskBlockCacheWrapped) Delete(ctx context.Context, blockIDs []kbfsblock.ID, cacheType DiskBlockCacheType) ( numRemoved int, sizeRemoved int64, err error) { // This is a write operation but we are only reading the pointers to the // caches. So we use a read lock. cache.mtx.RLock() defer cache.mtx.RUnlock() if cacheType == DiskBlockAnyCache || cacheType == DiskBlockSyncCache { numRemoved, sizeRemoved, err = cache.syncCache.Delete(ctx, blockIDs) if err != nil { return 0, 0, err } if cacheType == DiskBlockSyncCache { return numRemoved, sizeRemoved, err } } wsNumRemoved, wsSizeRemoved, err := cache.workingSetCache.Delete( ctx, blockIDs) if err != nil { return 0, 0, err } return wsNumRemoved + numRemoved, wsSizeRemoved + sizeRemoved, nil }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "blockIDs", "[", "]", "kbfsblock", ".", "ID", ",", "cacheType", "DiskBlockCacheType", ")", "(", "numRemoved", "int", ",", "sizeRemoved", "int64", ",", "err", "error", ")", "{", "// This is a write operation but we are only reading the pointers to the", "// caches. So we use a read lock.", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "if", "cacheType", "==", "DiskBlockAnyCache", "||", "cacheType", "==", "DiskBlockSyncCache", "{", "numRemoved", ",", "sizeRemoved", ",", "err", "=", "cache", ".", "syncCache", ".", "Delete", "(", "ctx", ",", "blockIDs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "0", ",", "err", "\n", "}", "\n", "if", "cacheType", "==", "DiskBlockSyncCache", "{", "return", "numRemoved", ",", "sizeRemoved", ",", "err", "\n", "}", "\n", "}", "\n\n", "wsNumRemoved", ",", "wsSizeRemoved", ",", "err", ":=", "cache", ".", "workingSetCache", ".", "Delete", "(", "ctx", ",", "blockIDs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "0", ",", "err", "\n", "}", "\n", "return", "wsNumRemoved", "+", "numRemoved", ",", "wsSizeRemoved", "+", "sizeRemoved", ",", "nil", "\n", "}" ]
// Delete implements the DiskBlockCache interface for diskBlockCacheWrapped.
[ "Delete", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L316-L339
161,136
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
UpdateMetadata
func (cache *diskBlockCacheWrapped) UpdateMetadata( ctx context.Context, tlfID tlf.ID, blockID kbfsblock.ID, prefetchStatus PrefetchStatus, cacheType DiskBlockCacheType) error { // This is a write operation but we are only reading the pointers to the // caches. So we use a read lock. cache.mtx.RLock() defer cache.mtx.RUnlock() primaryCache, secondaryCache := cache.rankCachesLocked(cacheType) err := primaryCache.UpdateMetadata(ctx, blockID, prefetchStatus) _, isNoSuchBlockError := errors.Cause(err).(data.NoSuchBlockError) if !isNoSuchBlockError { return err } if cacheType == DiskBlockSyncCache { // Try moving the block and getting it again. moved := cache.moveBetweenCachesLocked( ctx, tlfID, blockID, cacheType) if moved { err = primaryCache.UpdateMetadata(ctx, blockID, prefetchStatus) } return err } err = secondaryCache.UpdateMetadata(ctx, blockID, prefetchStatus) _, isNoSuchBlockError = errors.Cause(err).(data.NoSuchBlockError) if !isNoSuchBlockError { return err } // Try one last time in the primary cache, in case of this // sequence of events: // 0) Block exists in secondary. // 1) UpdateMetadata checks primary, gets NoSuchBlockError. // 2) Other goroutine writes block to primary. // 3) Other goroutine deletes block from primary. // 4) UpdateMetadata checks secondary, gets NoSuchBlockError. return primaryCache.UpdateMetadata(ctx, blockID, prefetchStatus) }
go
func (cache *diskBlockCacheWrapped) UpdateMetadata( ctx context.Context, tlfID tlf.ID, blockID kbfsblock.ID, prefetchStatus PrefetchStatus, cacheType DiskBlockCacheType) error { // This is a write operation but we are only reading the pointers to the // caches. So we use a read lock. cache.mtx.RLock() defer cache.mtx.RUnlock() primaryCache, secondaryCache := cache.rankCachesLocked(cacheType) err := primaryCache.UpdateMetadata(ctx, blockID, prefetchStatus) _, isNoSuchBlockError := errors.Cause(err).(data.NoSuchBlockError) if !isNoSuchBlockError { return err } if cacheType == DiskBlockSyncCache { // Try moving the block and getting it again. moved := cache.moveBetweenCachesLocked( ctx, tlfID, blockID, cacheType) if moved { err = primaryCache.UpdateMetadata(ctx, blockID, prefetchStatus) } return err } err = secondaryCache.UpdateMetadata(ctx, blockID, prefetchStatus) _, isNoSuchBlockError = errors.Cause(err).(data.NoSuchBlockError) if !isNoSuchBlockError { return err } // Try one last time in the primary cache, in case of this // sequence of events: // 0) Block exists in secondary. // 1) UpdateMetadata checks primary, gets NoSuchBlockError. // 2) Other goroutine writes block to primary. // 3) Other goroutine deletes block from primary. // 4) UpdateMetadata checks secondary, gets NoSuchBlockError. return primaryCache.UpdateMetadata(ctx, blockID, prefetchStatus) }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "UpdateMetadata", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "blockID", "kbfsblock", ".", "ID", ",", "prefetchStatus", "PrefetchStatus", ",", "cacheType", "DiskBlockCacheType", ")", "error", "{", "// This is a write operation but we are only reading the pointers to the", "// caches. So we use a read lock.", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "primaryCache", ",", "secondaryCache", ":=", "cache", ".", "rankCachesLocked", "(", "cacheType", ")", "\n\n", "err", ":=", "primaryCache", ".", "UpdateMetadata", "(", "ctx", ",", "blockID", ",", "prefetchStatus", ")", "\n", "_", ",", "isNoSuchBlockError", ":=", "errors", ".", "Cause", "(", "err", ")", ".", "(", "data", ".", "NoSuchBlockError", ")", "\n", "if", "!", "isNoSuchBlockError", "{", "return", "err", "\n", "}", "\n", "if", "cacheType", "==", "DiskBlockSyncCache", "{", "// Try moving the block and getting it again.", "moved", ":=", "cache", ".", "moveBetweenCachesLocked", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "cacheType", ")", "\n", "if", "moved", "{", "err", "=", "primaryCache", ".", "UpdateMetadata", "(", "ctx", ",", "blockID", ",", "prefetchStatus", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "err", "=", "secondaryCache", ".", "UpdateMetadata", "(", "ctx", ",", "blockID", ",", "prefetchStatus", ")", "\n", "_", ",", "isNoSuchBlockError", "=", "errors", ".", "Cause", "(", "err", ")", ".", "(", "data", ".", "NoSuchBlockError", ")", "\n", "if", "!", "isNoSuchBlockError", "{", "return", "err", "\n", "}", "\n", "// Try one last time in the primary cache, in case of this", "// sequence of events:", "// 0) Block exists in secondary.", "// 1) UpdateMetadata checks primary, gets NoSuchBlockError.", "// 2) Other goroutine writes block to primary.", "// 3) Other goroutine deletes block from primary.", "// 4) UpdateMetadata checks secondary, gets NoSuchBlockError.", "return", "primaryCache", ".", "UpdateMetadata", "(", "ctx", ",", "blockID", ",", "prefetchStatus", ")", "\n", "}" ]
// UpdateMetadata implements the DiskBlockCache interface for // diskBlockCacheWrapped.
[ "UpdateMetadata", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L343-L379
161,137
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
ClearAllTlfBlocks
func (cache *diskBlockCacheWrapped) ClearAllTlfBlocks( ctx context.Context, tlfID tlf.ID, cacheType DiskBlockCacheType) error { cache.mtx.RLock() defer cache.mtx.RUnlock() c, err := cache.getCacheLocked(cacheType) if err != nil { return err } return c.ClearAllTlfBlocks(ctx, tlfID) }
go
func (cache *diskBlockCacheWrapped) ClearAllTlfBlocks( ctx context.Context, tlfID tlf.ID, cacheType DiskBlockCacheType) error { cache.mtx.RLock() defer cache.mtx.RUnlock() c, err := cache.getCacheLocked(cacheType) if err != nil { return err } return c.ClearAllTlfBlocks(ctx, tlfID) }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "ClearAllTlfBlocks", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "cacheType", "DiskBlockCacheType", ")", "error", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "c", ",", "err", ":=", "cache", ".", "getCacheLocked", "(", "cacheType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "c", ".", "ClearAllTlfBlocks", "(", "ctx", ",", "tlfID", ")", "\n", "}" ]
// ClearAllTlfBlocks implements the DiskBlockCache interface for // diskBlockCacheWrapper.
[ "ClearAllTlfBlocks", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapper", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L383-L392
161,138
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
GetLastUnrefRev
func (cache *diskBlockCacheWrapped) GetLastUnrefRev( ctx context.Context, tlfID tlf.ID, cacheType DiskBlockCacheType) ( kbfsmd.Revision, error) { cache.mtx.RLock() defer cache.mtx.RUnlock() c, err := cache.getCacheLocked(cacheType) if err != nil { return kbfsmd.RevisionUninitialized, err } return c.GetLastUnrefRev(ctx, tlfID) }
go
func (cache *diskBlockCacheWrapped) GetLastUnrefRev( ctx context.Context, tlfID tlf.ID, cacheType DiskBlockCacheType) ( kbfsmd.Revision, error) { cache.mtx.RLock() defer cache.mtx.RUnlock() c, err := cache.getCacheLocked(cacheType) if err != nil { return kbfsmd.RevisionUninitialized, err } return c.GetLastUnrefRev(ctx, tlfID) }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "GetLastUnrefRev", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "cacheType", "DiskBlockCacheType", ")", "(", "kbfsmd", ".", "Revision", ",", "error", ")", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "c", ",", "err", ":=", "cache", ".", "getCacheLocked", "(", "cacheType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbfsmd", ".", "RevisionUninitialized", ",", "err", "\n", "}", "\n", "return", "c", ".", "GetLastUnrefRev", "(", "ctx", ",", "tlfID", ")", "\n", "}" ]
// GetLastUnrefRev implements the DiskBlockCache interface for // diskBlockCacheWrapped.
[ "GetLastUnrefRev", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L396-L406
161,139
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
Status
func (cache *diskBlockCacheWrapped) Status( ctx context.Context) map[string]DiskBlockCacheStatus { // This is a write operation but we are only reading the pointers to the // caches. So we use a read lock. cache.mtx.RLock() defer cache.mtx.RUnlock() statuses := make(map[string]DiskBlockCacheStatus, 2) if cache.workingSetCache != nil { for name, status := range cache.workingSetCache.Status(ctx) { statuses[name] = status } } if cache.syncCache == nil { return statuses } for name, status := range cache.syncCache.Status(ctx) { statuses[name] = status } return statuses }
go
func (cache *diskBlockCacheWrapped) Status( ctx context.Context) map[string]DiskBlockCacheStatus { // This is a write operation but we are only reading the pointers to the // caches. So we use a read lock. cache.mtx.RLock() defer cache.mtx.RUnlock() statuses := make(map[string]DiskBlockCacheStatus, 2) if cache.workingSetCache != nil { for name, status := range cache.workingSetCache.Status(ctx) { statuses[name] = status } } if cache.syncCache == nil { return statuses } for name, status := range cache.syncCache.Status(ctx) { statuses[name] = status } return statuses }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "Status", "(", "ctx", "context", ".", "Context", ")", "map", "[", "string", "]", "DiskBlockCacheStatus", "{", "// This is a write operation but we are only reading the pointers to the", "// caches. So we use a read lock.", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "statuses", ":=", "make", "(", "map", "[", "string", "]", "DiskBlockCacheStatus", ",", "2", ")", "\n", "if", "cache", ".", "workingSetCache", "!=", "nil", "{", "for", "name", ",", "status", ":=", "range", "cache", ".", "workingSetCache", ".", "Status", "(", "ctx", ")", "{", "statuses", "[", "name", "]", "=", "status", "\n", "}", "\n", "}", "\n", "if", "cache", ".", "syncCache", "==", "nil", "{", "return", "statuses", "\n", "}", "\n", "for", "name", ",", "status", ":=", "range", "cache", ".", "syncCache", ".", "Status", "(", "ctx", ")", "{", "statuses", "[", "name", "]", "=", "status", "\n", "}", "\n", "return", "statuses", "\n", "}" ]
// Status implements the DiskBlockCache interface for diskBlockCacheWrapped.
[ "Status", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L423-L442
161,140
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
Mark
func (cache *diskBlockCacheWrapped) Mark( ctx context.Context, blockID kbfsblock.ID, tag string, cacheType DiskBlockCacheType) error { cache.mtx.RLock() defer cache.mtx.RUnlock() c, err := cache.getCacheLocked(cacheType) if err != nil { return err } return c.Mark(ctx, blockID, tag) }
go
func (cache *diskBlockCacheWrapped) Mark( ctx context.Context, blockID kbfsblock.ID, tag string, cacheType DiskBlockCacheType) error { cache.mtx.RLock() defer cache.mtx.RUnlock() c, err := cache.getCacheLocked(cacheType) if err != nil { return err } return c.Mark(ctx, blockID, tag) }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "Mark", "(", "ctx", "context", ".", "Context", ",", "blockID", "kbfsblock", ".", "ID", ",", "tag", "string", ",", "cacheType", "DiskBlockCacheType", ")", "error", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "c", ",", "err", ":=", "cache", ".", "getCacheLocked", "(", "cacheType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "c", ".", "Mark", "(", "ctx", ",", "blockID", ",", "tag", ")", "\n", "}" ]
// Mark implements the DiskBlockCache interface for diskBlockCacheWrapped.
[ "Mark", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L445-L455
161,141
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
AddHomeTLF
func (cache *diskBlockCacheWrapped) AddHomeTLF(ctx context.Context, tlfID tlf.ID) error { cache.mtx.RLock() defer cache.mtx.RUnlock() if cache.syncCache == nil { return errors.New("Sync cache not enabled") } return cache.syncCache.AddHomeTLF(ctx, tlfID) }
go
func (cache *diskBlockCacheWrapped) AddHomeTLF(ctx context.Context, tlfID tlf.ID) error { cache.mtx.RLock() defer cache.mtx.RUnlock() if cache.syncCache == nil { return errors.New("Sync cache not enabled") } return cache.syncCache.AddHomeTLF(ctx, tlfID) }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "AddHomeTLF", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ")", "error", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "if", "cache", ".", "syncCache", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "cache", ".", "syncCache", ".", "AddHomeTLF", "(", "ctx", ",", "tlfID", ")", "\n", "}" ]
// AddHomeTLF implements the DiskBlockCache interface for diskBlockCacheWrapped.
[ "AddHomeTLF", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L476-L484
161,142
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
ClearHomeTLFs
func (cache *diskBlockCacheWrapped) ClearHomeTLFs(ctx context.Context) error { cache.mtx.RLock() defer cache.mtx.RUnlock() if cache.syncCache == nil { return errors.New("Sync cache not enabled") } return cache.syncCache.ClearHomeTLFs(ctx) }
go
func (cache *diskBlockCacheWrapped) ClearHomeTLFs(ctx context.Context) error { cache.mtx.RLock() defer cache.mtx.RUnlock() if cache.syncCache == nil { return errors.New("Sync cache not enabled") } return cache.syncCache.ClearHomeTLFs(ctx) }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "ClearHomeTLFs", "(", "ctx", "context", ".", "Context", ")", "error", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "if", "cache", ".", "syncCache", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "cache", ".", "syncCache", ".", "ClearHomeTLFs", "(", "ctx", ")", "\n", "}" ]
// ClearHomeTLFs implements the DiskBlockCache interface for // diskBlockCacheWrapped.
[ "ClearHomeTLFs", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L488-L495
161,143
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
WaitUntilStarted
func (cache *diskBlockCacheWrapped) WaitUntilStarted( cacheType DiskBlockCacheType) (err error) { cache.mtx.RLock() defer cache.mtx.RUnlock() if cacheType != DiskBlockWorkingSetCache { err = cache.syncCache.WaitUntilStarted() if err != nil { return err } } if cacheType != DiskBlockSyncCache { err = cache.workingSetCache.WaitUntilStarted() if err != nil { return err } } return nil }
go
func (cache *diskBlockCacheWrapped) WaitUntilStarted( cacheType DiskBlockCacheType) (err error) { cache.mtx.RLock() defer cache.mtx.RUnlock() if cacheType != DiskBlockWorkingSetCache { err = cache.syncCache.WaitUntilStarted() if err != nil { return err } } if cacheType != DiskBlockSyncCache { err = cache.workingSetCache.WaitUntilStarted() if err != nil { return err } } return nil }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "WaitUntilStarted", "(", "cacheType", "DiskBlockCacheType", ")", "(", "err", "error", ")", "{", "cache", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "if", "cacheType", "!=", "DiskBlockWorkingSetCache", "{", "err", "=", "cache", ".", "syncCache", ".", "WaitUntilStarted", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "if", "cacheType", "!=", "DiskBlockSyncCache", "{", "err", "=", "cache", ".", "workingSetCache", ".", "WaitUntilStarted", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// WaitUntilStarted implements the DiskBlockCache interface for // diskBlockCacheWrapped.
[ "WaitUntilStarted", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L572-L592
161,144
keybase/client
go/kbfs/libkbfs/disk_block_cache_wrapped.go
Shutdown
func (cache *diskBlockCacheWrapped) Shutdown(ctx context.Context) { cache.mtx.Lock() defer cache.mtx.Unlock() cache.workingSetCache.Shutdown(ctx) if cache.syncCache != nil { cache.syncCache.Shutdown(ctx) } }
go
func (cache *diskBlockCacheWrapped) Shutdown(ctx context.Context) { cache.mtx.Lock() defer cache.mtx.Unlock() cache.workingSetCache.Shutdown(ctx) if cache.syncCache != nil { cache.syncCache.Shutdown(ctx) } }
[ "func", "(", "cache", "*", "diskBlockCacheWrapped", ")", "Shutdown", "(", "ctx", "context", ".", "Context", ")", "{", "cache", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "Unlock", "(", ")", "\n", "cache", ".", "workingSetCache", ".", "Shutdown", "(", "ctx", ")", "\n", "if", "cache", ".", "syncCache", "!=", "nil", "{", "cache", ".", "syncCache", ".", "Shutdown", "(", "ctx", ")", "\n", "}", "\n", "}" ]
// Shutdown implements the DiskBlockCache interface for diskBlockCacheWrapped.
[ "Shutdown", "implements", "the", "DiskBlockCache", "interface", "for", "diskBlockCacheWrapped", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_wrapped.go#L595-L602
161,145
keybase/client
go/kbfs/libkbfs/chat_rpc.go
NewChatRPC
func NewChatRPC(config Config, kbCtx Context) *ChatRPC { log := config.MakeLogger("") deferLog := log.CloneWithAddedDepth(1) c := &ChatRPC{ log: log, vlog: config.MakeVLogger(log), deferLog: deferLog, config: config, convCBs: make(map[string][]ChatChannelNewMessageCB), } conn := NewSharedKeybaseConnection(kbCtx, config, c) c.client = chat1.LocalClient{Cli: conn.GetClient()} return c }
go
func NewChatRPC(config Config, kbCtx Context) *ChatRPC { log := config.MakeLogger("") deferLog := log.CloneWithAddedDepth(1) c := &ChatRPC{ log: log, vlog: config.MakeVLogger(log), deferLog: deferLog, config: config, convCBs: make(map[string][]ChatChannelNewMessageCB), } conn := NewSharedKeybaseConnection(kbCtx, config, c) c.client = chat1.LocalClient{Cli: conn.GetClient()} return c }
[ "func", "NewChatRPC", "(", "config", "Config", ",", "kbCtx", "Context", ")", "*", "ChatRPC", "{", "log", ":=", "config", ".", "MakeLogger", "(", "\"", "\"", ")", "\n", "deferLog", ":=", "log", ".", "CloneWithAddedDepth", "(", "1", ")", "\n", "c", ":=", "&", "ChatRPC", "{", "log", ":", "log", ",", "vlog", ":", "config", ".", "MakeVLogger", "(", "log", ")", ",", "deferLog", ":", "deferLog", ",", "config", ":", "config", ",", "convCBs", ":", "make", "(", "map", "[", "string", "]", "[", "]", "ChatChannelNewMessageCB", ")", ",", "}", "\n", "conn", ":=", "NewSharedKeybaseConnection", "(", "kbCtx", ",", "config", ",", "c", ")", "\n", "c", ".", "client", "=", "chat1", ".", "LocalClient", "{", "Cli", ":", "conn", ".", "GetClient", "(", ")", "}", "\n", "return", "c", "\n", "}" ]
// NewChatRPC constructs a new RPC based chat implementation.
[ "NewChatRPC", "constructs", "a", "new", "RPC", "based", "chat", "implementation", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L55-L68
161,146
keybase/client
go/kbfs/libkbfs/chat_rpc.go
NewChatActivity
func (c *ChatRPC) NewChatActivity( ctx context.Context, arg chat1.NewChatActivityArg) error { activityType, err := arg.Activity.ActivityType() if err != nil { return err } switch activityType { case chat1.ChatActivityType_NEW_CONVERSATION: // If we learn about a new conversation for a given TLF, // attempt to route it to the TLF. info := arg.Activity.NewConversation() err := c.newNotificationChannel(ctx, info.ConvID, info.Conv) if err != nil { return err } case chat1.ChatActivityType_INCOMING_MESSAGE: // If we learn about a new message for a given conversation ID, // let any registered callbacks for that conversation ID know. msg := arg.Activity.IncomingMessage() state, err := msg.Message.State() if err != nil { return err } if state != chat1.MessageUnboxedState_VALID { return nil } validMsg := msg.Message.Valid() msgType, err := validMsg.MessageBody.MessageType() if err != nil { return err } if msgType != chat1.MessageType_TEXT { return nil } body := validMsg.MessageBody.Text().Body c.convLock.RLock() cbs := c.convCBs[msg.ConvID.String()] c.convLock.RUnlock() // If this is on the self-write channel, cache it and we're // done. selfConvID, _ := c.getSelfConvInfoIfCached() if selfConvID.Eq(msg.ConvID) { return c.setLastWrittenConvID(ctx, body) } if len(cbs) == 0 { // No one is listening for this channel yet, so consider // it a new channel. err := c.newNotificationChannel(ctx, msg.ConvID, msg.Conv) if err != nil { return err } } else { for _, cb := range cbs { cb(msg.ConvID, body) } } } return nil }
go
func (c *ChatRPC) NewChatActivity( ctx context.Context, arg chat1.NewChatActivityArg) error { activityType, err := arg.Activity.ActivityType() if err != nil { return err } switch activityType { case chat1.ChatActivityType_NEW_CONVERSATION: // If we learn about a new conversation for a given TLF, // attempt to route it to the TLF. info := arg.Activity.NewConversation() err := c.newNotificationChannel(ctx, info.ConvID, info.Conv) if err != nil { return err } case chat1.ChatActivityType_INCOMING_MESSAGE: // If we learn about a new message for a given conversation ID, // let any registered callbacks for that conversation ID know. msg := arg.Activity.IncomingMessage() state, err := msg.Message.State() if err != nil { return err } if state != chat1.MessageUnboxedState_VALID { return nil } validMsg := msg.Message.Valid() msgType, err := validMsg.MessageBody.MessageType() if err != nil { return err } if msgType != chat1.MessageType_TEXT { return nil } body := validMsg.MessageBody.Text().Body c.convLock.RLock() cbs := c.convCBs[msg.ConvID.String()] c.convLock.RUnlock() // If this is on the self-write channel, cache it and we're // done. selfConvID, _ := c.getSelfConvInfoIfCached() if selfConvID.Eq(msg.ConvID) { return c.setLastWrittenConvID(ctx, body) } if len(cbs) == 0 { // No one is listening for this channel yet, so consider // it a new channel. err := c.newNotificationChannel(ctx, msg.ConvID, msg.Conv) if err != nil { return err } } else { for _, cb := range cbs { cb(msg.ConvID, body) } } } return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "NewChatActivity", "(", "ctx", "context", ".", "Context", ",", "arg", "chat1", ".", "NewChatActivityArg", ")", "error", "{", "activityType", ",", "err", ":=", "arg", ".", "Activity", ".", "ActivityType", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "switch", "activityType", "{", "case", "chat1", ".", "ChatActivityType_NEW_CONVERSATION", ":", "// If we learn about a new conversation for a given TLF,", "// attempt to route it to the TLF.", "info", ":=", "arg", ".", "Activity", ".", "NewConversation", "(", ")", "\n", "err", ":=", "c", ".", "newNotificationChannel", "(", "ctx", ",", "info", ".", "ConvID", ",", "info", ".", "Conv", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "case", "chat1", ".", "ChatActivityType_INCOMING_MESSAGE", ":", "// If we learn about a new message for a given conversation ID,", "// let any registered callbacks for that conversation ID know.", "msg", ":=", "arg", ".", "Activity", ".", "IncomingMessage", "(", ")", "\n", "state", ",", "err", ":=", "msg", ".", "Message", ".", "State", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "state", "!=", "chat1", ".", "MessageUnboxedState_VALID", "{", "return", "nil", "\n", "}", "\n\n", "validMsg", ":=", "msg", ".", "Message", ".", "Valid", "(", ")", "\n", "msgType", ",", "err", ":=", "validMsg", ".", "MessageBody", ".", "MessageType", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "msgType", "!=", "chat1", ".", "MessageType_TEXT", "{", "return", "nil", "\n", "}", "\n", "body", ":=", "validMsg", ".", "MessageBody", ".", "Text", "(", ")", ".", "Body", "\n\n", "c", ".", "convLock", ".", "RLock", "(", ")", "\n", "cbs", ":=", "c", ".", "convCBs", "[", "msg", ".", "ConvID", ".", "String", "(", ")", "]", "\n", "c", ".", "convLock", ".", "RUnlock", "(", ")", "\n\n", "// If this is on the self-write channel, cache it and we're", "// done.", "selfConvID", ",", "_", ":=", "c", ".", "getSelfConvInfoIfCached", "(", ")", "\n", "if", "selfConvID", ".", "Eq", "(", "msg", ".", "ConvID", ")", "{", "return", "c", ".", "setLastWrittenConvID", "(", "ctx", ",", "body", ")", "\n", "}", "\n\n", "if", "len", "(", "cbs", ")", "==", "0", "{", "// No one is listening for this channel yet, so consider", "// it a new channel.", "err", ":=", "c", ".", "newNotificationChannel", "(", "ctx", ",", "msg", ".", "ConvID", ",", "msg", ".", "Conv", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "else", "{", "for", "_", ",", "cb", ":=", "range", "cbs", "{", "cb", "(", "msg", ".", "ConvID", ",", "body", ")", "\n", "}", "\n", "}", "\n\n", "}", "\n", "return", "nil", "\n", "}" ]
// NewChatActivity implements the chat1.NotifyChatInterface for // ChatRPC.
[ "NewChatActivity", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L667-L730
161,147
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatIdentifyUpdate
func (c *ChatRPC) ChatIdentifyUpdate( _ context.Context, _ keybase1.CanonicalTLFNameAndIDWithBreaks) error { return nil }
go
func (c *ChatRPC) ChatIdentifyUpdate( _ context.Context, _ keybase1.CanonicalTLFNameAndIDWithBreaks) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatIdentifyUpdate", "(", "_", "context", ".", "Context", ",", "_", "keybase1", ".", "CanonicalTLFNameAndIDWithBreaks", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatIdentifyUpdate implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatIdentifyUpdate", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L734-L737
161,148
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatTLFFinalize
func (c *ChatRPC) ChatTLFFinalize( _ context.Context, _ chat1.ChatTLFFinalizeArg) error { return nil }
go
func (c *ChatRPC) ChatTLFFinalize( _ context.Context, _ chat1.ChatTLFFinalizeArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatTLFFinalize", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatTLFFinalizeArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatTLFFinalize implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatTLFFinalize", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L741-L744
161,149
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatTLFResolve
func (c *ChatRPC) ChatTLFResolve( _ context.Context, _ chat1.ChatTLFResolveArg) error { return nil }
go
func (c *ChatRPC) ChatTLFResolve( _ context.Context, _ chat1.ChatTLFResolveArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatTLFResolve", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatTLFResolveArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatTLFResolve implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatTLFResolve", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L748-L751
161,150
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatThreadsStale
func (c *ChatRPC) ChatThreadsStale( _ context.Context, _ chat1.ChatThreadsStaleArg) error { return nil }
go
func (c *ChatRPC) ChatThreadsStale( _ context.Context, _ chat1.ChatThreadsStaleArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatThreadsStale", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatThreadsStaleArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatThreadsStale implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatThreadsStale", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L761-L764
161,151
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatTypingUpdate
func (c *ChatRPC) ChatTypingUpdate( _ context.Context, _ []chat1.ConvTypingUpdate) error { return nil }
go
func (c *ChatRPC) ChatTypingUpdate( _ context.Context, _ []chat1.ConvTypingUpdate) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatTypingUpdate", "(", "_", "context", ".", "Context", ",", "_", "[", "]", "chat1", ".", "ConvTypingUpdate", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatTypingUpdate implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatTypingUpdate", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L768-L771
161,152
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatJoinedConversation
func (c *ChatRPC) ChatJoinedConversation( _ context.Context, _ chat1.ChatJoinedConversationArg) error { return nil }
go
func (c *ChatRPC) ChatJoinedConversation( _ context.Context, _ chat1.ChatJoinedConversationArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatJoinedConversation", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatJoinedConversationArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatJoinedConversation implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatJoinedConversation", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L775-L778
161,153
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatLeftConversation
func (c *ChatRPC) ChatLeftConversation( _ context.Context, _ chat1.ChatLeftConversationArg) error { return nil }
go
func (c *ChatRPC) ChatLeftConversation( _ context.Context, _ chat1.ChatLeftConversationArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatLeftConversation", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatLeftConversationArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatLeftConversation implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatLeftConversation", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L782-L785
161,154
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatResetConversation
func (c *ChatRPC) ChatResetConversation( _ context.Context, _ chat1.ChatResetConversationArg) error { return nil }
go
func (c *ChatRPC) ChatResetConversation( _ context.Context, _ chat1.ChatResetConversationArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatResetConversation", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatResetConversationArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatResetConversation implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatResetConversation", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L789-L792
161,155
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatInboxSyncStarted
func (c *ChatRPC) ChatInboxSyncStarted( _ context.Context, _ keybase1.UID) error { return nil }
go
func (c *ChatRPC) ChatInboxSyncStarted( _ context.Context, _ keybase1.UID) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatInboxSyncStarted", "(", "_", "context", ".", "Context", ",", "_", "keybase1", ".", "UID", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatInboxSyncStarted implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatInboxSyncStarted", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L796-L799
161,156
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatInboxSynced
func (c *ChatRPC) ChatInboxSynced( _ context.Context, _ chat1.ChatInboxSyncedArg) error { return nil }
go
func (c *ChatRPC) ChatInboxSynced( _ context.Context, _ chat1.ChatInboxSyncedArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatInboxSynced", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatInboxSyncedArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatInboxSynced implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatInboxSynced", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L803-L806
161,157
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatSetConvRetention
func (c *ChatRPC) ChatSetConvRetention( _ context.Context, _ chat1.ChatSetConvRetentionArg) error { return nil }
go
func (c *ChatRPC) ChatSetConvRetention( _ context.Context, _ chat1.ChatSetConvRetentionArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatSetConvRetention", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatSetConvRetentionArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatSetConvRetention implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatSetConvRetention", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L810-L813
161,158
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatSetTeamRetention
func (c *ChatRPC) ChatSetTeamRetention( _ context.Context, _ chat1.ChatSetTeamRetentionArg) error { return nil }
go
func (c *ChatRPC) ChatSetTeamRetention( _ context.Context, _ chat1.ChatSetTeamRetentionArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatSetTeamRetention", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatSetTeamRetentionArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatSetTeamRetention implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatSetTeamRetention", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L817-L820
161,159
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatSetConvSettings
func (c *ChatRPC) ChatSetConvSettings( _ context.Context, _ chat1.ChatSetConvSettingsArg) error { return nil }
go
func (c *ChatRPC) ChatSetConvSettings( _ context.Context, _ chat1.ChatSetConvSettingsArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatSetConvSettings", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatSetConvSettingsArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatSetConvSettings implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatSetConvSettings", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L824-L827
161,160
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatSubteamRename
func (c *ChatRPC) ChatSubteamRename( _ context.Context, _ chat1.ChatSubteamRenameArg) error { return nil }
go
func (c *ChatRPC) ChatSubteamRename( _ context.Context, _ chat1.ChatSubteamRenameArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatSubteamRename", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatSubteamRenameArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatSubteamRename implements the chat1.NotifyChatInterface for // ChatRPC.
[ "ChatSubteamRename", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L831-L834
161,161
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatKBFSToImpteamUpgrade
func (c *ChatRPC) ChatKBFSToImpteamUpgrade( _ context.Context, _ chat1.ChatKBFSToImpteamUpgradeArg) error { return nil }
go
func (c *ChatRPC) ChatKBFSToImpteamUpgrade( _ context.Context, _ chat1.ChatKBFSToImpteamUpgradeArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatKBFSToImpteamUpgrade", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatKBFSToImpteamUpgradeArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatKBFSToImpteamUpgrade implements the chat1.NotifyChatInterface // for ChatRPC.
[ "ChatKBFSToImpteamUpgrade", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L838-L841
161,162
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatAttachmentUploadStart
func (c *ChatRPC) ChatAttachmentUploadStart( _ context.Context, _ chat1.ChatAttachmentUploadStartArg) error { return nil }
go
func (c *ChatRPC) ChatAttachmentUploadStart( _ context.Context, _ chat1.ChatAttachmentUploadStartArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatAttachmentUploadStart", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatAttachmentUploadStartArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatAttachmentUploadStart implements the chat1.NotifyChatInterface // for ChatRPC.
[ "ChatAttachmentUploadStart", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L845-L848
161,163
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatAttachmentUploadProgress
func (c *ChatRPC) ChatAttachmentUploadProgress( _ context.Context, _ chat1.ChatAttachmentUploadProgressArg) error { return nil }
go
func (c *ChatRPC) ChatAttachmentUploadProgress( _ context.Context, _ chat1.ChatAttachmentUploadProgressArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatAttachmentUploadProgress", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatAttachmentUploadProgressArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatAttachmentUploadProgress implements the chat1.NotifyChatInterface // for ChatRPC.
[ "ChatAttachmentUploadProgress", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L852-L855
161,164
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatPaymentInfo
func (c *ChatRPC) ChatPaymentInfo( _ context.Context, _ chat1.ChatPaymentInfoArg) error { return nil }
go
func (c *ChatRPC) ChatPaymentInfo( _ context.Context, _ chat1.ChatPaymentInfoArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatPaymentInfo", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatPaymentInfoArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatPaymentInfo implements the chat1.NotifyChatInterface // for ChatRPC.
[ "ChatPaymentInfo", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L859-L862
161,165
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatRequestInfo
func (c *ChatRPC) ChatRequestInfo( _ context.Context, _ chat1.ChatRequestInfoArg) error { return nil }
go
func (c *ChatRPC) ChatRequestInfo( _ context.Context, _ chat1.ChatRequestInfoArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatRequestInfo", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatRequestInfoArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatRequestInfo implements the chat1.NotifyChatInterface // for ChatRPC.
[ "ChatRequestInfo", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L866-L869
161,166
keybase/client
go/kbfs/libkbfs/chat_rpc.go
ChatPromptUnfurl
func (c *ChatRPC) ChatPromptUnfurl(_ context.Context, _ chat1.ChatPromptUnfurlArg) error { return nil }
go
func (c *ChatRPC) ChatPromptUnfurl(_ context.Context, _ chat1.ChatPromptUnfurlArg) error { return nil }
[ "func", "(", "c", "*", "ChatRPC", ")", "ChatPromptUnfurl", "(", "_", "context", ".", "Context", ",", "_", "chat1", ".", "ChatPromptUnfurlArg", ")", "error", "{", "return", "nil", "\n", "}" ]
// ChatPromptUnfurl implements the chat1.NotifyChatInterface // for ChatRPC.
[ "ChatPromptUnfurl", "implements", "the", "chat1", ".", "NotifyChatInterface", "for", "ChatRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_rpc.go#L873-L875
161,167
keybase/client
go/libkb/loopback.go
NewLoopbackListener
func NewLoopbackListener(ctx LogContext) *LoopbackListener { return &LoopbackListener{ logCtx: ctx, ch: make(chan *LoopbackConn), isClosed: false, } }
go
func NewLoopbackListener(ctx LogContext) *LoopbackListener { return &LoopbackListener{ logCtx: ctx, ch: make(chan *LoopbackConn), isClosed: false, } }
[ "func", "NewLoopbackListener", "(", "ctx", "LogContext", ")", "*", "LoopbackListener", "{", "return", "&", "LoopbackListener", "{", "logCtx", ":", "ctx", ",", "ch", ":", "make", "(", "chan", "*", "LoopbackConn", ")", ",", "isClosed", ":", "false", ",", "}", "\n", "}" ]
// NewLoopbackListener creates a new Loopback listener
[ "NewLoopbackListener", "creates", "a", "new", "Loopback", "listener" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/loopback.go#L51-L57
161,168
keybase/client
go/libkb/loopback.go
NewLoopbackConnPair
func NewLoopbackConnPair() (*LoopbackConn, *LoopbackConn) { aCh := make(chan []byte) bCh := make(chan []byte) a := &LoopbackConn{ch: aCh} b := &LoopbackConn{ch: bCh} a.partnerCh = bCh b.partnerCh = aCh return a, b }
go
func NewLoopbackConnPair() (*LoopbackConn, *LoopbackConn) { aCh := make(chan []byte) bCh := make(chan []byte) a := &LoopbackConn{ch: aCh} b := &LoopbackConn{ch: bCh} a.partnerCh = bCh b.partnerCh = aCh return a, b }
[ "func", "NewLoopbackConnPair", "(", ")", "(", "*", "LoopbackConn", ",", "*", "LoopbackConn", ")", "{", "aCh", ":=", "make", "(", "chan", "[", "]", "byte", ")", "\n", "bCh", ":=", "make", "(", "chan", "[", "]", "byte", ")", "\n", "a", ":=", "&", "LoopbackConn", "{", "ch", ":", "aCh", "}", "\n", "b", ":=", "&", "LoopbackConn", "{", "ch", ":", "bCh", "}", "\n", "a", ".", "partnerCh", "=", "bCh", "\n", "b", ".", "partnerCh", "=", "aCh", "\n", "return", "a", ",", "b", "\n", "}" ]
// NewLoopbackConnPair makes a new loopback connection pair
[ "NewLoopbackConnPair", "makes", "a", "new", "loopback", "connection", "pair" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/loopback.go#L60-L68
161,169
keybase/client
go/libkb/loopback.go
Dial
func (ll *LoopbackListener) Dial() (net.Conn, error) { ll.logCtx.GetLog().Debug("+ LoopbackListener.Dial") ll.mutex.Lock() defer ll.mutex.Unlock() if ll.isClosed { return nil, syscall.EINVAL } a, b := NewLoopbackConnPair() ll.ch <- a return b, nil }
go
func (ll *LoopbackListener) Dial() (net.Conn, error) { ll.logCtx.GetLog().Debug("+ LoopbackListener.Dial") ll.mutex.Lock() defer ll.mutex.Unlock() if ll.isClosed { return nil, syscall.EINVAL } a, b := NewLoopbackConnPair() ll.ch <- a return b, nil }
[ "func", "(", "ll", "*", "LoopbackListener", ")", "Dial", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "ll", ".", "logCtx", ".", "GetLog", "(", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "ll", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "ll", ".", "mutex", ".", "Unlock", "(", ")", "\n", "if", "ll", ".", "isClosed", "{", "return", "nil", ",", "syscall", ".", "EINVAL", "\n", "}", "\n", "a", ",", "b", ":=", "NewLoopbackConnPair", "(", ")", "\n", "ll", ".", "ch", "<-", "a", "\n", "return", "b", ",", "nil", "\n", "}" ]
// LoopbackDial dials the given LoopbackListener and yields an new net.Conn // that's a connection to it.
[ "LoopbackDial", "dials", "the", "given", "LoopbackListener", "and", "yields", "an", "new", "net", ".", "Conn", "that", "s", "a", "connection", "to", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/loopback.go#L72-L82
161,170
keybase/client
go/libkb/loopback.go
Close
func (ll *LoopbackListener) Close() (err error) { ll.mutex.Lock() defer ll.mutex.Unlock() if ll.isClosed { return syscall.EINVAL } ll.isClosed = true close(ll.ch) return }
go
func (ll *LoopbackListener) Close() (err error) { ll.mutex.Lock() defer ll.mutex.Unlock() if ll.isClosed { return syscall.EINVAL } ll.isClosed = true close(ll.ch) return }
[ "func", "(", "ll", "*", "LoopbackListener", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "ll", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "ll", ".", "mutex", ".", "Unlock", "(", ")", "\n", "if", "ll", ".", "isClosed", "{", "return", "syscall", ".", "EINVAL", "\n", "}", "\n", "ll", ".", "isClosed", "=", "true", "\n", "close", "(", "ll", ".", "ch", ")", "\n", "return", "\n", "}" ]
// Close closes the listener. // Any blocked Accept operations will be unblocked and return errors
[ "Close", "closes", "the", "listener", ".", "Any", "blocked", "Accept", "operations", "will", "be", "unblocked", "and", "return", "errors" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/loopback.go#L102-L111
161,171
keybase/client
go/libkb/loopback.go
Close
func (lc *LoopbackConn) Close() (err error) { lc.wMutex.Lock() defer lc.wMutex.Unlock() if lc.isClosed { return syscall.EINVAL } lc.isClosed = true close(lc.ch) return nil }
go
func (lc *LoopbackConn) Close() (err error) { lc.wMutex.Lock() defer lc.wMutex.Unlock() if lc.isClosed { return syscall.EINVAL } lc.isClosed = true close(lc.ch) return nil }
[ "func", "(", "lc", "*", "LoopbackConn", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "lc", ".", "wMutex", ".", "Lock", "(", ")", "\n", "defer", "lc", ".", "wMutex", ".", "Unlock", "(", ")", "\n", "if", "lc", ".", "isClosed", "{", "return", "syscall", ".", "EINVAL", "\n", "}", "\n", "lc", ".", "isClosed", "=", "true", "\n", "close", "(", "lc", ".", "ch", ")", "\n", "return", "nil", "\n", "}" ]
// Close closes the connection. // Any blocked Read or Write operations will be unblocked and return errors.
[ "Close", "closes", "the", "connection", ".", "Any", "blocked", "Read", "or", "Write", "operations", "will", "be", "unblocked", "and", "return", "errors", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/loopback.go#L147-L156
161,172
keybase/client
go/kbfs/libdokan/new_folder_name.go
lpcwstrToString
func lpcwstrToString(ptr *uint16) string { if ptr == nil { return "" } var len = 0 for tmp := ptr; *tmp != 0; tmp = (*uint16)(unsafe.Pointer((uintptr(unsafe.Pointer(tmp)) + 2))) { len++ } raw := ptrUcs2Slice(ptr, len) return string(utf16.Decode(raw)) }
go
func lpcwstrToString(ptr *uint16) string { if ptr == nil { return "" } var len = 0 for tmp := ptr; *tmp != 0; tmp = (*uint16)(unsafe.Pointer((uintptr(unsafe.Pointer(tmp)) + 2))) { len++ } raw := ptrUcs2Slice(ptr, len) return string(utf16.Decode(raw)) }
[ "func", "lpcwstrToString", "(", "ptr", "*", "uint16", ")", "string", "{", "if", "ptr", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "var", "len", "=", "0", "\n", "for", "tmp", ":=", "ptr", ";", "*", "tmp", "!=", "0", ";", "tmp", "=", "(", "*", "uint16", ")", "(", "unsafe", ".", "Pointer", "(", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "tmp", ")", ")", "+", "2", ")", ")", ")", "{", "len", "++", "\n", "}", "\n", "raw", ":=", "ptrUcs2Slice", "(", "ptr", ",", "len", ")", "\n", "return", "string", "(", "utf16", ".", "Decode", "(", "raw", ")", ")", "\n", "}" ]
// lpcwstrToString converts a nul-terminated Windows wide string to a Go string,
[ "lpcwstrToString", "converts", "a", "nul", "-", "terminated", "Windows", "wide", "string", "to", "a", "Go", "string" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libdokan/new_folder_name.go#L57-L67
161,173
keybase/client
go/kbfs/libdokan/new_folder_name.go
ptrUcs2Slice
func ptrUcs2Slice(ptr *uint16, lenUcs2 int) []uint16 { return *(*[]uint16)(unsafe.Pointer(&reflect.SliceHeader{ Data: uintptr(unsafe.Pointer(ptr)), Len: lenUcs2, Cap: lenUcs2})) }
go
func ptrUcs2Slice(ptr *uint16, lenUcs2 int) []uint16 { return *(*[]uint16)(unsafe.Pointer(&reflect.SliceHeader{ Data: uintptr(unsafe.Pointer(ptr)), Len: lenUcs2, Cap: lenUcs2})) }
[ "func", "ptrUcs2Slice", "(", "ptr", "*", "uint16", ",", "lenUcs2", "int", ")", "[", "]", "uint16", "{", "return", "*", "(", "*", "[", "]", "uint16", ")", "(", "unsafe", ".", "Pointer", "(", "&", "reflect", ".", "SliceHeader", "{", "Data", ":", "uintptr", "(", "unsafe", ".", "Pointer", "(", "ptr", ")", ")", ",", "Len", ":", "lenUcs2", ",", "Cap", ":", "lenUcs2", "}", ")", ")", "\n", "}" ]
// ptrUcs2Slice takes a C Windows wide string and length in UCS2 // and returns it aliased as a uint16 slice.
[ "ptrUcs2Slice", "takes", "a", "C", "Windows", "wide", "string", "and", "length", "in", "UCS2", "and", "returns", "it", "aliased", "as", "a", "uint16", "slice", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libdokan/new_folder_name.go#L71-L76
161,174
keybase/client
go/kbfs/libfs/httpfs.go
Readdir
func (d *dir) Readdir(count int) (fis []os.FileInfo, err error) { d.fs.log.CDebugf(d.fs.ctx, "ReadDir %s", count) defer func() { d.fs.deferLog.CDebugf(d.fs.ctx, "ReadDir done: %+v", err) err = translateErr(err) }() return d.fs.readDir(d.node) }
go
func (d *dir) Readdir(count int) (fis []os.FileInfo, err error) { d.fs.log.CDebugf(d.fs.ctx, "ReadDir %s", count) defer func() { d.fs.deferLog.CDebugf(d.fs.ctx, "ReadDir done: %+v", err) err = translateErr(err) }() return d.fs.readDir(d.node) }
[ "func", "(", "d", "*", "dir", ")", "Readdir", "(", "count", "int", ")", "(", "fis", "[", "]", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "d", ".", "fs", ".", "log", ".", "CDebugf", "(", "d", ".", "fs", ".", "ctx", ",", "\"", "\"", ",", "count", ")", "\n", "defer", "func", "(", ")", "{", "d", ".", "fs", ".", "deferLog", ".", "CDebugf", "(", "d", ".", "fs", ".", "ctx", ",", "\"", "\"", ",", "err", ")", "\n", "err", "=", "translateErr", "(", "err", ")", "\n", "}", "(", ")", "\n\n", "return", "d", ".", "fs", ".", "readDir", "(", "d", ".", "node", ")", "\n", "}" ]
// Readdir reads children from d.
[ "Readdir", "reads", "children", "from", "d", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/httpfs.go#L19-L27
161,175
keybase/client
go/kbfs/libfs/httpfs.go
Read
func (fod fileOrDir) Read(p []byte) (n int, err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.file == nil { return 0, libkbfs.NotFileError{} } return fod.file.Read(p) }
go
func (fod fileOrDir) Read(p []byte) (n int, err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.file == nil { return 0, libkbfs.NotFileError{} } return fod.file.Read(p) }
[ "func", "(", "fod", "fileOrDir", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "err", "=", "translateErr", "(", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n", "if", "fod", ".", "file", "==", "nil", "{", "return", "0", ",", "libkbfs", ".", "NotFileError", "{", "}", "\n", "}", "\n", "return", "fod", ".", "file", ".", "Read", "(", "p", ")", "\n", "}" ]
// fileOrDir implements the http.File interface.
[ "fileOrDir", "implements", "the", "http", ".", "File", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/httpfs.go#L40-L50
161,176
keybase/client
go/kbfs/libfs/httpfs.go
Close
func (fod fileOrDir) Close() (err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.file != nil { err = fod.file.Close() } if fod.dir != nil { fod.dir.node = nil } fod.file = nil fod.dir = nil return err }
go
func (fod fileOrDir) Close() (err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.file != nil { err = fod.file.Close() } if fod.dir != nil { fod.dir.node = nil } fod.file = nil fod.dir = nil return err }
[ "func", "(", "fod", "fileOrDir", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "err", "=", "translateErr", "(", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n", "if", "fod", ".", "file", "!=", "nil", "{", "err", "=", "fod", ".", "file", ".", "Close", "(", ")", "\n", "}", "\n", "if", "fod", ".", "dir", "!=", "nil", "{", "fod", ".", "dir", ".", "node", "=", "nil", "\n", "}", "\n", "fod", ".", "file", "=", "nil", "\n", "fod", ".", "dir", "=", "nil", "\n", "return", "err", "\n", "}" ]
// Close implements the http.File interface.
[ "Close", "implements", "the", "http", ".", "File", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/httpfs.go#L53-L68
161,177
keybase/client
go/kbfs/libfs/httpfs.go
Seek
func (fod fileOrDir) Seek(offset int64, whence int) (n int64, err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.file == nil { return 0, libkbfs.NotFileError{} } return fod.file.Seek(offset, whence) }
go
func (fod fileOrDir) Seek(offset int64, whence int) (n int64, err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.file == nil { return 0, libkbfs.NotFileError{} } return fod.file.Seek(offset, whence) }
[ "func", "(", "fod", "fileOrDir", ")", "Seek", "(", "offset", "int64", ",", "whence", "int", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "err", "=", "translateErr", "(", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n", "if", "fod", ".", "file", "==", "nil", "{", "return", "0", ",", "libkbfs", ".", "NotFileError", "{", "}", "\n", "}", "\n", "return", "fod", ".", "file", ".", "Seek", "(", "offset", ",", "whence", ")", "\n", "}" ]
// Seek implements the http.File interface.
[ "Seek", "implements", "the", "http", ".", "File", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/httpfs.go#L71-L81
161,178
keybase/client
go/kbfs/libfs/httpfs.go
Readdir
func (fod fileOrDir) Readdir(count int) (fis []os.FileInfo, err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.dir == nil { return nil, libkbfs.NotDirError{} } return fod.dir.Readdir(count) }
go
func (fod fileOrDir) Readdir(count int) (fis []os.FileInfo, err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.dir == nil { return nil, libkbfs.NotDirError{} } return fod.dir.Readdir(count) }
[ "func", "(", "fod", "fileOrDir", ")", "Readdir", "(", "count", "int", ")", "(", "fis", "[", "]", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "err", "=", "translateErr", "(", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n", "if", "fod", ".", "dir", "==", "nil", "{", "return", "nil", ",", "libkbfs", ".", "NotDirError", "{", "}", "\n", "}", "\n", "return", "fod", ".", "dir", ".", "Readdir", "(", "count", ")", "\n", "}" ]
// Readdir implements the http.File interface.
[ "Readdir", "implements", "the", "http", ".", "File", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/httpfs.go#L84-L94
161,179
keybase/client
go/kbfs/libfs/httpfs.go
Stat
func (fod fileOrDir) Stat() (fi os.FileInfo, err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.file != nil { return &FileInfo{ fs: fod.file.fs, ei: fod.ei, node: fod.file.node, name: fod.file.node.GetBasename(), }, nil } else if fod.dir != nil { return &FileInfo{ fs: fod.dir.fs, ei: fod.ei, node: fod.dir.node, name: fod.dir.node.GetBasename(), }, nil } return nil, errors.New("invalid fod") }
go
func (fod fileOrDir) Stat() (fi os.FileInfo, err error) { defer func() { if err != nil { err = translateErr(err) } }() if fod.file != nil { return &FileInfo{ fs: fod.file.fs, ei: fod.ei, node: fod.file.node, name: fod.file.node.GetBasename(), }, nil } else if fod.dir != nil { return &FileInfo{ fs: fod.dir.fs, ei: fod.ei, node: fod.dir.node, name: fod.dir.node.GetBasename(), }, nil } return nil, errors.New("invalid fod") }
[ "func", "(", "fod", "fileOrDir", ")", "Stat", "(", ")", "(", "fi", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "err", "=", "translateErr", "(", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n", "if", "fod", ".", "file", "!=", "nil", "{", "return", "&", "FileInfo", "{", "fs", ":", "fod", ".", "file", ".", "fs", ",", "ei", ":", "fod", ".", "ei", ",", "node", ":", "fod", ".", "file", ".", "node", ",", "name", ":", "fod", ".", "file", ".", "node", ".", "GetBasename", "(", ")", ",", "}", ",", "nil", "\n", "}", "else", "if", "fod", ".", "dir", "!=", "nil", "{", "return", "&", "FileInfo", "{", "fs", ":", "fod", ".", "dir", ".", "fs", ",", "ei", ":", "fod", ".", "ei", ",", "node", ":", "fod", ".", "dir", ".", "node", ",", "name", ":", "fod", ".", "dir", ".", "node", ".", "GetBasename", "(", ")", ",", "}", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// Stat implements the http.File interface.
[ "Stat", "implements", "the", "http", ".", "File", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/httpfs.go#L97-L119
161,180
keybase/client
go/kbfs/libfs/httpfs.go
Open
func (hfs httpFileSystem) Open(filename string) (entry http.File, err error) { hfs.fs.log.CDebugf( hfs.fs.ctx, "hfs.Open %s", filename) defer func() { hfs.fs.deferLog.CDebugf(hfs.fs.ctx, "hfs.Open done: %+v", err) if err != nil { err = translateErr(err) } }() n, ei, err := hfs.fs.lookupOrCreateEntry(filename, os.O_RDONLY, 0600) if err != nil { return fileOrDir{}, err } if ei.Type.IsFile() { return fileOrDir{ file: &File{ fs: hfs.fs, filename: n.GetBasename(), node: n, readOnly: true, offset: 0, }, ei: ei, }, nil } return fileOrDir{ dir: &dir{ fs: hfs.fs, dirname: n.GetBasename(), node: n, }, ei: ei, }, nil }
go
func (hfs httpFileSystem) Open(filename string) (entry http.File, err error) { hfs.fs.log.CDebugf( hfs.fs.ctx, "hfs.Open %s", filename) defer func() { hfs.fs.deferLog.CDebugf(hfs.fs.ctx, "hfs.Open done: %+v", err) if err != nil { err = translateErr(err) } }() n, ei, err := hfs.fs.lookupOrCreateEntry(filename, os.O_RDONLY, 0600) if err != nil { return fileOrDir{}, err } if ei.Type.IsFile() { return fileOrDir{ file: &File{ fs: hfs.fs, filename: n.GetBasename(), node: n, readOnly: true, offset: 0, }, ei: ei, }, nil } return fileOrDir{ dir: &dir{ fs: hfs.fs, dirname: n.GetBasename(), node: n, }, ei: ei, }, nil }
[ "func", "(", "hfs", "httpFileSystem", ")", "Open", "(", "filename", "string", ")", "(", "entry", "http", ".", "File", ",", "err", "error", ")", "{", "hfs", ".", "fs", ".", "log", ".", "CDebugf", "(", "hfs", ".", "fs", ".", "ctx", ",", "\"", "\"", ",", "filename", ")", "\n", "defer", "func", "(", ")", "{", "hfs", ".", "fs", ".", "deferLog", ".", "CDebugf", "(", "hfs", ".", "fs", ".", "ctx", ",", "\"", "\"", ",", "err", ")", "\n", "if", "err", "!=", "nil", "{", "err", "=", "translateErr", "(", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "n", ",", "ei", ",", "err", ":=", "hfs", ".", "fs", ".", "lookupOrCreateEntry", "(", "filename", ",", "os", ".", "O_RDONLY", ",", "0600", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fileOrDir", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "ei", ".", "Type", ".", "IsFile", "(", ")", "{", "return", "fileOrDir", "{", "file", ":", "&", "File", "{", "fs", ":", "hfs", ".", "fs", ",", "filename", ":", "n", ".", "GetBasename", "(", ")", ",", "node", ":", "n", ",", "readOnly", ":", "true", ",", "offset", ":", "0", ",", "}", ",", "ei", ":", "ei", ",", "}", ",", "nil", "\n", "}", "\n", "return", "fileOrDir", "{", "dir", ":", "&", "dir", "{", "fs", ":", "hfs", ".", "fs", ",", "dirname", ":", "n", ".", "GetBasename", "(", ")", ",", "node", ":", "n", ",", "}", ",", "ei", ":", "ei", ",", "}", ",", "nil", "\n", "}" ]
// Open implements the http.FileSystem interface.
[ "Open", "implements", "the", "http", ".", "FileSystem", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/httpfs.go#L130-L165
161,181
keybase/client
go/chat/s3/attempt.go
Start
func (s AttemptStrategy) Start() *Attempt { now := time.Now() return &Attempt{ strategy: s, last: now, end: now.Add(s.Total), force: true, } }
go
func (s AttemptStrategy) Start() *Attempt { now := time.Now() return &Attempt{ strategy: s, last: now, end: now.Add(s.Total), force: true, } }
[ "func", "(", "s", "AttemptStrategy", ")", "Start", "(", ")", "*", "Attempt", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "return", "&", "Attempt", "{", "strategy", ":", "s", ",", "last", ":", "now", ",", "end", ":", "now", ".", "Add", "(", "s", ".", "Total", ")", ",", "force", ":", "true", ",", "}", "\n", "}" ]
// Start begins a new sequence of attempts for the given strategy.
[ "Start", "begins", "a", "new", "sequence", "of", "attempts", "for", "the", "given", "strategy", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/attempt.go#L25-L33
161,182
keybase/client
go/chat/s3/attempt.go
Next
func (a *Attempt) Next() bool { now := time.Now() sleep := a.nextSleep(now) if !a.force && !now.Add(sleep).Before(a.end) && a.strategy.Min <= a.count { return false } a.force = false if sleep > 0 && a.count > 0 { time.Sleep(sleep) now = time.Now() } a.count++ a.last = now return true }
go
func (a *Attempt) Next() bool { now := time.Now() sleep := a.nextSleep(now) if !a.force && !now.Add(sleep).Before(a.end) && a.strategy.Min <= a.count { return false } a.force = false if sleep > 0 && a.count > 0 { time.Sleep(sleep) now = time.Now() } a.count++ a.last = now return true }
[ "func", "(", "a", "*", "Attempt", ")", "Next", "(", ")", "bool", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "sleep", ":=", "a", ".", "nextSleep", "(", "now", ")", "\n", "if", "!", "a", ".", "force", "&&", "!", "now", ".", "Add", "(", "sleep", ")", ".", "Before", "(", "a", ".", "end", ")", "&&", "a", ".", "strategy", ".", "Min", "<=", "a", ".", "count", "{", "return", "false", "\n", "}", "\n", "a", ".", "force", "=", "false", "\n", "if", "sleep", ">", "0", "&&", "a", ".", "count", ">", "0", "{", "time", ".", "Sleep", "(", "sleep", ")", "\n", "now", "=", "time", ".", "Now", "(", ")", "\n", "}", "\n", "a", ".", "count", "++", "\n", "a", ".", "last", "=", "now", "\n", "return", "true", "\n", "}" ]
// Next waits until it is time to perform the next attempt or returns // false if it is time to stop trying.
[ "Next", "waits", "until", "it", "is", "time", "to", "perform", "the", "next", "attempt", "or", "returns", "false", "if", "it", "is", "time", "to", "stop", "trying", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/attempt.go#L37-L51
161,183
keybase/client
go/chat/s3/attempt.go
HasNext
func (a *Attempt) HasNext() bool { if a.force || a.strategy.Min > a.count { return true } now := time.Now() if now.Add(a.nextSleep(now)).Before(a.end) { a.force = true return true } return false }
go
func (a *Attempt) HasNext() bool { if a.force || a.strategy.Min > a.count { return true } now := time.Now() if now.Add(a.nextSleep(now)).Before(a.end) { a.force = true return true } return false }
[ "func", "(", "a", "*", "Attempt", ")", "HasNext", "(", ")", "bool", "{", "if", "a", ".", "force", "||", "a", ".", "strategy", ".", "Min", ">", "a", ".", "count", "{", "return", "true", "\n", "}", "\n", "now", ":=", "time", ".", "Now", "(", ")", "\n", "if", "now", ".", "Add", "(", "a", ".", "nextSleep", "(", "now", ")", ")", ".", "Before", "(", "a", ".", "end", ")", "{", "a", ".", "force", "=", "true", "\n", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// HasNext returns whether another attempt will be made if the current // one fails. If it returns true, the following call to Next is // guaranteed to return true.
[ "HasNext", "returns", "whether", "another", "attempt", "will", "be", "made", "if", "the", "current", "one", "fails", ".", "If", "it", "returns", "true", "the", "following", "call", "to", "Next", "is", "guaranteed", "to", "return", "true", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/attempt.go#L64-L74
161,184
keybase/client
go/stellar/note.go
noteSymmetricKey
func noteSymmetricKey(mctx libkb.MetaContext, other *keybase1.UserVersion) (res noteBuildSecret, err error) { meUV, err := mctx.G().GetMeUV(mctx.Ctx()) if err != nil { return res, err } puk1Gen, puk1Seed, err := loadOwnLatestPuk(mctx) if err != nil { return res, err } symmetricKey, err := puk1Seed.DeriveSymmetricKey(libkb.DeriveReasonPUKStellarNoteSelf) if err != nil { return res, err } var recipient *stellar1.NoteRecipient if other != nil && !other.Eq(meUV) { u2, err := loadUvUpk(mctx, *other) if err != nil { return res, fmt.Errorf("error loading recipient: %v", err) } puk2 := u2.GetLatestPerUserKey() if puk2 == nil { return res, fmt.Errorf("recipient has no per-user key") } // Overwite symmetricKey with the shared key. symmetricKey, err = noteMixKeys(mctx, puk1Seed, puk2.EncKID) if err != nil { return res, err } recipient = &stellar1.NoteRecipient{ User: *other, PukGen: keybase1.PerUserKeyGeneration(puk2.Gen), } } return noteBuildSecret{ symmetricKey: symmetricKey, sender: stellar1.NoteRecipient{ User: meUV, PukGen: puk1Gen, }, recipient: recipient, }, nil }
go
func noteSymmetricKey(mctx libkb.MetaContext, other *keybase1.UserVersion) (res noteBuildSecret, err error) { meUV, err := mctx.G().GetMeUV(mctx.Ctx()) if err != nil { return res, err } puk1Gen, puk1Seed, err := loadOwnLatestPuk(mctx) if err != nil { return res, err } symmetricKey, err := puk1Seed.DeriveSymmetricKey(libkb.DeriveReasonPUKStellarNoteSelf) if err != nil { return res, err } var recipient *stellar1.NoteRecipient if other != nil && !other.Eq(meUV) { u2, err := loadUvUpk(mctx, *other) if err != nil { return res, fmt.Errorf("error loading recipient: %v", err) } puk2 := u2.GetLatestPerUserKey() if puk2 == nil { return res, fmt.Errorf("recipient has no per-user key") } // Overwite symmetricKey with the shared key. symmetricKey, err = noteMixKeys(mctx, puk1Seed, puk2.EncKID) if err != nil { return res, err } recipient = &stellar1.NoteRecipient{ User: *other, PukGen: keybase1.PerUserKeyGeneration(puk2.Gen), } } return noteBuildSecret{ symmetricKey: symmetricKey, sender: stellar1.NoteRecipient{ User: meUV, PukGen: puk1Gen, }, recipient: recipient, }, nil }
[ "func", "noteSymmetricKey", "(", "mctx", "libkb", ".", "MetaContext", ",", "other", "*", "keybase1", ".", "UserVersion", ")", "(", "res", "noteBuildSecret", ",", "err", "error", ")", "{", "meUV", ",", "err", ":=", "mctx", ".", "G", "(", ")", ".", "GetMeUV", "(", "mctx", ".", "Ctx", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "puk1Gen", ",", "puk1Seed", ",", "err", ":=", "loadOwnLatestPuk", "(", "mctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "symmetricKey", ",", "err", ":=", "puk1Seed", ".", "DeriveSymmetricKey", "(", "libkb", ".", "DeriveReasonPUKStellarNoteSelf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "var", "recipient", "*", "stellar1", ".", "NoteRecipient", "\n", "if", "other", "!=", "nil", "&&", "!", "other", ".", "Eq", "(", "meUV", ")", "{", "u2", ",", "err", ":=", "loadUvUpk", "(", "mctx", ",", "*", "other", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "puk2", ":=", "u2", ".", "GetLatestPerUserKey", "(", ")", "\n", "if", "puk2", "==", "nil", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "// Overwite symmetricKey with the shared key.", "symmetricKey", ",", "err", "=", "noteMixKeys", "(", "mctx", ",", "puk1Seed", ",", "puk2", ".", "EncKID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "recipient", "=", "&", "stellar1", ".", "NoteRecipient", "{", "User", ":", "*", "other", ",", "PukGen", ":", "keybase1", ".", "PerUserKeyGeneration", "(", "puk2", ".", "Gen", ")", ",", "}", "\n", "}", "\n", "return", "noteBuildSecret", "{", "symmetricKey", ":", "symmetricKey", ",", "sender", ":", "stellar1", ".", "NoteRecipient", "{", "User", ":", "meUV", ",", "PukGen", ":", "puk1Gen", ",", "}", ",", "recipient", ":", "recipient", ",", "}", ",", "nil", "\n", "}" ]
// noteSymmetricKey returns a symmetric key to be used in encrypting a note. // The key is available to the current user and to the optional `other` recipient. // If `other` is nil the key is derived from the latest PUK seed. // If `other` is non-nil the key is derived from the nacl shared key of both users' latest PUK encryption keys.
[ "noteSymmetricKey", "returns", "a", "symmetric", "key", "to", "be", "used", "in", "encrypting", "a", "note", ".", "The", "key", "is", "available", "to", "the", "current", "user", "and", "to", "the", "optional", "other", "recipient", ".", "If", "other", "is", "nil", "the", "key", "is", "derived", "from", "the", "latest", "PUK", "seed", ".", "If", "other", "is", "non", "-", "nil", "the", "key", "is", "derived", "from", "the", "nacl", "shared", "key", "of", "both", "users", "latest", "PUK", "encryption", "keys", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/note.go#L27-L68
161,185
keybase/client
go/stellar/note.go
noteMixKeys
func noteMixKeys(mctx libkb.MetaContext, puk1 libkb.PerUserKeySeed, puk2EncKID keybase1.KID) (res libkb.NaclSecretBoxKey, err error) { puk1Enc, err := puk1.DeriveDHKey() if err != nil { return res, err } puk2EncGeneric, err := libkb.ImportKeypairFromKID(puk2EncKID) if err != nil { return res, err } puk2Enc, ok := puk2EncGeneric.(libkb.NaclDHKeyPair) if !ok { return res, fmt.Errorf("recipient per-user key was not a DH key") } var zeros [32]byte // This is a constant nonce used for key derivation. // The derived key will be used with one-time random nonces for the actual encryption/decryption. nonce := noteMixPukNonce() sharedSecretBox := box.Seal(nil, zeros[:], &nonce, (*[32]byte)(&puk2Enc.Public), (*[32]byte)(puk1Enc.Private)) return libkb.MakeByte32Soft(sharedSecretBox[len(sharedSecretBox)-32:]) }
go
func noteMixKeys(mctx libkb.MetaContext, puk1 libkb.PerUserKeySeed, puk2EncKID keybase1.KID) (res libkb.NaclSecretBoxKey, err error) { puk1Enc, err := puk1.DeriveDHKey() if err != nil { return res, err } puk2EncGeneric, err := libkb.ImportKeypairFromKID(puk2EncKID) if err != nil { return res, err } puk2Enc, ok := puk2EncGeneric.(libkb.NaclDHKeyPair) if !ok { return res, fmt.Errorf("recipient per-user key was not a DH key") } var zeros [32]byte // This is a constant nonce used for key derivation. // The derived key will be used with one-time random nonces for the actual encryption/decryption. nonce := noteMixPukNonce() sharedSecretBox := box.Seal(nil, zeros[:], &nonce, (*[32]byte)(&puk2Enc.Public), (*[32]byte)(puk1Enc.Private)) return libkb.MakeByte32Soft(sharedSecretBox[len(sharedSecretBox)-32:]) }
[ "func", "noteMixKeys", "(", "mctx", "libkb", ".", "MetaContext", ",", "puk1", "libkb", ".", "PerUserKeySeed", ",", "puk2EncKID", "keybase1", ".", "KID", ")", "(", "res", "libkb", ".", "NaclSecretBoxKey", ",", "err", "error", ")", "{", "puk1Enc", ",", "err", ":=", "puk1", ".", "DeriveDHKey", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "puk2EncGeneric", ",", "err", ":=", "libkb", ".", "ImportKeypairFromKID", "(", "puk2EncKID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "puk2Enc", ",", "ok", ":=", "puk2EncGeneric", ".", "(", "libkb", ".", "NaclDHKeyPair", ")", "\n", "if", "!", "ok", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "zeros", "[", "32", "]", "byte", "\n", "// This is a constant nonce used for key derivation.", "// The derived key will be used with one-time random nonces for the actual encryption/decryption.", "nonce", ":=", "noteMixPukNonce", "(", ")", "\n", "sharedSecretBox", ":=", "box", ".", "Seal", "(", "nil", ",", "zeros", "[", ":", "]", ",", "&", "nonce", ",", "(", "*", "[", "32", "]", "byte", ")", "(", "&", "puk2Enc", ".", "Public", ")", ",", "(", "*", "[", "32", "]", "byte", ")", "(", "puk1Enc", ".", "Private", ")", ")", "\n", "return", "libkb", ".", "MakeByte32Soft", "(", "sharedSecretBox", "[", "len", "(", "sharedSecretBox", ")", "-", "32", ":", "]", ")", "\n", "}" ]
// noteMixKeys derives a shared symmetric key for two DH keys. // The key is the last 32 bytes of the nacl box of 32 zeros with a use-specific nonce.
[ "noteMixKeys", "derives", "a", "shared", "symmetric", "key", "for", "two", "DH", "keys", ".", "The", "key", "is", "the", "last", "32", "bytes", "of", "the", "nacl", "box", "of", "32", "zeros", "with", "a", "use", "-", "specific", "nonce", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/note.go#L112-L131
161,186
keybase/client
go/stellar/note.go
noteMixPukNonce
func noteMixPukNonce() (res [24]byte) { reasonHash := sha256.Sum256([]byte(libkb.DeriveReasonPUKStellarNoteShared)) copy(res[:], reasonHash[:]) return res }
go
func noteMixPukNonce() (res [24]byte) { reasonHash := sha256.Sum256([]byte(libkb.DeriveReasonPUKStellarNoteShared)) copy(res[:], reasonHash[:]) return res }
[ "func", "noteMixPukNonce", "(", ")", "(", "res", "[", "24", "]", "byte", ")", "{", "reasonHash", ":=", "sha256", ".", "Sum256", "(", "[", "]", "byte", "(", "libkb", ".", "DeriveReasonPUKStellarNoteShared", ")", ")", "\n", "copy", "(", "res", "[", ":", "]", ",", "reasonHash", "[", ":", "]", ")", "\n", "return", "res", "\n", "}" ]
// noteMixPukNonce is a nonce used in key derivation for shared notes. // 24-byte prefix of the sha256 hash of a constant string.
[ "noteMixPukNonce", "is", "a", "nonce", "used", "in", "key", "derivation", "for", "shared", "notes", ".", "24", "-", "byte", "prefix", "of", "the", "sha256", "hash", "of", "a", "constant", "string", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/note.go#L135-L139
161,187
keybase/client
go/stellar/note.go
noteEncrypt
func noteEncrypt(mctx libkb.MetaContext, note stellar1.NoteContents, other *keybase1.UserVersion) (res stellar1.EncryptedNote, err error) { nbs, err := noteSymmetricKey(mctx, other) if err != nil { return res, fmt.Errorf("error getting encryption key for note: %v", err) } if nbs.symmetricKey.IsZero() { // This should never happen return res, fmt.Errorf("unexpected zero key") } res, err = noteEncryptHelper(mctx.Ctx(), note, nbs.symmetricKey) if err != nil { return res, err } res.Sender = nbs.sender res.Recipient = nbs.recipient return res, nil }
go
func noteEncrypt(mctx libkb.MetaContext, note stellar1.NoteContents, other *keybase1.UserVersion) (res stellar1.EncryptedNote, err error) { nbs, err := noteSymmetricKey(mctx, other) if err != nil { return res, fmt.Errorf("error getting encryption key for note: %v", err) } if nbs.symmetricKey.IsZero() { // This should never happen return res, fmt.Errorf("unexpected zero key") } res, err = noteEncryptHelper(mctx.Ctx(), note, nbs.symmetricKey) if err != nil { return res, err } res.Sender = nbs.sender res.Recipient = nbs.recipient return res, nil }
[ "func", "noteEncrypt", "(", "mctx", "libkb", ".", "MetaContext", ",", "note", "stellar1", ".", "NoteContents", ",", "other", "*", "keybase1", ".", "UserVersion", ")", "(", "res", "stellar1", ".", "EncryptedNote", ",", "err", "error", ")", "{", "nbs", ",", "err", ":=", "noteSymmetricKey", "(", "mctx", ",", "other", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "nbs", ".", "symmetricKey", ".", "IsZero", "(", ")", "{", "// This should never happen", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "res", ",", "err", "=", "noteEncryptHelper", "(", "mctx", ".", "Ctx", "(", ")", ",", "note", ",", "nbs", ".", "symmetricKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "res", ".", "Sender", "=", "nbs", ".", "sender", "\n", "res", ".", "Recipient", "=", "nbs", ".", "recipient", "\n", "return", "res", ",", "nil", "\n", "}" ]
// noteEncrypt encrypts a note for the logged-in user as well as optionally for `other`.
[ "noteEncrypt", "encrypts", "a", "note", "for", "the", "logged", "-", "in", "user", "as", "well", "as", "optionally", "for", "other", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/note.go#L163-L179
161,188
keybase/client
go/stellar/note.go
noteEncryptHelper
func noteEncryptHelper(ctx context.Context, note stellar1.NoteContents, symmetricKey libkb.NaclSecretBoxKey) (res stellar1.EncryptedNote, err error) { // Msgpack clearpack, err := libkb.MsgpackEncode(note) if err != nil { return res, err } // Secretbox var nonce [libkb.NaclDHNonceSize]byte nonce, err = libkb.RandomNaclDHNonce() if err != nil { return res, err } secbox := secretbox.Seal(nil, clearpack, &nonce, (*[libkb.NaclSecretBoxKeySize]byte)(&symmetricKey)) return stellar1.EncryptedNote{ V: 1, E: secbox, N: nonce, }, nil }
go
func noteEncryptHelper(ctx context.Context, note stellar1.NoteContents, symmetricKey libkb.NaclSecretBoxKey) (res stellar1.EncryptedNote, err error) { // Msgpack clearpack, err := libkb.MsgpackEncode(note) if err != nil { return res, err } // Secretbox var nonce [libkb.NaclDHNonceSize]byte nonce, err = libkb.RandomNaclDHNonce() if err != nil { return res, err } secbox := secretbox.Seal(nil, clearpack, &nonce, (*[libkb.NaclSecretBoxKeySize]byte)(&symmetricKey)) return stellar1.EncryptedNote{ V: 1, E: secbox, N: nonce, }, nil }
[ "func", "noteEncryptHelper", "(", "ctx", "context", ".", "Context", ",", "note", "stellar1", ".", "NoteContents", ",", "symmetricKey", "libkb", ".", "NaclSecretBoxKey", ")", "(", "res", "stellar1", ".", "EncryptedNote", ",", "err", "error", ")", "{", "// Msgpack", "clearpack", ",", "err", ":=", "libkb", ".", "MsgpackEncode", "(", "note", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n\n", "// Secretbox", "var", "nonce", "[", "libkb", ".", "NaclDHNonceSize", "]", "byte", "\n", "nonce", ",", "err", "=", "libkb", ".", "RandomNaclDHNonce", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "secbox", ":=", "secretbox", ".", "Seal", "(", "nil", ",", "clearpack", ",", "&", "nonce", ",", "(", "*", "[", "libkb", ".", "NaclSecretBoxKeySize", "]", "byte", ")", "(", "&", "symmetricKey", ")", ")", "\n\n", "return", "stellar1", ".", "EncryptedNote", "{", "V", ":", "1", ",", "E", ":", "secbox", ",", "N", ":", "nonce", ",", "}", ",", "nil", "\n", "}" ]
// noteEncryptHelper does the encryption part and returns a partially populated result.
[ "noteEncryptHelper", "does", "the", "encryption", "part", "and", "returns", "a", "partially", "populated", "result", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/note.go#L182-L202
161,189
keybase/client
go/kbfs/libkbfs/mdcache.go
NewMDCacheStandard
func NewMDCacheStandard(capacity int) *MDCacheStandard { mdLRU, err := lru.New(capacity) if err != nil { return nil } idLRU, err := lru.New(capacity) if err != nil { return nil } // Hard-code the nextMD cache size to something small, since only // one entry is used for each revoked device we need to verify. nextMDLRU, err := lru.New(defaultNextMDCacheCapacity) if err != nil { return nil } return &MDCacheStandard{lru: mdLRU, idLRU: idLRU, nextMDLRU: nextMDLRU} }
go
func NewMDCacheStandard(capacity int) *MDCacheStandard { mdLRU, err := lru.New(capacity) if err != nil { return nil } idLRU, err := lru.New(capacity) if err != nil { return nil } // Hard-code the nextMD cache size to something small, since only // one entry is used for each revoked device we need to verify. nextMDLRU, err := lru.New(defaultNextMDCacheCapacity) if err != nil { return nil } return &MDCacheStandard{lru: mdLRU, idLRU: idLRU, nextMDLRU: nextMDLRU} }
[ "func", "NewMDCacheStandard", "(", "capacity", "int", ")", "*", "MDCacheStandard", "{", "mdLRU", ",", "err", ":=", "lru", ".", "New", "(", "capacity", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "idLRU", ",", "err", ":=", "lru", ".", "New", "(", "capacity", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "// Hard-code the nextMD cache size to something small, since only", "// one entry is used for each revoked device we need to verify.", "nextMDLRU", ",", "err", ":=", "lru", ".", "New", "(", "defaultNextMDCacheCapacity", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "&", "MDCacheStandard", "{", "lru", ":", "mdLRU", ",", "idLRU", ":", "idLRU", ",", "nextMDLRU", ":", "nextMDLRU", "}", "\n", "}" ]
// NewMDCacheStandard constructs a new MDCacheStandard using the given // cache capacity.
[ "NewMDCacheStandard", "constructs", "a", "new", "MDCacheStandard", "using", "the", "given", "cache", "capacity", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L43-L59
161,190
keybase/client
go/kbfs/libkbfs/mdcache.go
Get
func (md *MDCacheStandard) Get(tlf tlf.ID, rev kbfsmd.Revision, bid kbfsmd.BranchID) ( ImmutableRootMetadata, error) { md.lock.RLock() defer md.lock.RUnlock() key := mdCacheKey{tlf, rev, bid} if tmp, ok := md.lru.Get(key); ok { if rmd, ok := tmp.(ImmutableRootMetadata); ok { return rmd, nil } return ImmutableRootMetadata{}, BadMDError{tlf} } return ImmutableRootMetadata{}, NoSuchMDError{tlf, rev, bid} }
go
func (md *MDCacheStandard) Get(tlf tlf.ID, rev kbfsmd.Revision, bid kbfsmd.BranchID) ( ImmutableRootMetadata, error) { md.lock.RLock() defer md.lock.RUnlock() key := mdCacheKey{tlf, rev, bid} if tmp, ok := md.lru.Get(key); ok { if rmd, ok := tmp.(ImmutableRootMetadata); ok { return rmd, nil } return ImmutableRootMetadata{}, BadMDError{tlf} } return ImmutableRootMetadata{}, NoSuchMDError{tlf, rev, bid} }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "Get", "(", "tlf", "tlf", ".", "ID", ",", "rev", "kbfsmd", ".", "Revision", ",", "bid", "kbfsmd", ".", "BranchID", ")", "(", "ImmutableRootMetadata", ",", "error", ")", "{", "md", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "md", ".", "lock", ".", "RUnlock", "(", ")", "\n", "key", ":=", "mdCacheKey", "{", "tlf", ",", "rev", ",", "bid", "}", "\n", "if", "tmp", ",", "ok", ":=", "md", ".", "lru", ".", "Get", "(", "key", ")", ";", "ok", "{", "if", "rmd", ",", "ok", ":=", "tmp", ".", "(", "ImmutableRootMetadata", ")", ";", "ok", "{", "return", "rmd", ",", "nil", "\n", "}", "\n", "return", "ImmutableRootMetadata", "{", "}", ",", "BadMDError", "{", "tlf", "}", "\n", "}", "\n", "return", "ImmutableRootMetadata", "{", "}", ",", "NoSuchMDError", "{", "tlf", ",", "rev", ",", "bid", "}", "\n", "}" ]
// Get implements the MDCache interface for MDCacheStandard.
[ "Get", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L62-L74
161,191
keybase/client
go/kbfs/libkbfs/mdcache.go
Put
func (md *MDCacheStandard) Put(rmd ImmutableRootMetadata) error { md.lock.Lock() defer md.lock.Unlock() key := mdCacheKey{rmd.TlfID(), rmd.Revision(), rmd.BID()} if _, ok := md.lru.Get(key); ok { // Don't overwrite the cache. In the case that `rmd` is // different from what's in the cache, we require that upper // layers manage the cache explicitly by deleting or replacing // it explicitly. return nil } md.lru.Add(key, rmd) return nil }
go
func (md *MDCacheStandard) Put(rmd ImmutableRootMetadata) error { md.lock.Lock() defer md.lock.Unlock() key := mdCacheKey{rmd.TlfID(), rmd.Revision(), rmd.BID()} if _, ok := md.lru.Get(key); ok { // Don't overwrite the cache. In the case that `rmd` is // different from what's in the cache, we require that upper // layers manage the cache explicitly by deleting or replacing // it explicitly. return nil } md.lru.Add(key, rmd) return nil }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "Put", "(", "rmd", "ImmutableRootMetadata", ")", "error", "{", "md", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "md", ".", "lock", ".", "Unlock", "(", ")", "\n", "key", ":=", "mdCacheKey", "{", "rmd", ".", "TlfID", "(", ")", ",", "rmd", ".", "Revision", "(", ")", ",", "rmd", ".", "BID", "(", ")", "}", "\n", "if", "_", ",", "ok", ":=", "md", ".", "lru", ".", "Get", "(", "key", ")", ";", "ok", "{", "// Don't overwrite the cache. In the case that `rmd` is", "// different from what's in the cache, we require that upper", "// layers manage the cache explicitly by deleting or replacing", "// it explicitly.", "return", "nil", "\n", "}", "\n", "md", ".", "lru", ".", "Add", "(", "key", ",", "rmd", ")", "\n", "return", "nil", "\n", "}" ]
// Put implements the MDCache interface for MDCacheStandard.
[ "Put", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L77-L90
161,192
keybase/client
go/kbfs/libkbfs/mdcache.go
Delete
func (md *MDCacheStandard) Delete(tlf tlf.ID, rev kbfsmd.Revision, bid kbfsmd.BranchID) { md.lock.Lock() defer md.lock.Unlock() key := mdCacheKey{tlf, rev, bid} md.lru.Remove(key) }
go
func (md *MDCacheStandard) Delete(tlf tlf.ID, rev kbfsmd.Revision, bid kbfsmd.BranchID) { md.lock.Lock() defer md.lock.Unlock() key := mdCacheKey{tlf, rev, bid} md.lru.Remove(key) }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "Delete", "(", "tlf", "tlf", ".", "ID", ",", "rev", "kbfsmd", ".", "Revision", ",", "bid", "kbfsmd", ".", "BranchID", ")", "{", "md", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "md", ".", "lock", ".", "Unlock", "(", ")", "\n", "key", ":=", "mdCacheKey", "{", "tlf", ",", "rev", ",", "bid", "}", "\n", "md", ".", "lru", ".", "Remove", "(", "key", ")", "\n", "}" ]
// Delete implements the MDCache interface for MDCacheStandard.
[ "Delete", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L93-L99
161,193
keybase/client
go/kbfs/libkbfs/mdcache.go
Replace
func (md *MDCacheStandard) Replace(newRmd ImmutableRootMetadata, oldBID kbfsmd.BranchID) error { md.lock.Lock() defer md.lock.Unlock() oldKey := mdCacheKey{newRmd.TlfID(), newRmd.Revision(), oldBID} newKey := mdCacheKey{newRmd.TlfID(), newRmd.Revision(), newRmd.BID()} // TODO: implement our own LRU where we can replace the old data // without affecting the LRU status. md.lru.Remove(oldKey) md.lru.Add(newKey, newRmd) return nil }
go
func (md *MDCacheStandard) Replace(newRmd ImmutableRootMetadata, oldBID kbfsmd.BranchID) error { md.lock.Lock() defer md.lock.Unlock() oldKey := mdCacheKey{newRmd.TlfID(), newRmd.Revision(), oldBID} newKey := mdCacheKey{newRmd.TlfID(), newRmd.Revision(), newRmd.BID()} // TODO: implement our own LRU where we can replace the old data // without affecting the LRU status. md.lru.Remove(oldKey) md.lru.Add(newKey, newRmd) return nil }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "Replace", "(", "newRmd", "ImmutableRootMetadata", ",", "oldBID", "kbfsmd", ".", "BranchID", ")", "error", "{", "md", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "md", ".", "lock", ".", "Unlock", "(", ")", "\n", "oldKey", ":=", "mdCacheKey", "{", "newRmd", ".", "TlfID", "(", ")", ",", "newRmd", ".", "Revision", "(", ")", ",", "oldBID", "}", "\n", "newKey", ":=", "mdCacheKey", "{", "newRmd", ".", "TlfID", "(", ")", ",", "newRmd", ".", "Revision", "(", ")", ",", "newRmd", ".", "BID", "(", ")", "}", "\n", "// TODO: implement our own LRU where we can replace the old data", "// without affecting the LRU status.", "md", ".", "lru", ".", "Remove", "(", "oldKey", ")", "\n", "md", ".", "lru", ".", "Add", "(", "newKey", ",", "newRmd", ")", "\n", "return", "nil", "\n", "}" ]
// Replace implements the MDCache interface for MDCacheStandard.
[ "Replace", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L102-L113
161,194
keybase/client
go/kbfs/libkbfs/mdcache.go
MarkPutToServer
func (md *MDCacheStandard) MarkPutToServer( tlf tlf.ID, rev kbfsmd.Revision, bid kbfsmd.BranchID) { md.lock.Lock() defer md.lock.Unlock() key := mdCacheKey{tlf, rev, bid} tmp, ok := md.lru.Get(key) if !ok { return } rmd, ok := tmp.(ImmutableRootMetadata) if !ok { return } rmd.putToServer = true md.lru.Add(key, rmd) }
go
func (md *MDCacheStandard) MarkPutToServer( tlf tlf.ID, rev kbfsmd.Revision, bid kbfsmd.BranchID) { md.lock.Lock() defer md.lock.Unlock() key := mdCacheKey{tlf, rev, bid} tmp, ok := md.lru.Get(key) if !ok { return } rmd, ok := tmp.(ImmutableRootMetadata) if !ok { return } rmd.putToServer = true md.lru.Add(key, rmd) }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "MarkPutToServer", "(", "tlf", "tlf", ".", "ID", ",", "rev", "kbfsmd", ".", "Revision", ",", "bid", "kbfsmd", ".", "BranchID", ")", "{", "md", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "md", ".", "lock", ".", "Unlock", "(", ")", "\n", "key", ":=", "mdCacheKey", "{", "tlf", ",", "rev", ",", "bid", "}", "\n", "tmp", ",", "ok", ":=", "md", ".", "lru", ".", "Get", "(", "key", ")", "\n", "if", "!", "ok", "{", "return", "\n", "}", "\n", "rmd", ",", "ok", ":=", "tmp", ".", "(", "ImmutableRootMetadata", ")", "\n", "if", "!", "ok", "{", "return", "\n", "}", "\n", "rmd", ".", "putToServer", "=", "true", "\n", "md", ".", "lru", ".", "Add", "(", "key", ",", "rmd", ")", "\n", "}" ]
// MarkPutToServer implements the MDCache interface for // MDCacheStandard.
[ "MarkPutToServer", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L117-L132
161,195
keybase/client
go/kbfs/libkbfs/mdcache.go
GetIDForHandle
func (md *MDCacheStandard) GetIDForHandle(handle *tlfhandle.Handle) (tlf.ID, error) { md.lock.RLock() defer md.lock.RUnlock() key := handle.GetCanonicalPath() tmp, ok := md.idLRU.Get(key) if !ok { return tlf.NullID, NoSuchTlfIDError{handle} } id, ok := tmp.(tlf.ID) if !ok { return tlf.NullID, errors.Errorf("Bad ID for handle %s", key) } return id, nil }
go
func (md *MDCacheStandard) GetIDForHandle(handle *tlfhandle.Handle) (tlf.ID, error) { md.lock.RLock() defer md.lock.RUnlock() key := handle.GetCanonicalPath() tmp, ok := md.idLRU.Get(key) if !ok { return tlf.NullID, NoSuchTlfIDError{handle} } id, ok := tmp.(tlf.ID) if !ok { return tlf.NullID, errors.Errorf("Bad ID for handle %s", key) } return id, nil }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "GetIDForHandle", "(", "handle", "*", "tlfhandle", ".", "Handle", ")", "(", "tlf", ".", "ID", ",", "error", ")", "{", "md", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "md", ".", "lock", ".", "RUnlock", "(", ")", "\n", "key", ":=", "handle", ".", "GetCanonicalPath", "(", ")", "\n", "tmp", ",", "ok", ":=", "md", ".", "idLRU", ".", "Get", "(", "key", ")", "\n", "if", "!", "ok", "{", "return", "tlf", ".", "NullID", ",", "NoSuchTlfIDError", "{", "handle", "}", "\n", "}", "\n", "id", ",", "ok", ":=", "tmp", ".", "(", "tlf", ".", "ID", ")", "\n", "if", "!", "ok", "{", "return", "tlf", ".", "NullID", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "return", "id", ",", "nil", "\n", "}" ]
// GetIDForHandle implements the MDCache interface for // MDCacheStandard.
[ "GetIDForHandle", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L136-L149
161,196
keybase/client
go/kbfs/libkbfs/mdcache.go
PutIDForHandle
func (md *MDCacheStandard) PutIDForHandle(handle *tlfhandle.Handle, id tlf.ID) error { md.lock.RLock() defer md.lock.RUnlock() key := handle.GetCanonicalPath() md.idLRU.Add(key, id) return nil }
go
func (md *MDCacheStandard) PutIDForHandle(handle *tlfhandle.Handle, id tlf.ID) error { md.lock.RLock() defer md.lock.RUnlock() key := handle.GetCanonicalPath() md.idLRU.Add(key, id) return nil }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "PutIDForHandle", "(", "handle", "*", "tlfhandle", ".", "Handle", ",", "id", "tlf", ".", "ID", ")", "error", "{", "md", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "md", ".", "lock", ".", "RUnlock", "(", ")", "\n", "key", ":=", "handle", ".", "GetCanonicalPath", "(", ")", "\n", "md", ".", "idLRU", ".", "Add", "(", "key", ",", "id", ")", "\n", "return", "nil", "\n", "}" ]
// PutIDForHandle implements the MDCache interface for // MDCacheStandard.
[ "PutIDForHandle", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L153-L159
161,197
keybase/client
go/kbfs/libkbfs/mdcache.go
ChangeHandleForID
func (md *MDCacheStandard) ChangeHandleForID( oldHandle *tlfhandle.Handle, newHandle *tlfhandle.Handle) { md.lock.RLock() defer md.lock.RUnlock() oldKey := oldHandle.GetCanonicalPath() tmp, ok := md.idLRU.Get(oldKey) if !ok { return } md.idLRU.Remove(oldKey) newKey := newHandle.GetCanonicalPath() md.idLRU.Add(newKey, tmp) return }
go
func (md *MDCacheStandard) ChangeHandleForID( oldHandle *tlfhandle.Handle, newHandle *tlfhandle.Handle) { md.lock.RLock() defer md.lock.RUnlock() oldKey := oldHandle.GetCanonicalPath() tmp, ok := md.idLRU.Get(oldKey) if !ok { return } md.idLRU.Remove(oldKey) newKey := newHandle.GetCanonicalPath() md.idLRU.Add(newKey, tmp) return }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "ChangeHandleForID", "(", "oldHandle", "*", "tlfhandle", ".", "Handle", ",", "newHandle", "*", "tlfhandle", ".", "Handle", ")", "{", "md", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "md", ".", "lock", ".", "RUnlock", "(", ")", "\n", "oldKey", ":=", "oldHandle", ".", "GetCanonicalPath", "(", ")", "\n", "tmp", ",", "ok", ":=", "md", ".", "idLRU", ".", "Get", "(", "oldKey", ")", "\n", "if", "!", "ok", "{", "return", "\n", "}", "\n", "md", ".", "idLRU", ".", "Remove", "(", "oldKey", ")", "\n", "newKey", ":=", "newHandle", ".", "GetCanonicalPath", "(", ")", "\n", "md", ".", "idLRU", ".", "Add", "(", "newKey", ",", "tmp", ")", "\n", "return", "\n", "}" ]
// ChangeHandleForID implements the MDCache interface for // MDCacheStandard.
[ "ChangeHandleForID", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L163-L176
161,198
keybase/client
go/kbfs/libkbfs/mdcache.go
GetNextMD
func (md *MDCacheStandard) GetNextMD(tlfID tlf.ID, rootSeqno keybase1.Seqno) ( nextKbfsRoot *kbfsmd.MerkleRoot, nextMerkleNodes [][]byte, nextRootSeqno keybase1.Seqno, err error) { key := mdcacheNextMDKey{tlfID, rootSeqno} tmp, ok := md.nextMDLRU.Get(key) if !ok { return nil, nil, 0, NextMDNotCachedError{tlfID, rootSeqno} } val, ok := tmp.(mdcacheNextMDVal) if !ok { return nil, nil, 0, errors.Errorf( "Bad next MD for %s, seqno=%d", tlfID, rootSeqno) } return val.nextKbfsRoot, val.nextMerkleNodes, val.nextRootSeqno, nil }
go
func (md *MDCacheStandard) GetNextMD(tlfID tlf.ID, rootSeqno keybase1.Seqno) ( nextKbfsRoot *kbfsmd.MerkleRoot, nextMerkleNodes [][]byte, nextRootSeqno keybase1.Seqno, err error) { key := mdcacheNextMDKey{tlfID, rootSeqno} tmp, ok := md.nextMDLRU.Get(key) if !ok { return nil, nil, 0, NextMDNotCachedError{tlfID, rootSeqno} } val, ok := tmp.(mdcacheNextMDVal) if !ok { return nil, nil, 0, errors.Errorf( "Bad next MD for %s, seqno=%d", tlfID, rootSeqno) } return val.nextKbfsRoot, val.nextMerkleNodes, val.nextRootSeqno, nil }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "GetNextMD", "(", "tlfID", "tlf", ".", "ID", ",", "rootSeqno", "keybase1", ".", "Seqno", ")", "(", "nextKbfsRoot", "*", "kbfsmd", ".", "MerkleRoot", ",", "nextMerkleNodes", "[", "]", "[", "]", "byte", ",", "nextRootSeqno", "keybase1", ".", "Seqno", ",", "err", "error", ")", "{", "key", ":=", "mdcacheNextMDKey", "{", "tlfID", ",", "rootSeqno", "}", "\n", "tmp", ",", "ok", ":=", "md", ".", "nextMDLRU", ".", "Get", "(", "key", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "nil", ",", "0", ",", "NextMDNotCachedError", "{", "tlfID", ",", "rootSeqno", "}", "\n", "}", "\n", "val", ",", "ok", ":=", "tmp", ".", "(", "mdcacheNextMDVal", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "nil", ",", "0", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "tlfID", ",", "rootSeqno", ")", "\n", "}", "\n", "return", "val", ".", "nextKbfsRoot", ",", "val", ".", "nextMerkleNodes", ",", "val", ".", "nextRootSeqno", ",", "nil", "\n", "}" ]
// GetNextMD implements the MDCache interface for MDCacheStandard.
[ "GetNextMD", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L190-L204
161,199
keybase/client
go/kbfs/libkbfs/mdcache.go
PutNextMD
func (md *MDCacheStandard) PutNextMD( tlfID tlf.ID, rootSeqno keybase1.Seqno, nextKbfsRoot *kbfsmd.MerkleRoot, nextMerkleNodes [][]byte, nextRootSeqno keybase1.Seqno) error { key := mdcacheNextMDKey{tlfID, rootSeqno} val := mdcacheNextMDVal{nextKbfsRoot, nextMerkleNodes, nextRootSeqno} md.nextMDLRU.Add(key, val) return nil }
go
func (md *MDCacheStandard) PutNextMD( tlfID tlf.ID, rootSeqno keybase1.Seqno, nextKbfsRoot *kbfsmd.MerkleRoot, nextMerkleNodes [][]byte, nextRootSeqno keybase1.Seqno) error { key := mdcacheNextMDKey{tlfID, rootSeqno} val := mdcacheNextMDVal{nextKbfsRoot, nextMerkleNodes, nextRootSeqno} md.nextMDLRU.Add(key, val) return nil }
[ "func", "(", "md", "*", "MDCacheStandard", ")", "PutNextMD", "(", "tlfID", "tlf", ".", "ID", ",", "rootSeqno", "keybase1", ".", "Seqno", ",", "nextKbfsRoot", "*", "kbfsmd", ".", "MerkleRoot", ",", "nextMerkleNodes", "[", "]", "[", "]", "byte", ",", "nextRootSeqno", "keybase1", ".", "Seqno", ")", "error", "{", "key", ":=", "mdcacheNextMDKey", "{", "tlfID", ",", "rootSeqno", "}", "\n", "val", ":=", "mdcacheNextMDVal", "{", "nextKbfsRoot", ",", "nextMerkleNodes", ",", "nextRootSeqno", "}", "\n", "md", ".", "nextMDLRU", ".", "Add", "(", "key", ",", "val", ")", "\n", "return", "nil", "\n", "}" ]
// PutNextMD implements the MDCache interface for MDCacheStandard.
[ "PutNextMD", "implements", "the", "MDCache", "interface", "for", "MDCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdcache.go#L207-L214