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
160,200
keybase/client
go/kbfs/libkbfs/disk_block_cache.go
Shutdown
func (cache *DiskBlockCacheLocal) Shutdown(ctx context.Context) { // Wait for the cache to either finish starting or error. select { case <-cache.startedCh: case <-cache.startErrCh: return } cache.lock.Lock() defer cache.lock.Unlock() // shutdownCh has to be checked under lock, otherwise we can race. select { case <-cache.shutdownCh: cache.log.CWarningf(ctx, "Shutdown called more than once") default: } close(cache.shutdownCh) if cache.blockDb == nil { return } cache.closer() cache.blockDb = nil cache.metaDb = nil cache.tlfDb = nil if cache.useLimiter() { cache.config.DiskLimiter().onSimpleByteTrackerDisable(ctx, cache.cacheType, int64(cache.getCurrBytes())) } cache.hitMeter.Shutdown() cache.missMeter.Shutdown() cache.putMeter.Shutdown() cache.updateMeter.Shutdown() cache.evictCountMeter.Shutdown() cache.evictSizeMeter.Shutdown() cache.deleteCountMeter.Shutdown() cache.deleteSizeMeter.Shutdown() }
go
func (cache *DiskBlockCacheLocal) Shutdown(ctx context.Context) { // Wait for the cache to either finish starting or error. select { case <-cache.startedCh: case <-cache.startErrCh: return } cache.lock.Lock() defer cache.lock.Unlock() // shutdownCh has to be checked under lock, otherwise we can race. select { case <-cache.shutdownCh: cache.log.CWarningf(ctx, "Shutdown called more than once") default: } close(cache.shutdownCh) if cache.blockDb == nil { return } cache.closer() cache.blockDb = nil cache.metaDb = nil cache.tlfDb = nil if cache.useLimiter() { cache.config.DiskLimiter().onSimpleByteTrackerDisable(ctx, cache.cacheType, int64(cache.getCurrBytes())) } cache.hitMeter.Shutdown() cache.missMeter.Shutdown() cache.putMeter.Shutdown() cache.updateMeter.Shutdown() cache.evictCountMeter.Shutdown() cache.evictSizeMeter.Shutdown() cache.deleteCountMeter.Shutdown() cache.deleteSizeMeter.Shutdown() }
[ "func", "(", "cache", "*", "DiskBlockCacheLocal", ")", "Shutdown", "(", "ctx", "context", ".", "Context", ")", "{", "// Wait for the cache to either finish starting or error.", "select", "{", "case", "<-", "cache", ".", "startedCh", ":", "case", "<-", "cache", ".", "startErrCh", ":", "return", "\n", "}", "\n", "cache", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", "lock", ".", "Unlock", "(", ")", "\n", "// shutdownCh has to be checked under lock, otherwise we can race.", "select", "{", "case", "<-", "cache", ".", "shutdownCh", ":", "cache", ".", "log", ".", "CWarningf", "(", "ctx", ",", "\"", "\"", ")", "\n", "default", ":", "}", "\n", "close", "(", "cache", ".", "shutdownCh", ")", "\n", "if", "cache", ".", "blockDb", "==", "nil", "{", "return", "\n", "}", "\n", "cache", ".", "closer", "(", ")", "\n", "cache", ".", "blockDb", "=", "nil", "\n", "cache", ".", "metaDb", "=", "nil", "\n", "cache", ".", "tlfDb", "=", "nil", "\n", "if", "cache", ".", "useLimiter", "(", ")", "{", "cache", ".", "config", ".", "DiskLimiter", "(", ")", ".", "onSimpleByteTrackerDisable", "(", "ctx", ",", "cache", ".", "cacheType", ",", "int64", "(", "cache", ".", "getCurrBytes", "(", ")", ")", ")", "\n", "}", "\n", "cache", ".", "hitMeter", ".", "Shutdown", "(", ")", "\n", "cache", ".", "missMeter", ".", "Shutdown", "(", ")", "\n", "cache", ".", "putMeter", ".", "Shutdown", "(", ")", "\n", "cache", ".", "updateMeter", ".", "Shutdown", "(", ")", "\n", "cache", ".", "evictCountMeter", ".", "Shutdown", "(", ")", "\n", "cache", ".", "evictSizeMeter", ".", "Shutdown", "(", ")", "\n", "cache", ".", "deleteCountMeter", ".", "Shutdown", "(", ")", "\n", "cache", ".", "deleteSizeMeter", ".", "Shutdown", "(", ")", "\n", "}" ]
// Shutdown implements the DiskBlockCache interface for DiskBlockCacheLocal.
[ "Shutdown", "implements", "the", "DiskBlockCache", "interface", "for", "DiskBlockCacheLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache.go#L1462-L1497
160,201
keybase/client
go/teams/seitan.go
ParseSeitanTokenFromPaste
func ParseSeitanTokenFromPaste(token string) (string, bool) { // If the person pasted the whole seitan SMS message in, then let's parse out the token if strings.Contains(token, "token: ") { m := tokenPasteRegexp.FindStringSubmatch(token) if len(m) == 1 { return strings.Split(m[0], " ")[1], true } return token, true } if IsSeitany(token) { return token, true } return token, false }
go
func ParseSeitanTokenFromPaste(token string) (string, bool) { // If the person pasted the whole seitan SMS message in, then let's parse out the token if strings.Contains(token, "token: ") { m := tokenPasteRegexp.FindStringSubmatch(token) if len(m) == 1 { return strings.Split(m[0], " ")[1], true } return token, true } if IsSeitany(token) { return token, true } return token, false }
[ "func", "ParseSeitanTokenFromPaste", "(", "token", "string", ")", "(", "string", ",", "bool", ")", "{", "// If the person pasted the whole seitan SMS message in, then let's parse out the token", "if", "strings", ".", "Contains", "(", "token", ",", "\"", "\"", ")", "{", "m", ":=", "tokenPasteRegexp", ".", "FindStringSubmatch", "(", "token", ")", "\n", "if", "len", "(", "m", ")", "==", "1", "{", "return", "strings", ".", "Split", "(", "m", "[", "0", "]", ",", "\"", "\"", ")", "[", "1", "]", ",", "true", "\n", "}", "\n", "return", "token", ",", "true", "\n", "}", "\n", "if", "IsSeitany", "(", "token", ")", "{", "return", "token", ",", "true", "\n", "}", "\n", "return", "token", ",", "false", "\n", "}" ]
// Returns the string that might be the token, and whether the content looked like a token paste.
[ "Returns", "the", "string", "that", "might", "be", "the", "token", "and", "whether", "the", "content", "looked", "like", "a", "token", "paste", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/seitan.go#L101-L114
160,202
keybase/client
go/teams/seitan.go
ParseIKeyFromString
func ParseIKeyFromString(token string) (ikey SeitanIKey, err error) { if len(token) != SeitanEncodedIKeyLength { return ikey, fmt.Errorf("invalid token length: expected %d characters, got %d", SeitanEncodedIKeyLength, len(token)) } if token[seitanEncodedIKeyPlusOffset] != '+' { return ikey, fmt.Errorf("invalid token format: expected %dth character to be '+'", seitanEncodedIKeyPlusOffset+1) } return SeitanIKey(strings.ToLower(token)), nil }
go
func ParseIKeyFromString(token string) (ikey SeitanIKey, err error) { if len(token) != SeitanEncodedIKeyLength { return ikey, fmt.Errorf("invalid token length: expected %d characters, got %d", SeitanEncodedIKeyLength, len(token)) } if token[seitanEncodedIKeyPlusOffset] != '+' { return ikey, fmt.Errorf("invalid token format: expected %dth character to be '+'", seitanEncodedIKeyPlusOffset+1) } return SeitanIKey(strings.ToLower(token)), nil }
[ "func", "ParseIKeyFromString", "(", "token", "string", ")", "(", "ikey", "SeitanIKey", ",", "err", "error", ")", "{", "if", "len", "(", "token", ")", "!=", "SeitanEncodedIKeyLength", "{", "return", "ikey", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "SeitanEncodedIKeyLength", ",", "len", "(", "token", ")", ")", "\n", "}", "\n", "if", "token", "[", "seitanEncodedIKeyPlusOffset", "]", "!=", "'+'", "{", "return", "ikey", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "seitanEncodedIKeyPlusOffset", "+", "1", ")", "\n", "}", "\n\n", "return", "SeitanIKey", "(", "strings", ".", "ToLower", "(", "token", ")", ")", ",", "nil", "\n", "}" ]
// ParseIKeyFromString safely creates SeitanIKey value from // plaintext string. Only format is checked - any 18-character token // with '+' character at position 5 can be "Invite Key". Alphabet is // not checked, as it is only a hint for token generation and it can // change over time, but we assume that token length stays the same.
[ "ParseIKeyFromString", "safely", "creates", "SeitanIKey", "value", "from", "plaintext", "string", ".", "Only", "format", "is", "checked", "-", "any", "18", "-", "character", "token", "with", "+", "character", "at", "position", "5", "can", "be", "Invite", "Key", ".", "Alphabet", "is", "not", "checked", "as", "it", "is", "only", "a", "hint", "for", "token", "generation", "and", "it", "can", "change", "over", "time", "but", "we", "assume", "that", "token", "length", "stays", "the", "same", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/seitan.go#L121-L130
160,203
keybase/client
go/kbfs/kbfsmd/extra_metadata.go
DumpExtraMetadata
func DumpExtraMetadata( codec kbfscodec.Codec, extra ExtraMetadata) (string, error) { var s string switch extra := extra.(type) { case *ExtraMetadataV3: serializedWKB, err := codec.Encode(extra.GetWriterKeyBundle()) if err != nil { return "", err } serializedRKB, err := codec.Encode(extra.GetReaderKeyBundle()) if err != nil { return "", err } s = fmt.Sprintf("WKB size: %d\nRKB size: %d\n", len(serializedWKB), len(serializedRKB)) } s += DumpConfig().Sdump(extra) return s, nil }
go
func DumpExtraMetadata( codec kbfscodec.Codec, extra ExtraMetadata) (string, error) { var s string switch extra := extra.(type) { case *ExtraMetadataV3: serializedWKB, err := codec.Encode(extra.GetWriterKeyBundle()) if err != nil { return "", err } serializedRKB, err := codec.Encode(extra.GetReaderKeyBundle()) if err != nil { return "", err } s = fmt.Sprintf("WKB size: %d\nRKB size: %d\n", len(serializedWKB), len(serializedRKB)) } s += DumpConfig().Sdump(extra) return s, nil }
[ "func", "DumpExtraMetadata", "(", "codec", "kbfscodec", ".", "Codec", ",", "extra", "ExtraMetadata", ")", "(", "string", ",", "error", ")", "{", "var", "s", "string", "\n", "switch", "extra", ":=", "extra", ".", "(", "type", ")", "{", "case", "*", "ExtraMetadataV3", ":", "serializedWKB", ",", "err", ":=", "codec", ".", "Encode", "(", "extra", ".", "GetWriterKeyBundle", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "serializedRKB", ",", "err", ":=", "codec", ".", "Encode", "(", "extra", ".", "GetReaderKeyBundle", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "s", "=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\\n", "\"", ",", "len", "(", "serializedWKB", ")", ",", "len", "(", "serializedRKB", ")", ")", "\n", "}", "\n\n", "s", "+=", "DumpConfig", "(", ")", ".", "Sdump", "(", "extra", ")", "\n", "return", "s", ",", "nil", "\n", "}" ]
// DumpExtraMetadata returns a detailed dump of the given // ExtraMetadata's contents.
[ "DumpExtraMetadata", "returns", "a", "detailed", "dump", "of", "the", "given", "ExtraMetadata", "s", "contents", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/extra_metadata.go#L24-L43
160,204
keybase/client
go/teams/list.go
verifyMemberRoleInTeam
func verifyMemberRoleInTeam(ctx context.Context, userID keybase1.UID, expectedRole keybase1.TeamRole, team *Team) (res keybase1.UserVersion, err error) { if expectedRole == keybase1.TeamRole_NONE { return res, nil } memberUV, err := team.chain().GetLatestUVWithUID(userID) if err != nil { return res, err } role, err := team.chain().GetUserRole(memberUV) if err != nil { return res, err } if role != expectedRole { return res, fmt.Errorf("unexpected member role: expected %v but actual role is %v", expectedRole, role) } return memberUV, nil }
go
func verifyMemberRoleInTeam(ctx context.Context, userID keybase1.UID, expectedRole keybase1.TeamRole, team *Team) (res keybase1.UserVersion, err error) { if expectedRole == keybase1.TeamRole_NONE { return res, nil } memberUV, err := team.chain().GetLatestUVWithUID(userID) if err != nil { return res, err } role, err := team.chain().GetUserRole(memberUV) if err != nil { return res, err } if role != expectedRole { return res, fmt.Errorf("unexpected member role: expected %v but actual role is %v", expectedRole, role) } return memberUV, nil }
[ "func", "verifyMemberRoleInTeam", "(", "ctx", "context", ".", "Context", ",", "userID", "keybase1", ".", "UID", ",", "expectedRole", "keybase1", ".", "TeamRole", ",", "team", "*", "Team", ")", "(", "res", "keybase1", ".", "UserVersion", ",", "err", "error", ")", "{", "if", "expectedRole", "==", "keybase1", ".", "TeamRole_NONE", "{", "return", "res", ",", "nil", "\n", "}", "\n\n", "memberUV", ",", "err", ":=", "team", ".", "chain", "(", ")", ".", "GetLatestUVWithUID", "(", "userID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "role", ",", "err", ":=", "team", ".", "chain", "(", ")", ".", "GetUserRole", "(", "memberUV", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "if", "role", "!=", "expectedRole", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "expectedRole", ",", "role", ")", "\n", "}", "\n", "return", "memberUV", ",", "nil", "\n", "}" ]
// verifyMemberRoleInTeam checks if role give in MemberInfo matches // what team chain says. Nothing is checked when MemberInfo's role is // NONE, in this context it means that user has implied membership in // the team and no role given in sigchain.
[ "verifyMemberRoleInTeam", "checks", "if", "role", "give", "in", "MemberInfo", "matches", "what", "team", "chain", "says", ".", "Nothing", "is", "checked", "when", "MemberInfo", "s", "role", "is", "NONE", "in", "this", "context", "it", "means", "that", "user", "has", "implied", "membership", "in", "the", "team", "and", "no", "role", "given", "in", "sigchain", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/list.go#L64-L82
160,205
keybase/client
go/kbfs/kbfsblock/id.go
IDFromString
func IDFromString(idStr string) (ID, error) { h, err := kbfshash.HashFromString(idStr) if err != nil { return ID{}, err } return ID{h}, nil }
go
func IDFromString(idStr string) (ID, error) { h, err := kbfshash.HashFromString(idStr) if err != nil { return ID{}, err } return ID{h}, nil }
[ "func", "IDFromString", "(", "idStr", "string", ")", "(", "ID", ",", "error", ")", "{", "h", ",", "err", ":=", "kbfshash", ".", "HashFromString", "(", "idStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ID", "{", "}", ",", "err", "\n", "}", "\n", "return", "ID", "{", "h", "}", ",", "nil", "\n", "}" ]
// IDFromString creates a ID from the given string. If the // returned error is nil, the returned ID is valid.
[ "IDFromString", "creates", "a", "ID", "from", "the", "given", "string", ".", "If", "the", "returned", "error", "is", "nil", "the", "returned", "ID", "is", "valid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L40-L46
160,206
keybase/client
go/kbfs/kbfsblock/id.go
IDFromBytes
func IDFromBytes(idBytes []byte) (ID, error) { h, err := kbfshash.HashFromBytes(idBytes) if err != nil { return ID{}, err } return ID{h}, nil }
go
func IDFromBytes(idBytes []byte) (ID, error) { h, err := kbfshash.HashFromBytes(idBytes) if err != nil { return ID{}, err } return ID{h}, nil }
[ "func", "IDFromBytes", "(", "idBytes", "[", "]", "byte", ")", "(", "ID", ",", "error", ")", "{", "h", ",", "err", ":=", "kbfshash", ".", "HashFromBytes", "(", "idBytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ID", "{", "}", ",", "err", "\n", "}", "\n", "return", "ID", "{", "h", "}", ",", "nil", "\n", "}" ]
// IDFromBytes creates a ID from the given bytes. If the returned error is nil, // the returned ID is valid.
[ "IDFromBytes", "creates", "a", "ID", "from", "the", "given", "bytes", ".", "If", "the", "returned", "error", "is", "nil", "the", "returned", "ID", "is", "valid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L50-L56
160,207
keybase/client
go/kbfs/kbfsblock/id.go
MarshalBinary
func (id ID) MarshalBinary() (data []byte, err error) { return id.h.MarshalBinary() }
go
func (id ID) MarshalBinary() (data []byte, err error) { return id.h.MarshalBinary() }
[ "func", "(", "id", "ID", ")", "MarshalBinary", "(", ")", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "return", "id", ".", "h", ".", "MarshalBinary", "(", ")", "\n", "}" ]
// MarshalBinary implements the encoding.BinaryMarshaler interface for // ID. Returns an error if the ID is invalid and not the zero // ID.
[ "MarshalBinary", "implements", "the", "encoding", ".", "BinaryMarshaler", "interface", "for", "ID", ".", "Returns", "an", "error", "if", "the", "ID", "is", "invalid", "and", "not", "the", "zero", "ID", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L76-L78
160,208
keybase/client
go/kbfs/kbfsblock/id.go
UnmarshalBinary
func (id *ID) UnmarshalBinary(data []byte) error { return id.h.UnmarshalBinary(data) }
go
func (id *ID) UnmarshalBinary(data []byte) error { return id.h.UnmarshalBinary(data) }
[ "func", "(", "id", "*", "ID", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "return", "id", ".", "h", ".", "UnmarshalBinary", "(", "data", ")", "\n", "}" ]
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface // for ID. Returns an error if the given byte array is non-empty and // the ID is invalid.
[ "UnmarshalBinary", "implements", "the", "encoding", ".", "BinaryUnmarshaler", "interface", "for", "ID", ".", "Returns", "an", "error", "if", "the", "given", "byte", "array", "is", "non", "-", "empty", "and", "the", "ID", "is", "invalid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L83-L85
160,209
keybase/client
go/kbfs/kbfsblock/id.go
MakeTemporaryID
func MakeTemporaryID() (ID, error) { var dh kbfshash.RawDefaultHash err := kbfscrypto.RandRead(dh[:]) if err != nil { return ID{}, err } h, err := kbfshash.HashFromRaw(kbfshash.DefaultHashType, dh[:]) if err != nil { return ID{}, err } return ID{h}, nil }
go
func MakeTemporaryID() (ID, error) { var dh kbfshash.RawDefaultHash err := kbfscrypto.RandRead(dh[:]) if err != nil { return ID{}, err } h, err := kbfshash.HashFromRaw(kbfshash.DefaultHashType, dh[:]) if err != nil { return ID{}, err } return ID{h}, nil }
[ "func", "MakeTemporaryID", "(", ")", "(", "ID", ",", "error", ")", "{", "var", "dh", "kbfshash", ".", "RawDefaultHash", "\n", "err", ":=", "kbfscrypto", ".", "RandRead", "(", "dh", "[", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ID", "{", "}", ",", "err", "\n", "}", "\n", "h", ",", "err", ":=", "kbfshash", ".", "HashFromRaw", "(", "kbfshash", ".", "DefaultHashType", ",", "dh", "[", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ID", "{", "}", ",", "err", "\n", "}", "\n", "return", "ID", "{", "h", "}", ",", "nil", "\n", "}" ]
// MakeTemporaryID generates a temporary block ID using a CSPRNG. This // is used for indirect blocks before they're committed to the server.
[ "MakeTemporaryID", "generates", "a", "temporary", "block", "ID", "using", "a", "CSPRNG", ".", "This", "is", "used", "for", "indirect", "blocks", "before", "they", "re", "committed", "to", "the", "server", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L105-L116
160,210
keybase/client
go/kbfs/kbfsblock/id.go
MakePermanentID
func MakePermanentID( encodedEncryptedData []byte, encryptionVer kbfscrypto.EncryptionVer) ( ID, error) { h, err := kbfshash.DoHash( encodedEncryptedData, encryptionVer.ToHashType()) if err != nil { return ID{}, err } return ID{h}, nil }
go
func MakePermanentID( encodedEncryptedData []byte, encryptionVer kbfscrypto.EncryptionVer) ( ID, error) { h, err := kbfshash.DoHash( encodedEncryptedData, encryptionVer.ToHashType()) if err != nil { return ID{}, err } return ID{h}, nil }
[ "func", "MakePermanentID", "(", "encodedEncryptedData", "[", "]", "byte", ",", "encryptionVer", "kbfscrypto", ".", "EncryptionVer", ")", "(", "ID", ",", "error", ")", "{", "h", ",", "err", ":=", "kbfshash", ".", "DoHash", "(", "encodedEncryptedData", ",", "encryptionVer", ".", "ToHashType", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ID", "{", "}", ",", "err", "\n", "}", "\n", "return", "ID", "{", "h", "}", ",", "nil", "\n", "}" ]
// MakePermanentID computes the permanent ID of a block given its // encoded and encrypted contents.
[ "MakePermanentID", "computes", "the", "permanent", "ID", "of", "a", "block", "given", "its", "encoded", "and", "encrypted", "contents", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L165-L174
160,211
keybase/client
go/kbfs/kbfsblock/id.go
VerifyID
func VerifyID(encodedEncryptedData []byte, id ID) error { return id.h.Verify(encodedEncryptedData) }
go
func VerifyID(encodedEncryptedData []byte, id ID) error { return id.h.Verify(encodedEncryptedData) }
[ "func", "VerifyID", "(", "encodedEncryptedData", "[", "]", "byte", ",", "id", "ID", ")", "error", "{", "return", "id", ".", "h", ".", "Verify", "(", "encodedEncryptedData", ")", "\n", "}" ]
// VerifyID verifies that the given block ID is the permanent block ID // for the given encoded and encrypted data.
[ "VerifyID", "verifies", "that", "the", "given", "block", "ID", "is", "the", "permanent", "block", "ID", "for", "the", "given", "encoded", "and", "encrypted", "data", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L178-L180
160,212
keybase/client
go/kbfs/kbfsblock/id.go
FakeID
func FakeID(b byte) ID { dh := kbfshash.RawDefaultHash{b} h, err := kbfshash.HashFromRaw(kbfshash.DefaultHashType, dh[:]) if err != nil { panic(err) } return ID{h} }
go
func FakeID(b byte) ID { dh := kbfshash.RawDefaultHash{b} h, err := kbfshash.HashFromRaw(kbfshash.DefaultHashType, dh[:]) if err != nil { panic(err) } return ID{h} }
[ "func", "FakeID", "(", "b", "byte", ")", "ID", "{", "dh", ":=", "kbfshash", ".", "RawDefaultHash", "{", "b", "}", "\n", "h", ",", "err", ":=", "kbfshash", ".", "HashFromRaw", "(", "kbfshash", ".", "DefaultHashType", ",", "dh", "[", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "ID", "{", "h", "}", "\n", "}" ]
// FakeID returns an ID derived from the given byte, suitable for // testing.
[ "FakeID", "returns", "an", "ID", "derived", "from", "the", "given", "byte", "suitable", "for", "testing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L184-L191
160,213
keybase/client
go/kbfs/kbfsblock/id.go
FakeIDAdd
func FakeIDAdd(id ID, b byte) ID { return FakeID(id.h.Bytes()[1] + b) }
go
func FakeIDAdd(id ID, b byte) ID { return FakeID(id.h.Bytes()[1] + b) }
[ "func", "FakeIDAdd", "(", "id", "ID", ",", "b", "byte", ")", "ID", "{", "return", "FakeID", "(", "id", ".", "h", ".", "Bytes", "(", ")", "[", "1", "]", "+", "b", ")", "\n", "}" ]
// FakeIDAdd returns an ID derived from the given ID and the given // byte, suitable for testing.
[ "FakeIDAdd", "returns", "an", "ID", "derived", "from", "the", "given", "ID", "and", "the", "given", "byte", "suitable", "for", "testing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/id.go#L195-L197
160,214
keybase/client
go/teams/chain.go
GetUserRoleAtSeqno
func (t TeamSigChainState) GetUserRoleAtSeqno(user keybase1.UserVersion, seqno keybase1.Seqno) (keybase1.TeamRole, error) { role := keybase1.TeamRole_NONE if seqno <= 0 { return role, fmt.Errorf("seqno %v is less than 1", seqno) } for _, point := range t.inner.UserLog[user] { if point.SigMeta.SigChainLocation.Seqno > seqno { return role, nil } role = point.Role } return role, nil }
go
func (t TeamSigChainState) GetUserRoleAtSeqno(user keybase1.UserVersion, seqno keybase1.Seqno) (keybase1.TeamRole, error) { role := keybase1.TeamRole_NONE if seqno <= 0 { return role, fmt.Errorf("seqno %v is less than 1", seqno) } for _, point := range t.inner.UserLog[user] { if point.SigMeta.SigChainLocation.Seqno > seqno { return role, nil } role = point.Role } return role, nil }
[ "func", "(", "t", "TeamSigChainState", ")", "GetUserRoleAtSeqno", "(", "user", "keybase1", ".", "UserVersion", ",", "seqno", "keybase1", ".", "Seqno", ")", "(", "keybase1", ".", "TeamRole", ",", "error", ")", "{", "role", ":=", "keybase1", ".", "TeamRole_NONE", "\n", "if", "seqno", "<=", "0", "{", "return", "role", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "seqno", ")", "\n", "}", "\n", "for", "_", ",", "point", ":=", "range", "t", ".", "inner", ".", "UserLog", "[", "user", "]", "{", "if", "point", ".", "SigMeta", ".", "SigChainLocation", ".", "Seqno", ">", "seqno", "{", "return", "role", ",", "nil", "\n", "}", "\n", "role", "=", "point", ".", "Role", "\n", "}", "\n", "return", "role", ",", "nil", "\n", "}" ]
// Get the user's role right after link at seqno was processed.
[ "Get", "the", "user", "s", "role", "right", "after", "link", "at", "seqno", "was", "processed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L119-L131
160,215
keybase/client
go/teams/chain.go
findRoleDowngrade
func findRoleDowngrade(points []keybase1.UserLogPoint, role keybase1.TeamRole) *keybase1.SignatureMetadata { for _, p := range points { if !p.Role.IsOrAbove(role) { return &p.SigMeta } } return nil }
go
func findRoleDowngrade(points []keybase1.UserLogPoint, role keybase1.TeamRole) *keybase1.SignatureMetadata { for _, p := range points { if !p.Role.IsOrAbove(role) { return &p.SigMeta } } return nil }
[ "func", "findRoleDowngrade", "(", "points", "[", "]", "keybase1", ".", "UserLogPoint", ",", "role", "keybase1", ".", "TeamRole", ")", "*", "keybase1", ".", "SignatureMetadata", "{", "for", "_", ",", "p", ":=", "range", "points", "{", "if", "!", "p", ".", "Role", ".", "IsOrAbove", "(", "role", ")", "{", "return", "&", "p", ".", "SigMeta", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Find a point where the role is taken away.
[ "Find", "a", "point", "where", "the", "role", "is", "taken", "away", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L188-L195
160,216
keybase/client
go/teams/chain.go
AssertWasRoleOrAboveAt
func (t TeamSigChainState) AssertWasRoleOrAboveAt(uv keybase1.UserVersion, role keybase1.TeamRole, scl keybase1.SigChainLocation) (err error) { mkErr := func(format string, args ...interface{}) error { msg := fmt.Sprintf(format, args...) if role.IsOrAbove(keybase1.TeamRole_ADMIN) { return NewAdminPermissionError(t.GetID(), uv, msg) } return NewPermissionError(t.GetID(), uv, msg) } if scl.Seqno < keybase1.Seqno(0) { return mkErr("negative seqno: %v", scl.Seqno) } points := t.inner.UserLog[uv] for i := len(points) - 1; i >= 0; i-- { point := points[i] if err := point.SigMeta.SigChainLocation.Comparable(scl); err != nil { return mkErr(err.Error()) } if point.SigMeta.SigChainLocation.LessThanOrEqualTo(scl) && point.Role.IsOrAbove(role) { // OK great, we found a point with the role in the log that's less than or equal to the given one. // But now we reverse and go forward, and check that it wasn't revoked or downgraded. // If so, that's a problem! if right := findRoleDowngrade(points[(i+1):], role); right != nil && right.SigChainLocation.LessThanOrEqualTo(scl) { return mkErr("%v permission was downgraded too soon!", role) } return nil } } return mkErr("%v role point not found", role) }
go
func (t TeamSigChainState) AssertWasRoleOrAboveAt(uv keybase1.UserVersion, role keybase1.TeamRole, scl keybase1.SigChainLocation) (err error) { mkErr := func(format string, args ...interface{}) error { msg := fmt.Sprintf(format, args...) if role.IsOrAbove(keybase1.TeamRole_ADMIN) { return NewAdminPermissionError(t.GetID(), uv, msg) } return NewPermissionError(t.GetID(), uv, msg) } if scl.Seqno < keybase1.Seqno(0) { return mkErr("negative seqno: %v", scl.Seqno) } points := t.inner.UserLog[uv] for i := len(points) - 1; i >= 0; i-- { point := points[i] if err := point.SigMeta.SigChainLocation.Comparable(scl); err != nil { return mkErr(err.Error()) } if point.SigMeta.SigChainLocation.LessThanOrEqualTo(scl) && point.Role.IsOrAbove(role) { // OK great, we found a point with the role in the log that's less than or equal to the given one. // But now we reverse and go forward, and check that it wasn't revoked or downgraded. // If so, that's a problem! if right := findRoleDowngrade(points[(i+1):], role); right != nil && right.SigChainLocation.LessThanOrEqualTo(scl) { return mkErr("%v permission was downgraded too soon!", role) } return nil } } return mkErr("%v role point not found", role) }
[ "func", "(", "t", "TeamSigChainState", ")", "AssertWasRoleOrAboveAt", "(", "uv", "keybase1", ".", "UserVersion", ",", "role", "keybase1", ".", "TeamRole", ",", "scl", "keybase1", ".", "SigChainLocation", ")", "(", "err", "error", ")", "{", "mkErr", ":=", "func", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "args", "...", ")", "\n", "if", "role", ".", "IsOrAbove", "(", "keybase1", ".", "TeamRole_ADMIN", ")", "{", "return", "NewAdminPermissionError", "(", "t", ".", "GetID", "(", ")", ",", "uv", ",", "msg", ")", "\n", "}", "\n", "return", "NewPermissionError", "(", "t", ".", "GetID", "(", ")", ",", "uv", ",", "msg", ")", "\n", "}", "\n", "if", "scl", ".", "Seqno", "<", "keybase1", ".", "Seqno", "(", "0", ")", "{", "return", "mkErr", "(", "\"", "\"", ",", "scl", ".", "Seqno", ")", "\n", "}", "\n", "points", ":=", "t", ".", "inner", ".", "UserLog", "[", "uv", "]", "\n", "for", "i", ":=", "len", "(", "points", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "point", ":=", "points", "[", "i", "]", "\n", "if", "err", ":=", "point", ".", "SigMeta", ".", "SigChainLocation", ".", "Comparable", "(", "scl", ")", ";", "err", "!=", "nil", "{", "return", "mkErr", "(", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "if", "point", ".", "SigMeta", ".", "SigChainLocation", ".", "LessThanOrEqualTo", "(", "scl", ")", "&&", "point", ".", "Role", ".", "IsOrAbove", "(", "role", ")", "{", "// OK great, we found a point with the role in the log that's less than or equal to the given one.", "// But now we reverse and go forward, and check that it wasn't revoked or downgraded.", "// If so, that's a problem!", "if", "right", ":=", "findRoleDowngrade", "(", "points", "[", "(", "i", "+", "1", ")", ":", "]", ",", "role", ")", ";", "right", "!=", "nil", "&&", "right", ".", "SigChainLocation", ".", "LessThanOrEqualTo", "(", "scl", ")", "{", "return", "mkErr", "(", "\"", "\"", ",", "role", ")", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "}", "\n", "return", "mkErr", "(", "\"", "\"", ",", "role", ")", "\n", "}" ]
// AssertWasRoleOrAboveAt asserts that user `uv` had `role` or above on the // team just after the given SigChainLocation `scl`. // We start at the point given, go backwards until we find a promotion, // then go forwards to make sure there wasn't a demotion before the specified time. // If there was, return a PermissionError. If no adminship was found at all, return a PermissionError.
[ "AssertWasRoleOrAboveAt", "asserts", "that", "user", "uv", "had", "role", "or", "above", "on", "the", "team", "just", "after", "the", "given", "SigChainLocation", "scl", ".", "We", "start", "at", "the", "point", "given", "go", "backwards", "until", "we", "find", "a", "promotion", "then", "go", "forwards", "to", "make", "sure", "there", "wasn", "t", "a", "demotion", "before", "the", "specified", "time", ".", "If", "there", "was", "return", "a", "PermissionError", ".", "If", "no", "adminship", "was", "found", "at", "all", "return", "a", "PermissionError", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L202-L231
160,217
keybase/client
go/teams/chain.go
IsLinkFilled
func (t TeamSigChainState) IsLinkFilled(seqno keybase1.Seqno) bool { if seqno > t.inner.LastSeqno { return false } if seqno < 0 { return false } return !t.inner.StubbedLinks[seqno] }
go
func (t TeamSigChainState) IsLinkFilled(seqno keybase1.Seqno) bool { if seqno > t.inner.LastSeqno { return false } if seqno < 0 { return false } return !t.inner.StubbedLinks[seqno] }
[ "func", "(", "t", "TeamSigChainState", ")", "IsLinkFilled", "(", "seqno", "keybase1", ".", "Seqno", ")", "bool", "{", "if", "seqno", ">", "t", ".", "inner", ".", "LastSeqno", "{", "return", "false", "\n", "}", "\n", "if", "seqno", "<", "0", "{", "return", "false", "\n", "}", "\n", "return", "!", "t", ".", "inner", ".", "StubbedLinks", "[", "seqno", "]", "\n", "}" ]
// Whether the link has been processed and is not stubbed.
[ "Whether", "the", "link", "has", "been", "processed", "and", "is", "not", "stubbed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L324-L332
160,218
keybase/client
go/teams/chain.go
inform
func (t *TeamSigChainState) inform(u keybase1.UserVersion, role keybase1.TeamRole, sigMeta keybase1.SignatureMetadata) { currentRole := t.getUserRole(u) if currentRole == role { // no change in role, now new checkpoint needed return } t.inner.UserLog[u] = append(t.inner.UserLog[u], keybase1.UserLogPoint{ Role: role, SigMeta: sigMeta, }) }
go
func (t *TeamSigChainState) inform(u keybase1.UserVersion, role keybase1.TeamRole, sigMeta keybase1.SignatureMetadata) { currentRole := t.getUserRole(u) if currentRole == role { // no change in role, now new checkpoint needed return } t.inner.UserLog[u] = append(t.inner.UserLog[u], keybase1.UserLogPoint{ Role: role, SigMeta: sigMeta, }) }
[ "func", "(", "t", "*", "TeamSigChainState", ")", "inform", "(", "u", "keybase1", ".", "UserVersion", ",", "role", "keybase1", ".", "TeamRole", ",", "sigMeta", "keybase1", ".", "SignatureMetadata", ")", "{", "currentRole", ":=", "t", ".", "getUserRole", "(", "u", ")", "\n", "if", "currentRole", "==", "role", "{", "// no change in role, now new checkpoint needed", "return", "\n", "}", "\n", "t", ".", "inner", ".", "UserLog", "[", "u", "]", "=", "append", "(", "t", ".", "inner", ".", "UserLog", "[", "u", "]", ",", "keybase1", ".", "UserLogPoint", "{", "Role", ":", "role", ",", "SigMeta", ":", "sigMeta", ",", "}", ")", "\n", "}" ]
// Inform the UserLog of a user's role. // Mutates the UserLog. // Must be called with seqno's and events in correct order. // Idempotent if called correctly.
[ "Inform", "the", "UserLog", "of", "a", "user", "s", "role", ".", "Mutates", "the", "UserLog", ".", "Must", "be", "called", "with", "seqno", "s", "and", "events", "in", "correct", "order", ".", "Idempotent", "if", "called", "correctly", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L350-L360
160,219
keybase/client
go/teams/chain.go
ListSubteams
func (t *TeamSigChainState) ListSubteams() (res []keybase1.TeamIDAndName) { type Entry struct { ID keybase1.TeamID Name keybase1.TeamName // Seqno of the last cached rename of this team Seqno keybase1.Seqno } // Use a map to deduplicate names. If there is a subteam name // collision, take the one with the latest (parent) seqno // modifying its name. // A collision could occur if you were removed from a team // and miss its renaming or deletion to stubbing. resMap := make(map[string] /*TeamName*/ Entry) for subteamID, points := range t.inner.SubteamLog { if len(points) == 0 { // this should never happen continue } lastPoint := points[len(points)-1] if lastPoint.Name.IsNil() { // the subteam has been deleted continue } entry := Entry{ ID: subteamID, Name: lastPoint.Name, Seqno: lastPoint.Seqno, } existing, ok := resMap[entry.Name.String()] replace := !ok || (entry.Seqno >= existing.Seqno) if replace { resMap[entry.Name.String()] = entry } } for _, entry := range resMap { res = append(res, keybase1.TeamIDAndName{ Id: entry.ID, Name: entry.Name, }) } return res }
go
func (t *TeamSigChainState) ListSubteams() (res []keybase1.TeamIDAndName) { type Entry struct { ID keybase1.TeamID Name keybase1.TeamName // Seqno of the last cached rename of this team Seqno keybase1.Seqno } // Use a map to deduplicate names. If there is a subteam name // collision, take the one with the latest (parent) seqno // modifying its name. // A collision could occur if you were removed from a team // and miss its renaming or deletion to stubbing. resMap := make(map[string] /*TeamName*/ Entry) for subteamID, points := range t.inner.SubteamLog { if len(points) == 0 { // this should never happen continue } lastPoint := points[len(points)-1] if lastPoint.Name.IsNil() { // the subteam has been deleted continue } entry := Entry{ ID: subteamID, Name: lastPoint.Name, Seqno: lastPoint.Seqno, } existing, ok := resMap[entry.Name.String()] replace := !ok || (entry.Seqno >= existing.Seqno) if replace { resMap[entry.Name.String()] = entry } } for _, entry := range resMap { res = append(res, keybase1.TeamIDAndName{ Id: entry.ID, Name: entry.Name, }) } return res }
[ "func", "(", "t", "*", "TeamSigChainState", ")", "ListSubteams", "(", ")", "(", "res", "[", "]", "keybase1", ".", "TeamIDAndName", ")", "{", "type", "Entry", "struct", "{", "ID", "keybase1", ".", "TeamID", "\n", "Name", "keybase1", ".", "TeamName", "\n", "// Seqno of the last cached rename of this team", "Seqno", "keybase1", ".", "Seqno", "\n", "}", "\n", "// Use a map to deduplicate names. If there is a subteam name", "// collision, take the one with the latest (parent) seqno", "// modifying its name.", "// A collision could occur if you were removed from a team", "// and miss its renaming or deletion to stubbing.", "resMap", ":=", "make", "(", "map", "[", "string", "]", "/*TeamName*/", "Entry", ")", "\n", "for", "subteamID", ",", "points", ":=", "range", "t", ".", "inner", ".", "SubteamLog", "{", "if", "len", "(", "points", ")", "==", "0", "{", "// this should never happen", "continue", "\n", "}", "\n", "lastPoint", ":=", "points", "[", "len", "(", "points", ")", "-", "1", "]", "\n", "if", "lastPoint", ".", "Name", ".", "IsNil", "(", ")", "{", "// the subteam has been deleted", "continue", "\n", "}", "\n", "entry", ":=", "Entry", "{", "ID", ":", "subteamID", ",", "Name", ":", "lastPoint", ".", "Name", ",", "Seqno", ":", "lastPoint", ".", "Seqno", ",", "}", "\n", "existing", ",", "ok", ":=", "resMap", "[", "entry", ".", "Name", ".", "String", "(", ")", "]", "\n", "replace", ":=", "!", "ok", "||", "(", "entry", ".", "Seqno", ">=", "existing", ".", "Seqno", ")", "\n", "if", "replace", "{", "resMap", "[", "entry", ".", "Name", ".", "String", "(", ")", "]", "=", "entry", "\n", "}", "\n", "}", "\n", "for", "_", ",", "entry", ":=", "range", "resMap", "{", "res", "=", "append", "(", "res", ",", "keybase1", ".", "TeamIDAndName", "{", "Id", ":", "entry", ".", "ID", ",", "Name", ":", "entry", ".", "Name", ",", "}", ")", "\n", "}", "\n", "return", "res", "\n", "}" ]
// Only call this on a Team that has been loaded with NeedAdmin. // Otherwise, you might get incoherent answers due to links that // were stubbed over the life of the cached object. // // For subteams that you were removed from, this list may // still include them because your removal was stubbed. // The list will not contain duplicate names. // Since this should only be called when you are an admin, // none of that should really come up, but it's here just to be less fragile.
[ "Only", "call", "this", "on", "a", "Team", "that", "has", "been", "loaded", "with", "NeedAdmin", ".", "Otherwise", "you", "might", "get", "incoherent", "answers", "due", "to", "links", "that", "were", "stubbed", "over", "the", "life", "of", "the", "cached", "object", ".", "For", "subteams", "that", "you", "were", "removed", "from", "this", "list", "may", "still", "include", "them", "because", "your", "removal", "was", "stubbed", ".", "The", "list", "will", "not", "contain", "duplicate", "names", ".", "Since", "this", "should", "only", "be", "called", "when", "you", "are", "an", "admin", "none", "of", "that", "should", "really", "come", "up", "but", "it", "s", "here", "just", "to", "be", "less", "fragile", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L447-L488
160,220
keybase/client
go/teams/chain.go
SubteamRenameOccurred
func (t *TeamSigChainState) SubteamRenameOccurred( subteamID keybase1.TeamID, newName keybase1.TeamName, seqno keybase1.Seqno) error { points := t.inner.SubteamLog[subteamID] if len(points) == 0 { return fmt.Errorf("subteam %v has no name log", subteamID) } for _, point := range points { if point.Seqno == seqno { if point.Name.LastPart().Eq(newName.LastPart()) { // found it! return nil } } if point.Seqno > seqno { break } } return fmt.Errorf("subteam %v did not have rename entry in log: %v %v", subteamID, newName, seqno) }
go
func (t *TeamSigChainState) SubteamRenameOccurred( subteamID keybase1.TeamID, newName keybase1.TeamName, seqno keybase1.Seqno) error { points := t.inner.SubteamLog[subteamID] if len(points) == 0 { return fmt.Errorf("subteam %v has no name log", subteamID) } for _, point := range points { if point.Seqno == seqno { if point.Name.LastPart().Eq(newName.LastPart()) { // found it! return nil } } if point.Seqno > seqno { break } } return fmt.Errorf("subteam %v did not have rename entry in log: %v %v", subteamID, newName, seqno) }
[ "func", "(", "t", "*", "TeamSigChainState", ")", "SubteamRenameOccurred", "(", "subteamID", "keybase1", ".", "TeamID", ",", "newName", "keybase1", ".", "TeamName", ",", "seqno", "keybase1", ".", "Seqno", ")", "error", "{", "points", ":=", "t", ".", "inner", ".", "SubteamLog", "[", "subteamID", "]", "\n", "if", "len", "(", "points", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "subteamID", ")", "\n", "}", "\n", "for", "_", ",", "point", ":=", "range", "points", "{", "if", "point", ".", "Seqno", "==", "seqno", "{", "if", "point", ".", "Name", ".", "LastPart", "(", ")", ".", "Eq", "(", "newName", ".", "LastPart", "(", ")", ")", "{", "// found it!", "return", "nil", "\n", "}", "\n", "}", "\n", "if", "point", ".", "Seqno", ">", "seqno", "{", "break", "\n", "}", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "subteamID", ",", "newName", ",", "seqno", ")", "\n", "}" ]
// Check that a subteam rename occurred just so. // That the subteam `subteamID` got a new name `newName` at exactly `seqno` in this, // the parent, chain. // Note this only checks against the last part of `newName` because mid-team renames are such a pain. // This is currently linear in the number of times that subteam has been renamed. // It should be easy to add an index if need be.
[ "Check", "that", "a", "subteam", "rename", "occurred", "just", "so", ".", "That", "the", "subteam", "subteamID", "got", "a", "new", "name", "newName", "at", "exactly", "seqno", "in", "this", "the", "parent", "chain", ".", "Note", "this", "only", "checks", "against", "the", "last", "part", "of", "newName", "because", "mid", "-", "team", "renames", "are", "such", "a", "pain", ".", "This", "is", "currently", "linear", "in", "the", "number", "of", "times", "that", "subteam", "has", "been", "renamed", ".", "It", "should", "be", "easy", "to", "add", "an", "index", "if", "need", "be", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L496-L516
160,221
keybase/client
go/teams/chain.go
InflateLink
func InflateLink(ctx context.Context, g *libkb.GlobalContext, reader keybase1.UserVersion, state TeamSigChainState, link *ChainLinkUnpacked, signer SignerX) (res TeamSigChainState, err error) { if link.isStubbed() { return TeamSigChainState{}, NewStubbedError(link) } if link.Seqno() > state.GetLatestSeqno() { return TeamSigChainState{}, NewInflateErrorWithNote(link, fmt.Sprintf("seqno off the chain %v > %v", link.Seqno(), state.GetLatestSeqno())) } // Check the that the link id matches our stubbed record. seenLinkID, err := state.GetLibkbLinkIDBySeqno(link.Seqno()) if err != nil { return TeamSigChainState{}, err } if !seenLinkID.Eq(link.LinkID()) { return TeamSigChainState{}, NewInflateErrorWithNote(link, fmt.Sprintf("link id mismatch: %v != %v", link.LinkID().String(), seenLinkID.String())) } // Check that the link has not already been inflated. if _, ok := state.inner.StubbedLinks[link.Seqno()]; !ok { return TeamSigChainState{}, NewInflateErrorWithNote(link, "already inflated") } t := &teamSigchainPlayer{ Contextified: libkb.NewContextified(g), reader: reader, } iRes, err := t.addInnerLink(&state, link, signer, true) if err != nil { return TeamSigChainState{}, err } delete(iRes.newState.inner.StubbedLinks, link.Seqno()) return iRes.newState, nil }
go
func InflateLink(ctx context.Context, g *libkb.GlobalContext, reader keybase1.UserVersion, state TeamSigChainState, link *ChainLinkUnpacked, signer SignerX) (res TeamSigChainState, err error) { if link.isStubbed() { return TeamSigChainState{}, NewStubbedError(link) } if link.Seqno() > state.GetLatestSeqno() { return TeamSigChainState{}, NewInflateErrorWithNote(link, fmt.Sprintf("seqno off the chain %v > %v", link.Seqno(), state.GetLatestSeqno())) } // Check the that the link id matches our stubbed record. seenLinkID, err := state.GetLibkbLinkIDBySeqno(link.Seqno()) if err != nil { return TeamSigChainState{}, err } if !seenLinkID.Eq(link.LinkID()) { return TeamSigChainState{}, NewInflateErrorWithNote(link, fmt.Sprintf("link id mismatch: %v != %v", link.LinkID().String(), seenLinkID.String())) } // Check that the link has not already been inflated. if _, ok := state.inner.StubbedLinks[link.Seqno()]; !ok { return TeamSigChainState{}, NewInflateErrorWithNote(link, "already inflated") } t := &teamSigchainPlayer{ Contextified: libkb.NewContextified(g), reader: reader, } iRes, err := t.addInnerLink(&state, link, signer, true) if err != nil { return TeamSigChainState{}, err } delete(iRes.newState.inner.StubbedLinks, link.Seqno()) return iRes.newState, nil }
[ "func", "InflateLink", "(", "ctx", "context", ".", "Context", ",", "g", "*", "libkb", ".", "GlobalContext", ",", "reader", "keybase1", ".", "UserVersion", ",", "state", "TeamSigChainState", ",", "link", "*", "ChainLinkUnpacked", ",", "signer", "SignerX", ")", "(", "res", "TeamSigChainState", ",", "err", "error", ")", "{", "if", "link", ".", "isStubbed", "(", ")", "{", "return", "TeamSigChainState", "{", "}", ",", "NewStubbedError", "(", "link", ")", "\n", "}", "\n", "if", "link", ".", "Seqno", "(", ")", ">", "state", ".", "GetLatestSeqno", "(", ")", "{", "return", "TeamSigChainState", "{", "}", ",", "NewInflateErrorWithNote", "(", "link", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "link", ".", "Seqno", "(", ")", ",", "state", ".", "GetLatestSeqno", "(", ")", ")", ")", "\n", "}", "\n\n", "// Check the that the link id matches our stubbed record.", "seenLinkID", ",", "err", ":=", "state", ".", "GetLibkbLinkIDBySeqno", "(", "link", ".", "Seqno", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "TeamSigChainState", "{", "}", ",", "err", "\n", "}", "\n", "if", "!", "seenLinkID", ".", "Eq", "(", "link", ".", "LinkID", "(", ")", ")", "{", "return", "TeamSigChainState", "{", "}", ",", "NewInflateErrorWithNote", "(", "link", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "link", ".", "LinkID", "(", ")", ".", "String", "(", ")", ",", "seenLinkID", ".", "String", "(", ")", ")", ")", "\n", "}", "\n\n", "// Check that the link has not already been inflated.", "if", "_", ",", "ok", ":=", "state", ".", "inner", ".", "StubbedLinks", "[", "link", ".", "Seqno", "(", ")", "]", ";", "!", "ok", "{", "return", "TeamSigChainState", "{", "}", ",", "NewInflateErrorWithNote", "(", "link", ",", "\"", "\"", ")", "\n", "}", "\n\n", "t", ":=", "&", "teamSigchainPlayer", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "reader", ":", "reader", ",", "}", "\n", "iRes", ",", "err", ":=", "t", ".", "addInnerLink", "(", "&", "state", ",", "link", ",", "signer", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "return", "TeamSigChainState", "{", "}", ",", "err", "\n", "}", "\n\n", "delete", "(", "iRes", ".", "newState", ".", "inner", ".", "StubbedLinks", ",", "link", ".", "Seqno", "(", ")", ")", "\n\n", "return", "iRes", ".", "newState", ",", "nil", "\n\n", "}" ]
// InflateLink adds the full inner link for a link that has already been added in stubbed form. // `state` is moved into this function. There must exist no live references into it from now on.
[ "InflateLink", "adds", "the", "full", "inner", "link", "for", "a", "link", "that", "has", "already", "been", "added", "in", "stubbed", "form", ".", "state", "is", "moved", "into", "this", "function", ".", "There", "must", "exist", "no", "live", "references", "into", "it", "from", "now", "on", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L601-L639
160,222
keybase/client
go/teams/chain.go
appendChainLinkHelper
func (t *teamSigchainPlayer) appendChainLinkHelper( ctx context.Context, prevState *TeamSigChainState, link *ChainLinkUnpacked, signer *SignerX) ( res TeamSigChainState, err error) { err = t.checkOuterLink(ctx, prevState, link) if err != nil { return res, fmt.Errorf("team sigchain outer link: %s", err) } var newState *TeamSigChainState if link.isStubbed() { if prevState == nil { return res, NewStubbedErrorWithNote(link, "first link cannot be stubbed") } newState2 := prevState.DeepCopy() newState = &newState2 } else { if signer == nil || !signer.signer.Uid.Exists() { return res, NewInvalidLink(link, "signing user not provided for team link") } iRes, err := t.addInnerLink(prevState, link, *signer, false) if err != nil { return res, err } newState = &iRes.newState } newState.inner.LastSeqno = link.Seqno() newState.inner.LastLinkID = link.LinkID().Export() newState.inner.LinkIDs[link.Seqno()] = link.LinkID().Export() if link.isStubbed() { newState.inner.StubbedLinks[link.Seqno()] = true } // Store the head merkle sequence to the DB, for use in the audit mechanism. // For the purposes of testing, we disable this feature, so we can check // the lazy-repopulation scheme for old stored teams (without a full cache bust). if link.Seqno() == keybase1.Seqno(1) && !link.isStubbed() && !t.G().Env.Test.TeamNoHeadMerkleStore { tmp := link.inner.Body.MerkleRoot.ToMerkleRootV2() newState.inner.HeadMerkle = &tmp } if !link.isStubbed() && newState.inner.MerkleRoots != nil { newState.inner.MerkleRoots[link.Seqno()] = link.inner.Body.MerkleRoot.ToMerkleRootV2() } return *newState, nil }
go
func (t *teamSigchainPlayer) appendChainLinkHelper( ctx context.Context, prevState *TeamSigChainState, link *ChainLinkUnpacked, signer *SignerX) ( res TeamSigChainState, err error) { err = t.checkOuterLink(ctx, prevState, link) if err != nil { return res, fmt.Errorf("team sigchain outer link: %s", err) } var newState *TeamSigChainState if link.isStubbed() { if prevState == nil { return res, NewStubbedErrorWithNote(link, "first link cannot be stubbed") } newState2 := prevState.DeepCopy() newState = &newState2 } else { if signer == nil || !signer.signer.Uid.Exists() { return res, NewInvalidLink(link, "signing user not provided for team link") } iRes, err := t.addInnerLink(prevState, link, *signer, false) if err != nil { return res, err } newState = &iRes.newState } newState.inner.LastSeqno = link.Seqno() newState.inner.LastLinkID = link.LinkID().Export() newState.inner.LinkIDs[link.Seqno()] = link.LinkID().Export() if link.isStubbed() { newState.inner.StubbedLinks[link.Seqno()] = true } // Store the head merkle sequence to the DB, for use in the audit mechanism. // For the purposes of testing, we disable this feature, so we can check // the lazy-repopulation scheme for old stored teams (without a full cache bust). if link.Seqno() == keybase1.Seqno(1) && !link.isStubbed() && !t.G().Env.Test.TeamNoHeadMerkleStore { tmp := link.inner.Body.MerkleRoot.ToMerkleRootV2() newState.inner.HeadMerkle = &tmp } if !link.isStubbed() && newState.inner.MerkleRoots != nil { newState.inner.MerkleRoots[link.Seqno()] = link.inner.Body.MerkleRoot.ToMerkleRootV2() } return *newState, nil }
[ "func", "(", "t", "*", "teamSigchainPlayer", ")", "appendChainLinkHelper", "(", "ctx", "context", ".", "Context", ",", "prevState", "*", "TeamSigChainState", ",", "link", "*", "ChainLinkUnpacked", ",", "signer", "*", "SignerX", ")", "(", "res", "TeamSigChainState", ",", "err", "error", ")", "{", "err", "=", "t", ".", "checkOuterLink", "(", "ctx", ",", "prevState", ",", "link", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "var", "newState", "*", "TeamSigChainState", "\n", "if", "link", ".", "isStubbed", "(", ")", "{", "if", "prevState", "==", "nil", "{", "return", "res", ",", "NewStubbedErrorWithNote", "(", "link", ",", "\"", "\"", ")", "\n", "}", "\n", "newState2", ":=", "prevState", ".", "DeepCopy", "(", ")", "\n", "newState", "=", "&", "newState2", "\n", "}", "else", "{", "if", "signer", "==", "nil", "||", "!", "signer", ".", "signer", ".", "Uid", ".", "Exists", "(", ")", "{", "return", "res", ",", "NewInvalidLink", "(", "link", ",", "\"", "\"", ")", "\n", "}", "\n", "iRes", ",", "err", ":=", "t", ".", "addInnerLink", "(", "prevState", ",", "link", ",", "*", "signer", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "newState", "=", "&", "iRes", ".", "newState", "\n", "}", "\n\n", "newState", ".", "inner", ".", "LastSeqno", "=", "link", ".", "Seqno", "(", ")", "\n", "newState", ".", "inner", ".", "LastLinkID", "=", "link", ".", "LinkID", "(", ")", ".", "Export", "(", ")", "\n", "newState", ".", "inner", ".", "LinkIDs", "[", "link", ".", "Seqno", "(", ")", "]", "=", "link", ".", "LinkID", "(", ")", ".", "Export", "(", ")", "\n\n", "if", "link", ".", "isStubbed", "(", ")", "{", "newState", ".", "inner", ".", "StubbedLinks", "[", "link", ".", "Seqno", "(", ")", "]", "=", "true", "\n", "}", "\n\n", "// Store the head merkle sequence to the DB, for use in the audit mechanism.", "// For the purposes of testing, we disable this feature, so we can check", "// the lazy-repopulation scheme for old stored teams (without a full cache bust).", "if", "link", ".", "Seqno", "(", ")", "==", "keybase1", ".", "Seqno", "(", "1", ")", "&&", "!", "link", ".", "isStubbed", "(", ")", "&&", "!", "t", ".", "G", "(", ")", ".", "Env", ".", "Test", ".", "TeamNoHeadMerkleStore", "{", "tmp", ":=", "link", ".", "inner", ".", "Body", ".", "MerkleRoot", ".", "ToMerkleRootV2", "(", ")", "\n", "newState", ".", "inner", ".", "HeadMerkle", "=", "&", "tmp", "\n", "}", "\n\n", "if", "!", "link", ".", "isStubbed", "(", ")", "&&", "newState", ".", "inner", ".", "MerkleRoots", "!=", "nil", "{", "newState", ".", "inner", ".", "MerkleRoots", "[", "link", ".", "Seqno", "(", ")", "]", "=", "link", ".", "inner", ".", "Body", ".", "MerkleRoot", ".", "ToMerkleRootV2", "(", ")", "\n", "}", "\n\n", "return", "*", "newState", ",", "nil", "\n", "}" ]
// Add a chain link to the end. // `prevState` is moved into this function. There must exist no live references into it from now on. // `signer` may be nil iff link is stubbed. // If `prevState` is nil this is the first chain link.
[ "Add", "a", "chain", "link", "to", "the", "end", ".", "prevState", "is", "moved", "into", "this", "function", ".", "There", "must", "exist", "no", "live", "references", "into", "it", "from", "now", "on", ".", "signer", "may", "be", "nil", "iff", "link", "is", "stubbed", ".", "If", "prevState", "is", "nil", "this", "is", "the", "first", "chain", "link", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L651-L699
160,223
keybase/client
go/teams/chain.go
roleUpdatesDemoteOwners
func (t *teamSigchainPlayer) roleUpdatesDemoteOwners(prev *TeamSigChainState, roleUpdates map[keybase1.TeamRole][]keybase1.UserVersion) bool { // It is OK to readmit an owner if the owner reset and is coming in at a lower permission // level. So check that case here. readmittingResetUser := func(uv keybase1.UserVersion) bool { for toRole, uvs := range roleUpdates { if toRole == keybase1.TeamRole_NONE { continue } for _, newUV := range uvs { if newUV.Uid.Equal(uv.Uid) && newUV.EldestSeqno > uv.EldestSeqno { return true } } } return false } for toRole, uvs := range roleUpdates { if toRole == keybase1.TeamRole_OWNER { continue } for _, uv := range uvs { fromRole, err := prev.GetUserRole(uv) if err != nil { continue // ignore error, user not in team } if toRole == keybase1.TeamRole_NONE && fromRole == keybase1.TeamRole_OWNER && readmittingResetUser(uv) { continue } if fromRole == keybase1.TeamRole_OWNER { // This is an intent to demote an owner. return true } } } return false }
go
func (t *teamSigchainPlayer) roleUpdatesDemoteOwners(prev *TeamSigChainState, roleUpdates map[keybase1.TeamRole][]keybase1.UserVersion) bool { // It is OK to readmit an owner if the owner reset and is coming in at a lower permission // level. So check that case here. readmittingResetUser := func(uv keybase1.UserVersion) bool { for toRole, uvs := range roleUpdates { if toRole == keybase1.TeamRole_NONE { continue } for _, newUV := range uvs { if newUV.Uid.Equal(uv.Uid) && newUV.EldestSeqno > uv.EldestSeqno { return true } } } return false } for toRole, uvs := range roleUpdates { if toRole == keybase1.TeamRole_OWNER { continue } for _, uv := range uvs { fromRole, err := prev.GetUserRole(uv) if err != nil { continue // ignore error, user not in team } if toRole == keybase1.TeamRole_NONE && fromRole == keybase1.TeamRole_OWNER && readmittingResetUser(uv) { continue } if fromRole == keybase1.TeamRole_OWNER { // This is an intent to demote an owner. return true } } } return false }
[ "func", "(", "t", "*", "teamSigchainPlayer", ")", "roleUpdatesDemoteOwners", "(", "prev", "*", "TeamSigChainState", ",", "roleUpdates", "map", "[", "keybase1", ".", "TeamRole", "]", "[", "]", "keybase1", ".", "UserVersion", ")", "bool", "{", "// It is OK to readmit an owner if the owner reset and is coming in at a lower permission", "// level. So check that case here.", "readmittingResetUser", ":=", "func", "(", "uv", "keybase1", ".", "UserVersion", ")", "bool", "{", "for", "toRole", ",", "uvs", ":=", "range", "roleUpdates", "{", "if", "toRole", "==", "keybase1", ".", "TeamRole_NONE", "{", "continue", "\n", "}", "\n", "for", "_", ",", "newUV", ":=", "range", "uvs", "{", "if", "newUV", ".", "Uid", ".", "Equal", "(", "uv", ".", "Uid", ")", "&&", "newUV", ".", "EldestSeqno", ">", "uv", ".", "EldestSeqno", "{", "return", "true", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}", "\n\n", "for", "toRole", ",", "uvs", ":=", "range", "roleUpdates", "{", "if", "toRole", "==", "keybase1", ".", "TeamRole_OWNER", "{", "continue", "\n", "}", "\n", "for", "_", ",", "uv", ":=", "range", "uvs", "{", "fromRole", ",", "err", ":=", "prev", ".", "GetUserRole", "(", "uv", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "// ignore error, user not in team", "\n", "}", "\n", "if", "toRole", "==", "keybase1", ".", "TeamRole_NONE", "&&", "fromRole", "==", "keybase1", ".", "TeamRole_OWNER", "&&", "readmittingResetUser", "(", "uv", ")", "{", "continue", "\n", "}", "\n", "if", "fromRole", "==", "keybase1", ".", "TeamRole_OWNER", "{", "// This is an intent to demote an owner.", "return", "true", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// Whether the roleUpdates would demote any current owner to a lesser role.
[ "Whether", "the", "roleUpdates", "would", "demote", "any", "current", "owner", "to", "a", "lesser", "role", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L1946-L1983
160,224
keybase/client
go/teams/chain.go
updateMembership
func (t *teamSigchainPlayer) updateMembership(stateToUpdate *TeamSigChainState, roleUpdates chainRoleUpdates, sigMeta keybase1.SignatureMetadata) { for role, uvs := range roleUpdates { for _, uv := range uvs { stateToUpdate.inform(uv, role, sigMeta) } } }
go
func (t *teamSigchainPlayer) updateMembership(stateToUpdate *TeamSigChainState, roleUpdates chainRoleUpdates, sigMeta keybase1.SignatureMetadata) { for role, uvs := range roleUpdates { for _, uv := range uvs { stateToUpdate.inform(uv, role, sigMeta) } } }
[ "func", "(", "t", "*", "teamSigchainPlayer", ")", "updateMembership", "(", "stateToUpdate", "*", "TeamSigChainState", ",", "roleUpdates", "chainRoleUpdates", ",", "sigMeta", "keybase1", ".", "SignatureMetadata", ")", "{", "for", "role", ",", "uvs", ":=", "range", "roleUpdates", "{", "for", "_", ",", "uv", ":=", "range", "uvs", "{", "stateToUpdate", ".", "inform", "(", "uv", ",", "role", ",", "sigMeta", ")", "\n", "}", "\n", "}", "\n", "}" ]
// Update `userLog` with the membership in roleUpdates. // The `NONE` list removes users. // The other lists add users.
[ "Update", "userLog", "with", "the", "membership", "in", "roleUpdates", ".", "The", "NONE", "list", "removes", "users", ".", "The", "other", "lists", "add", "users", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L2025-L2031
160,225
keybase/client
go/teams/chain.go
assertSubteamName
func (t *teamSigchainPlayer) assertSubteamName(parent *TeamSigChainState, parentSeqno keybase1.Seqno, subteamNameStr string) (keybase1.TeamName, error) { // Ideally, we would assert the team name is a direct child of this team's name. // But the middle parts of the names might be out of date. // Instead assert: // - The root team name is same. // - The subteam is 1 level deeper. // - The last part of the parent team's name matched // at the parent-seqno that this subteam name was mentioned. // (If the subteam is a.b.c.d then c should match) // The reason this is pegged at seqno instead of simply the latest parent name is // hard to explain, see TestRenameInflateSubteamAfterRenameParent. subteamName, err := keybase1.TeamNameFromString(subteamNameStr) if err != nil { return subteamName, fmt.Errorf("invalid subteam team name '%s': %v", subteamNameStr, err) } if !parent.inner.RootAncestor.Eq(subteamName.RootAncestorName()) { return subteamName, fmt.Errorf("subteam is of a different root team: %v != %v", subteamName.RootAncestorName(), parent.inner.RootAncestor) } expectedDepth := parent.inner.NameDepth + 1 if subteamName.Depth() != expectedDepth { return subteamName, fmt.Errorf("subteam name has depth %v but expected %v", subteamName.Depth(), expectedDepth) } // The last part of the parent name at parentSeqno. var parentLastPart keybase1.TeamNamePart for _, point := range parent.inner.NameLog { if point.Seqno > parentSeqno { break } parentLastPart = point.LastPart } subteamSecondToLastPart := subteamName.Parts[len(subteamName.Parts)-2] if !subteamSecondToLastPart.Eq(parentLastPart) { return subteamName, fmt.Errorf("subteam name has wrong name for us: %v != %v", subteamSecondToLastPart, parentLastPart) } return subteamName, nil }
go
func (t *teamSigchainPlayer) assertSubteamName(parent *TeamSigChainState, parentSeqno keybase1.Seqno, subteamNameStr string) (keybase1.TeamName, error) { // Ideally, we would assert the team name is a direct child of this team's name. // But the middle parts of the names might be out of date. // Instead assert: // - The root team name is same. // - The subteam is 1 level deeper. // - The last part of the parent team's name matched // at the parent-seqno that this subteam name was mentioned. // (If the subteam is a.b.c.d then c should match) // The reason this is pegged at seqno instead of simply the latest parent name is // hard to explain, see TestRenameInflateSubteamAfterRenameParent. subteamName, err := keybase1.TeamNameFromString(subteamNameStr) if err != nil { return subteamName, fmt.Errorf("invalid subteam team name '%s': %v", subteamNameStr, err) } if !parent.inner.RootAncestor.Eq(subteamName.RootAncestorName()) { return subteamName, fmt.Errorf("subteam is of a different root team: %v != %v", subteamName.RootAncestorName(), parent.inner.RootAncestor) } expectedDepth := parent.inner.NameDepth + 1 if subteamName.Depth() != expectedDepth { return subteamName, fmt.Errorf("subteam name has depth %v but expected %v", subteamName.Depth(), expectedDepth) } // The last part of the parent name at parentSeqno. var parentLastPart keybase1.TeamNamePart for _, point := range parent.inner.NameLog { if point.Seqno > parentSeqno { break } parentLastPart = point.LastPart } subteamSecondToLastPart := subteamName.Parts[len(subteamName.Parts)-2] if !subteamSecondToLastPart.Eq(parentLastPart) { return subteamName, fmt.Errorf("subteam name has wrong name for us: %v != %v", subteamSecondToLastPart, parentLastPart) } return subteamName, nil }
[ "func", "(", "t", "*", "teamSigchainPlayer", ")", "assertSubteamName", "(", "parent", "*", "TeamSigChainState", ",", "parentSeqno", "keybase1", ".", "Seqno", ",", "subteamNameStr", "string", ")", "(", "keybase1", ".", "TeamName", ",", "error", ")", "{", "// Ideally, we would assert the team name is a direct child of this team's name.", "// But the middle parts of the names might be out of date.", "// Instead assert:", "// - The root team name is same.", "// - The subteam is 1 level deeper.", "// - The last part of the parent team's name matched", "// at the parent-seqno that this subteam name was mentioned.", "// (If the subteam is a.b.c.d then c should match)", "// The reason this is pegged at seqno instead of simply the latest parent name is", "// hard to explain, see TestRenameInflateSubteamAfterRenameParent.", "subteamName", ",", "err", ":=", "keybase1", ".", "TeamNameFromString", "(", "subteamNameStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "subteamName", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "subteamNameStr", ",", "err", ")", "\n", "}", "\n\n", "if", "!", "parent", ".", "inner", ".", "RootAncestor", ".", "Eq", "(", "subteamName", ".", "RootAncestorName", "(", ")", ")", "{", "return", "subteamName", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "subteamName", ".", "RootAncestorName", "(", ")", ",", "parent", ".", "inner", ".", "RootAncestor", ")", "\n", "}", "\n\n", "expectedDepth", ":=", "parent", ".", "inner", ".", "NameDepth", "+", "1", "\n", "if", "subteamName", ".", "Depth", "(", ")", "!=", "expectedDepth", "{", "return", "subteamName", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "subteamName", ".", "Depth", "(", ")", ",", "expectedDepth", ")", "\n", "}", "\n\n", "// The last part of the parent name at parentSeqno.", "var", "parentLastPart", "keybase1", ".", "TeamNamePart", "\n", "for", "_", ",", "point", ":=", "range", "parent", ".", "inner", ".", "NameLog", "{", "if", "point", ".", "Seqno", ">", "parentSeqno", "{", "break", "\n", "}", "\n", "parentLastPart", "=", "point", ".", "LastPart", "\n", "}", "\n\n", "subteamSecondToLastPart", ":=", "subteamName", ".", "Parts", "[", "len", "(", "subteamName", ".", "Parts", ")", "-", "2", "]", "\n", "if", "!", "subteamSecondToLastPart", ".", "Eq", "(", "parentLastPart", ")", "{", "return", "subteamName", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "subteamSecondToLastPart", ",", "parentLastPart", ")", "\n", "}", "\n\n", "return", "subteamName", ",", "nil", "\n", "}" ]
// Check that the subteam name is valid and kind of is a child of this chain. // Returns the parsed subteam name.
[ "Check", "that", "the", "subteam", "name", "is", "valid", "and", "kind", "of", "is", "a", "child", "of", "this", "chain", ".", "Returns", "the", "parsed", "subteam", "name", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain.go#L2064-L2109
160,226
keybase/client
go/auth/user_keys_api.go
NewUserKeyAPIer
func NewUserKeyAPIer(log logger.Logger, api libkb.API) UserKeyAPIer { return &userKeyAPI{log: log, api: api} }
go
func NewUserKeyAPIer(log logger.Logger, api libkb.API) UserKeyAPIer { return &userKeyAPI{log: log, api: api} }
[ "func", "NewUserKeyAPIer", "(", "log", "logger", ".", "Logger", ",", "api", "libkb", ".", "API", ")", "UserKeyAPIer", "{", "return", "&", "userKeyAPI", "{", "log", ":", "log", ",", "api", ":", "api", "}", "\n", "}" ]
// NewUserKeyAPIer returns a UserKeyAPIer implementation.
[ "NewUserKeyAPIer", "returns", "a", "UserKeyAPIer", "implementation", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/user_keys_api.go#L126-L128
160,227
keybase/client
go/kbfs/libgit/on_demand_storer.go
NewOnDemandStorer
func NewOnDemandStorer(s storage.Storer) (*OnDemandStorer, error) { // Track a small number of recent in-memory objects, to improve // performance without impacting memory too much. // // LRU is very helpful here because of the way delta compression // works. It first sorts the objects by type and descending size, // and then compares each object to a sliding window of previous // objects to find a good match. By default in git, the sliding // window for compression is 10, and it's good to have a // slightly larger cache size than that to avoid thrashing. // // To avoid memory pressure, it might be nice to additionally // consider capping the total size of this cache (e.g., with // github.com/keybase/cache). However, since the set in use is // based on the sliding window, it seems like that should be the // limiting factor. Eventually we might hit some repo where // there's a set of large objects that can overrun memory, but at // the limit that could be any two objects, and then the // compression algorithm in go-git is worthless. So for now, // let's just limit by number of entries, and add size-limits // later if needed. recentCache, err := lru.New(25) if err != nil { return nil, err } return &OnDemandStorer{s, recentCache}, nil }
go
func NewOnDemandStorer(s storage.Storer) (*OnDemandStorer, error) { // Track a small number of recent in-memory objects, to improve // performance without impacting memory too much. // // LRU is very helpful here because of the way delta compression // works. It first sorts the objects by type and descending size, // and then compares each object to a sliding window of previous // objects to find a good match. By default in git, the sliding // window for compression is 10, and it's good to have a // slightly larger cache size than that to avoid thrashing. // // To avoid memory pressure, it might be nice to additionally // consider capping the total size of this cache (e.g., with // github.com/keybase/cache). However, since the set in use is // based on the sliding window, it seems like that should be the // limiting factor. Eventually we might hit some repo where // there's a set of large objects that can overrun memory, but at // the limit that could be any two objects, and then the // compression algorithm in go-git is worthless. So for now, // let's just limit by number of entries, and add size-limits // later if needed. recentCache, err := lru.New(25) if err != nil { return nil, err } return &OnDemandStorer{s, recentCache}, nil }
[ "func", "NewOnDemandStorer", "(", "s", "storage", ".", "Storer", ")", "(", "*", "OnDemandStorer", ",", "error", ")", "{", "// Track a small number of recent in-memory objects, to improve", "// performance without impacting memory too much.", "//", "// LRU is very helpful here because of the way delta compression", "// works. It first sorts the objects by type and descending size,", "// and then compares each object to a sliding window of previous", "// objects to find a good match. By default in git, the sliding", "// window for compression is 10, and it's good to have a", "// slightly larger cache size than that to avoid thrashing.", "//", "// To avoid memory pressure, it might be nice to additionally", "// consider capping the total size of this cache (e.g., with", "// github.com/keybase/cache). However, since the set in use is", "// based on the sliding window, it seems like that should be the", "// limiting factor. Eventually we might hit some repo where", "// there's a set of large objects that can overrun memory, but at", "// the limit that could be any two objects, and then the", "// compression algorithm in go-git is worthless. So for now,", "// let's just limit by number of entries, and add size-limits", "// later if needed.", "recentCache", ",", "err", ":=", "lru", ".", "New", "(", "25", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "OnDemandStorer", "{", "s", ",", "recentCache", "}", ",", "nil", "\n", "}" ]
// NewOnDemandStorer constructs an on-demand storage layer on top of // an existing `Storer`.
[ "NewOnDemandStorer", "constructs", "an", "on", "-", "demand", "storage", "layer", "on", "top", "of", "an", "existing", "Storer", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/on_demand_storer.go#L28-L54
160,228
keybase/client
go/kbfs/libgit/on_demand_storer.go
EncodedObject
func (ods *OnDemandStorer) EncodedObject( ot plumbing.ObjectType, hash plumbing.Hash) ( plumbing.EncodedObject, error) { o := &onDemandObject{ s: ods.Storer, hash: hash, objType: ot, size: -1, recentCache: ods.recentCache, } // If the object is missing, we need to return an error for that // here. But don't read all the object data from disk by calling // `Storer.EncodedObject()` or `o.cache()`. Instead use a // KBFS-specific `HasEncodedObject()` method that just tells us // whether or not the object exists. err := ods.Storer.HasEncodedObject(hash) if err != nil { return nil, err } return o, nil }
go
func (ods *OnDemandStorer) EncodedObject( ot plumbing.ObjectType, hash plumbing.Hash) ( plumbing.EncodedObject, error) { o := &onDemandObject{ s: ods.Storer, hash: hash, objType: ot, size: -1, recentCache: ods.recentCache, } // If the object is missing, we need to return an error for that // here. But don't read all the object data from disk by calling // `Storer.EncodedObject()` or `o.cache()`. Instead use a // KBFS-specific `HasEncodedObject()` method that just tells us // whether or not the object exists. err := ods.Storer.HasEncodedObject(hash) if err != nil { return nil, err } return o, nil }
[ "func", "(", "ods", "*", "OnDemandStorer", ")", "EncodedObject", "(", "ot", "plumbing", ".", "ObjectType", ",", "hash", "plumbing", ".", "Hash", ")", "(", "plumbing", ".", "EncodedObject", ",", "error", ")", "{", "o", ":=", "&", "onDemandObject", "{", "s", ":", "ods", ".", "Storer", ",", "hash", ":", "hash", ",", "objType", ":", "ot", ",", "size", ":", "-", "1", ",", "recentCache", ":", "ods", ".", "recentCache", ",", "}", "\n", "// If the object is missing, we need to return an error for that", "// here. But don't read all the object data from disk by calling", "// `Storer.EncodedObject()` or `o.cache()`. Instead use a", "// KBFS-specific `HasEncodedObject()` method that just tells us", "// whether or not the object exists.", "err", ":=", "ods", ".", "Storer", ".", "HasEncodedObject", "(", "hash", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "o", ",", "nil", "\n", "}" ]
// EncodedObject implements the storage.Storer interface for OnDemandStorer.
[ "EncodedObject", "implements", "the", "storage", ".", "Storer", "interface", "for", "OnDemandStorer", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/on_demand_storer.go#L57-L78
160,229
keybase/client
go/kbfs/libgit/on_demand_storer.go
DeltaObject
func (ods *OnDemandStorer) DeltaObject( ot plumbing.ObjectType, hash plumbing.Hash) ( plumbing.EncodedObject, error) { edos, ok := ods.Storer.(storer.DeltaObjectStorer) if !ok { return nil, errors.New("Not a delta storer") } o := &onDemandDeltaObject{ s: edos, hash: hash, objType: ot, size: -1, recentCache: ods.recentCache, } // Need to see if this is a delta object, which means reading all // the data. _, err := o.cache() _, notDelta := err.(notDeltaError) if notDelta { return ods.EncodedObject(ot, hash) } else if err != nil { return nil, err } return o, nil }
go
func (ods *OnDemandStorer) DeltaObject( ot plumbing.ObjectType, hash plumbing.Hash) ( plumbing.EncodedObject, error) { edos, ok := ods.Storer.(storer.DeltaObjectStorer) if !ok { return nil, errors.New("Not a delta storer") } o := &onDemandDeltaObject{ s: edos, hash: hash, objType: ot, size: -1, recentCache: ods.recentCache, } // Need to see if this is a delta object, which means reading all // the data. _, err := o.cache() _, notDelta := err.(notDeltaError) if notDelta { return ods.EncodedObject(ot, hash) } else if err != nil { return nil, err } return o, nil }
[ "func", "(", "ods", "*", "OnDemandStorer", ")", "DeltaObject", "(", "ot", "plumbing", ".", "ObjectType", ",", "hash", "plumbing", ".", "Hash", ")", "(", "plumbing", ".", "EncodedObject", ",", "error", ")", "{", "edos", ",", "ok", ":=", "ods", ".", "Storer", ".", "(", "storer", ".", "DeltaObjectStorer", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "o", ":=", "&", "onDemandDeltaObject", "{", "s", ":", "edos", ",", "hash", ":", "hash", ",", "objType", ":", "ot", ",", "size", ":", "-", "1", ",", "recentCache", ":", "ods", ".", "recentCache", ",", "}", "\n", "// Need to see if this is a delta object, which means reading all", "// the data.", "_", ",", "err", ":=", "o", ".", "cache", "(", ")", "\n", "_", ",", "notDelta", ":=", "err", ".", "(", "notDeltaError", ")", "\n", "if", "notDelta", "{", "return", "ods", ".", "EncodedObject", "(", "ot", ",", "hash", ")", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "o", ",", "nil", "\n", "}" ]
// DeltaObject implements the storer.DeltaObjectStorer interface for // OnDemandStorer.
[ "DeltaObject", "implements", "the", "storer", ".", "DeltaObjectStorer", "interface", "for", "OnDemandStorer", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/on_demand_storer.go#L82-L106
160,230
keybase/client
go/libkb/timer.go
Start
func (s *SimpleTimer) Start() { if s.start == nil { tmp := time.Now() s.start = &tmp } }
go
func (s *SimpleTimer) Start() { if s.start == nil { tmp := time.Now() s.start = &tmp } }
[ "func", "(", "s", "*", "SimpleTimer", ")", "Start", "(", ")", "{", "if", "s", ".", "start", "==", "nil", "{", "tmp", ":=", "time", ".", "Now", "(", ")", "\n", "s", ".", "start", "=", "&", "tmp", "\n", "}", "\n", "}" ]
// Start the timer running, if it's not already started.
[ "Start", "the", "timer", "running", "if", "it", "s", "not", "already", "started", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/timer.go#L19-L24
160,231
keybase/client
go/libkb/timer.go
Stop
func (s *SimpleTimer) Stop() time.Duration { if s.start != nil { s.total += time.Since(*s.start) } else { panic("SimpleTimer Stop()'ed without being started") } return s.GetTotal() }
go
func (s *SimpleTimer) Stop() time.Duration { if s.start != nil { s.total += time.Since(*s.start) } else { panic("SimpleTimer Stop()'ed without being started") } return s.GetTotal() }
[ "func", "(", "s", "*", "SimpleTimer", ")", "Stop", "(", ")", "time", ".", "Duration", "{", "if", "s", ".", "start", "!=", "nil", "{", "s", ".", "total", "+=", "time", ".", "Since", "(", "*", "s", ".", "start", ")", "\n", "}", "else", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "s", ".", "GetTotal", "(", ")", "\n", "}" ]
// Stop the timer; panic if it hasn't been previously started. Return // the total duration spent in the timer.
[ "Stop", "the", "timer", ";", "panic", "if", "it", "hasn", "t", "been", "previously", "started", ".", "Return", "the", "total", "duration", "spent", "in", "the", "timer", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/timer.go#L28-L35
160,232
keybase/client
go/libkb/timer.go
Report
func (r *ReportingTimerReal) Report(prefix string) { dur := r.Stop() r.Reset() r.G().Log.Info("timer: %s [%d ms]", prefix, dur/time.Millisecond) }
go
func (r *ReportingTimerReal) Report(prefix string) { dur := r.Stop() r.Reset() r.G().Log.Info("timer: %s [%d ms]", prefix, dur/time.Millisecond) }
[ "func", "(", "r", "*", "ReportingTimerReal", ")", "Report", "(", "prefix", "string", ")", "{", "dur", ":=", "r", ".", "Stop", "(", ")", "\n", "r", ".", "Reset", "(", ")", "\n", "r", ".", "G", "(", ")", ".", "Log", ".", "Info", "(", "\"", "\"", ",", "prefix", ",", "dur", "/", "time", ".", "Millisecond", ")", "\n", "}" ]
// Report stops and resets the timer, then logs to Info what the duration was.
[ "Report", "stops", "and", "resets", "the", "timer", "then", "logs", "to", "Info", "what", "the", "duration", "was", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/timer.go#L67-L71
160,233
keybase/client
go/libkb/timer.go
NewTimerSet
func NewTimerSet(g *GlobalContext) *TimerSet { s := g.Env.GetTimers() sel := TimerNone for _, c := range s { switch c { case 'a': sel |= TimerAPI case 'x': sel |= TimerXAPI case 'r': sel |= TimerRPC } } return &TimerSet{sel: sel, Contextified: Contextified{g}} }
go
func NewTimerSet(g *GlobalContext) *TimerSet { s := g.Env.GetTimers() sel := TimerNone for _, c := range s { switch c { case 'a': sel |= TimerAPI case 'x': sel |= TimerXAPI case 'r': sel |= TimerRPC } } return &TimerSet{sel: sel, Contextified: Contextified{g}} }
[ "func", "NewTimerSet", "(", "g", "*", "GlobalContext", ")", "*", "TimerSet", "{", "s", ":=", "g", ".", "Env", ".", "GetTimers", "(", ")", "\n", "sel", ":=", "TimerNone", "\n", "for", "_", ",", "c", ":=", "range", "s", "{", "switch", "c", "{", "case", "'a'", ":", "sel", "|=", "TimerAPI", "\n", "case", "'x'", ":", "sel", "|=", "TimerXAPI", "\n", "case", "'r'", ":", "sel", "|=", "TimerRPC", "\n\n", "}", "\n", "}", "\n", "return", "&", "TimerSet", "{", "sel", ":", "sel", ",", "Contextified", ":", "Contextified", "{", "g", "}", "}", "\n", "}" ]
// NewTimerSet looks into the given context for configuration information // about how to set up timers. It then returns the corresponding TimerSet.
[ "NewTimerSet", "looks", "into", "the", "given", "context", "for", "configuration", "information", "about", "how", "to", "set", "up", "timers", ".", "It", "then", "returns", "the", "corresponding", "TimerSet", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/timer.go#L102-L117
160,234
keybase/client
go/libkb/timer.go
Start
func (s TimerSet) Start(sel TimerSelector) ReportingTimer { var ret ReportingTimer if s.sel&sel == sel { tmp := NewReportingTimerReal(s.Contextified) tmp.Start() ret = tmp } else { ret = ReportingTimerDummy{} } return ret }
go
func (s TimerSet) Start(sel TimerSelector) ReportingTimer { var ret ReportingTimer if s.sel&sel == sel { tmp := NewReportingTimerReal(s.Contextified) tmp.Start() ret = tmp } else { ret = ReportingTimerDummy{} } return ret }
[ "func", "(", "s", "TimerSet", ")", "Start", "(", "sel", "TimerSelector", ")", "ReportingTimer", "{", "var", "ret", "ReportingTimer", "\n", "if", "s", ".", "sel", "&", "sel", "==", "sel", "{", "tmp", ":=", "NewReportingTimerReal", "(", "s", ".", "Contextified", ")", "\n", "tmp", ".", "Start", "(", ")", "\n", "ret", "=", "tmp", "\n", "}", "else", "{", "ret", "=", "ReportingTimerDummy", "{", "}", "\n", "}", "\n", "return", "ret", "\n", "}" ]
// Start allocates and starts a new timer if the passed TimerSelector // is currently enabled. Otherwise, it just returns a Dummy timer.
[ "Start", "allocates", "and", "starts", "a", "new", "timer", "if", "the", "passed", "TimerSelector", "is", "currently", "enabled", ".", "Otherwise", "it", "just", "returns", "a", "Dummy", "timer", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/timer.go#L121-L131
160,235
keybase/client
go/libkb/chain_link_v2.go
IsSupportedTeamType
func (t SigchainV2Type) IsSupportedTeamType() bool { switch t { case SigchainV2TypeTeamRoot, SigchainV2TypeTeamNewSubteam, SigchainV2TypeTeamChangeMembership, SigchainV2TypeTeamRotateKey, SigchainV2TypeTeamLeave, SigchainV2TypeTeamSubteamHead, SigchainV2TypeTeamRenameSubteam, SigchainV2TypeTeamInvite, SigchainV2TypeTeamRenameUpPointer, SigchainV2TypeTeamDeleteRoot, SigchainV2TypeTeamDeleteSubteam, SigchainV2TypeTeamDeleteUpPointer, SigchainV2TypeTeamKBFSSettings, SigchainV2TypeTeamSettings: return true default: return false } }
go
func (t SigchainV2Type) IsSupportedTeamType() bool { switch t { case SigchainV2TypeTeamRoot, SigchainV2TypeTeamNewSubteam, SigchainV2TypeTeamChangeMembership, SigchainV2TypeTeamRotateKey, SigchainV2TypeTeamLeave, SigchainV2TypeTeamSubteamHead, SigchainV2TypeTeamRenameSubteam, SigchainV2TypeTeamInvite, SigchainV2TypeTeamRenameUpPointer, SigchainV2TypeTeamDeleteRoot, SigchainV2TypeTeamDeleteSubteam, SigchainV2TypeTeamDeleteUpPointer, SigchainV2TypeTeamKBFSSettings, SigchainV2TypeTeamSettings: return true default: return false } }
[ "func", "(", "t", "SigchainV2Type", ")", "IsSupportedTeamType", "(", ")", "bool", "{", "switch", "t", "{", "case", "SigchainV2TypeTeamRoot", ",", "SigchainV2TypeTeamNewSubteam", ",", "SigchainV2TypeTeamChangeMembership", ",", "SigchainV2TypeTeamRotateKey", ",", "SigchainV2TypeTeamLeave", ",", "SigchainV2TypeTeamSubteamHead", ",", "SigchainV2TypeTeamRenameSubteam", ",", "SigchainV2TypeTeamInvite", ",", "SigchainV2TypeTeamRenameUpPointer", ",", "SigchainV2TypeTeamDeleteRoot", ",", "SigchainV2TypeTeamDeleteSubteam", ",", "SigchainV2TypeTeamDeleteUpPointer", ",", "SigchainV2TypeTeamKBFSSettings", ",", "SigchainV2TypeTeamSettings", ":", "return", "true", "\n", "default", ":", "return", "false", "\n", "}", "\n", "}" ]
// Whether a type is for team sigchains. // Also the list of which types are supported by this client.
[ "Whether", "a", "type", "is", "for", "team", "sigchains", ".", "Also", "the", "list", "of", "which", "types", "are", "supported", "by", "this", "client", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/chain_link_v2.go#L117-L137
160,236
keybase/client
go/libkb/chain_link_v2.go
TeamAllowStub
func (t SigchainV2Type) TeamAllowStub(role keybase1.TeamRole) bool { if role.IsAdminOrAbove() { // Links cannot be stubbed for owners and admins return false } switch t { case SigchainV2TypeTeamNewSubteam, SigchainV2TypeTeamRenameSubteam, SigchainV2TypeTeamDeleteSubteam, SigchainV2TypeTeamInvite: return true default: // Disallow stubbing of other known links. // Allow stubbing of unknown link types for forward compatibility. return !t.IsSupportedTeamType() } }
go
func (t SigchainV2Type) TeamAllowStub(role keybase1.TeamRole) bool { if role.IsAdminOrAbove() { // Links cannot be stubbed for owners and admins return false } switch t { case SigchainV2TypeTeamNewSubteam, SigchainV2TypeTeamRenameSubteam, SigchainV2TypeTeamDeleteSubteam, SigchainV2TypeTeamInvite: return true default: // Disallow stubbing of other known links. // Allow stubbing of unknown link types for forward compatibility. return !t.IsSupportedTeamType() } }
[ "func", "(", "t", "SigchainV2Type", ")", "TeamAllowStub", "(", "role", "keybase1", ".", "TeamRole", ")", "bool", "{", "if", "role", ".", "IsAdminOrAbove", "(", ")", "{", "// Links cannot be stubbed for owners and admins", "return", "false", "\n", "}", "\n", "switch", "t", "{", "case", "SigchainV2TypeTeamNewSubteam", ",", "SigchainV2TypeTeamRenameSubteam", ",", "SigchainV2TypeTeamDeleteSubteam", ",", "SigchainV2TypeTeamInvite", ":", "return", "true", "\n", "default", ":", "// Disallow stubbing of other known links.", "// Allow stubbing of unknown link types for forward compatibility.", "return", "!", "t", ".", "IsSupportedTeamType", "(", ")", "\n", "}", "\n", "}" ]
// Whether the type can be stubbed for a team member with role
[ "Whether", "the", "type", "can", "be", "stubbed", "for", "a", "team", "member", "with", "role" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/chain_link_v2.go#L166-L182
160,237
keybase/client
go/libkb/appstate.go
NextUpdate
func (a *MobileAppState) NextUpdate(lastState *keybase1.MobileAppState) chan keybase1.MobileAppState { a.Lock() defer a.Unlock() ch := make(chan keybase1.MobileAppState, 1) if lastState != nil && *lastState != a.state { ch <- a.state } else { a.updateChs = append(a.updateChs, ch) } return ch }
go
func (a *MobileAppState) NextUpdate(lastState *keybase1.MobileAppState) chan keybase1.MobileAppState { a.Lock() defer a.Unlock() ch := make(chan keybase1.MobileAppState, 1) if lastState != nil && *lastState != a.state { ch <- a.state } else { a.updateChs = append(a.updateChs, ch) } return ch }
[ "func", "(", "a", "*", "MobileAppState", ")", "NextUpdate", "(", "lastState", "*", "keybase1", ".", "MobileAppState", ")", "chan", "keybase1", ".", "MobileAppState", "{", "a", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "Unlock", "(", ")", "\n", "ch", ":=", "make", "(", "chan", "keybase1", ".", "MobileAppState", ",", "1", ")", "\n", "if", "lastState", "!=", "nil", "&&", "*", "lastState", "!=", "a", ".", "state", "{", "ch", "<-", "a", ".", "state", "\n", "}", "else", "{", "a", ".", "updateChs", "=", "append", "(", "a", ".", "updateChs", ",", "ch", ")", "\n", "}", "\n", "return", "ch", "\n", "}" ]
// NextUpdate returns a channel that triggers when the app state changes
[ "NextUpdate", "returns", "a", "channel", "that", "triggers", "when", "the", "app", "state", "changes" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/appstate.go#L28-L38
160,238
keybase/client
go/libkb/appstate.go
Update
func (a *MobileAppState) Update(state keybase1.MobileAppState) { a.Lock() defer a.Unlock() defer a.G().Trace(fmt.Sprintf("MobileAppState.Update(%v)", state), func() error { return nil })() if a.state != state { a.G().Log.Debug("MobileAppState.Update: useful update: %v, we are currently in state: %v", state, a.state) a.state = state for _, ch := range a.updateChs { ch <- state } a.updateChs = nil // cancel RPCs if we go into the background switch a.state { case keybase1.MobileAppState_BACKGROUND: a.G().RPCCanceler.CancelLiveContexts(RPCCancelerReasonBackground) } } else { a.G().Log.Debug("MobileAppState.Update: ignoring update: %v, we are currently in state: %v", state, a.state) } }
go
func (a *MobileAppState) Update(state keybase1.MobileAppState) { a.Lock() defer a.Unlock() defer a.G().Trace(fmt.Sprintf("MobileAppState.Update(%v)", state), func() error { return nil })() if a.state != state { a.G().Log.Debug("MobileAppState.Update: useful update: %v, we are currently in state: %v", state, a.state) a.state = state for _, ch := range a.updateChs { ch <- state } a.updateChs = nil // cancel RPCs if we go into the background switch a.state { case keybase1.MobileAppState_BACKGROUND: a.G().RPCCanceler.CancelLiveContexts(RPCCancelerReasonBackground) } } else { a.G().Log.Debug("MobileAppState.Update: ignoring update: %v, we are currently in state: %v", state, a.state) } }
[ "func", "(", "a", "*", "MobileAppState", ")", "Update", "(", "state", "keybase1", ".", "MobileAppState", ")", "{", "a", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "Unlock", "(", ")", "\n", "defer", "a", ".", "G", "(", ")", ".", "Trace", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "state", ")", ",", "func", "(", ")", "error", "{", "return", "nil", "}", ")", "(", ")", "\n", "if", "a", ".", "state", "!=", "state", "{", "a", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ",", "state", ",", "a", ".", "state", ")", "\n", "a", ".", "state", "=", "state", "\n", "for", "_", ",", "ch", ":=", "range", "a", ".", "updateChs", "{", "ch", "<-", "state", "\n", "}", "\n", "a", ".", "updateChs", "=", "nil", "\n\n", "// cancel RPCs if we go into the background", "switch", "a", ".", "state", "{", "case", "keybase1", ".", "MobileAppState_BACKGROUND", ":", "a", ".", "G", "(", ")", ".", "RPCCanceler", ".", "CancelLiveContexts", "(", "RPCCancelerReasonBackground", ")", "\n", "}", "\n", "}", "else", "{", "a", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ",", "state", ",", "a", ".", "state", ")", "\n", "}", "\n", "}" ]
// Update updates the current app state, and notifies any waiting calls from NextUpdate
[ "Update", "updates", "the", "current", "app", "state", "and", "notifies", "any", "waiting", "calls", "from", "NextUpdate" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/appstate.go#L41-L63
160,239
keybase/client
go/libkb/appstate.go
State
func (a *MobileAppState) State() keybase1.MobileAppState { a.Lock() defer a.Unlock() return a.state }
go
func (a *MobileAppState) State() keybase1.MobileAppState { a.Lock() defer a.Unlock() return a.state }
[ "func", "(", "a", "*", "MobileAppState", ")", "State", "(", ")", "keybase1", ".", "MobileAppState", "{", "a", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "Unlock", "(", ")", "\n", "return", "a", ".", "state", "\n", "}" ]
// State returns the current app state
[ "State", "returns", "the", "current", "app", "state" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/appstate.go#L66-L70
160,240
keybase/client
go/kbfs/libkbfs/block_ops_constrained.go
NewBlockOpsConstrained
func NewBlockOpsConstrained(delegate BlockOps, bwKBps int) *BlockOpsConstrained { return &BlockOpsConstrained{ BlockOps: delegate, bwKBps: bwKBps, } }
go
func NewBlockOpsConstrained(delegate BlockOps, bwKBps int) *BlockOpsConstrained { return &BlockOpsConstrained{ BlockOps: delegate, bwKBps: bwKBps, } }
[ "func", "NewBlockOpsConstrained", "(", "delegate", "BlockOps", ",", "bwKBps", "int", ")", "*", "BlockOpsConstrained", "{", "return", "&", "BlockOpsConstrained", "{", "BlockOps", ":", "delegate", ",", "bwKBps", ":", "bwKBps", ",", "}", "\n", "}" ]
// NewBlockOpsConstrained constructs a new BlockOpsConstrained.
[ "NewBlockOpsConstrained", "constructs", "a", "new", "BlockOpsConstrained", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops_constrained.go#L26-L31
160,241
keybase/client
go/utils/bin_path.go
BinPath
func BinPath() (string, error) { exePath, err := os.Executable() if err != nil { return "", err } return filepath.EvalSymlinks(exePath) }
go
func BinPath() (string, error) { exePath, err := os.Executable() if err != nil { return "", err } return filepath.EvalSymlinks(exePath) }
[ "func", "BinPath", "(", ")", "(", "string", ",", "error", ")", "{", "exePath", ",", "err", ":=", "os", ".", "Executable", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "filepath", ".", "EvalSymlinks", "(", "exePath", ")", "\n", "}" ]
// BinPath returns path to the keybase executable. If the executable path is a // symlink, the target path is returned.
[ "BinPath", "returns", "path", "to", "the", "keybase", "executable", ".", "If", "the", "executable", "path", "is", "a", "symlink", "the", "target", "path", "is", "returned", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/utils/bin_path.go#L13-L19
160,242
keybase/client
go/kbfs/libgit/browser.go
Open
func (b *Browser) Open(filename string) (f billy.File, err error) { if b.tree == nil { return nil, errors.New("Empty repo") } defer translateGitError(&err) for i := 0; i < maxSymlinkLevels; i++ { fi, err := b.Lstat(filename) if err != nil { return nil, err } // Check if this is a submodule. if sfi, ok := fi.(*submoduleFileInfo); ok { return sfi.sf, nil } // If it's not a symlink, we can return right away. if fi.Mode()&os.ModeSymlink == 0 { f, err := b.tree.File(filename) if err != nil { return nil, err } return newBrowserFile(f) } filename, err = b.followSymlink(filename) if err != nil { return nil, err } } return nil, errors.New("cannot resolve deep symlink chain") }
go
func (b *Browser) Open(filename string) (f billy.File, err error) { if b.tree == nil { return nil, errors.New("Empty repo") } defer translateGitError(&err) for i := 0; i < maxSymlinkLevels; i++ { fi, err := b.Lstat(filename) if err != nil { return nil, err } // Check if this is a submodule. if sfi, ok := fi.(*submoduleFileInfo); ok { return sfi.sf, nil } // If it's not a symlink, we can return right away. if fi.Mode()&os.ModeSymlink == 0 { f, err := b.tree.File(filename) if err != nil { return nil, err } return newBrowserFile(f) } filename, err = b.followSymlink(filename) if err != nil { return nil, err } } return nil, errors.New("cannot resolve deep symlink chain") }
[ "func", "(", "b", "*", "Browser", ")", "Open", "(", "filename", "string", ")", "(", "f", "billy", ".", "File", ",", "err", "error", ")", "{", "if", "b", ".", "tree", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "defer", "translateGitError", "(", "&", "err", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "maxSymlinkLevels", ";", "i", "++", "{", "fi", ",", "err", ":=", "b", ".", "Lstat", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Check if this is a submodule.", "if", "sfi", ",", "ok", ":=", "fi", ".", "(", "*", "submoduleFileInfo", ")", ";", "ok", "{", "return", "sfi", ".", "sf", ",", "nil", "\n", "}", "\n\n", "// If it's not a symlink, we can return right away.", "if", "fi", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "0", "{", "f", ",", "err", ":=", "b", ".", "tree", ".", "File", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newBrowserFile", "(", "f", ")", "\n", "}", "\n\n", "filename", ",", "err", "=", "b", ".", "followSymlink", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// Open implements the billy.Filesystem interface for Browser.
[ "Open", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L182-L214
160,243
keybase/client
go/kbfs/libgit/browser.go
OpenFile
func (b *Browser) OpenFile(filename string, flag int, _ os.FileMode) ( f billy.File, err error) { if b.tree == nil { return nil, errors.New("Empty repo") } if flag&os.O_CREATE != 0 { return nil, errors.New("browser can't create files") } return b.Open(filename) }
go
func (b *Browser) OpenFile(filename string, flag int, _ os.FileMode) ( f billy.File, err error) { if b.tree == nil { return nil, errors.New("Empty repo") } if flag&os.O_CREATE != 0 { return nil, errors.New("browser can't create files") } return b.Open(filename) }
[ "func", "(", "b", "*", "Browser", ")", "OpenFile", "(", "filename", "string", ",", "flag", "int", ",", "_", "os", ".", "FileMode", ")", "(", "f", "billy", ".", "File", ",", "err", "error", ")", "{", "if", "b", ".", "tree", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "flag", "&", "os", ".", "O_CREATE", "!=", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "b", ".", "Open", "(", "filename", ")", "\n", "}" ]
// OpenFile implements the billy.Filesystem interface for Browser.
[ "OpenFile", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L217-L228
160,244
keybase/client
go/kbfs/libgit/browser.go
Lstat
func (b *Browser) Lstat(filename string) (fi os.FileInfo, err error) { if b.tree == nil { return nil, errors.New("Empty repo") } if strings.HasPrefix(filename, AutogitCommitPrefix) { commit := strings.TrimPrefix(filename, AutogitCommitPrefix) hash := plumbing.NewHash(commit) f, err := b.getCommitFile(context.Background(), hash) if err != nil { return nil, err } return f.GetInfo(), nil } cachePath := path.Join(b.root, filename) if fi, ok := b.sharedCache.getFileInfo(b.commitHash, cachePath); ok { return fi, nil } defer translateGitError(&err) entry, err := b.tree.FindEntry(filename) if err != nil { return nil, errors.WithStack(err) } size, err := b.tree.Size(filename) switch errors.Cause(err) { case nil: // Git doesn't keep track of the mtime of individual files // anywhere, so just use the timestamp from the commit. fi = &browserFileInfo{entry, size, b.mtime} case plumbing.ErrObjectNotFound: // This is likely a git submodule. sf := newSubmoduleFile(entry.Hash, filename, b.mtime) fi = sf.GetInfo() default: return nil, errors.WithStack(err) } b.sharedCache.setFileInfo(b.commitHash, cachePath, fi) return fi, nil }
go
func (b *Browser) Lstat(filename string) (fi os.FileInfo, err error) { if b.tree == nil { return nil, errors.New("Empty repo") } if strings.HasPrefix(filename, AutogitCommitPrefix) { commit := strings.TrimPrefix(filename, AutogitCommitPrefix) hash := plumbing.NewHash(commit) f, err := b.getCommitFile(context.Background(), hash) if err != nil { return nil, err } return f.GetInfo(), nil } cachePath := path.Join(b.root, filename) if fi, ok := b.sharedCache.getFileInfo(b.commitHash, cachePath); ok { return fi, nil } defer translateGitError(&err) entry, err := b.tree.FindEntry(filename) if err != nil { return nil, errors.WithStack(err) } size, err := b.tree.Size(filename) switch errors.Cause(err) { case nil: // Git doesn't keep track of the mtime of individual files // anywhere, so just use the timestamp from the commit. fi = &browserFileInfo{entry, size, b.mtime} case plumbing.ErrObjectNotFound: // This is likely a git submodule. sf := newSubmoduleFile(entry.Hash, filename, b.mtime) fi = sf.GetInfo() default: return nil, errors.WithStack(err) } b.sharedCache.setFileInfo(b.commitHash, cachePath, fi) return fi, nil }
[ "func", "(", "b", "*", "Browser", ")", "Lstat", "(", "filename", "string", ")", "(", "fi", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "if", "b", ".", "tree", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "strings", ".", "HasPrefix", "(", "filename", ",", "AutogitCommitPrefix", ")", "{", "commit", ":=", "strings", ".", "TrimPrefix", "(", "filename", ",", "AutogitCommitPrefix", ")", "\n", "hash", ":=", "plumbing", ".", "NewHash", "(", "commit", ")", "\n", "f", ",", "err", ":=", "b", ".", "getCommitFile", "(", "context", ".", "Background", "(", ")", ",", "hash", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "f", ".", "GetInfo", "(", ")", ",", "nil", "\n", "}", "\n\n", "cachePath", ":=", "path", ".", "Join", "(", "b", ".", "root", ",", "filename", ")", "\n", "if", "fi", ",", "ok", ":=", "b", ".", "sharedCache", ".", "getFileInfo", "(", "b", ".", "commitHash", ",", "cachePath", ")", ";", "ok", "{", "return", "fi", ",", "nil", "\n", "}", "\n", "defer", "translateGitError", "(", "&", "err", ")", "\n", "entry", ",", "err", ":=", "b", ".", "tree", ".", "FindEntry", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "WithStack", "(", "err", ")", "\n", "}", "\n\n", "size", ",", "err", ":=", "b", ".", "tree", ".", "Size", "(", "filename", ")", "\n", "switch", "errors", ".", "Cause", "(", "err", ")", "{", "case", "nil", ":", "// Git doesn't keep track of the mtime of individual files", "// anywhere, so just use the timestamp from the commit.", "fi", "=", "&", "browserFileInfo", "{", "entry", ",", "size", ",", "b", ".", "mtime", "}", "\n", "case", "plumbing", ".", "ErrObjectNotFound", ":", "// This is likely a git submodule.", "sf", ":=", "newSubmoduleFile", "(", "entry", ".", "Hash", ",", "filename", ",", "b", ".", "mtime", ")", "\n", "fi", "=", "sf", ".", "GetInfo", "(", ")", "\n", "default", ":", "return", "nil", ",", "errors", ".", "WithStack", "(", "err", ")", "\n", "}", "\n\n", "b", ".", "sharedCache", ".", "setFileInfo", "(", "b", ".", "commitHash", ",", "cachePath", ",", "fi", ")", "\n", "return", "fi", ",", "nil", "\n", "}" ]
// Lstat implements the billy.Filesystem interface for Browser.
[ "Lstat", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L231-L272
160,245
keybase/client
go/kbfs/libgit/browser.go
Stat
func (b *Browser) Stat(filename string) (fi os.FileInfo, err error) { defer translateGitError(&err) for i := 0; i < maxSymlinkLevels; i++ { fi, err := b.Lstat(filename) if err != nil { return nil, err } // If it's not a symlink, we can return right away. if fi.Mode()&os.ModeSymlink == 0 { return fi, nil } filename, err = b.followSymlink(filename) if err != nil { return nil, err } } return nil, errors.New("cannot resolve deep symlink chain") }
go
func (b *Browser) Stat(filename string) (fi os.FileInfo, err error) { defer translateGitError(&err) for i := 0; i < maxSymlinkLevels; i++ { fi, err := b.Lstat(filename) if err != nil { return nil, err } // If it's not a symlink, we can return right away. if fi.Mode()&os.ModeSymlink == 0 { return fi, nil } filename, err = b.followSymlink(filename) if err != nil { return nil, err } } return nil, errors.New("cannot resolve deep symlink chain") }
[ "func", "(", "b", "*", "Browser", ")", "Stat", "(", "filename", "string", ")", "(", "fi", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "defer", "translateGitError", "(", "&", "err", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "maxSymlinkLevels", ";", "i", "++", "{", "fi", ",", "err", ":=", "b", ".", "Lstat", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// If it's not a symlink, we can return right away.", "if", "fi", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "0", "{", "return", "fi", ",", "nil", "\n", "}", "\n\n", "filename", ",", "err", "=", "b", ".", "followSymlink", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// Stat implements the billy.Filesystem interface for Browser.
[ "Stat", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L275-L293
160,246
keybase/client
go/kbfs/libgit/browser.go
Join
func (b *Browser) Join(elem ...string) string { return path.Clean(path.Join(elem...)) }
go
func (b *Browser) Join(elem ...string) string { return path.Clean(path.Join(elem...)) }
[ "func", "(", "b", "*", "Browser", ")", "Join", "(", "elem", "...", "string", ")", "string", "{", "return", "path", ".", "Clean", "(", "path", ".", "Join", "(", "elem", "...", ")", ")", "\n", "}" ]
// Join implements the billy.Filesystem interface for Browser.
[ "Join", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L296-L298
160,247
keybase/client
go/kbfs/libgit/browser.go
ReadDir
func (b *Browser) ReadDir(p string) (fis []os.FileInfo, err error) { if p == "" { p = "." } if b.tree == nil { if p == "." { // Branch with no commits. return nil, nil } return nil, errors.New("Empty repo") } cachePath := path.Join(b.root, p) if fis, ok := b.sharedCache.getChildrenFileInfos( b.commitHash, cachePath); ok { return fis, nil } defer translateGitError(&err) var dirTree *object.Tree if p == "." { dirTree = b.tree } else { dirTree, err = b.tree.Tree(p) if err != nil { return nil, err } } childrenPathsToCache := make([]string, 0, len(dirTree.Entries)) for _, e := range dirTree.Entries { fi, err := b.Lstat(path.Join(p, e.Name)) if err != nil { return nil, err } fis = append(fis, fi) childrenPathsToCache = append(childrenPathsToCache, path.Join(cachePath, e.Name)) } b.sharedCache.setChildrenPaths( b.commitHash, cachePath, childrenPathsToCache) return fis, nil }
go
func (b *Browser) ReadDir(p string) (fis []os.FileInfo, err error) { if p == "" { p = "." } if b.tree == nil { if p == "." { // Branch with no commits. return nil, nil } return nil, errors.New("Empty repo") } cachePath := path.Join(b.root, p) if fis, ok := b.sharedCache.getChildrenFileInfos( b.commitHash, cachePath); ok { return fis, nil } defer translateGitError(&err) var dirTree *object.Tree if p == "." { dirTree = b.tree } else { dirTree, err = b.tree.Tree(p) if err != nil { return nil, err } } childrenPathsToCache := make([]string, 0, len(dirTree.Entries)) for _, e := range dirTree.Entries { fi, err := b.Lstat(path.Join(p, e.Name)) if err != nil { return nil, err } fis = append(fis, fi) childrenPathsToCache = append(childrenPathsToCache, path.Join(cachePath, e.Name)) } b.sharedCache.setChildrenPaths( b.commitHash, cachePath, childrenPathsToCache) return fis, nil }
[ "func", "(", "b", "*", "Browser", ")", "ReadDir", "(", "p", "string", ")", "(", "fis", "[", "]", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "if", "p", "==", "\"", "\"", "{", "p", "=", "\"", "\"", "\n", "}", "\n\n", "if", "b", ".", "tree", "==", "nil", "{", "if", "p", "==", "\"", "\"", "{", "// Branch with no commits.", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "cachePath", ":=", "path", ".", "Join", "(", "b", ".", "root", ",", "p", ")", "\n\n", "if", "fis", ",", "ok", ":=", "b", ".", "sharedCache", ".", "getChildrenFileInfos", "(", "b", ".", "commitHash", ",", "cachePath", ")", ";", "ok", "{", "return", "fis", ",", "nil", "\n", "}", "\n\n", "defer", "translateGitError", "(", "&", "err", ")", "\n", "var", "dirTree", "*", "object", ".", "Tree", "\n", "if", "p", "==", "\"", "\"", "{", "dirTree", "=", "b", ".", "tree", "\n", "}", "else", "{", "dirTree", ",", "err", "=", "b", ".", "tree", ".", "Tree", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "childrenPathsToCache", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "dirTree", ".", "Entries", ")", ")", "\n", "for", "_", ",", "e", ":=", "range", "dirTree", ".", "Entries", "{", "fi", ",", "err", ":=", "b", ".", "Lstat", "(", "path", ".", "Join", "(", "p", ",", "e", ".", "Name", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "fis", "=", "append", "(", "fis", ",", "fi", ")", "\n", "childrenPathsToCache", "=", "append", "(", "childrenPathsToCache", ",", "path", ".", "Join", "(", "cachePath", ",", "e", ".", "Name", ")", ")", "\n", "}", "\n", "b", ".", "sharedCache", ".", "setChildrenPaths", "(", "b", ".", "commitHash", ",", "cachePath", ",", "childrenPathsToCache", ")", "\n\n", "return", "fis", ",", "nil", "\n", "}" ]
// ReadDir implements the billy.Filesystem interface for Browser.
[ "ReadDir", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L301-L345
160,248
keybase/client
go/kbfs/libgit/browser.go
Readlink
func (b *Browser) Readlink(link string) (target string, err error) { defer translateGitError(&err) fi, err := b.Lstat(link) if err != nil { return "", err } // If it's not a symlink, error right away. if fi.Mode()&os.ModeSymlink == 0 { return "", errors.New("not a symlink") } return b.readLink(link) }
go
func (b *Browser) Readlink(link string) (target string, err error) { defer translateGitError(&err) fi, err := b.Lstat(link) if err != nil { return "", err } // If it's not a symlink, error right away. if fi.Mode()&os.ModeSymlink == 0 { return "", errors.New("not a symlink") } return b.readLink(link) }
[ "func", "(", "b", "*", "Browser", ")", "Readlink", "(", "link", "string", ")", "(", "target", "string", ",", "err", "error", ")", "{", "defer", "translateGitError", "(", "&", "err", ")", "\n", "fi", ",", "err", ":=", "b", ".", "Lstat", "(", "link", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "// If it's not a symlink, error right away.", "if", "fi", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "0", "{", "return", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "b", ".", "readLink", "(", "link", ")", "\n", "}" ]
// Readlink implements the billy.Filesystem interface for Browser.
[ "Readlink", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L348-L360
160,249
keybase/client
go/kbfs/libgit/browser.go
Chroot
func (b *Browser) Chroot(p string) (newFS billy.Filesystem, err error) { if b.tree == nil { return nil, errors.New("Empty repo") } defer translateGitError(&err) newTree, err := b.tree.Tree(p) if err != nil { return nil, err } return &Browser{ tree: newTree, root: b.Join(b.root, p), mtime: b.mtime, commitHash: b.commitHash, sharedCache: b.sharedCache, }, nil }
go
func (b *Browser) Chroot(p string) (newFS billy.Filesystem, err error) { if b.tree == nil { return nil, errors.New("Empty repo") } defer translateGitError(&err) newTree, err := b.tree.Tree(p) if err != nil { return nil, err } return &Browser{ tree: newTree, root: b.Join(b.root, p), mtime: b.mtime, commitHash: b.commitHash, sharedCache: b.sharedCache, }, nil }
[ "func", "(", "b", "*", "Browser", ")", "Chroot", "(", "p", "string", ")", "(", "newFS", "billy", ".", "Filesystem", ",", "err", "error", ")", "{", "if", "b", ".", "tree", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "defer", "translateGitError", "(", "&", "err", ")", "\n", "newTree", ",", "err", ":=", "b", ".", "tree", ".", "Tree", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "Browser", "{", "tree", ":", "newTree", ",", "root", ":", "b", ".", "Join", "(", "b", ".", "root", ",", "p", ")", ",", "mtime", ":", "b", ".", "mtime", ",", "commitHash", ":", "b", ".", "commitHash", ",", "sharedCache", ":", "b", ".", "sharedCache", ",", "}", ",", "nil", "\n", "}" ]
// Chroot implements the billy.Filesystem interface for Browser.
[ "Chroot", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L363-L380
160,250
keybase/client
go/kbfs/libgit/browser.go
MkdirAll
func (b *Browser) MkdirAll(_ string, _ os.FileMode) (err error) { return errors.New("browser cannot mkdir") }
go
func (b *Browser) MkdirAll(_ string, _ os.FileMode) (err error) { return errors.New("browser cannot mkdir") }
[ "func", "(", "b", "*", "Browser", ")", "MkdirAll", "(", "_", "string", ",", "_", "os", ".", "FileMode", ")", "(", "err", "error", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// MkdirAll implements the billy.Filesystem interface for Browser.
[ "MkdirAll", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L410-L412
160,251
keybase/client
go/kbfs/libgit/browser.go
Symlink
func (b *Browser) Symlink(_, _ string) (err error) { return errors.New("browser cannot make symlinks") }
go
func (b *Browser) Symlink(_, _ string) (err error) { return errors.New("browser cannot make symlinks") }
[ "func", "(", "b", "*", "Browser", ")", "Symlink", "(", "_", ",", "_", "string", ")", "(", "err", "error", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// Symlink implements the billy.Filesystem interface for Browser.
[ "Symlink", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "Browser", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/browser.go#L415-L417
160,252
keybase/client
go/engine/login_with_paperkey.go
NewLoginWithPaperKey
func NewLoginWithPaperKey(g *libkb.GlobalContext) *LoginWithPaperKey { return &LoginWithPaperKey{ Contextified: libkb.NewContextified(g), } }
go
func NewLoginWithPaperKey(g *libkb.GlobalContext) *LoginWithPaperKey { return &LoginWithPaperKey{ Contextified: libkb.NewContextified(g), } }
[ "func", "NewLoginWithPaperKey", "(", "g", "*", "libkb", ".", "GlobalContext", ")", "*", "LoginWithPaperKey", "{", "return", "&", "LoginWithPaperKey", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewLoginWithPaperKey creates a LoginWithPaperKey engine. // Uses the paperkey to log in and unlock LKS.
[ "NewLoginWithPaperKey", "creates", "a", "LoginWithPaperKey", "engine", ".", "Uses", "the", "paperkey", "to", "log", "in", "and", "unlock", "LKS", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_with_paperkey.go#L20-L24
160,253
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
FavoriteDelete
func (k *KeybaseDaemonLocal) FavoriteDelete( ctx context.Context, folder keybase1.Folder) error { if err := checkContext(ctx); err != nil { return err } k.lock.Lock() defer k.lock.Unlock() session, err := k.CurrentSession(ctx, 0) if err != nil { return err } return k.favoriteStore.FavoriteDelete(session.UID, folder) }
go
func (k *KeybaseDaemonLocal) FavoriteDelete( ctx context.Context, folder keybase1.Folder) error { if err := checkContext(ctx); err != nil { return err } k.lock.Lock() defer k.lock.Unlock() session, err := k.CurrentSession(ctx, 0) if err != nil { return err } return k.favoriteStore.FavoriteDelete(session.UID, folder) }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "FavoriteDelete", "(", "ctx", "context", ".", "Context", ",", "folder", "keybase1", ".", "Folder", ")", "error", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "k", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "k", ".", "lock", ".", "Unlock", "(", ")", "\n", "session", ",", "err", ":=", "k", ".", "CurrentSession", "(", "ctx", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "k", ".", "favoriteStore", ".", "FavoriteDelete", "(", "session", ".", "UID", ",", "folder", ")", "\n", "}" ]
// FavoriteDelete implements KeybaseDaemon for KeybaseDaemonLocal.
[ "FavoriteDelete", "implements", "KeybaseDaemon", "for", "KeybaseDaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L319-L332
160,254
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
FavoriteList
func (k *KeybaseDaemonLocal) FavoriteList( ctx context.Context, sessionID int) (keybase1.FavoritesResult, error) { if err := checkContext(ctx); err != nil { return keybase1.FavoritesResult{}, err } k.lock.Lock() defer k.lock.Unlock() session, err := k.CurrentSession(ctx, 0) if err != nil { return keybase1.FavoritesResult{}, err } // This is only used for testing, so it's okay to only have favorites here. favs, err := k.favoriteStore.FavoriteList(session.UID) if err != nil { return keybase1.FavoritesResult{}, err } return keybase1.FavoritesResult{ FavoriteFolders: favs, IgnoredFolders: []keybase1.Folder{}, NewFolders: []keybase1.Folder{}, }, nil }
go
func (k *KeybaseDaemonLocal) FavoriteList( ctx context.Context, sessionID int) (keybase1.FavoritesResult, error) { if err := checkContext(ctx); err != nil { return keybase1.FavoritesResult{}, err } k.lock.Lock() defer k.lock.Unlock() session, err := k.CurrentSession(ctx, 0) if err != nil { return keybase1.FavoritesResult{}, err } // This is only used for testing, so it's okay to only have favorites here. favs, err := k.favoriteStore.FavoriteList(session.UID) if err != nil { return keybase1.FavoritesResult{}, err } return keybase1.FavoritesResult{ FavoriteFolders: favs, IgnoredFolders: []keybase1.Folder{}, NewFolders: []keybase1.Folder{}, }, nil }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "FavoriteList", "(", "ctx", "context", ".", "Context", ",", "sessionID", "int", ")", "(", "keybase1", ".", "FavoritesResult", ",", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "keybase1", ".", "FavoritesResult", "{", "}", ",", "err", "\n", "}", "\n\n", "k", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "k", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "session", ",", "err", ":=", "k", ".", "CurrentSession", "(", "ctx", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "keybase1", ".", "FavoritesResult", "{", "}", ",", "err", "\n", "}", "\n\n", "// This is only used for testing, so it's okay to only have favorites here.", "favs", ",", "err", ":=", "k", ".", "favoriteStore", ".", "FavoriteList", "(", "session", ".", "UID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "keybase1", ".", "FavoritesResult", "{", "}", ",", "err", "\n", "}", "\n", "return", "keybase1", ".", "FavoritesResult", "{", "FavoriteFolders", ":", "favs", ",", "IgnoredFolders", ":", "[", "]", "keybase1", ".", "Folder", "{", "}", ",", "NewFolders", ":", "[", "]", "keybase1", ".", "Folder", "{", "}", ",", "}", ",", "nil", "\n", "}" ]
// FavoriteList implements KeybaseDaemon for KeybaseDaemonLocal.
[ "FavoriteList", "implements", "KeybaseDaemon", "for", "KeybaseDaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L335-L359
160,255
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
EncryptFavorites
func (k *KeybaseDaemonLocal) EncryptFavorites(ctx context.Context, dataToEncrypt []byte) ([]byte, error) { return nil, checkContext(ctx) }
go
func (k *KeybaseDaemonLocal) EncryptFavorites(ctx context.Context, dataToEncrypt []byte) ([]byte, error) { return nil, checkContext(ctx) }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "EncryptFavorites", "(", "ctx", "context", ".", "Context", ",", "dataToEncrypt", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "nil", ",", "checkContext", "(", "ctx", ")", "\n", "}" ]
// EncryptFavorites implements KeybaseService for KeybaseDaemonLocal
[ "EncryptFavorites", "implements", "KeybaseService", "for", "KeybaseDaemonLocal" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L362-L365
160,256
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
DecryptFavorites
func (k *KeybaseDaemonLocal) DecryptFavorites(ctx context.Context, dataToDecrypt []byte) ([]byte, error) { return nil, checkContext(ctx) }
go
func (k *KeybaseDaemonLocal) DecryptFavorites(ctx context.Context, dataToDecrypt []byte) ([]byte, error) { return nil, checkContext(ctx) }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "DecryptFavorites", "(", "ctx", "context", ".", "Context", ",", "dataToDecrypt", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "nil", ",", "checkContext", "(", "ctx", ")", "\n", "}" ]
// DecryptFavorites implements KeybaseService for KeybaseDaemonLocal
[ "DecryptFavorites", "implements", "KeybaseService", "for", "KeybaseDaemonLocal" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L368-L371
160,257
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
NotifyOnlineStatusChanged
func (k *KeybaseDaemonLocal) NotifyOnlineStatusChanged(ctx context.Context, online bool) error { return checkContext(ctx) }
go
func (k *KeybaseDaemonLocal) NotifyOnlineStatusChanged(ctx context.Context, online bool) error { return checkContext(ctx) }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "NotifyOnlineStatusChanged", "(", "ctx", "context", ".", "Context", ",", "online", "bool", ")", "error", "{", "return", "checkContext", "(", "ctx", ")", "\n", "}" ]
// NotifyOnlineStatusChanged implements KeybaseDaemon for KeybaseDeamonLocal.
[ "NotifyOnlineStatusChanged", "implements", "KeybaseDaemon", "for", "KeybaseDeamonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L374-L376
160,258
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
Notify
func (k *KeybaseDaemonLocal) Notify(ctx context.Context, notification *keybase1.FSNotification) error { return checkContext(ctx) }
go
func (k *KeybaseDaemonLocal) Notify(ctx context.Context, notification *keybase1.FSNotification) error { return checkContext(ctx) }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "Notify", "(", "ctx", "context", ".", "Context", ",", "notification", "*", "keybase1", ".", "FSNotification", ")", "error", "{", "return", "checkContext", "(", "ctx", ")", "\n", "}" ]
// Notify implements KeybaseDaemon for KeybaseDeamonLocal.
[ "Notify", "implements", "KeybaseDaemon", "for", "KeybaseDeamonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L379-L381
160,259
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
NotifyPathUpdated
func (k *KeybaseDaemonLocal) NotifyPathUpdated( ctx context.Context, _ string) error { return checkContext(ctx) }
go
func (k *KeybaseDaemonLocal) NotifyPathUpdated( ctx context.Context, _ string) error { return checkContext(ctx) }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "NotifyPathUpdated", "(", "ctx", "context", ".", "Context", ",", "_", "string", ")", "error", "{", "return", "checkContext", "(", "ctx", ")", "\n", "}" ]
// NotifyPathUpdated implements KeybaseDaemon for KeybaseDeamonLocal.
[ "NotifyPathUpdated", "implements", "KeybaseDaemon", "for", "KeybaseDeamonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L384-L387
160,260
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
NotifySyncStatus
func (k *KeybaseDaemonLocal) NotifySyncStatus(ctx context.Context, _ *keybase1.FSPathSyncStatus) error { return checkContext(ctx) }
go
func (k *KeybaseDaemonLocal) NotifySyncStatus(ctx context.Context, _ *keybase1.FSPathSyncStatus) error { return checkContext(ctx) }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "NotifySyncStatus", "(", "ctx", "context", ".", "Context", ",", "_", "*", "keybase1", ".", "FSPathSyncStatus", ")", "error", "{", "return", "checkContext", "(", "ctx", ")", "\n", "}" ]
// NotifySyncStatus implements KeybaseDaemon for KeybaseDeamonLocal.
[ "NotifySyncStatus", "implements", "KeybaseDaemon", "for", "KeybaseDeamonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L390-L393
160,261
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
NotifyOverallSyncStatus
func (k *KeybaseDaemonLocal) NotifyOverallSyncStatus( ctx context.Context, _ keybase1.FolderSyncStatus) error { return checkContext(ctx) }
go
func (k *KeybaseDaemonLocal) NotifyOverallSyncStatus( ctx context.Context, _ keybase1.FolderSyncStatus) error { return checkContext(ctx) }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "NotifyOverallSyncStatus", "(", "ctx", "context", ".", "Context", ",", "_", "keybase1", ".", "FolderSyncStatus", ")", "error", "{", "return", "checkContext", "(", "ctx", ")", "\n", "}" ]
// NotifyOverallSyncStatus implements KeybaseDaemon for KeybaseDeamonLocal.
[ "NotifyOverallSyncStatus", "implements", "KeybaseDaemon", "for", "KeybaseDeamonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L396-L399
160,262
keybase/client
go/kbfs/libkbfs/keybase_daemon_local.go
PutGitMetadata
func (k *KeybaseDaemonLocal) PutGitMetadata( ctx context.Context, folder keybase1.Folder, repoID keybase1.RepoID, metadata keybase1.GitLocalMetadata) error { return nil }
go
func (k *KeybaseDaemonLocal) PutGitMetadata( ctx context.Context, folder keybase1.Folder, repoID keybase1.RepoID, metadata keybase1.GitLocalMetadata) error { return nil }
[ "func", "(", "k", "*", "KeybaseDaemonLocal", ")", "PutGitMetadata", "(", "ctx", "context", ".", "Context", ",", "folder", "keybase1", ".", "Folder", ",", "repoID", "keybase1", ".", "RepoID", ",", "metadata", "keybase1", ".", "GitLocalMetadata", ")", "error", "{", "return", "nil", "\n", "}" ]
// PutGitMetadata implements the KeybaseService interface for // KeybaseDaemonLocal.
[ "PutGitMetadata", "implements", "the", "KeybaseService", "interface", "for", "KeybaseDaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_local.go#L421-L425
160,263
keybase/client
go/protocol/keybase1/teams.go
FindNextMerkleRootAfterTeamRemoval
func (c TeamsClient) FindNextMerkleRootAfterTeamRemoval(ctx context.Context, __arg FindNextMerkleRootAfterTeamRemovalArg) (res NextMerkleRootRes, err error) { err = c.Cli.Call(ctx, "keybase.1.teams.findNextMerkleRootAfterTeamRemoval", []interface{}{__arg}, &res) return }
go
func (c TeamsClient) FindNextMerkleRootAfterTeamRemoval(ctx context.Context, __arg FindNextMerkleRootAfterTeamRemovalArg) (res NextMerkleRootRes, err error) { err = c.Cli.Call(ctx, "keybase.1.teams.findNextMerkleRootAfterTeamRemoval", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "TeamsClient", ")", "FindNextMerkleRootAfterTeamRemoval", "(", "ctx", "context", ".", "Context", ",", "__arg", "FindNextMerkleRootAfterTeamRemovalArg", ")", "(", "res", "NextMerkleRootRes", ",", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "&", "res", ")", "\n", "return", "\n", "}" ]
// FindNextMerkleRootAfterTeamRemoval finds the first Merkle root that contains the user being // removed from the team at that given seqno in the team's chain. You should pass in a previous // Merkle root as a starting point for the binary search.
[ "FindNextMerkleRootAfterTeamRemoval", "finds", "the", "first", "Merkle", "root", "that", "contains", "the", "user", "being", "removed", "from", "the", "team", "at", "that", "given", "seqno", "in", "the", "team", "s", "chain", ".", "You", "should", "pass", "in", "a", "previous", "Merkle", "root", "as", "a", "starting", "point", "for", "the", "binary", "search", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/teams.go#L4129-L4132
160,264
keybase/client
go/protocol/keybase1/teams.go
ProfileTeamLoad
func (c TeamsClient) ProfileTeamLoad(ctx context.Context, arg LoadTeamArg) (res ProfileTeamLoadRes, err error) { __arg := ProfileTeamLoadArg{Arg: arg} err = c.Cli.Call(ctx, "keybase.1.teams.profileTeamLoad", []interface{}{__arg}, &res) return }
go
func (c TeamsClient) ProfileTeamLoad(ctx context.Context, arg LoadTeamArg) (res ProfileTeamLoadRes, err error) { __arg := ProfileTeamLoadArg{Arg: arg} err = c.Cli.Call(ctx, "keybase.1.teams.profileTeamLoad", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "TeamsClient", ")", "ProfileTeamLoad", "(", "ctx", "context", ".", "Context", ",", "arg", "LoadTeamArg", ")", "(", "res", "ProfileTeamLoadRes", ",", "err", "error", ")", "{", "__arg", ":=", "ProfileTeamLoadArg", "{", "Arg", ":", "arg", "}", "\n", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "&", "res", ")", "\n", "return", "\n", "}" ]
// ProfileTeamLoad loads a team and then throws it on the ground, for the purposes of profiling // the team load machinery.
[ "ProfileTeamLoad", "loads", "a", "team", "and", "then", "throws", "it", "on", "the", "ground", "for", "the", "purposes", "of", "profiling", "the", "team", "load", "machinery", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/teams.go#L4145-L4149
160,265
keybase/client
go/protocol/keybase1/teams.go
GetTeamID
func (c TeamsClient) GetTeamID(ctx context.Context, teamName string) (res TeamID, err error) { __arg := GetTeamIDArg{TeamName: teamName} err = c.Cli.Call(ctx, "keybase.1.teams.getTeamID", []interface{}{__arg}, &res) return }
go
func (c TeamsClient) GetTeamID(ctx context.Context, teamName string) (res TeamID, err error) { __arg := GetTeamIDArg{TeamName: teamName} err = c.Cli.Call(ctx, "keybase.1.teams.getTeamID", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "TeamsClient", ")", "GetTeamID", "(", "ctx", "context", ".", "Context", ",", "teamName", "string", ")", "(", "res", "TeamID", ",", "err", "error", ")", "{", "__arg", ":=", "GetTeamIDArg", "{", "TeamName", ":", "teamName", "}", "\n", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "&", "res", ")", "\n", "return", "\n", "}" ]
// Gets a TeamID from a team name string. Returns an error if the // current user can't read the team.
[ "Gets", "a", "TeamID", "from", "a", "team", "name", "string", ".", "Returns", "an", "error", "if", "the", "current", "user", "can", "t", "read", "the", "team", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/teams.go#L4153-L4157
160,266
keybase/client
go/protocol/keybase1/fs.go
List
func (c FsClient) List(ctx context.Context, __arg ListArg) (res ListResult, err error) { err = c.Cli.Call(ctx, "keybase.1.fs.List", []interface{}{__arg}, &res) return }
go
func (c FsClient) List(ctx context.Context, __arg ListArg) (res ListResult, err error) { err = c.Cli.Call(ctx, "keybase.1.fs.List", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "FsClient", ")", "List", "(", "ctx", "context", ".", "Context", ",", "__arg", "ListArg", ")", "(", "res", "ListResult", ",", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "&", "res", ")", "\n", "return", "\n", "}" ]
// List files in a path. Implemented by KBFS service.
[ "List", "files", "in", "a", "path", ".", "Implemented", "by", "KBFS", "service", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/fs.go#L79-L82
160,267
keybase/client
go/kbfs/libkbfs/bserver_remote.go
resetAuth
func (b *blockServerRemoteClientHandler) resetAuth( ctx context.Context, c keybase1.BlockInterface) (err error) { ctx = context.WithValue(ctx, ctxBServerResetKey, b.name) defer func() { b.deferLog.CDebugf( ctx, "BlockServerRemote: resetAuth called, err: %#v", err) }() session, err := b.csg.GetCurrentSession(ctx) if err != nil { b.log.CDebugf( ctx, "%s: User logged out, skipping resetAuth", b.name) return nil } // request a challenge challenge, err := c.GetSessionChallenge(ctx) if err != nil { return err } // get a new signature signature, err := b.authToken.Sign(ctx, session.Name, session.UID, session.VerifyingKey, challenge) if err != nil { return err } return c.AuthenticateSession(ctx, signature) }
go
func (b *blockServerRemoteClientHandler) resetAuth( ctx context.Context, c keybase1.BlockInterface) (err error) { ctx = context.WithValue(ctx, ctxBServerResetKey, b.name) defer func() { b.deferLog.CDebugf( ctx, "BlockServerRemote: resetAuth called, err: %#v", err) }() session, err := b.csg.GetCurrentSession(ctx) if err != nil { b.log.CDebugf( ctx, "%s: User logged out, skipping resetAuth", b.name) return nil } // request a challenge challenge, err := c.GetSessionChallenge(ctx) if err != nil { return err } // get a new signature signature, err := b.authToken.Sign(ctx, session.Name, session.UID, session.VerifyingKey, challenge) if err != nil { return err } return c.AuthenticateSession(ctx, signature) }
[ "func", "(", "b", "*", "blockServerRemoteClientHandler", ")", "resetAuth", "(", "ctx", "context", ".", "Context", ",", "c", "keybase1", ".", "BlockInterface", ")", "(", "err", "error", ")", "{", "ctx", "=", "context", ".", "WithValue", "(", "ctx", ",", "ctxBServerResetKey", ",", "b", ".", "name", ")", "\n\n", "defer", "func", "(", ")", "{", "b", ".", "deferLog", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "err", ")", "\n", "}", "(", ")", "\n\n", "session", ",", "err", ":=", "b", ".", "csg", ".", "GetCurrentSession", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "b", ".", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "b", ".", "name", ")", "\n", "return", "nil", "\n", "}", "\n\n", "// request a challenge", "challenge", ",", "err", ":=", "c", ".", "GetSessionChallenge", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// get a new signature", "signature", ",", "err", ":=", "b", ".", "authToken", ".", "Sign", "(", "ctx", ",", "session", ".", "Name", ",", "session", ".", "UID", ",", "session", ".", "VerifyingKey", ",", "challenge", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "c", ".", "AuthenticateSession", "(", "ctx", ",", "signature", ")", "\n", "}" ]
// resetAuth is called to reset the authorization on a BlockServer // connection.
[ "resetAuth", "is", "called", "to", "reset", "the", "authorization", "on", "a", "BlockServer", "connection", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L159-L189
160,268
keybase/client
go/kbfs/libkbfs/bserver_remote.go
NewBlockServerRemote
func NewBlockServerRemote(config blockServerRemoteConfig, blkSrvRemote rpc.Remote, rpcLogFactory rpc.LogFactory) *BlockServerRemote { log := config.MakeLogger("BSR") deferLog := log.CloneWithAddedDepth(1) bs := &BlockServerRemote{ config: config, log: traceLogger{log}, deferLog: traceLogger{deferLog}, blkSrvRemote: blkSrvRemote, } // Use two separate auth clients -- one for writes and one for // reads. This allows small reads to avoid getting trapped behind // large asynchronous writes. TODO: use some real network QoS to // achieve better prioritization within the actual network. bs.putConn = newBlockServerRemoteClientHandler( "BlockServerRemotePut", log, config.Signer(), config.CurrentSessionGetter(), blkSrvRemote, rpcLogFactory) bs.getConn = newBlockServerRemoteClientHandler( "BlockServerRemoteGet", log, config.Signer(), config.CurrentSessionGetter(), blkSrvRemote, rpcLogFactory) bs.shutdownFn = func() { bs.putConn.shutdown() bs.getConn.shutdown() } return bs }
go
func NewBlockServerRemote(config blockServerRemoteConfig, blkSrvRemote rpc.Remote, rpcLogFactory rpc.LogFactory) *BlockServerRemote { log := config.MakeLogger("BSR") deferLog := log.CloneWithAddedDepth(1) bs := &BlockServerRemote{ config: config, log: traceLogger{log}, deferLog: traceLogger{deferLog}, blkSrvRemote: blkSrvRemote, } // Use two separate auth clients -- one for writes and one for // reads. This allows small reads to avoid getting trapped behind // large asynchronous writes. TODO: use some real network QoS to // achieve better prioritization within the actual network. bs.putConn = newBlockServerRemoteClientHandler( "BlockServerRemotePut", log, config.Signer(), config.CurrentSessionGetter(), blkSrvRemote, rpcLogFactory) bs.getConn = newBlockServerRemoteClientHandler( "BlockServerRemoteGet", log, config.Signer(), config.CurrentSessionGetter(), blkSrvRemote, rpcLogFactory) bs.shutdownFn = func() { bs.putConn.shutdown() bs.getConn.shutdown() } return bs }
[ "func", "NewBlockServerRemote", "(", "config", "blockServerRemoteConfig", ",", "blkSrvRemote", "rpc", ".", "Remote", ",", "rpcLogFactory", "rpc", ".", "LogFactory", ")", "*", "BlockServerRemote", "{", "log", ":=", "config", ".", "MakeLogger", "(", "\"", "\"", ")", "\n", "deferLog", ":=", "log", ".", "CloneWithAddedDepth", "(", "1", ")", "\n", "bs", ":=", "&", "BlockServerRemote", "{", "config", ":", "config", ",", "log", ":", "traceLogger", "{", "log", "}", ",", "deferLog", ":", "traceLogger", "{", "deferLog", "}", ",", "blkSrvRemote", ":", "blkSrvRemote", ",", "}", "\n", "// Use two separate auth clients -- one for writes and one for", "// reads. This allows small reads to avoid getting trapped behind", "// large asynchronous writes. TODO: use some real network QoS to", "// achieve better prioritization within the actual network.", "bs", ".", "putConn", "=", "newBlockServerRemoteClientHandler", "(", "\"", "\"", ",", "log", ",", "config", ".", "Signer", "(", ")", ",", "config", ".", "CurrentSessionGetter", "(", ")", ",", "blkSrvRemote", ",", "rpcLogFactory", ")", "\n", "bs", ".", "getConn", "=", "newBlockServerRemoteClientHandler", "(", "\"", "\"", ",", "log", ",", "config", ".", "Signer", "(", ")", ",", "config", ".", "CurrentSessionGetter", "(", ")", ",", "blkSrvRemote", ",", "rpcLogFactory", ")", "\n\n", "bs", ".", "shutdownFn", "=", "func", "(", ")", "{", "bs", ".", "putConn", ".", "shutdown", "(", ")", "\n", "bs", ".", "getConn", ".", "shutdown", "(", ")", "\n", "}", "\n", "return", "bs", "\n", "}" ]
// NewBlockServerRemote constructs a new BlockServerRemote for the // given address.
[ "NewBlockServerRemote", "constructs", "a", "new", "BlockServerRemote", "for", "the", "given", "address", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L314-L340
160,269
keybase/client
go/kbfs/libkbfs/bserver_remote.go
Get
func (b *BlockServerRemote) Get( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context, cacheType DiskBlockCacheType) ( buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, err error) { ctx = rpc.WithFireNow(ctx) var res keybase1.GetBlockRes b.log.LazyTrace(ctx, "BServer: Get %s", id) // Once the block has been retrieved, cache it. defer func() { b.log.LazyTrace(ctx, "BServer: Get %s done (err=%v)", id, err) if err != nil { b.deferLog.CWarningf( ctx, "Get id=%s tlf=%s context=%s sz=%d err=%v", id, tlfID, context, len(buf), err) } else { // But don't cache it if it's archived data. if res.Status == keybase1.BlockStatus_ARCHIVED { return } b.deferLog.CDebugf( ctx, "Get id=%s tlf=%s context=%s sz=%d", id, tlfID, context, len(buf)) dbc := b.config.DiskBlockCache() if dbc != nil { // This used to be called in a goroutine to prevent blocking // the `Get`. But we need this cached synchronously so prefetch // operations can work correctly. dbc.Put(ctx, tlfID, id, buf, serverHalf, cacheType) } } }() arg := kbfsblock.MakeGetBlockArg(tlfID, id, context) res, err = b.getConn.getClient().GetBlock(ctx, arg) return kbfsblock.ParseGetBlockRes(res, err) }
go
func (b *BlockServerRemote) Get( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context, cacheType DiskBlockCacheType) ( buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, err error) { ctx = rpc.WithFireNow(ctx) var res keybase1.GetBlockRes b.log.LazyTrace(ctx, "BServer: Get %s", id) // Once the block has been retrieved, cache it. defer func() { b.log.LazyTrace(ctx, "BServer: Get %s done (err=%v)", id, err) if err != nil { b.deferLog.CWarningf( ctx, "Get id=%s tlf=%s context=%s sz=%d err=%v", id, tlfID, context, len(buf), err) } else { // But don't cache it if it's archived data. if res.Status == keybase1.BlockStatus_ARCHIVED { return } b.deferLog.CDebugf( ctx, "Get id=%s tlf=%s context=%s sz=%d", id, tlfID, context, len(buf)) dbc := b.config.DiskBlockCache() if dbc != nil { // This used to be called in a goroutine to prevent blocking // the `Get`. But we need this cached synchronously so prefetch // operations can work correctly. dbc.Put(ctx, tlfID, id, buf, serverHalf, cacheType) } } }() arg := kbfsblock.MakeGetBlockArg(tlfID, id, context) res, err = b.getConn.getClient().GetBlock(ctx, arg) return kbfsblock.ParseGetBlockRes(res, err) }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "id", "kbfsblock", ".", "ID", ",", "context", "kbfsblock", ".", "Context", ",", "cacheType", "DiskBlockCacheType", ")", "(", "buf", "[", "]", "byte", ",", "serverHalf", "kbfscrypto", ".", "BlockCryptKeyServerHalf", ",", "err", "error", ")", "{", "ctx", "=", "rpc", ".", "WithFireNow", "(", "ctx", ")", "\n", "var", "res", "keybase1", ".", "GetBlockRes", "\n", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "id", ")", "\n\n", "// Once the block has been retrieved, cache it.", "defer", "func", "(", ")", "{", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "err", ")", "\n", "if", "err", "!=", "nil", "{", "b", ".", "deferLog", ".", "CWarningf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ",", "len", "(", "buf", ")", ",", "err", ")", "\n", "}", "else", "{", "// But don't cache it if it's archived data.", "if", "res", ".", "Status", "==", "keybase1", ".", "BlockStatus_ARCHIVED", "{", "return", "\n", "}", "\n\n", "b", ".", "deferLog", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ",", "len", "(", "buf", ")", ")", "\n", "dbc", ":=", "b", ".", "config", ".", "DiskBlockCache", "(", ")", "\n", "if", "dbc", "!=", "nil", "{", "// This used to be called in a goroutine to prevent blocking", "// the `Get`. But we need this cached synchronously so prefetch", "// operations can work correctly.", "dbc", ".", "Put", "(", "ctx", ",", "tlfID", ",", "id", ",", "buf", ",", "serverHalf", ",", "cacheType", ")", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n\n", "arg", ":=", "kbfsblock", ".", "MakeGetBlockArg", "(", "tlfID", ",", "id", ",", "context", ")", "\n", "res", ",", "err", "=", "b", ".", "getConn", ".", "getClient", "(", ")", ".", "GetBlock", "(", "ctx", ",", "arg", ")", "\n", "return", "kbfsblock", ".", "ParseGetBlockRes", "(", "res", ",", "err", ")", "\n", "}" ]
// Get implements the BlockServer interface for BlockServerRemote.
[ "Get", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L377-L414
160,270
keybase/client
go/kbfs/libkbfs/bserver_remote.go
GetEncodedSize
func (b *BlockServerRemote) GetEncodedSize( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context) ( size uint32, status keybase1.BlockStatus, err error) { ctx = rpc.WithFireNow(ctx) b.log.LazyTrace(ctx, "BServer: GetEncodedSize %s", id) defer func() { b.log.LazyTrace( ctx, "BServer: GetEncodedSize %s done (err=%v)", id, err) if err != nil { b.deferLog.CWarningf( ctx, "GetEncodedSize id=%s tlf=%s context=%s err=%v", id, tlfID, context, err) } else { b.deferLog.CDebugf( ctx, "GetEncodedSize id=%s tlf=%s context=%s sz=%d status=%s", id, tlfID, context, size, status) } }() arg := kbfsblock.MakeGetBlockArg(tlfID, id, context) arg.SizeOnly = true res, err := b.getConn.getClient().GetBlock(ctx, arg) if err != nil { return 0, 0, nil } return uint32(res.Size), res.Status, nil }
go
func (b *BlockServerRemote) GetEncodedSize( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context) ( size uint32, status keybase1.BlockStatus, err error) { ctx = rpc.WithFireNow(ctx) b.log.LazyTrace(ctx, "BServer: GetEncodedSize %s", id) defer func() { b.log.LazyTrace( ctx, "BServer: GetEncodedSize %s done (err=%v)", id, err) if err != nil { b.deferLog.CWarningf( ctx, "GetEncodedSize id=%s tlf=%s context=%s err=%v", id, tlfID, context, err) } else { b.deferLog.CDebugf( ctx, "GetEncodedSize id=%s tlf=%s context=%s sz=%d status=%s", id, tlfID, context, size, status) } }() arg := kbfsblock.MakeGetBlockArg(tlfID, id, context) arg.SizeOnly = true res, err := b.getConn.getClient().GetBlock(ctx, arg) if err != nil { return 0, 0, nil } return uint32(res.Size), res.Status, nil }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "GetEncodedSize", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "id", "kbfsblock", ".", "ID", ",", "context", "kbfsblock", ".", "Context", ")", "(", "size", "uint32", ",", "status", "keybase1", ".", "BlockStatus", ",", "err", "error", ")", "{", "ctx", "=", "rpc", ".", "WithFireNow", "(", "ctx", ")", "\n", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "id", ")", "\n", "defer", "func", "(", ")", "{", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "err", ")", "\n", "if", "err", "!=", "nil", "{", "b", ".", "deferLog", ".", "CWarningf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ",", "err", ")", "\n", "}", "else", "{", "b", ".", "deferLog", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ",", "size", ",", "status", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "arg", ":=", "kbfsblock", ".", "MakeGetBlockArg", "(", "tlfID", ",", "id", ",", "context", ")", "\n", "arg", ".", "SizeOnly", "=", "true", "\n", "res", ",", "err", ":=", "b", ".", "getConn", ".", "getClient", "(", ")", ".", "GetBlock", "(", "ctx", ",", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "0", ",", "nil", "\n", "}", "\n", "return", "uint32", "(", "res", ".", "Size", ")", ",", "res", ".", "Status", ",", "nil", "\n", "}" ]
// GetEncodedSize implements the BlockServer interface for BlockServerRemote.
[ "GetEncodedSize", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L417-L444
160,271
keybase/client
go/kbfs/libkbfs/bserver_remote.go
Put
func (b *BlockServerRemote) Put( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, bContext kbfsblock.Context, buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, cacheType DiskBlockCacheType) (err error) { ctx = rpc.WithFireNow(ctx) dbc := b.config.DiskBlockCache() if dbc != nil { dbc.Put(ctx, tlfID, id, buf, serverHalf, cacheType) } size := len(buf) b.log.LazyTrace(ctx, "BServer: Put %s", id) defer func() { b.log.LazyTrace(ctx, "BServer: Put %s done (err=%v)", id, err) if err != nil { b.deferLog.CWarningf( ctx, "Put id=%s tlf=%s context=%s sz=%d err=%v", id, tlfID, bContext, size, err) } else { b.deferLog.CDebugf( ctx, "Put id=%s tlf=%s context=%s sz=%d", id, tlfID, bContext, size) } }() arg := kbfsblock.MakePutBlockArg(tlfID, id, bContext, buf, serverHalf) // Handle OverQuota errors at the caller return b.putConn.getClient().PutBlock(ctx, arg) }
go
func (b *BlockServerRemote) Put( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, bContext kbfsblock.Context, buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, cacheType DiskBlockCacheType) (err error) { ctx = rpc.WithFireNow(ctx) dbc := b.config.DiskBlockCache() if dbc != nil { dbc.Put(ctx, tlfID, id, buf, serverHalf, cacheType) } size := len(buf) b.log.LazyTrace(ctx, "BServer: Put %s", id) defer func() { b.log.LazyTrace(ctx, "BServer: Put %s done (err=%v)", id, err) if err != nil { b.deferLog.CWarningf( ctx, "Put id=%s tlf=%s context=%s sz=%d err=%v", id, tlfID, bContext, size, err) } else { b.deferLog.CDebugf( ctx, "Put id=%s tlf=%s context=%s sz=%d", id, tlfID, bContext, size) } }() arg := kbfsblock.MakePutBlockArg(tlfID, id, bContext, buf, serverHalf) // Handle OverQuota errors at the caller return b.putConn.getClient().PutBlock(ctx, arg) }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "Put", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "id", "kbfsblock", ".", "ID", ",", "bContext", "kbfsblock", ".", "Context", ",", "buf", "[", "]", "byte", ",", "serverHalf", "kbfscrypto", ".", "BlockCryptKeyServerHalf", ",", "cacheType", "DiskBlockCacheType", ")", "(", "err", "error", ")", "{", "ctx", "=", "rpc", ".", "WithFireNow", "(", "ctx", ")", "\n", "dbc", ":=", "b", ".", "config", ".", "DiskBlockCache", "(", ")", "\n", "if", "dbc", "!=", "nil", "{", "dbc", ".", "Put", "(", "ctx", ",", "tlfID", ",", "id", ",", "buf", ",", "serverHalf", ",", "cacheType", ")", "\n", "}", "\n", "size", ":=", "len", "(", "buf", ")", "\n", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "id", ")", "\n", "defer", "func", "(", ")", "{", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "err", ")", "\n", "if", "err", "!=", "nil", "{", "b", ".", "deferLog", ".", "CWarningf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "bContext", ",", "size", ",", "err", ")", "\n", "}", "else", "{", "b", ".", "deferLog", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "bContext", ",", "size", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "arg", ":=", "kbfsblock", ".", "MakePutBlockArg", "(", "tlfID", ",", "id", ",", "bContext", ",", "buf", ",", "serverHalf", ")", "\n", "// Handle OverQuota errors at the caller", "return", "b", ".", "putConn", ".", "getClient", "(", ")", ".", "PutBlock", "(", "ctx", ",", "arg", ")", "\n", "}" ]
// Put implements the BlockServer interface for BlockServerRemote.
[ "Put", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L447-L475
160,272
keybase/client
go/kbfs/libkbfs/bserver_remote.go
AddBlockReference
func (b *BlockServerRemote) AddBlockReference(ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context) (err error) { ctx = rpc.WithFireNow(ctx) b.log.LazyTrace(ctx, "BServer: AddRef %s", id) defer func() { b.log.LazyTrace(ctx, "BServer: AddRef %s done (err=%v)", id, err) if err != nil { b.deferLog.CWarningf( ctx, "AddBlockReference id=%s tlf=%s context=%s err=%v", id, tlfID, context, err) } else { b.deferLog.CDebugf( ctx, "AddBlockReference id=%s tlf=%s context=%s", id, tlfID, context) } }() arg := kbfsblock.MakeAddReferenceArg(tlfID, id, context) // Handle OverQuota errors at the caller return b.putConn.getClient().AddReference(ctx, arg) }
go
func (b *BlockServerRemote) AddBlockReference(ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context) (err error) { ctx = rpc.WithFireNow(ctx) b.log.LazyTrace(ctx, "BServer: AddRef %s", id) defer func() { b.log.LazyTrace(ctx, "BServer: AddRef %s done (err=%v)", id, err) if err != nil { b.deferLog.CWarningf( ctx, "AddBlockReference id=%s tlf=%s context=%s err=%v", id, tlfID, context, err) } else { b.deferLog.CDebugf( ctx, "AddBlockReference id=%s tlf=%s context=%s", id, tlfID, context) } }() arg := kbfsblock.MakeAddReferenceArg(tlfID, id, context) // Handle OverQuota errors at the caller return b.putConn.getClient().AddReference(ctx, arg) }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "AddBlockReference", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "id", "kbfsblock", ".", "ID", ",", "context", "kbfsblock", ".", "Context", ")", "(", "err", "error", ")", "{", "ctx", "=", "rpc", ".", "WithFireNow", "(", "ctx", ")", "\n", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "id", ")", "\n", "defer", "func", "(", ")", "{", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "err", ")", "\n", "if", "err", "!=", "nil", "{", "b", ".", "deferLog", ".", "CWarningf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ",", "err", ")", "\n", "}", "else", "{", "b", ".", "deferLog", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "arg", ":=", "kbfsblock", ".", "MakeAddReferenceArg", "(", "tlfID", ",", "id", ",", "context", ")", "\n", "// Handle OverQuota errors at the caller", "return", "b", ".", "putConn", ".", "getClient", "(", ")", ".", "AddReference", "(", "ctx", ",", "arg", ")", "\n", "}" ]
// AddBlockReference implements the BlockServer interface for BlockServerRemote
[ "AddBlockReference", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L509-L529
160,273
keybase/client
go/kbfs/libkbfs/bserver_remote.go
RemoveBlockReferences
func (b *BlockServerRemote) RemoveBlockReferences(ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) (liveCounts map[kbfsblock.ID]int, err error) { ctx = rpc.WithFireNow(ctx) // TODO: Define a more compact printout of contexts. b.log.LazyTrace(ctx, "BServer: RemRef %v", contexts) defer func() { b.log.LazyTrace(ctx, "BServer: RemRef %v done (err=%v)", contexts, err) if err != nil { b.deferLog.CWarningf(ctx, "RemoveBlockReferences batch size=%d err=%v", len(contexts), err) } else { b.deferLog.CDebugf(ctx, "RemoveBlockReferences batch size=%d", len(contexts)) } }() doneRefs, err := kbfsblock.BatchDowngradeReferences(ctx, b.log, tlfID, contexts, false, b.putConn.getClient()) return kbfsblock.GetLiveCounts(doneRefs), err }
go
func (b *BlockServerRemote) RemoveBlockReferences(ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) (liveCounts map[kbfsblock.ID]int, err error) { ctx = rpc.WithFireNow(ctx) // TODO: Define a more compact printout of contexts. b.log.LazyTrace(ctx, "BServer: RemRef %v", contexts) defer func() { b.log.LazyTrace(ctx, "BServer: RemRef %v done (err=%v)", contexts, err) if err != nil { b.deferLog.CWarningf(ctx, "RemoveBlockReferences batch size=%d err=%v", len(contexts), err) } else { b.deferLog.CDebugf(ctx, "RemoveBlockReferences batch size=%d", len(contexts)) } }() doneRefs, err := kbfsblock.BatchDowngradeReferences(ctx, b.log, tlfID, contexts, false, b.putConn.getClient()) return kbfsblock.GetLiveCounts(doneRefs), err }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "RemoveBlockReferences", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "contexts", "kbfsblock", ".", "ContextMap", ")", "(", "liveCounts", "map", "[", "kbfsblock", ".", "ID", "]", "int", ",", "err", "error", ")", "{", "ctx", "=", "rpc", ".", "WithFireNow", "(", "ctx", ")", "\n", "// TODO: Define a more compact printout of contexts.", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "contexts", ")", "\n", "defer", "func", "(", ")", "{", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "contexts", ",", "err", ")", "\n", "if", "err", "!=", "nil", "{", "b", ".", "deferLog", ".", "CWarningf", "(", "ctx", ",", "\"", "\"", ",", "len", "(", "contexts", ")", ",", "err", ")", "\n", "}", "else", "{", "b", ".", "deferLog", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "len", "(", "contexts", ")", ")", "\n", "}", "\n", "}", "(", ")", "\n", "doneRefs", ",", "err", ":=", "kbfsblock", ".", "BatchDowngradeReferences", "(", "ctx", ",", "b", ".", "log", ",", "tlfID", ",", "contexts", ",", "false", ",", "b", ".", "putConn", ".", "getClient", "(", ")", ")", "\n", "return", "kbfsblock", ".", "GetLiveCounts", "(", "doneRefs", ")", ",", "err", "\n", "}" ]
// RemoveBlockReferences implements the BlockServer interface for // BlockServerRemote
[ "RemoveBlockReferences", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L533-L548
160,274
keybase/client
go/kbfs/libkbfs/bserver_remote.go
ArchiveBlockReferences
func (b *BlockServerRemote) ArchiveBlockReferences(ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) (err error) { ctx = rpc.WithFireNow(ctx) b.log.LazyTrace(ctx, "BServer: ArchiveRef %v", contexts) defer func() { b.log.LazyTrace(ctx, "BServer: ArchiveRef %v done (err=%v)", contexts, err) if err != nil { b.deferLog.CWarningf(ctx, "ArchiveBlockReferences batch size=%d err=%v", len(contexts), err) } else { b.deferLog.CDebugf(ctx, "ArchiveBlockReferences batch size=%d", len(contexts)) } }() _, err = kbfsblock.BatchDowngradeReferences(ctx, b.log, tlfID, contexts, true, b.putConn.getClient()) return err }
go
func (b *BlockServerRemote) ArchiveBlockReferences(ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) (err error) { ctx = rpc.WithFireNow(ctx) b.log.LazyTrace(ctx, "BServer: ArchiveRef %v", contexts) defer func() { b.log.LazyTrace(ctx, "BServer: ArchiveRef %v done (err=%v)", contexts, err) if err != nil { b.deferLog.CWarningf(ctx, "ArchiveBlockReferences batch size=%d err=%v", len(contexts), err) } else { b.deferLog.CDebugf(ctx, "ArchiveBlockReferences batch size=%d", len(contexts)) } }() _, err = kbfsblock.BatchDowngradeReferences(ctx, b.log, tlfID, contexts, true, b.putConn.getClient()) return err }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "ArchiveBlockReferences", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "contexts", "kbfsblock", ".", "ContextMap", ")", "(", "err", "error", ")", "{", "ctx", "=", "rpc", ".", "WithFireNow", "(", "ctx", ")", "\n", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "contexts", ")", "\n", "defer", "func", "(", ")", "{", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "contexts", ",", "err", ")", "\n", "if", "err", "!=", "nil", "{", "b", ".", "deferLog", ".", "CWarningf", "(", "ctx", ",", "\"", "\"", ",", "len", "(", "contexts", ")", ",", "err", ")", "\n", "}", "else", "{", "b", ".", "deferLog", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "len", "(", "contexts", ")", ")", "\n", "}", "\n", "}", "(", ")", "\n", "_", ",", "err", "=", "kbfsblock", ".", "BatchDowngradeReferences", "(", "ctx", ",", "b", ".", "log", ",", "tlfID", ",", "contexts", ",", "true", ",", "b", ".", "putConn", ".", "getClient", "(", ")", ")", "\n", "return", "err", "\n", "}" ]
// ArchiveBlockReferences implements the BlockServer interface for // BlockServerRemote
[ "ArchiveBlockReferences", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L552-L566
160,275
keybase/client
go/kbfs/libkbfs/bserver_remote.go
GetLiveBlockReferences
func (b *BlockServerRemote) GetLiveBlockReferences( ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) ( liveCounts map[kbfsblock.ID]int, err error) { return kbfsblock.GetReferenceCount( ctx, tlfID, contexts, keybase1.BlockStatus_LIVE, b.getConn.getClient()) }
go
func (b *BlockServerRemote) GetLiveBlockReferences( ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) ( liveCounts map[kbfsblock.ID]int, err error) { return kbfsblock.GetReferenceCount( ctx, tlfID, contexts, keybase1.BlockStatus_LIVE, b.getConn.getClient()) }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "GetLiveBlockReferences", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "contexts", "kbfsblock", ".", "ContextMap", ")", "(", "liveCounts", "map", "[", "kbfsblock", ".", "ID", "]", "int", ",", "err", "error", ")", "{", "return", "kbfsblock", ".", "GetReferenceCount", "(", "ctx", ",", "tlfID", ",", "contexts", ",", "keybase1", ".", "BlockStatus_LIVE", ",", "b", ".", "getConn", ".", "getClient", "(", ")", ")", "\n", "}" ]
// GetLiveBlockReferences implements the BlockServer interface for // BlockServerRemote.
[ "GetLiveBlockReferences", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L570-L575
160,276
keybase/client
go/kbfs/libkbfs/bserver_remote.go
IsUnflushed
func (b *BlockServerRemote) IsUnflushed( _ context.Context, _ tlf.ID, _ kbfsblock.ID) ( bool, error) { return false, nil }
go
func (b *BlockServerRemote) IsUnflushed( _ context.Context, _ tlf.ID, _ kbfsblock.ID) ( bool, error) { return false, nil }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "IsUnflushed", "(", "_", "context", ".", "Context", ",", "_", "tlf", ".", "ID", ",", "_", "kbfsblock", ".", "ID", ")", "(", "bool", ",", "error", ")", "{", "return", "false", ",", "nil", "\n", "}" ]
// IsUnflushed implements the BlockServer interface for BlockServerRemote.
[ "IsUnflushed", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L578-L582
160,277
keybase/client
go/kbfs/libkbfs/bserver_remote.go
GetUserQuotaInfo
func (b *BlockServerRemote) GetUserQuotaInfo(ctx context.Context) (info *kbfsblock.QuotaInfo, err error) { ctx = rpc.WithFireNow(ctx) b.log.LazyTrace(ctx, "BServer: GetUserQuotaInfo") defer func() { b.log.LazyTrace(ctx, "BServer: GetUserQuotaInfo done (err=%v)", err) }() res, err := b.getConn.getClient().GetUserQuotaInfo(ctx) return kbfsblock.ParseGetQuotaInfoRes(b.config.Codec(), res, err) }
go
func (b *BlockServerRemote) GetUserQuotaInfo(ctx context.Context) (info *kbfsblock.QuotaInfo, err error) { ctx = rpc.WithFireNow(ctx) b.log.LazyTrace(ctx, "BServer: GetUserQuotaInfo") defer func() { b.log.LazyTrace(ctx, "BServer: GetUserQuotaInfo done (err=%v)", err) }() res, err := b.getConn.getClient().GetUserQuotaInfo(ctx) return kbfsblock.ParseGetQuotaInfoRes(b.config.Codec(), res, err) }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "GetUserQuotaInfo", "(", "ctx", "context", ".", "Context", ")", "(", "info", "*", "kbfsblock", ".", "QuotaInfo", ",", "err", "error", ")", "{", "ctx", "=", "rpc", ".", "WithFireNow", "(", "ctx", ")", "\n", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "b", ".", "log", ".", "LazyTrace", "(", "ctx", ",", "\"", "\"", ",", "err", ")", "\n", "}", "(", ")", "\n", "res", ",", "err", ":=", "b", ".", "getConn", ".", "getClient", "(", ")", ".", "GetUserQuotaInfo", "(", "ctx", ")", "\n", "return", "kbfsblock", ".", "ParseGetQuotaInfoRes", "(", "b", ".", "config", ".", "Codec", "(", ")", ",", "res", ",", "err", ")", "\n", "}" ]
// GetUserQuotaInfo implements the BlockServer interface for BlockServerRemote
[ "GetUserQuotaInfo", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L585-L593
160,278
keybase/client
go/kbfs/libkbfs/bserver_remote.go
Shutdown
func (b *BlockServerRemote) Shutdown(ctx context.Context) { if b.shutdownFn != nil { b.shutdownFn() } b.getConn.shutdown() b.putConn.shutdown() }
go
func (b *BlockServerRemote) Shutdown(ctx context.Context) { if b.shutdownFn != nil { b.shutdownFn() } b.getConn.shutdown() b.putConn.shutdown() }
[ "func", "(", "b", "*", "BlockServerRemote", ")", "Shutdown", "(", "ctx", "context", ".", "Context", ")", "{", "if", "b", ".", "shutdownFn", "!=", "nil", "{", "b", ".", "shutdownFn", "(", ")", "\n", "}", "\n", "b", ".", "getConn", ".", "shutdown", "(", ")", "\n", "b", ".", "putConn", ".", "shutdown", "(", ")", "\n", "}" ]
// Shutdown implements the BlockServer interface for BlockServerRemote.
[ "Shutdown", "implements", "the", "BlockServer", "interface", "for", "BlockServerRemote", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_remote.go#L609-L615
160,279
keybase/client
go/engine/pgp_decrypt.go
NewPGPDecrypt
func NewPGPDecrypt(g *libkb.GlobalContext, arg *PGPDecryptArg) *PGPDecrypt { return &PGPDecrypt{ arg: arg, Contextified: libkb.NewContextified(g), } }
go
func NewPGPDecrypt(g *libkb.GlobalContext, arg *PGPDecryptArg) *PGPDecrypt { return &PGPDecrypt{ arg: arg, Contextified: libkb.NewContextified(g), } }
[ "func", "NewPGPDecrypt", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "arg", "*", "PGPDecryptArg", ")", "*", "PGPDecrypt", "{", "return", "&", "PGPDecrypt", "{", "arg", ":", "arg", ",", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewPGPDecrypt creates a PGPDecrypt engine.
[ "NewPGPDecrypt", "creates", "a", "PGPDecrypt", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_decrypt.go#L31-L36
160,280
keybase/client
go/kbfs/kbfsmd/id.go
MakeID
func MakeID(codec kbfscodec.Codec, md RootMetadata) (ID, error) { // Make sure that the serialized metadata is set; otherwise we // won't get the right ID. if md.GetSerializedPrivateMetadata() == nil { return ID{}, errors.WithStack(MissingDataError{md.TlfID()}) } buf, err := codec.Encode(md) if err != nil { return ID{}, err } h, err := kbfshash.DefaultHash(buf) if err != nil { return ID{}, err } return ID{h}, nil }
go
func MakeID(codec kbfscodec.Codec, md RootMetadata) (ID, error) { // Make sure that the serialized metadata is set; otherwise we // won't get the right ID. if md.GetSerializedPrivateMetadata() == nil { return ID{}, errors.WithStack(MissingDataError{md.TlfID()}) } buf, err := codec.Encode(md) if err != nil { return ID{}, err } h, err := kbfshash.DefaultHash(buf) if err != nil { return ID{}, err } return ID{h}, nil }
[ "func", "MakeID", "(", "codec", "kbfscodec", ".", "Codec", ",", "md", "RootMetadata", ")", "(", "ID", ",", "error", ")", "{", "// Make sure that the serialized metadata is set; otherwise we", "// won't get the right ID.", "if", "md", ".", "GetSerializedPrivateMetadata", "(", ")", "==", "nil", "{", "return", "ID", "{", "}", ",", "errors", ".", "WithStack", "(", "MissingDataError", "{", "md", ".", "TlfID", "(", ")", "}", ")", "\n", "}", "\n\n", "buf", ",", "err", ":=", "codec", ".", "Encode", "(", "md", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ID", "{", "}", ",", "err", "\n", "}", "\n\n", "h", ",", "err", ":=", "kbfshash", ".", "DefaultHash", "(", "buf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ID", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "ID", "{", "h", "}", ",", "nil", "\n", "}" ]
// MakeID creates a new ID from the given RootMetadata object.
[ "MakeID", "creates", "a", "new", "ID", "from", "the", "given", "RootMetadata", "object", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/id.go#L28-L46
160,281
keybase/client
go/install/install_unix.go
AutoInstall
func AutoInstall(context Context, _ string, _ bool, timeout time.Duration, log Log) (newProc bool, err error) { err = os.MkdirAll(context.GetConfigDir(), 0755) if err != nil { return false, err } err = ToggleAutostart(context, true, true) if err != nil { // Ignore if we couldn't write to autostart log.Errorf("Autoinstall failed: %s.", err) } return false, nil }
go
func AutoInstall(context Context, _ string, _ bool, timeout time.Duration, log Log) (newProc bool, err error) { err = os.MkdirAll(context.GetConfigDir(), 0755) if err != nil { return false, err } err = ToggleAutostart(context, true, true) if err != nil { // Ignore if we couldn't write to autostart log.Errorf("Autoinstall failed: %s.", err) } return false, nil }
[ "func", "AutoInstall", "(", "context", "Context", ",", "_", "string", ",", "_", "bool", ",", "timeout", "time", ".", "Duration", ",", "log", "Log", ")", "(", "newProc", "bool", ",", "err", "error", ")", "{", "err", "=", "os", ".", "MkdirAll", "(", "context", ".", "GetConfigDir", "(", ")", ",", "0755", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "err", "=", "ToggleAutostart", "(", "context", ",", "true", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "// Ignore if we couldn't write to autostart", "log", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "false", ",", "nil", "\n", "}" ]
// AutoInstall installs auto start on unix
[ "AutoInstall", "installs", "auto", "start", "on", "unix" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/install/install_unix.go#L119-L132
160,282
keybase/client
go/install/install_unix.go
KBFSBinPath
func KBFSBinPath(runMode libkb.RunMode, binPath string) (string, error) { return kbfsBinPathDefault(runMode, binPath) }
go
func KBFSBinPath(runMode libkb.RunMode, binPath string) (string, error) { return kbfsBinPathDefault(runMode, binPath) }
[ "func", "KBFSBinPath", "(", "runMode", "libkb", ".", "RunMode", ",", "binPath", "string", ")", "(", "string", ",", "error", ")", "{", "return", "kbfsBinPathDefault", "(", "runMode", ",", "binPath", ")", "\n", "}" ]
// KBFSBinPath returns the path to the KBFS executable
[ "KBFSBinPath", "returns", "the", "path", "to", "the", "KBFS", "executable" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/install/install_unix.go#L140-L142
160,283
keybase/client
go/engine/pgp_encrypt.go
NewPGPEncrypt
func NewPGPEncrypt(g *libkb.GlobalContext, arg *PGPEncryptArg) *PGPEncrypt { return &PGPEncrypt{ arg: arg, Contextified: libkb.NewContextified(g), } }
go
func NewPGPEncrypt(g *libkb.GlobalContext, arg *PGPEncryptArg) *PGPEncrypt { return &PGPEncrypt{ arg: arg, Contextified: libkb.NewContextified(g), } }
[ "func", "NewPGPEncrypt", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "arg", "*", "PGPEncryptArg", ")", "*", "PGPEncrypt", "{", "return", "&", "PGPEncrypt", "{", "arg", ":", "arg", ",", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewPGPEncrypt creates a PGPEncrypt engine.
[ "NewPGPEncrypt", "creates", "a", "PGPEncrypt", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_encrypt.go#L34-L39
160,284
keybase/client
go/engine/pgp_encrypt.go
Add
func (k *keyset) Add(bundle *libkb.PGPKeyBundle) { kid := bundle.GetKID() if _, ok := k.keys[kid]; ok { return } k.keys[kid] = bundle k.index = append(k.index, kid) }
go
func (k *keyset) Add(bundle *libkb.PGPKeyBundle) { kid := bundle.GetKID() if _, ok := k.keys[kid]; ok { return } k.keys[kid] = bundle k.index = append(k.index, kid) }
[ "func", "(", "k", "*", "keyset", ")", "Add", "(", "bundle", "*", "libkb", ".", "PGPKeyBundle", ")", "{", "kid", ":=", "bundle", ".", "GetKID", "(", ")", "\n", "if", "_", ",", "ok", ":=", "k", ".", "keys", "[", "kid", "]", ";", "ok", "{", "return", "\n", "}", "\n", "k", ".", "keys", "[", "kid", "]", "=", "bundle", "\n", "k", ".", "index", "=", "append", "(", "k", ".", "index", ",", "kid", ")", "\n", "}" ]
// Add adds bundle to the keyset. If a key already exists, it // will be ignored.
[ "Add", "adds", "bundle", "to", "the", "keyset", ".", "If", "a", "key", "already", "exists", "it", "will", "be", "ignored", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_encrypt.go#L226-L233
160,285
keybase/client
go/engine/pgp_encrypt.go
Sorted
func (k *keyset) Sorted() []*libkb.PGPKeyBundle { var sorted []*libkb.PGPKeyBundle for _, kid := range k.index { sorted = append(sorted, k.keys[kid]) } return sorted }
go
func (k *keyset) Sorted() []*libkb.PGPKeyBundle { var sorted []*libkb.PGPKeyBundle for _, kid := range k.index { sorted = append(sorted, k.keys[kid]) } return sorted }
[ "func", "(", "k", "*", "keyset", ")", "Sorted", "(", ")", "[", "]", "*", "libkb", ".", "PGPKeyBundle", "{", "var", "sorted", "[", "]", "*", "libkb", ".", "PGPKeyBundle", "\n", "for", "_", ",", "kid", ":=", "range", "k", ".", "index", "{", "sorted", "=", "append", "(", "sorted", ",", "k", ".", "keys", "[", "kid", "]", ")", "\n", "}", "\n", "return", "sorted", "\n", "}" ]
// Sorted returns the unique keys in insertion order.
[ "Sorted", "returns", "the", "unique", "keys", "in", "insertion", "order", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_encrypt.go#L236-L242
160,286
keybase/client
go/libkb/session.go
Invalidate
func (s *Session) Invalidate() { s.G().Log.Debug("invalidating session") s.valid = false s.mtime = time.Time{} s.token = "" s.csrf = "" s.checked = false }
go
func (s *Session) Invalidate() { s.G().Log.Debug("invalidating session") s.valid = false s.mtime = time.Time{} s.token = "" s.csrf = "" s.checked = false }
[ "func", "(", "s", "*", "Session", ")", "Invalidate", "(", ")", "{", "s", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ")", "\n", "s", ".", "valid", "=", "false", "\n", "s", ".", "mtime", "=", "time", ".", "Time", "{", "}", "\n", "s", ".", "token", "=", "\"", "\"", "\n", "s", ".", "csrf", "=", "\"", "\"", "\n", "s", ".", "checked", "=", "false", "\n", "}" ]
// Invalidate marks the session as invalid and posts a logout // notification.
[ "Invalidate", "marks", "the", "session", "as", "invalid", "and", "posts", "a", "logout", "notification", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/session.go#L113-L120
160,287
keybase/client
go/libkb/naclwrap.go
MakeNaclSigningKeyPairFromSecret
func MakeNaclSigningKeyPairFromSecret(secret [NaclSigningKeySecretSize]byte) (NaclSigningKeyPair, error) { r := bytes.NewReader(secret[:]) kp, err := makeNaclSigningKeyPair(r) if err != nil { return NaclSigningKeyPair{}, err } if r.Len() > 0 { return NaclSigningKeyPair{}, fmt.Errorf("Did not use %d secret byte(s)", r.Len()) } return kp, err }
go
func MakeNaclSigningKeyPairFromSecret(secret [NaclSigningKeySecretSize]byte) (NaclSigningKeyPair, error) { r := bytes.NewReader(secret[:]) kp, err := makeNaclSigningKeyPair(r) if err != nil { return NaclSigningKeyPair{}, err } if r.Len() > 0 { return NaclSigningKeyPair{}, fmt.Errorf("Did not use %d secret byte(s)", r.Len()) } return kp, err }
[ "func", "MakeNaclSigningKeyPairFromSecret", "(", "secret", "[", "NaclSigningKeySecretSize", "]", "byte", ")", "(", "NaclSigningKeyPair", ",", "error", ")", "{", "r", ":=", "bytes", ".", "NewReader", "(", "secret", "[", ":", "]", ")", "\n\n", "kp", ",", "err", ":=", "makeNaclSigningKeyPair", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NaclSigningKeyPair", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "r", ".", "Len", "(", ")", ">", "0", "{", "return", "NaclSigningKeyPair", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "r", ".", "Len", "(", ")", ")", "\n", "}", "\n\n", "return", "kp", ",", "err", "\n", "}" ]
// MakeNaclSigningKeyPairFromSecret makes a signing key pair given a // secret. Of course, the security of depends entirely on the // randomness of the bytes in the secret.
[ "MakeNaclSigningKeyPairFromSecret", "makes", "a", "signing", "key", "pair", "given", "a", "secret", ".", "Of", "course", "the", "security", "of", "depends", "entirely", "on", "the", "randomness", "of", "the", "bytes", "in", "the", "secret", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/naclwrap.go#L409-L422
160,288
keybase/client
go/libkb/naclwrap.go
MakeNaclDHKeyPairFromSecret
func MakeNaclDHKeyPairFromSecret(secret [NaclDHKeySecretSize]byte) (NaclDHKeyPair, error) { r := bytes.NewReader(secret[:]) kp, err := makeNaclDHKeyPair(r) if err != nil { return NaclDHKeyPair{}, err } if r.Len() > 0 { return NaclDHKeyPair{}, fmt.Errorf("Did not use %d secret byte(s)", r.Len()) } return kp, err }
go
func MakeNaclDHKeyPairFromSecret(secret [NaclDHKeySecretSize]byte) (NaclDHKeyPair, error) { r := bytes.NewReader(secret[:]) kp, err := makeNaclDHKeyPair(r) if err != nil { return NaclDHKeyPair{}, err } if r.Len() > 0 { return NaclDHKeyPair{}, fmt.Errorf("Did not use %d secret byte(s)", r.Len()) } return kp, err }
[ "func", "MakeNaclDHKeyPairFromSecret", "(", "secret", "[", "NaclDHKeySecretSize", "]", "byte", ")", "(", "NaclDHKeyPair", ",", "error", ")", "{", "r", ":=", "bytes", ".", "NewReader", "(", "secret", "[", ":", "]", ")", "\n\n", "kp", ",", "err", ":=", "makeNaclDHKeyPair", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NaclDHKeyPair", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "r", ".", "Len", "(", ")", ">", "0", "{", "return", "NaclDHKeyPair", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "r", ".", "Len", "(", ")", ")", "\n", "}", "\n\n", "return", "kp", ",", "err", "\n", "}" ]
// MakeNaclDHKeyPairFromSecret makes a DH key pair given a secret. Of // course, the security of depends entirely on the randomness of the // bytes in the secret.
[ "MakeNaclDHKeyPairFromSecret", "makes", "a", "DH", "key", "pair", "given", "a", "secret", ".", "Of", "course", "the", "security", "of", "depends", "entirely", "on", "the", "randomness", "of", "the", "bytes", "in", "the", "secret", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/naclwrap.go#L460-L473
160,289
keybase/client
go/libkb/naclwrap.go
EncryptToString
func (k NaclSigningKeyPair) EncryptToString(plaintext []byte, sender GenericKey) (ciphertext string, err error) { err = KeyCannotEncryptError{} return }
go
func (k NaclSigningKeyPair) EncryptToString(plaintext []byte, sender GenericKey) (ciphertext string, err error) { err = KeyCannotEncryptError{} return }
[ "func", "(", "k", "NaclSigningKeyPair", ")", "EncryptToString", "(", "plaintext", "[", "]", "byte", ",", "sender", "GenericKey", ")", "(", "ciphertext", "string", ",", "err", "error", ")", "{", "err", "=", "KeyCannotEncryptError", "{", "}", "\n", "return", "\n", "}" ]
// EncryptToString fails for this type of key.
[ "EncryptToString", "fails", "for", "this", "type", "of", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/naclwrap.go#L514-L517
160,290
keybase/client
go/libkb/naclwrap.go
Encrypt
func (k NaclDHKeyPair) Encrypt(msg []byte, sender *NaclDHKeyPair) (*NaclEncryptionInfo, error) { if sender == nil { if tmp, err := GenerateNaclDHKeyPair(); err == nil { sender = &tmp } else { return nil, err } } else if sender.Private == nil { return nil, NoSecretKeyError{} } var nonce [NaclDHNonceSize]byte if nRead, err := rand.Read(nonce[:]); err != nil { return nil, err } else if nRead != NaclDHNonceSize { return nil, fmt.Errorf("Short random read: %d", nRead) } var ctext []byte ctext = box.Seal(ctext, msg, &nonce, ((*[32]byte)(&k.Public)), ((*[32]byte)(sender.Private))) ret := &NaclEncryptionInfo{ Ciphertext: ctext, EncryptionType: kbcrypto.KIDNaclDH, Nonce: nonce[:], Receiver: k.GetKID().ToBytes(), Sender: sender.GetKID().ToBytes(), } return ret, nil }
go
func (k NaclDHKeyPair) Encrypt(msg []byte, sender *NaclDHKeyPair) (*NaclEncryptionInfo, error) { if sender == nil { if tmp, err := GenerateNaclDHKeyPair(); err == nil { sender = &tmp } else { return nil, err } } else if sender.Private == nil { return nil, NoSecretKeyError{} } var nonce [NaclDHNonceSize]byte if nRead, err := rand.Read(nonce[:]); err != nil { return nil, err } else if nRead != NaclDHNonceSize { return nil, fmt.Errorf("Short random read: %d", nRead) } var ctext []byte ctext = box.Seal(ctext, msg, &nonce, ((*[32]byte)(&k.Public)), ((*[32]byte)(sender.Private))) ret := &NaclEncryptionInfo{ Ciphertext: ctext, EncryptionType: kbcrypto.KIDNaclDH, Nonce: nonce[:], Receiver: k.GetKID().ToBytes(), Sender: sender.GetKID().ToBytes(), } return ret, nil }
[ "func", "(", "k", "NaclDHKeyPair", ")", "Encrypt", "(", "msg", "[", "]", "byte", ",", "sender", "*", "NaclDHKeyPair", ")", "(", "*", "NaclEncryptionInfo", ",", "error", ")", "{", "if", "sender", "==", "nil", "{", "if", "tmp", ",", "err", ":=", "GenerateNaclDHKeyPair", "(", ")", ";", "err", "==", "nil", "{", "sender", "=", "&", "tmp", "\n", "}", "else", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "else", "if", "sender", ".", "Private", "==", "nil", "{", "return", "nil", ",", "NoSecretKeyError", "{", "}", "\n", "}", "\n\n", "var", "nonce", "[", "NaclDHNonceSize", "]", "byte", "\n", "if", "nRead", ",", "err", ":=", "rand", ".", "Read", "(", "nonce", "[", ":", "]", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "else", "if", "nRead", "!=", "NaclDHNonceSize", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "nRead", ")", "\n", "}", "\n\n", "var", "ctext", "[", "]", "byte", "\n", "ctext", "=", "box", ".", "Seal", "(", "ctext", ",", "msg", ",", "&", "nonce", ",", "(", "(", "*", "[", "32", "]", "byte", ")", "(", "&", "k", ".", "Public", ")", ")", ",", "(", "(", "*", "[", "32", "]", "byte", ")", "(", "sender", ".", "Private", ")", ")", ")", "\n", "ret", ":=", "&", "NaclEncryptionInfo", "{", "Ciphertext", ":", "ctext", ",", "EncryptionType", ":", "kbcrypto", ".", "KIDNaclDH", ",", "Nonce", ":", "nonce", "[", ":", "]", ",", "Receiver", ":", "k", ".", "GetKID", "(", ")", ".", "ToBytes", "(", ")", ",", "Sender", ":", "sender", ".", "GetKID", "(", ")", ".", "ToBytes", "(", ")", ",", "}", "\n\n", "return", "ret", ",", "nil", "\n", "}" ]
// Encrypt a message to the key `k` from the given `sender`. If sender is nil, an ephemeral // keypair will be invented
[ "Encrypt", "a", "message", "to", "the", "key", "k", "from", "the", "given", "sender", ".", "If", "sender", "is", "nil", "an", "ephemeral", "keypair", "will", "be", "invented" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/naclwrap.go#L549-L578
160,291
keybase/client
go/libkb/naclwrap.go
EncryptToString
func (k NaclDHKeyPair) EncryptToString(plaintext []byte, sender GenericKey) (string, error) { var senderDh *NaclDHKeyPair if sender != nil { var ok bool if senderDh, ok = sender.(*NaclDHKeyPair); !ok { return "", NoSecretKeyError{} } } info, err := k.Encrypt(plaintext, senderDh) if err != nil { return "", err } return kbcrypto.EncodePacketToArmoredString(info) }
go
func (k NaclDHKeyPair) EncryptToString(plaintext []byte, sender GenericKey) (string, error) { var senderDh *NaclDHKeyPair if sender != nil { var ok bool if senderDh, ok = sender.(*NaclDHKeyPair); !ok { return "", NoSecretKeyError{} } } info, err := k.Encrypt(plaintext, senderDh) if err != nil { return "", err } return kbcrypto.EncodePacketToArmoredString(info) }
[ "func", "(", "k", "NaclDHKeyPair", ")", "EncryptToString", "(", "plaintext", "[", "]", "byte", ",", "sender", "GenericKey", ")", "(", "string", ",", "error", ")", "{", "var", "senderDh", "*", "NaclDHKeyPair", "\n", "if", "sender", "!=", "nil", "{", "var", "ok", "bool", "\n", "if", "senderDh", ",", "ok", "=", "sender", ".", "(", "*", "NaclDHKeyPair", ")", ";", "!", "ok", "{", "return", "\"", "\"", ",", "NoSecretKeyError", "{", "}", "\n", "}", "\n", "}", "\n\n", "info", ",", "err", ":=", "k", ".", "Encrypt", "(", "plaintext", ",", "senderDh", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "kbcrypto", ".", "EncodePacketToArmoredString", "(", "info", ")", "\n", "}" ]
// EncryptToString encrypts the plaintext using DiffieHelman; the this object is // the receiver, and the passed sender is optional. If not provided, we'll make // up an ephemeral key.
[ "EncryptToString", "encrypts", "the", "plaintext", "using", "DiffieHelman", ";", "the", "this", "object", "is", "the", "receiver", "and", "the", "passed", "sender", "is", "optional", ".", "If", "not", "provided", "we", "ll", "make", "up", "an", "ephemeral", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/naclwrap.go#L583-L598
160,292
keybase/client
go/libkb/naclwrap.go
DecryptFromString
func (k NaclDHKeyPair) DecryptFromString(ciphertext string) (msg []byte, sender keybase1.KID, err error) { var nei NaclEncryptionInfo if nei, err = DecodeArmoredNaclEncryptionInfoPacket(ciphertext); err != nil { return } return k.Decrypt(&nei) }
go
func (k NaclDHKeyPair) DecryptFromString(ciphertext string) (msg []byte, sender keybase1.KID, err error) { var nei NaclEncryptionInfo if nei, err = DecodeArmoredNaclEncryptionInfoPacket(ciphertext); err != nil { return } return k.Decrypt(&nei) }
[ "func", "(", "k", "NaclDHKeyPair", ")", "DecryptFromString", "(", "ciphertext", "string", ")", "(", "msg", "[", "]", "byte", ",", "sender", "keybase1", ".", "KID", ",", "err", "error", ")", "{", "var", "nei", "NaclEncryptionInfo", "\n\n", "if", "nei", ",", "err", "=", "DecodeArmoredNaclEncryptionInfoPacket", "(", "ciphertext", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "return", "k", ".", "Decrypt", "(", "&", "nei", ")", "\n", "}" ]
// DecryptFromString decrypts the output of EncryptToString above, // and returns the kbcrypto.KID of the other end.
[ "DecryptFromString", "decrypts", "the", "output", "of", "EncryptToString", "above", "and", "returns", "the", "kbcrypto", ".", "KID", "of", "the", "other", "end", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/naclwrap.go#L685-L693
160,293
keybase/client
go/protocol/keybase1/login_ui.go
DisplayResetProgress
func (c LoginUiClient) DisplayResetProgress(ctx context.Context, __arg DisplayResetProgressArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.loginUi.displayResetProgress", []interface{}{__arg}, nil) return }
go
func (c LoginUiClient) DisplayResetProgress(ctx context.Context, __arg DisplayResetProgressArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.loginUi.displayResetProgress", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "LoginUiClient", ")", "DisplayResetProgress", "(", "ctx", "context", ".", "Context", ",", "__arg", "DisplayResetProgressArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "nil", ")", "\n", "return", "\n", "}" ]
// In some flows the user will get
[ "In", "some", "flows", "the", "user", "will", "get" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login_ui.go#L215-L218
160,294
keybase/client
go/libkb/pdpka.go
PopulateArgs
func (lp PDPKALoginPackage) PopulateArgs(h *HTTPArgs) { h.Add("pdpka4", S{string(lp.pdpka4)}) h.Add("pdpka5", S{string(lp.pdpka5)}) }
go
func (lp PDPKALoginPackage) PopulateArgs(h *HTTPArgs) { h.Add("pdpka4", S{string(lp.pdpka4)}) h.Add("pdpka5", S{string(lp.pdpka5)}) }
[ "func", "(", "lp", "PDPKALoginPackage", ")", "PopulateArgs", "(", "h", "*", "HTTPArgs", ")", "{", "h", ".", "Add", "(", "\"", "\"", ",", "S", "{", "string", "(", "lp", ".", "pdpka4", ")", "}", ")", "\n", "h", ".", "Add", "(", "\"", "\"", ",", "S", "{", "string", "(", "lp", ".", "pdpka5", ")", "}", ")", "\n", "}" ]
// PopulateArgs populates the given HTTP args with parameters in this PDPKA package. // Right now that includes v4 and v5 of the PDPKA login system.
[ "PopulateArgs", "populates", "the", "given", "HTTP", "args", "with", "parameters", "in", "this", "PDPKA", "package", ".", "Right", "now", "that", "includes", "v4", "and", "v5", "of", "the", "PDPKA", "login", "system", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pdpka.go#L164-L167
160,295
keybase/client
go/kbfs/libkbfs/md_id_journal.go
move
func (j *mdIDJournal) move(newDir string) (oldDir string, err error) { return j.j.move(newDir) }
go
func (j *mdIDJournal) move(newDir string) (oldDir string, err error) { return j.j.move(newDir) }
[ "func", "(", "j", "*", "mdIDJournal", ")", "move", "(", "newDir", "string", ")", "(", "oldDir", "string", ",", "err", "error", ")", "{", "return", "j", ".", "j", ".", "move", "(", "newDir", ")", "\n", "}" ]
// Note that since diskJournal.move takes a pointer receiver, so must // this.
[ "Note", "that", "since", "diskJournal", ".", "move", "takes", "a", "pointer", "receiver", "so", "must", "this", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_id_journal.go#L294-L296
160,296
keybase/client
go/kbnm/installer/installer.go
UninstallKBNM
func UninstallKBNM() error { u, err := CurrentUser() if err != nil { return err } app := hostmanifest.App{ Name: kbnmAppName, } for _, whitelist := range hostmanifest.KnownInstallers() { if err := whitelist.Uninstall(u, app); err != nil { return err } } return nil }
go
func UninstallKBNM() error { u, err := CurrentUser() if err != nil { return err } app := hostmanifest.App{ Name: kbnmAppName, } for _, whitelist := range hostmanifest.KnownInstallers() { if err := whitelist.Uninstall(u, app); err != nil { return err } } return nil }
[ "func", "UninstallKBNM", "(", ")", "error", "{", "u", ",", "err", ":=", "CurrentUser", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "app", ":=", "hostmanifest", ".", "App", "{", "Name", ":", "kbnmAppName", ",", "}", "\n\n", "for", "_", ",", "whitelist", ":=", "range", "hostmanifest", ".", "KnownInstallers", "(", ")", "{", "if", "err", ":=", "whitelist", ".", "Uninstall", "(", "u", ",", "app", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// UninstallKBNM removes NativeMessaging whitelisting for KBNM.
[ "UninstallKBNM", "removes", "NativeMessaging", "whitelisting", "for", "KBNM", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbnm/installer/installer.go#L34-L51
160,297
keybase/client
go/kbnm/installer/installer.go
InstallKBNM
func InstallKBNM(path string) error { u, err := CurrentUser() if err != nil { return err } // If we're installing in an overlay, we need to strip it as a prefix from // the path we detect. overlay := os.Getenv("KBNM_INSTALL_OVERLAY") if overlay != "" { // This is a bit arcane because filepath.HasPrefix deprecated due to // being broken, but what it does is it attempts to map path as // relative to overlay. If it succeeds and they're both absolute paths // (which means the relative path won't start with "../"), then make // path an absolute path with the overlay removed // filepath.Rel takes care of normalizing paths which is an advantage // over direct string comparisons which would be simpler. rel, err := filepath.Rel(overlay, path) if err == nil && !strings.HasPrefix(rel, ".") { path = "/" + rel } } app := hostmanifest.App{ Name: kbnmAppName, Description: "Keybase Native Messaging API", Path: path, Type: "stdio", } var manifest hostmanifest.AppManifest for browser, whitelist := range hostmanifest.KnownInstallers() { switch browser { case "chrome", "chromium": manifest = hostmanifest.ChromeApp{ App: app, AllowedOrigins: []string{ // Production public version in the store "chrome-extension://ognfafcpbkogffpmmdglhbjboeojlefj/", // Hard-coded key from the repo version "chrome-extension://kockbbfoibcdfibclaojljblnhpnjndg/", // Keybase-internal version "chrome-extension://gnjkbjlgkpiaehpibpdefaieklbfljjm/", }, } case "firefox": manifest = hostmanifest.FirefoxApp{ App: app, AllowedExtensions: []string{ "[email protected]", }, } } if err := whitelist.Install(u, manifest); err != nil { return err } } return nil }
go
func InstallKBNM(path string) error { u, err := CurrentUser() if err != nil { return err } // If we're installing in an overlay, we need to strip it as a prefix from // the path we detect. overlay := os.Getenv("KBNM_INSTALL_OVERLAY") if overlay != "" { // This is a bit arcane because filepath.HasPrefix deprecated due to // being broken, but what it does is it attempts to map path as // relative to overlay. If it succeeds and they're both absolute paths // (which means the relative path won't start with "../"), then make // path an absolute path with the overlay removed // filepath.Rel takes care of normalizing paths which is an advantage // over direct string comparisons which would be simpler. rel, err := filepath.Rel(overlay, path) if err == nil && !strings.HasPrefix(rel, ".") { path = "/" + rel } } app := hostmanifest.App{ Name: kbnmAppName, Description: "Keybase Native Messaging API", Path: path, Type: "stdio", } var manifest hostmanifest.AppManifest for browser, whitelist := range hostmanifest.KnownInstallers() { switch browser { case "chrome", "chromium": manifest = hostmanifest.ChromeApp{ App: app, AllowedOrigins: []string{ // Production public version in the store "chrome-extension://ognfafcpbkogffpmmdglhbjboeojlefj/", // Hard-coded key from the repo version "chrome-extension://kockbbfoibcdfibclaojljblnhpnjndg/", // Keybase-internal version "chrome-extension://gnjkbjlgkpiaehpibpdefaieklbfljjm/", }, } case "firefox": manifest = hostmanifest.FirefoxApp{ App: app, AllowedExtensions: []string{ "[email protected]", }, } } if err := whitelist.Install(u, manifest); err != nil { return err } } return nil }
[ "func", "InstallKBNM", "(", "path", "string", ")", "error", "{", "u", ",", "err", ":=", "CurrentUser", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// If we're installing in an overlay, we need to strip it as a prefix from", "// the path we detect.", "overlay", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "overlay", "!=", "\"", "\"", "{", "// This is a bit arcane because filepath.HasPrefix deprecated due to", "// being broken, but what it does is it attempts to map path as", "// relative to overlay. If it succeeds and they're both absolute paths", "// (which means the relative path won't start with \"../\"), then make", "// path an absolute path with the overlay removed", "// filepath.Rel takes care of normalizing paths which is an advantage", "// over direct string comparisons which would be simpler.", "rel", ",", "err", ":=", "filepath", ".", "Rel", "(", "overlay", ",", "path", ")", "\n", "if", "err", "==", "nil", "&&", "!", "strings", ".", "HasPrefix", "(", "rel", ",", "\"", "\"", ")", "{", "path", "=", "\"", "\"", "+", "rel", "\n", "}", "\n", "}", "\n\n", "app", ":=", "hostmanifest", ".", "App", "{", "Name", ":", "kbnmAppName", ",", "Description", ":", "\"", "\"", ",", "Path", ":", "path", ",", "Type", ":", "\"", "\"", ",", "}", "\n\n", "var", "manifest", "hostmanifest", ".", "AppManifest", "\n", "for", "browser", ",", "whitelist", ":=", "range", "hostmanifest", ".", "KnownInstallers", "(", ")", "{", "switch", "browser", "{", "case", "\"", "\"", ",", "\"", "\"", ":", "manifest", "=", "hostmanifest", ".", "ChromeApp", "{", "App", ":", "app", ",", "AllowedOrigins", ":", "[", "]", "string", "{", "// Production public version in the store", "\"", "\"", ",", "// Hard-coded key from the repo version", "\"", "\"", ",", "// Keybase-internal version", "\"", "\"", ",", "}", ",", "}", "\n", "case", "\"", "\"", ":", "manifest", "=", "hostmanifest", ".", "FirefoxApp", "{", "App", ":", "app", ",", "AllowedExtensions", ":", "[", "]", "string", "{", "\"", "\"", ",", "}", ",", "}", "\n", "}", "\n\n", "if", "err", ":=", "whitelist", ".", "Install", "(", "u", ",", "manifest", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// InstallKBNM writes NativeMessaging whitelisting for KBNM.
[ "InstallKBNM", "writes", "NativeMessaging", "whitelisting", "for", "KBNM", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbnm/installer/installer.go#L54-L113
160,298
keybase/client
go/libkb/socket.go
ResetSocket
func (g *GlobalContext) ResetSocket(clearError bool) (net.Conn, rpc.Transporter, bool, error) { g.SocketWrapper = nil return g.GetSocket(clearError) }
go
func (g *GlobalContext) ResetSocket(clearError bool) (net.Conn, rpc.Transporter, bool, error) { g.SocketWrapper = nil return g.GetSocket(clearError) }
[ "func", "(", "g", "*", "GlobalContext", ")", "ResetSocket", "(", "clearError", "bool", ")", "(", "net", ".", "Conn", ",", "rpc", ".", "Transporter", ",", "bool", ",", "error", ")", "{", "g", ".", "SocketWrapper", "=", "nil", "\n", "return", "g", ".", "GetSocket", "(", "clearError", ")", "\n", "}" ]
// ResetSocket clears and returns a new socket
[ "ResetSocket", "clears", "and", "returns", "a", "new", "socket" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/socket.go#L58-L61
160,299
keybase/client
go/stellar/wallet_state.go
NewWalletState
func NewWalletState(g *libkb.GlobalContext, r remote.Remoter) *WalletState { ws := &WalletState{ Contextified: libkb.NewContextified(g), Remoter: r, accounts: make(map[stellar1.AccountID]*AccountState), rates: make(map[string]rateEntry), refreshGroup: &singleflight.Group{}, refreshReqs: make(chan stellar1.AccountID, 100), rateGroup: &singleflight.Group{}, options: NewOptions(), } g.PushShutdownHook(ws.Shutdown) go ws.backgroundRefresh() return ws }
go
func NewWalletState(g *libkb.GlobalContext, r remote.Remoter) *WalletState { ws := &WalletState{ Contextified: libkb.NewContextified(g), Remoter: r, accounts: make(map[stellar1.AccountID]*AccountState), rates: make(map[string]rateEntry), refreshGroup: &singleflight.Group{}, refreshReqs: make(chan stellar1.AccountID, 100), rateGroup: &singleflight.Group{}, options: NewOptions(), } g.PushShutdownHook(ws.Shutdown) go ws.backgroundRefresh() return ws }
[ "func", "NewWalletState", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "r", "remote", ".", "Remoter", ")", "*", "WalletState", "{", "ws", ":=", "&", "WalletState", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "Remoter", ":", "r", ",", "accounts", ":", "make", "(", "map", "[", "stellar1", ".", "AccountID", "]", "*", "AccountState", ")", ",", "rates", ":", "make", "(", "map", "[", "string", "]", "rateEntry", ")", ",", "refreshGroup", ":", "&", "singleflight", ".", "Group", "{", "}", ",", "refreshReqs", ":", "make", "(", "chan", "stellar1", ".", "AccountID", ",", "100", ")", ",", "rateGroup", ":", "&", "singleflight", ".", "Group", "{", "}", ",", "options", ":", "NewOptions", "(", ")", ",", "}", "\n\n", "g", ".", "PushShutdownHook", "(", "ws", ".", "Shutdown", ")", "\n\n", "go", "ws", ".", "backgroundRefresh", "(", ")", "\n\n", "return", "ws", "\n", "}" ]
// NewWalletState creates a wallet state with a remoter that will be // used for any network calls.
[ "NewWalletState", "creates", "a", "wallet", "state", "with", "a", "remoter", "that", "will", "be", "used", "for", "any", "network", "calls", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/wallet_state.go#L48-L65