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
|
---|---|---|---|---|---|---|---|---|---|---|---|
159,600 | keybase/client | go/stellar/relays/relays.go | DecryptB64 | func DecryptB64(mctx libkb.MetaContext, teamID keybase1.TeamID, boxB64 string) (res stellar1.RelayContents, err error) {
pack, err := base64.StdEncoding.DecodeString(boxB64)
if err != nil {
return res, fmt.Errorf("error decoding relay box: %v", err)
}
var box stellar1.EncryptedRelaySecret
err = libkb.MsgpackDecode(&box, pack)
if err != nil {
return res, err
}
appKey, err := getKeyForDecryption(mctx, teamID, box.Gen)
if err != nil {
return res, err
}
return decrypt(box, appKey)
} | go | func DecryptB64(mctx libkb.MetaContext, teamID keybase1.TeamID, boxB64 string) (res stellar1.RelayContents, err error) {
pack, err := base64.StdEncoding.DecodeString(boxB64)
if err != nil {
return res, fmt.Errorf("error decoding relay box: %v", err)
}
var box stellar1.EncryptedRelaySecret
err = libkb.MsgpackDecode(&box, pack)
if err != nil {
return res, err
}
appKey, err := getKeyForDecryption(mctx, teamID, box.Gen)
if err != nil {
return res, err
}
return decrypt(box, appKey)
} | [
"func",
"DecryptB64",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"teamID",
"keybase1",
".",
"TeamID",
",",
"boxB64",
"string",
")",
"(",
"res",
"stellar1",
".",
"RelayContents",
",",
"err",
"error",
")",
"{",
"pack",
",",
"err",
":=",
"base64",
".",
"StdEncoding",
".",
"DecodeString",
"(",
"boxB64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"var",
"box",
"stellar1",
".",
"EncryptedRelaySecret",
"\n",
"err",
"=",
"libkb",
".",
"MsgpackDecode",
"(",
"&",
"box",
",",
"pack",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n",
"appKey",
",",
"err",
":=",
"getKeyForDecryption",
"(",
"mctx",
",",
"teamID",
",",
"box",
".",
"Gen",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n",
"return",
"decrypt",
"(",
"box",
",",
"appKey",
")",
"\n",
"}"
] | // `boxB64` should be a stellar1.EncryptedRelaySecret | [
"boxB64",
"should",
"be",
"a",
"stellar1",
".",
"EncryptedRelaySecret"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/relays/relays.go#L154-L169 |
159,601 | keybase/client | go/terminalescaper/escaper.go | Clean | func Clean(s string) string {
return replace(func(r rune) rune {
if r >= 32 && r != 127 { // Values below 32 (and 127) are special non printing characters (i.e. DEL, ESC, carriage return).
return r
} else if r == '\n' || r == '\t' { // Allow newlines and tabs.
return r
} else if r == rune(keyEscape) {
// Start of a vt100 escape sequence. If not a color, we will
// substitute it with '^[' (this is how it is usually shown, i.e.
// in vim).
return -1
}
return -2
}, s)
} | go | func Clean(s string) string {
return replace(func(r rune) rune {
if r >= 32 && r != 127 { // Values below 32 (and 127) are special non printing characters (i.e. DEL, ESC, carriage return).
return r
} else if r == '\n' || r == '\t' { // Allow newlines and tabs.
return r
} else if r == rune(keyEscape) {
// Start of a vt100 escape sequence. If not a color, we will
// substitute it with '^[' (this is how it is usually shown, i.e.
// in vim).
return -1
}
return -2
}, s)
} | [
"func",
"Clean",
"(",
"s",
"string",
")",
"string",
"{",
"return",
"replace",
"(",
"func",
"(",
"r",
"rune",
")",
"rune",
"{",
"if",
"r",
">=",
"32",
"&&",
"r",
"!=",
"127",
"{",
"// Values below 32 (and 127) are special non printing characters (i.e. DEL, ESC, carriage return).",
"return",
"r",
"\n",
"}",
"else",
"if",
"r",
"==",
"'\\n'",
"||",
"r",
"==",
"'\\t'",
"{",
"// Allow newlines and tabs.",
"return",
"r",
"\n",
"}",
"else",
"if",
"r",
"==",
"rune",
"(",
"keyEscape",
")",
"{",
"// Start of a vt100 escape sequence. If not a color, we will",
"// substitute it with '^[' (this is how it is usually shown, i.e.",
"// in vim).",
"return",
"-",
"1",
"\n",
"}",
"\n",
"return",
"-",
"2",
"\n",
"}",
",",
"s",
")",
"\n",
"}"
] | // Clean escapes the UTF8 encoded string provided as input so it is safe to print on a unix terminal.
// It removes non printing characters and substitutes the vt100 escape character 0x1b with '^['. | [
"Clean",
"escapes",
"the",
"UTF8",
"encoded",
"string",
"provided",
"as",
"input",
"so",
"it",
"is",
"safe",
"to",
"print",
"on",
"a",
"unix",
"terminal",
".",
"It",
"removes",
"non",
"printing",
"characters",
"and",
"substitutes",
"the",
"vt100",
"escape",
"character",
"0x1b",
"with",
"^",
"[",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/terminalescaper/escaper.go#L47-L61 |
159,602 | keybase/client | go/libkb/burst_cache.go | NewBurstCache | func NewBurstCache(g *GlobalContext, cacheSize int, cacheLife time.Duration, cacheName string) *BurstCache {
lru, err := lru.New(cacheSize)
if err != nil {
g.Log.Fatalf("Bad LRU Constructor: %s", err.Error())
}
return &BurstCache{
Contextified: NewContextified(g),
lru: lru,
cacheLife: cacheLife,
cacheName: cacheName,
}
} | go | func NewBurstCache(g *GlobalContext, cacheSize int, cacheLife time.Duration, cacheName string) *BurstCache {
lru, err := lru.New(cacheSize)
if err != nil {
g.Log.Fatalf("Bad LRU Constructor: %s", err.Error())
}
return &BurstCache{
Contextified: NewContextified(g),
lru: lru,
cacheLife: cacheLife,
cacheName: cacheName,
}
} | [
"func",
"NewBurstCache",
"(",
"g",
"*",
"GlobalContext",
",",
"cacheSize",
"int",
",",
"cacheLife",
"time",
".",
"Duration",
",",
"cacheName",
"string",
")",
"*",
"BurstCache",
"{",
"lru",
",",
"err",
":=",
"lru",
".",
"New",
"(",
"cacheSize",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"g",
".",
"Log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"&",
"BurstCache",
"{",
"Contextified",
":",
"NewContextified",
"(",
"g",
")",
",",
"lru",
":",
"lru",
",",
"cacheLife",
":",
"cacheLife",
",",
"cacheName",
":",
"cacheName",
",",
"}",
"\n",
"}"
] | // NewBurstCache makes a new burst cache with the given size and cacheLife.
// The cache will be at most cacheSize items long, and items will live in there for
// at most cacheLife duration. For debug logging purposes, this cache will be known
// as cacheName. | [
"NewBurstCache",
"makes",
"a",
"new",
"burst",
"cache",
"with",
"the",
"given",
"size",
"and",
"cacheLife",
".",
"The",
"cache",
"will",
"be",
"at",
"most",
"cacheSize",
"items",
"long",
"and",
"items",
"will",
"live",
"in",
"there",
"for",
"at",
"most",
"cacheLife",
"duration",
".",
"For",
"debug",
"logging",
"purposes",
"this",
"cache",
"will",
"be",
"known",
"as",
"cacheName",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/burst_cache.go#L32-L43 |
159,603 | keybase/client | go/client/cmd_simplefs_sync.go | NewCmdSimpleFSSync | func NewCmdSimpleFSSync(
cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "sync",
Usage: "Manages the per-folder syncing state",
Subcommands: append([]cli.Command{
NewCmdSimpleFSSyncEnable(cl, g),
NewCmdSimpleFSSyncDisable(cl, g),
NewCmdSimpleFSSyncShow(cl, g),
}),
}
} | go | func NewCmdSimpleFSSync(
cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "sync",
Usage: "Manages the per-folder syncing state",
Subcommands: append([]cli.Command{
NewCmdSimpleFSSyncEnable(cl, g),
NewCmdSimpleFSSyncDisable(cl, g),
NewCmdSimpleFSSyncShow(cl, g),
}),
}
} | [
"func",
"NewCmdSimpleFSSync",
"(",
"cl",
"*",
"libcmdline",
".",
"CommandLine",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"Subcommands",
":",
"append",
"(",
"[",
"]",
"cli",
".",
"Command",
"{",
"NewCmdSimpleFSSyncEnable",
"(",
"cl",
",",
"g",
")",
",",
"NewCmdSimpleFSSyncDisable",
"(",
"cl",
",",
"g",
")",
",",
"NewCmdSimpleFSSyncShow",
"(",
"cl",
",",
"g",
")",
",",
"}",
")",
",",
"}",
"\n",
"}"
] | // NewCmdSimpleFSSync creates the sync command, which is just a holder
// for subcommands. | [
"NewCmdSimpleFSSync",
"creates",
"the",
"sync",
"command",
"which",
"is",
"just",
"a",
"holder",
"for",
"subcommands",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_simplefs_sync.go#L14-L25 |
159,604 | keybase/client | go/jsonhelpers/json_helpers.go | JSONStringSimple | func JSONStringSimple(object *jsonw.Wrapper) (string, error) {
x, err := object.GetInt()
if err == nil {
return fmt.Sprintf("%d", x), nil
}
y, err := object.GetString()
if err == nil {
return y, nil
}
z, err := object.GetBool()
if err == nil {
if z {
return "true", nil
}
return "false", nil
}
return "", fmt.Errorf("Non-simple object: %v", object)
} | go | func JSONStringSimple(object *jsonw.Wrapper) (string, error) {
x, err := object.GetInt()
if err == nil {
return fmt.Sprintf("%d", x), nil
}
y, err := object.GetString()
if err == nil {
return y, nil
}
z, err := object.GetBool()
if err == nil {
if z {
return "true", nil
}
return "false", nil
}
return "", fmt.Errorf("Non-simple object: %v", object)
} | [
"func",
"JSONStringSimple",
"(",
"object",
"*",
"jsonw",
".",
"Wrapper",
")",
"(",
"string",
",",
"error",
")",
"{",
"x",
",",
"err",
":=",
"object",
".",
"GetInt",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"x",
")",
",",
"nil",
"\n",
"}",
"\n",
"y",
",",
"err",
":=",
"object",
".",
"GetString",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"y",
",",
"nil",
"\n",
"}",
"\n",
"z",
",",
"err",
":=",
"object",
".",
"GetBool",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"z",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"object",
")",
"\n",
"}"
] | // JSONStringSimple converts a simple json object into a string. Simple
// objects are those that are not arrays or objects. Non-simple objects result
// in an error. | [
"JSONStringSimple",
"converts",
"a",
"simple",
"json",
"object",
"into",
"a",
"string",
".",
"Simple",
"objects",
"are",
"those",
"that",
"are",
"not",
"arrays",
"or",
"objects",
".",
"Non",
"-",
"simple",
"objects",
"result",
"in",
"an",
"error",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/jsonhelpers/json_helpers.go#L14-L32 |
159,605 | keybase/client | go/jsonhelpers/json_helpers.go | pyindex | func pyindex(index, len int) (int, bool) {
if len <= 0 {
return 0, false
}
// wrap from the end
if index < 0 {
index = len + index
}
if index < 0 || index >= len {
return 0, false
}
return index, true
} | go | func pyindex(index, len int) (int, bool) {
if len <= 0 {
return 0, false
}
// wrap from the end
if index < 0 {
index = len + index
}
if index < 0 || index >= len {
return 0, false
}
return index, true
} | [
"func",
"pyindex",
"(",
"index",
",",
"len",
"int",
")",
"(",
"int",
",",
"bool",
")",
"{",
"if",
"len",
"<=",
"0",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"// wrap from the end",
"if",
"index",
"<",
"0",
"{",
"index",
"=",
"len",
"+",
"index",
"\n",
"}",
"\n",
"if",
"index",
"<",
"0",
"||",
"index",
">=",
"len",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"return",
"index",
",",
"true",
"\n",
"}"
] | // pyindex converts an index into a real index like python.
// Returns an index to use and whether the index is safe to use. | [
"pyindex",
"converts",
"an",
"index",
"into",
"a",
"real",
"index",
"like",
"python",
".",
"Returns",
"an",
"index",
"to",
"use",
"and",
"whether",
"the",
"index",
"is",
"safe",
"to",
"use",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/jsonhelpers/json_helpers.go#L36-L48 |
159,606 | keybase/client | go/jsonhelpers/json_helpers.go | jsonUnpackArray | func jsonUnpackArray(w *jsonw.Wrapper) ([]*jsonw.Wrapper, error) {
w, err := w.ToArray()
if err != nil {
return nil, err
}
length, err := w.Len()
if err != nil {
return nil, err
}
res := make([]*jsonw.Wrapper, length)
for i := 0; i < length; i++ {
res[i] = w.AtIndex(i)
}
return res, nil
} | go | func jsonUnpackArray(w *jsonw.Wrapper) ([]*jsonw.Wrapper, error) {
w, err := w.ToArray()
if err != nil {
return nil, err
}
length, err := w.Len()
if err != nil {
return nil, err
}
res := make([]*jsonw.Wrapper, length)
for i := 0; i < length; i++ {
res[i] = w.AtIndex(i)
}
return res, nil
} | [
"func",
"jsonUnpackArray",
"(",
"w",
"*",
"jsonw",
".",
"Wrapper",
")",
"(",
"[",
"]",
"*",
"jsonw",
".",
"Wrapper",
",",
"error",
")",
"{",
"w",
",",
"err",
":=",
"w",
".",
"ToArray",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"length",
",",
"err",
":=",
"w",
".",
"Len",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"res",
":=",
"make",
"(",
"[",
"]",
"*",
"jsonw",
".",
"Wrapper",
",",
"length",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
"{",
"res",
"[",
"i",
"]",
"=",
"w",
".",
"AtIndex",
"(",
"i",
")",
"\n",
"}",
"\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] | // Return the elements of an array. | [
"Return",
"the",
"elements",
"of",
"an",
"array",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/jsonhelpers/json_helpers.go#L51-L65 |
159,607 | keybase/client | go/jsonhelpers/json_helpers.go | JSONGetChildren | func JSONGetChildren(w *jsonw.Wrapper) ([]*jsonw.Wrapper, error) {
dict, err := w.ToDictionary()
isDict := err == nil
array, err := w.ToArray()
isArray := err == nil
switch {
case isDict:
keys, err := dict.Keys()
if err != nil {
return nil, err
}
var res = make([]*jsonw.Wrapper, len(keys))
for i, key := range keys {
res[i] = dict.AtKey(key)
}
return res, nil
case isArray:
return jsonUnpackArray(array)
default:
return nil, errors.New("got children of non-container")
}
} | go | func JSONGetChildren(w *jsonw.Wrapper) ([]*jsonw.Wrapper, error) {
dict, err := w.ToDictionary()
isDict := err == nil
array, err := w.ToArray()
isArray := err == nil
switch {
case isDict:
keys, err := dict.Keys()
if err != nil {
return nil, err
}
var res = make([]*jsonw.Wrapper, len(keys))
for i, key := range keys {
res[i] = dict.AtKey(key)
}
return res, nil
case isArray:
return jsonUnpackArray(array)
default:
return nil, errors.New("got children of non-container")
}
} | [
"func",
"JSONGetChildren",
"(",
"w",
"*",
"jsonw",
".",
"Wrapper",
")",
"(",
"[",
"]",
"*",
"jsonw",
".",
"Wrapper",
",",
"error",
")",
"{",
"dict",
",",
"err",
":=",
"w",
".",
"ToDictionary",
"(",
")",
"\n",
"isDict",
":=",
"err",
"==",
"nil",
"\n",
"array",
",",
"err",
":=",
"w",
".",
"ToArray",
"(",
")",
"\n",
"isArray",
":=",
"err",
"==",
"nil",
"\n\n",
"switch",
"{",
"case",
"isDict",
":",
"keys",
",",
"err",
":=",
"dict",
".",
"Keys",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"res",
"=",
"make",
"(",
"[",
"]",
"*",
"jsonw",
".",
"Wrapper",
",",
"len",
"(",
"keys",
")",
")",
"\n",
"for",
"i",
",",
"key",
":=",
"range",
"keys",
"{",
"res",
"[",
"i",
"]",
"=",
"dict",
".",
"AtKey",
"(",
"key",
")",
"\n",
"}",
"\n",
"return",
"res",
",",
"nil",
"\n",
"case",
"isArray",
":",
"return",
"jsonUnpackArray",
"(",
"array",
")",
"\n",
"default",
":",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // Return the elements of an array or values of a map. | [
"Return",
"the",
"elements",
"of",
"an",
"array",
"or",
"values",
"of",
"a",
"map",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/jsonhelpers/json_helpers.go#L68-L90 |
159,608 | keybase/client | go/kbfs/libfuse/alias.go | Attr | func (*Alias) Attr(ctx context.Context, a *fuse.Attr) error {
a.Mode = os.ModeSymlink | 0777
// Aliases can't be moved, so let bazil generate an inode.
return nil
} | go | func (*Alias) Attr(ctx context.Context, a *fuse.Attr) error {
a.Mode = os.ModeSymlink | 0777
// Aliases can't be moved, so let bazil generate an inode.
return nil
} | [
"func",
"(",
"*",
"Alias",
")",
"Attr",
"(",
"ctx",
"context",
".",
"Context",
",",
"a",
"*",
"fuse",
".",
"Attr",
")",
"error",
"{",
"a",
".",
"Mode",
"=",
"os",
".",
"ModeSymlink",
"|",
"0777",
"\n",
"// Aliases can't be moved, so let bazil generate an inode.",
"return",
"nil",
"\n",
"}"
] | // Attr implements the fs.Node interface for Alias. | [
"Attr",
"implements",
"the",
"fs",
".",
"Node",
"interface",
"for",
"Alias",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/alias.go#L29-L33 |
159,609 | keybase/client | go/kbfs/libfuse/alias.go | Readlink | func (a *Alias) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) {
return a.realPath, nil
} | go | func (a *Alias) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) {
return a.realPath, nil
} | [
"func",
"(",
"a",
"*",
"Alias",
")",
"Readlink",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"ReadlinkRequest",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"a",
".",
"realPath",
",",
"nil",
"\n",
"}"
] | // Readlink implements the fs.NodeReadlinker interface for Alias. | [
"Readlink",
"implements",
"the",
"fs",
".",
"NodeReadlinker",
"interface",
"for",
"Alias",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/alias.go#L38-L40 |
159,610 | keybase/client | go/chat/teams.go | shouldFallbackToSlowLoadAfterFTLError | func shouldFallbackToSlowLoadAfterFTLError(m libkb.MetaContext, err error) bool {
if err == nil {
return false
}
switch tErr := err.(type) {
case libkb.TeamFTLOutdatedError:
m.Debug("Our FTL implementation is too old; falling back to slow loader (%v)", err)
return true
case libkb.FeatureFlagError:
if tErr.Feature() == libkb.FeatureFTL {
m.Debug("FTL feature-flagged off on the server, falling back to regular loader")
return true
}
}
return false
} | go | func shouldFallbackToSlowLoadAfterFTLError(m libkb.MetaContext, err error) bool {
if err == nil {
return false
}
switch tErr := err.(type) {
case libkb.TeamFTLOutdatedError:
m.Debug("Our FTL implementation is too old; falling back to slow loader (%v)", err)
return true
case libkb.FeatureFlagError:
if tErr.Feature() == libkb.FeatureFTL {
m.Debug("FTL feature-flagged off on the server, falling back to regular loader")
return true
}
}
return false
} | [
"func",
"shouldFallbackToSlowLoadAfterFTLError",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"tErr",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"libkb",
".",
"TeamFTLOutdatedError",
":",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"true",
"\n",
"case",
"libkb",
".",
"FeatureFlagError",
":",
"if",
"tErr",
".",
"Feature",
"(",
")",
"==",
"libkb",
".",
"FeatureFTL",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // shouldFallbackToSlowLoadAfterFTLError returns trues if the given error should result
// in a retry via slow loading. Right now, it only happens if the server tells us
// that our FTL is outdated, or FTL is feature-flagged off on the server. | [
"shouldFallbackToSlowLoadAfterFTLError",
"returns",
"trues",
"if",
"the",
"given",
"error",
"should",
"result",
"in",
"a",
"retry",
"via",
"slow",
"loading",
".",
"Right",
"now",
"it",
"only",
"happens",
"if",
"the",
"server",
"tells",
"us",
"that",
"our",
"FTL",
"is",
"outdated",
"or",
"FTL",
"is",
"feature",
"-",
"flagged",
"off",
"on",
"the",
"server",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/teams.go#L40-L55 |
159,611 | keybase/client | go/teams/service_helper.go | ImplicitAdmins | func ImplicitAdmins(ctx context.Context, g *libkb.GlobalContext, teamID keybase1.TeamID) (res []keybase1.TeamMemberDetails, err error) {
defer g.CTraceTimed(ctx, fmt.Sprintf("teams::ImplicitAdmins(%v)", teamID), func() error { return err })()
if teamID.IsRootTeam() {
// Root teams have only explicit admins.
return nil, nil
}
uvs, err := g.GetTeamLoader().ImplicitAdmins(ctx, teamID)
if err != nil {
return nil, err
}
return userVersionsToDetails(ctx, g, uvs)
} | go | func ImplicitAdmins(ctx context.Context, g *libkb.GlobalContext, teamID keybase1.TeamID) (res []keybase1.TeamMemberDetails, err error) {
defer g.CTraceTimed(ctx, fmt.Sprintf("teams::ImplicitAdmins(%v)", teamID), func() error { return err })()
if teamID.IsRootTeam() {
// Root teams have only explicit admins.
return nil, nil
}
uvs, err := g.GetTeamLoader().ImplicitAdmins(ctx, teamID)
if err != nil {
return nil, err
}
return userVersionsToDetails(ctx, g, uvs)
} | [
"func",
"ImplicitAdmins",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"teamID",
"keybase1",
".",
"TeamID",
")",
"(",
"res",
"[",
"]",
"keybase1",
".",
"TeamMemberDetails",
",",
"err",
"error",
")",
"{",
"defer",
"g",
".",
"CTraceTimed",
"(",
"ctx",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"teamID",
")",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"if",
"teamID",
".",
"IsRootTeam",
"(",
")",
"{",
"// Root teams have only explicit admins.",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"uvs",
",",
"err",
":=",
"g",
".",
"GetTeamLoader",
"(",
")",
".",
"ImplicitAdmins",
"(",
"ctx",
",",
"teamID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"userVersionsToDetails",
"(",
"ctx",
",",
"g",
",",
"uvs",
")",
"\n",
"}"
] | // List all the admins of ancestor teams.
// Includes admins of the specified team only if they are also admins of ancestor teams. | [
"List",
"all",
"the",
"admins",
"of",
"ancestor",
"teams",
".",
"Includes",
"admins",
"of",
"the",
"specified",
"team",
"only",
"if",
"they",
"are",
"also",
"admins",
"of",
"ancestor",
"teams",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/service_helper.go#L73-L85 |
159,612 | keybase/client | go/teams/service_helper.go | membersHideInactiveDuplicates | func membersHideInactiveDuplicates(ctx context.Context, g *libkb.GlobalContext, members *keybase1.TeamMembersDetails) {
// If a UID appears multiple times with different TeamMemberStatus, only show the 'ACTIVE' version.
// This can happen when an owner resets and is re-added as an admin by an admin.
seenActive := make(map[keybase1.UID]bool)
lists := []*[]keybase1.TeamMemberDetails{
&members.Owners,
&members.Admins,
&members.Writers,
&members.Readers,
}
// Scan for active rows
for _, rows := range lists {
for _, row := range *rows {
if row.Status == keybase1.TeamMemberStatus_ACTIVE {
seenActive[row.Uv.Uid] = true
}
}
}
// Filter out superseded inactive rows
for _, rows := range lists {
filtered := []keybase1.TeamMemberDetails{}
for _, row := range *rows {
if row.Status == keybase1.TeamMemberStatus_ACTIVE || !seenActive[row.Uv.Uid] {
filtered = append(filtered, row)
} else {
g.Log.CDebugf(ctx, "membersHideInactiveDuplicates filtered out row: %v %v", row.Uv, row.Status)
}
}
*rows = filtered
}
} | go | func membersHideInactiveDuplicates(ctx context.Context, g *libkb.GlobalContext, members *keybase1.TeamMembersDetails) {
// If a UID appears multiple times with different TeamMemberStatus, only show the 'ACTIVE' version.
// This can happen when an owner resets and is re-added as an admin by an admin.
seenActive := make(map[keybase1.UID]bool)
lists := []*[]keybase1.TeamMemberDetails{
&members.Owners,
&members.Admins,
&members.Writers,
&members.Readers,
}
// Scan for active rows
for _, rows := range lists {
for _, row := range *rows {
if row.Status == keybase1.TeamMemberStatus_ACTIVE {
seenActive[row.Uv.Uid] = true
}
}
}
// Filter out superseded inactive rows
for _, rows := range lists {
filtered := []keybase1.TeamMemberDetails{}
for _, row := range *rows {
if row.Status == keybase1.TeamMemberStatus_ACTIVE || !seenActive[row.Uv.Uid] {
filtered = append(filtered, row)
} else {
g.Log.CDebugf(ctx, "membersHideInactiveDuplicates filtered out row: %v %v", row.Uv, row.Status)
}
}
*rows = filtered
}
} | [
"func",
"membersHideInactiveDuplicates",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"members",
"*",
"keybase1",
".",
"TeamMembersDetails",
")",
"{",
"// If a UID appears multiple times with different TeamMemberStatus, only show the 'ACTIVE' version.",
"// This can happen when an owner resets and is re-added as an admin by an admin.",
"seenActive",
":=",
"make",
"(",
"map",
"[",
"keybase1",
".",
"UID",
"]",
"bool",
")",
"\n",
"lists",
":=",
"[",
"]",
"*",
"[",
"]",
"keybase1",
".",
"TeamMemberDetails",
"{",
"&",
"members",
".",
"Owners",
",",
"&",
"members",
".",
"Admins",
",",
"&",
"members",
".",
"Writers",
",",
"&",
"members",
".",
"Readers",
",",
"}",
"\n",
"// Scan for active rows",
"for",
"_",
",",
"rows",
":=",
"range",
"lists",
"{",
"for",
"_",
",",
"row",
":=",
"range",
"*",
"rows",
"{",
"if",
"row",
".",
"Status",
"==",
"keybase1",
".",
"TeamMemberStatus_ACTIVE",
"{",
"seenActive",
"[",
"row",
".",
"Uv",
".",
"Uid",
"]",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"// Filter out superseded inactive rows",
"for",
"_",
",",
"rows",
":=",
"range",
"lists",
"{",
"filtered",
":=",
"[",
"]",
"keybase1",
".",
"TeamMemberDetails",
"{",
"}",
"\n",
"for",
"_",
",",
"row",
":=",
"range",
"*",
"rows",
"{",
"if",
"row",
".",
"Status",
"==",
"keybase1",
".",
"TeamMemberStatus_ACTIVE",
"||",
"!",
"seenActive",
"[",
"row",
".",
"Uv",
".",
"Uid",
"]",
"{",
"filtered",
"=",
"append",
"(",
"filtered",
",",
"row",
")",
"\n",
"}",
"else",
"{",
"g",
".",
"Log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"row",
".",
"Uv",
",",
"row",
".",
"Status",
")",
"\n",
"}",
"\n",
"}",
"\n",
"*",
"rows",
"=",
"filtered",
"\n",
"}",
"\n",
"}"
] | // If a UID appears multiple times with different TeamMemberStatus, only show the 'ACTIVE' version.
// This can happen when an owner resets and is re-added as an admin by an admin.
// Mutates `members` | [
"If",
"a",
"UID",
"appears",
"multiple",
"times",
"with",
"different",
"TeamMemberStatus",
"only",
"show",
"the",
"ACTIVE",
"version",
".",
"This",
"can",
"happen",
"when",
"an",
"owner",
"resets",
"and",
"is",
"re",
"-",
"added",
"as",
"an",
"admin",
"by",
"an",
"admin",
".",
"Mutates",
"members"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/service_helper.go#L118-L148 |
159,613 | keybase/client | go/teams/service_helper.go | splitBulk | func splitBulk(s string) []string {
f := func(c rune) bool {
return c == '\n' || c == ','
}
split := strings.FieldsFunc(s, f)
for i, s := range split {
split[i] = strings.TrimSpace(s)
}
return split
} | go | func splitBulk(s string) []string {
f := func(c rune) bool {
return c == '\n' || c == ','
}
split := strings.FieldsFunc(s, f)
for i, s := range split {
split[i] = strings.TrimSpace(s)
}
return split
} | [
"func",
"splitBulk",
"(",
"s",
"string",
")",
"[",
"]",
"string",
"{",
"f",
":=",
"func",
"(",
"c",
"rune",
")",
"bool",
"{",
"return",
"c",
"==",
"'\\n'",
"||",
"c",
"==",
"','",
"\n",
"}",
"\n",
"split",
":=",
"strings",
".",
"FieldsFunc",
"(",
"s",
",",
"f",
")",
"\n",
"for",
"i",
",",
"s",
":=",
"range",
"split",
"{",
"split",
"[",
"i",
"]",
"=",
"strings",
".",
"TrimSpace",
"(",
"s",
")",
"\n",
"}",
"\n",
"return",
"split",
"\n",
"}"
] | // splitBulk splits on newline or comma. | [
"splitBulk",
"splits",
"on",
"newline",
"or",
"comma",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/service_helper.go#L1425-L1434 |
159,614 | keybase/client | go/teams/service_helper.go | CreateTLF | func CreateTLF(ctx context.Context, g *libkb.GlobalContext, arg keybase1.CreateTLFArg) (err error) {
defer g.CTrace(ctx, fmt.Sprintf("CreateTLF(%v)", arg), func() error { return err })()
ctx = libkb.WithLogTag(ctx, "CREATETLF")
return RetryIfPossible(ctx, g, func(ctx context.Context, _ int) error {
t, err := GetForTeamManagementByTeamID(ctx, g, arg.TeamID, false)
if err != nil {
return err
}
role, err := t.myRole(ctx)
if err != nil {
return err
}
if !role.IsWriterOrAbove() {
return fmt.Errorf("permission denied: need writer access (or above)")
}
return t.AssociateWithTLFID(ctx, arg.TlfID)
})
} | go | func CreateTLF(ctx context.Context, g *libkb.GlobalContext, arg keybase1.CreateTLFArg) (err error) {
defer g.CTrace(ctx, fmt.Sprintf("CreateTLF(%v)", arg), func() error { return err })()
ctx = libkb.WithLogTag(ctx, "CREATETLF")
return RetryIfPossible(ctx, g, func(ctx context.Context, _ int) error {
t, err := GetForTeamManagementByTeamID(ctx, g, arg.TeamID, false)
if err != nil {
return err
}
role, err := t.myRole(ctx)
if err != nil {
return err
}
if !role.IsWriterOrAbove() {
return fmt.Errorf("permission denied: need writer access (or above)")
}
return t.AssociateWithTLFID(ctx, arg.TlfID)
})
} | [
"func",
"CreateTLF",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"arg",
"keybase1",
".",
"CreateTLFArg",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"g",
".",
"CTrace",
"(",
"ctx",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"arg",
")",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"ctx",
"=",
"libkb",
".",
"WithLogTag",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"return",
"RetryIfPossible",
"(",
"ctx",
",",
"g",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"int",
")",
"error",
"{",
"t",
",",
"err",
":=",
"GetForTeamManagementByTeamID",
"(",
"ctx",
",",
"g",
",",
"arg",
".",
"TeamID",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"role",
",",
"err",
":=",
"t",
".",
"myRole",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"role",
".",
"IsWriterOrAbove",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"t",
".",
"AssociateWithTLFID",
"(",
"ctx",
",",
"arg",
".",
"TlfID",
")",
"\n",
"}",
")",
"\n",
"}"
] | // CreateTLF is called by KBFS when a TLF ID is associated with an implicit team.
// Should work on either named or implicit teams. | [
"CreateTLF",
"is",
"called",
"by",
"KBFS",
"when",
"a",
"TLF",
"ID",
"is",
"associated",
"with",
"an",
"implicit",
"team",
".",
"Should",
"work",
"on",
"either",
"named",
"or",
"implicit",
"teams",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/service_helper.go#L1464-L1481 |
159,615 | keybase/client | go/flexibletable/table.go | Insert | func (t *Table) Insert(row Row) error {
if len(t.rows) > 0 && len(t.rows[0]) != len(row) {
return InconsistentRowsError{existingRows: len(t.rows), newRow: len(row)}
}
t.rows = append(t.rows, row)
t.nInserts++
return nil
} | go | func (t *Table) Insert(row Row) error {
if len(t.rows) > 0 && len(t.rows[0]) != len(row) {
return InconsistentRowsError{existingRows: len(t.rows), newRow: len(row)}
}
t.rows = append(t.rows, row)
t.nInserts++
return nil
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"Insert",
"(",
"row",
"Row",
")",
"error",
"{",
"if",
"len",
"(",
"t",
".",
"rows",
")",
">",
"0",
"&&",
"len",
"(",
"t",
".",
"rows",
"[",
"0",
"]",
")",
"!=",
"len",
"(",
"row",
")",
"{",
"return",
"InconsistentRowsError",
"{",
"existingRows",
":",
"len",
"(",
"t",
".",
"rows",
")",
",",
"newRow",
":",
"len",
"(",
"row",
")",
"}",
"\n",
"}",
"\n",
"t",
".",
"rows",
"=",
"append",
"(",
"t",
".",
"rows",
",",
"row",
")",
"\n",
"t",
".",
"nInserts",
"++",
"\n",
"return",
"nil",
"\n",
"}"
] | // Insert inserts a row into the table | [
"Insert",
"inserts",
"a",
"row",
"into",
"the",
"table"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/flexibletable/table.go#L39-L46 |
159,616 | keybase/client | go/flexibletable/table.go | Render | func (t Table) Render(w io.Writer, cellSep string, maxWidth int, constraints []ColumnConstraint) error {
if len(t.rows) == 0 {
return NoRowsError{}
}
if len(constraints) != len(t.rows[0]) {
return InconsistentRowsError{existingRows: len(t.rows[0]), newRow: len(constraints)}
}
err := t.breakOnLineBreaks()
if err != nil {
return err
}
widths, err := t.renderFirstPass(cellSep, maxWidth, constraints)
if err != nil {
return err
}
rows, err := t.renderSecondPass(constraints, widths)
if err != nil {
return err
}
// write out
for _, row := range rows {
fmt.Fprint(w, strings.Join(row, cellSep))
fmt.Fprintln(w)
}
return nil
} | go | func (t Table) Render(w io.Writer, cellSep string, maxWidth int, constraints []ColumnConstraint) error {
if len(t.rows) == 0 {
return NoRowsError{}
}
if len(constraints) != len(t.rows[0]) {
return InconsistentRowsError{existingRows: len(t.rows[0]), newRow: len(constraints)}
}
err := t.breakOnLineBreaks()
if err != nil {
return err
}
widths, err := t.renderFirstPass(cellSep, maxWidth, constraints)
if err != nil {
return err
}
rows, err := t.renderSecondPass(constraints, widths)
if err != nil {
return err
}
// write out
for _, row := range rows {
fmt.Fprint(w, strings.Join(row, cellSep))
fmt.Fprintln(w)
}
return nil
} | [
"func",
"(",
"t",
"Table",
")",
"Render",
"(",
"w",
"io",
".",
"Writer",
",",
"cellSep",
"string",
",",
"maxWidth",
"int",
",",
"constraints",
"[",
"]",
"ColumnConstraint",
")",
"error",
"{",
"if",
"len",
"(",
"t",
".",
"rows",
")",
"==",
"0",
"{",
"return",
"NoRowsError",
"{",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"constraints",
")",
"!=",
"len",
"(",
"t",
".",
"rows",
"[",
"0",
"]",
")",
"{",
"return",
"InconsistentRowsError",
"{",
"existingRows",
":",
"len",
"(",
"t",
".",
"rows",
"[",
"0",
"]",
")",
",",
"newRow",
":",
"len",
"(",
"constraints",
")",
"}",
"\n",
"}",
"\n\n",
"err",
":=",
"t",
".",
"breakOnLineBreaks",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"widths",
",",
"err",
":=",
"t",
".",
"renderFirstPass",
"(",
"cellSep",
",",
"maxWidth",
",",
"constraints",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"rows",
",",
"err",
":=",
"t",
".",
"renderSecondPass",
"(",
"constraints",
",",
"widths",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// write out",
"for",
"_",
",",
"row",
":=",
"range",
"rows",
"{",
"fmt",
".",
"Fprint",
"(",
"w",
",",
"strings",
".",
"Join",
"(",
"row",
",",
"cellSep",
")",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"w",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Render renders the table into writer. The constraints parameter specifies
// how each column should be constrained while being rendered. Positive values
// limit the maximum width. | [
"Render",
"renders",
"the",
"table",
"into",
"writer",
".",
"The",
"constraints",
"parameter",
"specifies",
"how",
"each",
"column",
"should",
"be",
"constrained",
"while",
"being",
"rendered",
".",
"Positive",
"values",
"limit",
"the",
"maximum",
"width",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/flexibletable/table.go#L207-L237 |
159,617 | keybase/client | go/libkb/remote_proof_links.go | NewRemoteProofLinks | func NewRemoteProofLinks(g *GlobalContext) *RemoteProofLinks {
return &RemoteProofLinks{
Contextified: NewContextified(g),
links: make(map[string][]ProofLinkWithState),
}
} | go | func NewRemoteProofLinks(g *GlobalContext) *RemoteProofLinks {
return &RemoteProofLinks{
Contextified: NewContextified(g),
links: make(map[string][]ProofLinkWithState),
}
} | [
"func",
"NewRemoteProofLinks",
"(",
"g",
"*",
"GlobalContext",
")",
"*",
"RemoteProofLinks",
"{",
"return",
"&",
"RemoteProofLinks",
"{",
"Contextified",
":",
"NewContextified",
"(",
"g",
")",
",",
"links",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"ProofLinkWithState",
")",
",",
"}",
"\n",
"}"
] | // NewRemoteProofLinks creates a new empty collection of proof
// links. | [
"NewRemoteProofLinks",
"creates",
"a",
"new",
"empty",
"collection",
"of",
"proof",
"links",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/remote_proof_links.go#L27-L32 |
159,618 | keybase/client | go/libkb/remote_proof_links.go | Insert | func (r *RemoteProofLinks) Insert(link RemoteProofChainLink, err ProofError) {
key := link.TableKey()
if len(key) == 0 {
return
}
r.links[key] = append(r.links[key], ProofLinkWithState{link: link, state: ProofErrorToState(err)})
} | go | func (r *RemoteProofLinks) Insert(link RemoteProofChainLink, err ProofError) {
key := link.TableKey()
if len(key) == 0 {
return
}
r.links[key] = append(r.links[key], ProofLinkWithState{link: link, state: ProofErrorToState(err)})
} | [
"func",
"(",
"r",
"*",
"RemoteProofLinks",
")",
"Insert",
"(",
"link",
"RemoteProofChainLink",
",",
"err",
"ProofError",
")",
"{",
"key",
":=",
"link",
".",
"TableKey",
"(",
")",
"\n",
"if",
"len",
"(",
"key",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"r",
".",
"links",
"[",
"key",
"]",
"=",
"append",
"(",
"r",
".",
"links",
"[",
"key",
"]",
",",
"ProofLinkWithState",
"{",
"link",
":",
"link",
",",
"state",
":",
"ProofErrorToState",
"(",
"err",
")",
"}",
")",
"\n",
"}"
] | // Insert adds a link to the collection of proof links. | [
"Insert",
"adds",
"a",
"link",
"to",
"the",
"collection",
"of",
"proof",
"links",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/remote_proof_links.go#L35-L41 |
159,619 | keybase/client | go/libkb/remote_proof_links.go | ForService | func (r *RemoteProofLinks) ForService(st ServiceType) []RemoteProofChainLink {
var links []RemoteProofChainLink
for _, linkWithState := range r.links[st.Key()] {
if linkWithState.link.LastWriterWins() {
// Clear the array if it's a last-writer wins service.
// (like many social networks)
links = nil
}
if linkWithState.link.IsRevoked() {
continue
}
links = append(links, linkWithState.link)
}
return links
} | go | func (r *RemoteProofLinks) ForService(st ServiceType) []RemoteProofChainLink {
var links []RemoteProofChainLink
for _, linkWithState := range r.links[st.Key()] {
if linkWithState.link.LastWriterWins() {
// Clear the array if it's a last-writer wins service.
// (like many social networks)
links = nil
}
if linkWithState.link.IsRevoked() {
continue
}
links = append(links, linkWithState.link)
}
return links
} | [
"func",
"(",
"r",
"*",
"RemoteProofLinks",
")",
"ForService",
"(",
"st",
"ServiceType",
")",
"[",
"]",
"RemoteProofChainLink",
"{",
"var",
"links",
"[",
"]",
"RemoteProofChainLink",
"\n",
"for",
"_",
",",
"linkWithState",
":=",
"range",
"r",
".",
"links",
"[",
"st",
".",
"Key",
"(",
")",
"]",
"{",
"if",
"linkWithState",
".",
"link",
".",
"LastWriterWins",
"(",
")",
"{",
"// Clear the array if it's a last-writer wins service.",
"// (like many social networks)",
"links",
"=",
"nil",
"\n",
"}",
"\n",
"if",
"linkWithState",
".",
"link",
".",
"IsRevoked",
"(",
")",
"{",
"continue",
"\n",
"}",
"\n",
"links",
"=",
"append",
"(",
"links",
",",
"linkWithState",
".",
"link",
")",
"\n",
"}",
"\n",
"return",
"links",
"\n",
"}"
] | // ForService returns all the active proof links for a service. | [
"ForService",
"returns",
"all",
"the",
"active",
"proof",
"links",
"for",
"a",
"service",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/remote_proof_links.go#L44-L58 |
159,620 | keybase/client | go/libkb/remote_proof_links.go | Active | func (r *RemoteProofLinks) Active() []RemoteProofChainLink {
a := r.active()
links := make([]RemoteProofChainLink, len(a))
for i, b := range a {
links[i] = b.link
}
return links
} | go | func (r *RemoteProofLinks) Active() []RemoteProofChainLink {
a := r.active()
links := make([]RemoteProofChainLink, len(a))
for i, b := range a {
links[i] = b.link
}
return links
} | [
"func",
"(",
"r",
"*",
"RemoteProofLinks",
")",
"Active",
"(",
")",
"[",
"]",
"RemoteProofChainLink",
"{",
"a",
":=",
"r",
".",
"active",
"(",
")",
"\n",
"links",
":=",
"make",
"(",
"[",
"]",
"RemoteProofChainLink",
",",
"len",
"(",
"a",
")",
")",
"\n",
"for",
"i",
",",
"b",
":=",
"range",
"a",
"{",
"links",
"[",
"i",
"]",
"=",
"b",
".",
"link",
"\n",
"}",
"\n",
"return",
"links",
"\n",
"}"
] | // Active returns all the active proof links, deduplicating any and
// honoring the LastWriterWins option. | [
"Active",
"returns",
"all",
"the",
"active",
"proof",
"links",
"deduplicating",
"any",
"and",
"honoring",
"the",
"LastWriterWins",
"option",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/remote_proof_links.go#L62-L69 |
159,621 | keybase/client | go/libkb/remote_proof_links.go | TrackingStatement | func (r *RemoteProofLinks) TrackingStatement() *jsonw.Wrapper {
var proofs []*jsonw.Wrapper
for _, x := range r.active() {
d, err := x.link.ToTrackingStatement(x.state)
if err != nil {
r.G().Log.Warning("Problem with a proof: %s", err)
continue
}
if d != nil {
proofs = append(proofs, d)
}
}
res := jsonw.NewArray(len(proofs))
for i, proof := range proofs {
res.SetIndex(i, proof)
}
return res
} | go | func (r *RemoteProofLinks) TrackingStatement() *jsonw.Wrapper {
var proofs []*jsonw.Wrapper
for _, x := range r.active() {
d, err := x.link.ToTrackingStatement(x.state)
if err != nil {
r.G().Log.Warning("Problem with a proof: %s", err)
continue
}
if d != nil {
proofs = append(proofs, d)
}
}
res := jsonw.NewArray(len(proofs))
for i, proof := range proofs {
res.SetIndex(i, proof)
}
return res
} | [
"func",
"(",
"r",
"*",
"RemoteProofLinks",
")",
"TrackingStatement",
"(",
")",
"*",
"jsonw",
".",
"Wrapper",
"{",
"var",
"proofs",
"[",
"]",
"*",
"jsonw",
".",
"Wrapper",
"\n",
"for",
"_",
",",
"x",
":=",
"range",
"r",
".",
"active",
"(",
")",
"{",
"d",
",",
"err",
":=",
"x",
".",
"link",
".",
"ToTrackingStatement",
"(",
"x",
".",
"state",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r",
".",
"G",
"(",
")",
".",
"Log",
".",
"Warning",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"if",
"d",
"!=",
"nil",
"{",
"proofs",
"=",
"append",
"(",
"proofs",
",",
"d",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"res",
":=",
"jsonw",
".",
"NewArray",
"(",
"len",
"(",
"proofs",
")",
")",
"\n",
"for",
"i",
",",
"proof",
":=",
"range",
"proofs",
"{",
"res",
".",
"SetIndex",
"(",
"i",
",",
"proof",
")",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] | // TrackingStatement generates the remote proofs portions of the
// tracking statement from the active proofs. | [
"TrackingStatement",
"generates",
"the",
"remote",
"proofs",
"portions",
"of",
"the",
"tracking",
"statement",
"from",
"the",
"active",
"proofs",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/remote_proof_links.go#L73-L91 |
159,622 | keybase/client | go/libkb/remote_proof_links.go | TrackSet | func (r *RemoteProofLinks) TrackSet() *TrackSet {
ret := NewTrackSet()
for _, ap := range r.active() {
ret.Add(ap)
}
return ret
} | go | func (r *RemoteProofLinks) TrackSet() *TrackSet {
ret := NewTrackSet()
for _, ap := range r.active() {
ret.Add(ap)
}
return ret
} | [
"func",
"(",
"r",
"*",
"RemoteProofLinks",
")",
"TrackSet",
"(",
")",
"*",
"TrackSet",
"{",
"ret",
":=",
"NewTrackSet",
"(",
")",
"\n",
"for",
"_",
",",
"ap",
":=",
"range",
"r",
".",
"active",
"(",
")",
"{",
"ret",
".",
"Add",
"(",
"ap",
")",
"\n",
"}",
"\n",
"return",
"ret",
"\n",
"}"
] | // TrackSet creates a new TrackSet with all the active proofs. | [
"TrackSet",
"creates",
"a",
"new",
"TrackSet",
"with",
"all",
"the",
"active",
"proofs",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/remote_proof_links.go#L94-L100 |
159,623 | keybase/client | go/libkb/remote_proof_links.go | AddProofsToSet | func (r *RemoteProofLinks) AddProofsToSet(existing *ProofSet, okStates []keybase1.ProofState) {
if okStates == nil {
okStates = []keybase1.ProofState{keybase1.ProofState_OK}
}
isOkState := func(s1 keybase1.ProofState) bool {
for _, s2 := range okStates {
if s1 == s2 {
return true
}
}
return false
}
for _, a := range r.active() {
if !isOkState(a.state) {
continue
}
AddToProofSetNoChecks(a.link, existing)
}
} | go | func (r *RemoteProofLinks) AddProofsToSet(existing *ProofSet, okStates []keybase1.ProofState) {
if okStates == nil {
okStates = []keybase1.ProofState{keybase1.ProofState_OK}
}
isOkState := func(s1 keybase1.ProofState) bool {
for _, s2 := range okStates {
if s1 == s2 {
return true
}
}
return false
}
for _, a := range r.active() {
if !isOkState(a.state) {
continue
}
AddToProofSetNoChecks(a.link, existing)
}
} | [
"func",
"(",
"r",
"*",
"RemoteProofLinks",
")",
"AddProofsToSet",
"(",
"existing",
"*",
"ProofSet",
",",
"okStates",
"[",
"]",
"keybase1",
".",
"ProofState",
")",
"{",
"if",
"okStates",
"==",
"nil",
"{",
"okStates",
"=",
"[",
"]",
"keybase1",
".",
"ProofState",
"{",
"keybase1",
".",
"ProofState_OK",
"}",
"\n",
"}",
"\n",
"isOkState",
":=",
"func",
"(",
"s1",
"keybase1",
".",
"ProofState",
")",
"bool",
"{",
"for",
"_",
",",
"s2",
":=",
"range",
"okStates",
"{",
"if",
"s1",
"==",
"s2",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"a",
":=",
"range",
"r",
".",
"active",
"(",
")",
"{",
"if",
"!",
"isOkState",
"(",
"a",
".",
"state",
")",
"{",
"continue",
"\n",
"}",
"\n",
"AddToProofSetNoChecks",
"(",
"a",
".",
"link",
",",
"existing",
")",
"\n",
"}",
"\n",
"}"
] | // AddProofsToSet adds the active proofs to an existing ProofSet, if they're one of the
// given OkStates. If okStates is nil, then we check only against keybase1.ProofState_OK. | [
"AddProofsToSet",
"adds",
"the",
"active",
"proofs",
"to",
"an",
"existing",
"ProofSet",
"if",
"they",
"re",
"one",
"of",
"the",
"given",
"OkStates",
".",
"If",
"okStates",
"is",
"nil",
"then",
"we",
"check",
"only",
"against",
"keybase1",
".",
"ProofState_OK",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/remote_proof_links.go#L104-L122 |
159,624 | keybase/client | go/libkb/device.go | NewPaperDevice | func NewPaperDevice(passphrasePrefix string) (*Device, error) {
did, err := NewDeviceID()
if err != nil {
return nil, err
}
s := DeviceStatusActive
desc := passphrasePrefix
d := &Device{
ID: did,
Type: DeviceTypePaper,
Status: &s,
Description: &desc,
}
return d, nil
} | go | func NewPaperDevice(passphrasePrefix string) (*Device, error) {
did, err := NewDeviceID()
if err != nil {
return nil, err
}
s := DeviceStatusActive
desc := passphrasePrefix
d := &Device{
ID: did,
Type: DeviceTypePaper,
Status: &s,
Description: &desc,
}
return d, nil
} | [
"func",
"NewPaperDevice",
"(",
"passphrasePrefix",
"string",
")",
"(",
"*",
"Device",
",",
"error",
")",
"{",
"did",
",",
"err",
":=",
"NewDeviceID",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"s",
":=",
"DeviceStatusActive",
"\n",
"desc",
":=",
"passphrasePrefix",
"\n\n",
"d",
":=",
"&",
"Device",
"{",
"ID",
":",
"did",
",",
"Type",
":",
"DeviceTypePaper",
",",
"Status",
":",
"&",
"s",
",",
"Description",
":",
"&",
"desc",
",",
"}",
"\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // NewPaperDevice creates a new paper backup key device | [
"NewPaperDevice",
"creates",
"a",
"new",
"paper",
"backup",
"key",
"device"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/device.go#L45-L60 |
159,625 | keybase/client | go/protocol/keybase1/merkle.go | GetCurrentMerkleRoot | func (c MerkleClient) GetCurrentMerkleRoot(ctx context.Context, freshnessMsec int) (res MerkleRootAndTime, err error) {
__arg := GetCurrentMerkleRootArg{FreshnessMsec: freshnessMsec}
err = c.Cli.Call(ctx, "keybase.1.merkle.getCurrentMerkleRoot", []interface{}{__arg}, &res)
return
} | go | func (c MerkleClient) GetCurrentMerkleRoot(ctx context.Context, freshnessMsec int) (res MerkleRootAndTime, err error) {
__arg := GetCurrentMerkleRootArg{FreshnessMsec: freshnessMsec}
err = c.Cli.Call(ctx, "keybase.1.merkle.getCurrentMerkleRoot", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"MerkleClient",
")",
"GetCurrentMerkleRoot",
"(",
"ctx",
"context",
".",
"Context",
",",
"freshnessMsec",
"int",
")",
"(",
"res",
"MerkleRootAndTime",
",",
"err",
"error",
")",
"{",
"__arg",
":=",
"GetCurrentMerkleRootArg",
"{",
"FreshnessMsec",
":",
"freshnessMsec",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // GetCurrentMerkleRoot gets the current-most Merkle root from the keybase server.
// The caller can specify how stale a result can be with freshnessMsec.
// If 0 is specified, then any amount of staleness is OK. If -1 is specified, then
// we force a GET and a round-trip. | [
"GetCurrentMerkleRoot",
"gets",
"the",
"current",
"-",
"most",
"Merkle",
"root",
"from",
"the",
"keybase",
"server",
".",
"The",
"caller",
"can",
"specify",
"how",
"stale",
"a",
"result",
"can",
"be",
"with",
"freshnessMsec",
".",
"If",
"0",
"is",
"specified",
"then",
"any",
"amount",
"of",
"staleness",
"is",
"OK",
".",
"If",
"-",
"1",
"is",
"specified",
"then",
"we",
"force",
"a",
"GET",
"and",
"a",
"round",
"-",
"trip",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/merkle.go#L115-L119 |
159,626 | keybase/client | go/protocol/keybase1/merkle.go | VerifyMerkleRootAndKBFS | func (c MerkleClient) VerifyMerkleRootAndKBFS(ctx context.Context, __arg VerifyMerkleRootAndKBFSArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.merkle.verifyMerkleRootAndKBFS", []interface{}{__arg}, nil)
return
} | go | func (c MerkleClient) VerifyMerkleRootAndKBFS(ctx context.Context, __arg VerifyMerkleRootAndKBFSArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.merkle.verifyMerkleRootAndKBFS", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"MerkleClient",
")",
"VerifyMerkleRootAndKBFS",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"VerifyMerkleRootAndKBFSArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // VerifyMerkleRootAndKBFS checks that the given merkle root is indeed a valid
// root of the keybase server's Merkle tree, and that the given KBFS root
// is included in that global root. | [
"VerifyMerkleRootAndKBFS",
"checks",
"that",
"the",
"given",
"merkle",
"root",
"is",
"indeed",
"a",
"valid",
"root",
"of",
"the",
"keybase",
"server",
"s",
"Merkle",
"tree",
"and",
"that",
"the",
"given",
"KBFS",
"root",
"is",
"included",
"in",
"that",
"global",
"root",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/merkle.go#L124-L127 |
159,627 | keybase/client | go/kbfs/data/block_types.go | Equals | func (i Int64Offset) Equals(other Offset) bool {
otherI, ok := other.(Int64Offset)
if !ok {
panic(fmt.Sprintf("Can't compare against non-int offset: %T", other))
}
return int64(i) == int64(otherI)
} | go | func (i Int64Offset) Equals(other Offset) bool {
otherI, ok := other.(Int64Offset)
if !ok {
panic(fmt.Sprintf("Can't compare against non-int offset: %T", other))
}
return int64(i) == int64(otherI)
} | [
"func",
"(",
"i",
"Int64Offset",
")",
"Equals",
"(",
"other",
"Offset",
")",
"bool",
"{",
"otherI",
",",
"ok",
":=",
"other",
".",
"(",
"Int64Offset",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"other",
")",
")",
"\n",
"}",
"\n",
"return",
"int64",
"(",
"i",
")",
"==",
"int64",
"(",
"otherI",
")",
"\n",
"}"
] | // Equals implements the Offset interface for Int64Offset. | [
"Equals",
"implements",
"the",
"Offset",
"interface",
"for",
"Int64Offset",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L22-L28 |
159,628 | keybase/client | go/kbfs/data/block_types.go | Less | func (s *StringOffset) Less(other Offset) bool {
if s == nil {
return other != nil
} else if other == nil {
return false
}
otherS, ok := other.(*StringOffset)
if !ok {
panic(fmt.Sprintf("Can't compare against non-string offset: %T", other))
}
return string(*s) < string(*otherS)
} | go | func (s *StringOffset) Less(other Offset) bool {
if s == nil {
return other != nil
} else if other == nil {
return false
}
otherS, ok := other.(*StringOffset)
if !ok {
panic(fmt.Sprintf("Can't compare against non-string offset: %T", other))
}
return string(*s) < string(*otherS)
} | [
"func",
"(",
"s",
"*",
"StringOffset",
")",
"Less",
"(",
"other",
"Offset",
")",
"bool",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"other",
"!=",
"nil",
"\n",
"}",
"else",
"if",
"other",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"otherS",
",",
"ok",
":=",
"other",
".",
"(",
"*",
"StringOffset",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"other",
")",
")",
"\n",
"}",
"\n",
"return",
"string",
"(",
"*",
"s",
")",
"<",
"string",
"(",
"*",
"otherS",
")",
"\n",
"}"
] | // Less implements the Offset interface for StringOffset. | [
"Less",
"implements",
"the",
"Offset",
"interface",
"for",
"StringOffset",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L63-L74 |
159,629 | keybase/client | go/kbfs/data/block_types.go | GetEncodedSize | func (cb *CommonBlock) GetEncodedSize() uint32 {
cb.cacheMtx.RLock()
defer cb.cacheMtx.RUnlock()
return cb.cachedEncodedSize
} | go | func (cb *CommonBlock) GetEncodedSize() uint32 {
cb.cacheMtx.RLock()
defer cb.cacheMtx.RUnlock()
return cb.cachedEncodedSize
} | [
"func",
"(",
"cb",
"*",
"CommonBlock",
")",
"GetEncodedSize",
"(",
")",
"uint32",
"{",
"cb",
".",
"cacheMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"cb",
".",
"cacheMtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"cb",
".",
"cachedEncodedSize",
"\n",
"}"
] | // GetEncodedSize implements the Block interface for CommonBlock | [
"GetEncodedSize",
"implements",
"the",
"Block",
"interface",
"for",
"CommonBlock"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L128-L132 |
159,630 | keybase/client | go/kbfs/data/block_types.go | SetEncodedSize | func (cb *CommonBlock) SetEncodedSize(size uint32) {
cb.cacheMtx.Lock()
defer cb.cacheMtx.Unlock()
cb.cachedEncodedSize = size
} | go | func (cb *CommonBlock) SetEncodedSize(size uint32) {
cb.cacheMtx.Lock()
defer cb.cacheMtx.Unlock()
cb.cachedEncodedSize = size
} | [
"func",
"(",
"cb",
"*",
"CommonBlock",
")",
"SetEncodedSize",
"(",
"size",
"uint32",
")",
"{",
"cb",
".",
"cacheMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cb",
".",
"cacheMtx",
".",
"Unlock",
"(",
")",
"\n",
"cb",
".",
"cachedEncodedSize",
"=",
"size",
"\n",
"}"
] | // SetEncodedSize implements the Block interface for CommonBlock | [
"SetEncodedSize",
"implements",
"the",
"Block",
"interface",
"for",
"CommonBlock"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L135-L139 |
159,631 | keybase/client | go/kbfs/data/block_types.go | Set | func (cb *CommonBlock) Set(other Block) {
otherCommon := other.ToCommonBlock()
cb.IsInd = otherCommon.IsInd
cb.UnknownFieldSetHandler = otherCommon.UnknownFieldSetHandler
cb.SetEncodedSize(otherCommon.GetEncodedSize())
} | go | func (cb *CommonBlock) Set(other Block) {
otherCommon := other.ToCommonBlock()
cb.IsInd = otherCommon.IsInd
cb.UnknownFieldSetHandler = otherCommon.UnknownFieldSetHandler
cb.SetEncodedSize(otherCommon.GetEncodedSize())
} | [
"func",
"(",
"cb",
"*",
"CommonBlock",
")",
"Set",
"(",
"other",
"Block",
")",
"{",
"otherCommon",
":=",
"other",
".",
"ToCommonBlock",
"(",
")",
"\n",
"cb",
".",
"IsInd",
"=",
"otherCommon",
".",
"IsInd",
"\n",
"cb",
".",
"UnknownFieldSetHandler",
"=",
"otherCommon",
".",
"UnknownFieldSetHandler",
"\n",
"cb",
".",
"SetEncodedSize",
"(",
"otherCommon",
".",
"GetEncodedSize",
"(",
")",
")",
"\n",
"}"
] | // Set implements the Block interface for CommonBlock. | [
"Set",
"implements",
"the",
"Block",
"interface",
"for",
"CommonBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L177-L182 |
159,632 | keybase/client | go/kbfs/data/block_types.go | DeepCopy | func (cb *CommonBlock) DeepCopy() CommonBlock {
return CommonBlock{
IsInd: cb.IsInd,
// We don't need to copy UnknownFieldSetHandler because it's immutable.
UnknownFieldSetHandler: cb.UnknownFieldSetHandler,
cachedEncodedSize: cb.GetEncodedSize(),
}
} | go | func (cb *CommonBlock) DeepCopy() CommonBlock {
return CommonBlock{
IsInd: cb.IsInd,
// We don't need to copy UnknownFieldSetHandler because it's immutable.
UnknownFieldSetHandler: cb.UnknownFieldSetHandler,
cachedEncodedSize: cb.GetEncodedSize(),
}
} | [
"func",
"(",
"cb",
"*",
"CommonBlock",
")",
"DeepCopy",
"(",
")",
"CommonBlock",
"{",
"return",
"CommonBlock",
"{",
"IsInd",
":",
"cb",
".",
"IsInd",
",",
"// We don't need to copy UnknownFieldSetHandler because it's immutable.",
"UnknownFieldSetHandler",
":",
"cb",
".",
"UnknownFieldSetHandler",
",",
"cachedEncodedSize",
":",
"cb",
".",
"GetEncodedSize",
"(",
")",
",",
"}",
"\n",
"}"
] | // DeepCopy copies a CommonBlock without the lock. | [
"DeepCopy",
"copies",
"a",
"CommonBlock",
"without",
"the",
"lock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L190-L197 |
159,633 | keybase/client | go/kbfs/data/block_types.go | NewDirBlockWithPtrs | func NewDirBlockWithPtrs(isInd bool) BlockWithPtrs {
db := NewDirBlock().(*DirBlock)
db.IsInd = isInd
return db
} | go | func NewDirBlockWithPtrs(isInd bool) BlockWithPtrs {
db := NewDirBlock().(*DirBlock)
db.IsInd = isInd
return db
} | [
"func",
"NewDirBlockWithPtrs",
"(",
"isInd",
"bool",
")",
"BlockWithPtrs",
"{",
"db",
":=",
"NewDirBlock",
"(",
")",
".",
"(",
"*",
"DirBlock",
")",
"\n",
"db",
".",
"IsInd",
"=",
"isInd",
"\n",
"return",
"db",
"\n",
"}"
] | // NewDirBlockWithPtrs creates a new, empty DirBlock. | [
"NewDirBlockWithPtrs",
"creates",
"a",
"new",
"empty",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L233-L237 |
159,634 | keybase/client | go/kbfs/data/block_types.go | IsTail | func (db *DirBlock) IsTail() bool {
if db.IsInd {
return len(db.IPtrs) == 0
}
for _, de := range db.Children {
if de.Type != Sym {
return false
}
}
return true
} | go | func (db *DirBlock) IsTail() bool {
if db.IsInd {
return len(db.IPtrs) == 0
}
for _, de := range db.Children {
if de.Type != Sym {
return false
}
}
return true
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"IsTail",
"(",
")",
"bool",
"{",
"if",
"db",
".",
"IsInd",
"{",
"return",
"len",
"(",
"db",
".",
"IPtrs",
")",
"==",
"0",
"\n",
"}",
"\n",
"for",
"_",
",",
"de",
":=",
"range",
"db",
".",
"Children",
"{",
"if",
"de",
".",
"Type",
"!=",
"Sym",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // IsTail implements the Block interface for DirBlock. | [
"IsTail",
"implements",
"the",
"Block",
"interface",
"for",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L250-L260 |
159,635 | keybase/client | go/kbfs/data/block_types.go | Set | func (db *DirBlock) Set(other Block) {
otherDb := other.(*DirBlock)
dbCopy := otherDb.DeepCopy()
db.Children = dbCopy.Children
db.IPtrs = dbCopy.IPtrs
db.ToCommonBlock().Set(dbCopy.ToCommonBlock())
} | go | func (db *DirBlock) Set(other Block) {
otherDb := other.(*DirBlock)
dbCopy := otherDb.DeepCopy()
db.Children = dbCopy.Children
db.IPtrs = dbCopy.IPtrs
db.ToCommonBlock().Set(dbCopy.ToCommonBlock())
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"Set",
"(",
"other",
"Block",
")",
"{",
"otherDb",
":=",
"other",
".",
"(",
"*",
"DirBlock",
")",
"\n",
"dbCopy",
":=",
"otherDb",
".",
"DeepCopy",
"(",
")",
"\n",
"db",
".",
"Children",
"=",
"dbCopy",
".",
"Children",
"\n",
"db",
".",
"IPtrs",
"=",
"dbCopy",
".",
"IPtrs",
"\n",
"db",
".",
"ToCommonBlock",
"(",
")",
".",
"Set",
"(",
"dbCopy",
".",
"ToCommonBlock",
"(",
")",
")",
"\n",
"}"
] | // Set implements the Block interface for DirBlock | [
"Set",
"implements",
"the",
"Block",
"interface",
"for",
"DirBlock"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L277-L283 |
159,636 | keybase/client | go/kbfs/data/block_types.go | DeepCopy | func (db *DirBlock) DeepCopy() *DirBlock {
childrenCopy := make(map[string]DirEntry, len(db.Children))
for k, v := range db.Children {
childrenCopy[k] = v
}
var iptrsCopy []IndirectDirPtr
if db.IsInd {
iptrsCopy = make([]IndirectDirPtr, len(db.IPtrs))
copy(iptrsCopy, db.IPtrs)
}
return &DirBlock{
CommonBlock: db.CommonBlock.DeepCopy(),
Children: childrenCopy,
IPtrs: iptrsCopy,
}
} | go | func (db *DirBlock) DeepCopy() *DirBlock {
childrenCopy := make(map[string]DirEntry, len(db.Children))
for k, v := range db.Children {
childrenCopy[k] = v
}
var iptrsCopy []IndirectDirPtr
if db.IsInd {
iptrsCopy = make([]IndirectDirPtr, len(db.IPtrs))
copy(iptrsCopy, db.IPtrs)
}
return &DirBlock{
CommonBlock: db.CommonBlock.DeepCopy(),
Children: childrenCopy,
IPtrs: iptrsCopy,
}
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"DeepCopy",
"(",
")",
"*",
"DirBlock",
"{",
"childrenCopy",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"DirEntry",
",",
"len",
"(",
"db",
".",
"Children",
")",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"db",
".",
"Children",
"{",
"childrenCopy",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"var",
"iptrsCopy",
"[",
"]",
"IndirectDirPtr",
"\n",
"if",
"db",
".",
"IsInd",
"{",
"iptrsCopy",
"=",
"make",
"(",
"[",
"]",
"IndirectDirPtr",
",",
"len",
"(",
"db",
".",
"IPtrs",
")",
")",
"\n",
"copy",
"(",
"iptrsCopy",
",",
"db",
".",
"IPtrs",
")",
"\n",
"}",
"\n",
"return",
"&",
"DirBlock",
"{",
"CommonBlock",
":",
"db",
".",
"CommonBlock",
".",
"DeepCopy",
"(",
")",
",",
"Children",
":",
"childrenCopy",
",",
"IPtrs",
":",
"iptrsCopy",
",",
"}",
"\n",
"}"
] | // DeepCopy makes a complete copy of a DirBlock | [
"DeepCopy",
"makes",
"a",
"complete",
"copy",
"of",
"a",
"DirBlock"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L286-L301 |
159,637 | keybase/client | go/kbfs/data/block_types.go | NumIndirectPtrs | func (db *DirBlock) NumIndirectPtrs() int {
if !db.IsInd {
panic("NumIndirectPtrs called on a direct directory block")
}
return len(db.IPtrs)
} | go | func (db *DirBlock) NumIndirectPtrs() int {
if !db.IsInd {
panic("NumIndirectPtrs called on a direct directory block")
}
return len(db.IPtrs)
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"NumIndirectPtrs",
"(",
")",
"int",
"{",
"if",
"!",
"db",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"len",
"(",
"db",
".",
"IPtrs",
")",
"\n",
"}"
] | // NumIndirectPtrs implements the BlockWithPtrs interface for DirBlock. | [
"NumIndirectPtrs",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L324-L329 |
159,638 | keybase/client | go/kbfs/data/block_types.go | IndirectPtr | func (db *DirBlock) IndirectPtr(i int) (BlockInfo, Offset) {
if !db.IsInd {
panic("IndirectPtr called on a direct directory block")
}
iptr := db.IPtrs[i]
off := StringOffset(iptr.Off)
return iptr.BlockInfo, &off
} | go | func (db *DirBlock) IndirectPtr(i int) (BlockInfo, Offset) {
if !db.IsInd {
panic("IndirectPtr called on a direct directory block")
}
iptr := db.IPtrs[i]
off := StringOffset(iptr.Off)
return iptr.BlockInfo, &off
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"IndirectPtr",
"(",
"i",
"int",
")",
"(",
"BlockInfo",
",",
"Offset",
")",
"{",
"if",
"!",
"db",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"iptr",
":=",
"db",
".",
"IPtrs",
"[",
"i",
"]",
"\n",
"off",
":=",
"StringOffset",
"(",
"iptr",
".",
"Off",
")",
"\n",
"return",
"iptr",
".",
"BlockInfo",
",",
"&",
"off",
"\n",
"}"
] | // IndirectPtr implements the BlockWithPtrs interface for DirBlock. | [
"IndirectPtr",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L332-L339 |
159,639 | keybase/client | go/kbfs/data/block_types.go | ClearIndirectPtrSize | func (db *DirBlock) ClearIndirectPtrSize(i int) {
if !db.IsInd {
panic("ClearIndirectPtrSize called on a direct directory block")
}
db.IPtrs[i].EncodedSize = 0
} | go | func (db *DirBlock) ClearIndirectPtrSize(i int) {
if !db.IsInd {
panic("ClearIndirectPtrSize called on a direct directory block")
}
db.IPtrs[i].EncodedSize = 0
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"ClearIndirectPtrSize",
"(",
"i",
"int",
")",
"{",
"if",
"!",
"db",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"db",
".",
"IPtrs",
"[",
"i",
"]",
".",
"EncodedSize",
"=",
"0",
"\n",
"}"
] | // ClearIndirectPtrSize implements the BlockWithPtrs interface for DirBlock. | [
"ClearIndirectPtrSize",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L361-L366 |
159,640 | keybase/client | go/kbfs/data/block_types.go | SetIndirectPtrType | func (db *DirBlock) SetIndirectPtrType(i int, dt BlockDirectType) {
if !db.IsInd {
panic("SetIndirectPtrType called on a direct directory block")
}
db.IPtrs[i].DirectType = dt
} | go | func (db *DirBlock) SetIndirectPtrType(i int, dt BlockDirectType) {
if !db.IsInd {
panic("SetIndirectPtrType called on a direct directory block")
}
db.IPtrs[i].DirectType = dt
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"SetIndirectPtrType",
"(",
"i",
"int",
",",
"dt",
"BlockDirectType",
")",
"{",
"if",
"!",
"db",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"db",
".",
"IPtrs",
"[",
"i",
"]",
".",
"DirectType",
"=",
"dt",
"\n",
"}"
] | // SetIndirectPtrType implements the BlockWithPtrs interface for DirBlock. | [
"SetIndirectPtrType",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L369-L374 |
159,641 | keybase/client | go/kbfs/data/block_types.go | SwapIndirectPtrs | func (db *DirBlock) SwapIndirectPtrs(i int, other BlockWithPtrs, otherI int) {
otherDB, ok := other.(*DirBlock)
if !ok {
panic(fmt.Sprintf(
"SwapIndirectPtrs cannot swap between block types: %T", other))
}
db.IPtrs[i], otherDB.IPtrs[otherI] = otherDB.IPtrs[otherI], db.IPtrs[i]
} | go | func (db *DirBlock) SwapIndirectPtrs(i int, other BlockWithPtrs, otherI int) {
otherDB, ok := other.(*DirBlock)
if !ok {
panic(fmt.Sprintf(
"SwapIndirectPtrs cannot swap between block types: %T", other))
}
db.IPtrs[i], otherDB.IPtrs[otherI] = otherDB.IPtrs[otherI], db.IPtrs[i]
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"SwapIndirectPtrs",
"(",
"i",
"int",
",",
"other",
"BlockWithPtrs",
",",
"otherI",
"int",
")",
"{",
"otherDB",
",",
"ok",
":=",
"other",
".",
"(",
"*",
"DirBlock",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"other",
")",
")",
"\n",
"}",
"\n\n",
"db",
".",
"IPtrs",
"[",
"i",
"]",
",",
"otherDB",
".",
"IPtrs",
"[",
"otherI",
"]",
"=",
"otherDB",
".",
"IPtrs",
"[",
"otherI",
"]",
",",
"db",
".",
"IPtrs",
"[",
"i",
"]",
"\n",
"}"
] | // SwapIndirectPtrs implements the BlockWithPtrs interface for DirBlock. | [
"SwapIndirectPtrs",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L377-L385 |
159,642 | keybase/client | go/kbfs/data/block_types.go | SetIndirectPtrOff | func (db *DirBlock) SetIndirectPtrOff(i int, off Offset) {
if !db.IsInd {
panic("SetIndirectPtrOff called on a direct directory block")
}
sOff, ok := off.(*StringOffset)
if !ok {
panic(fmt.Sprintf("SetIndirectPtrOff called on a dirctory block "+
"with a %T offset", off))
}
db.IPtrs[i].Off = *sOff
} | go | func (db *DirBlock) SetIndirectPtrOff(i int, off Offset) {
if !db.IsInd {
panic("SetIndirectPtrOff called on a direct directory block")
}
sOff, ok := off.(*StringOffset)
if !ok {
panic(fmt.Sprintf("SetIndirectPtrOff called on a dirctory block "+
"with a %T offset", off))
}
db.IPtrs[i].Off = *sOff
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"SetIndirectPtrOff",
"(",
"i",
"int",
",",
"off",
"Offset",
")",
"{",
"if",
"!",
"db",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"sOff",
",",
"ok",
":=",
"off",
".",
"(",
"*",
"StringOffset",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"off",
")",
")",
"\n",
"}",
"\n",
"db",
".",
"IPtrs",
"[",
"i",
"]",
".",
"Off",
"=",
"*",
"sOff",
"\n",
"}"
] | // SetIndirectPtrOff implements the BlockWithPtrs interface for DirBlock. | [
"SetIndirectPtrOff",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L388-L398 |
159,643 | keybase/client | go/kbfs/data/block_types.go | SetIndirectPtrInfo | func (db *DirBlock) SetIndirectPtrInfo(i int, info BlockInfo) {
if !db.IsInd {
panic("SetIndirectPtrInfo called on a direct directory block")
}
db.IPtrs[i].BlockInfo = info
} | go | func (db *DirBlock) SetIndirectPtrInfo(i int, info BlockInfo) {
if !db.IsInd {
panic("SetIndirectPtrInfo called on a direct directory block")
}
db.IPtrs[i].BlockInfo = info
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"SetIndirectPtrInfo",
"(",
"i",
"int",
",",
"info",
"BlockInfo",
")",
"{",
"if",
"!",
"db",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"db",
".",
"IPtrs",
"[",
"i",
"]",
".",
"BlockInfo",
"=",
"info",
"\n",
"}"
] | // SetIndirectPtrInfo implements the BlockWithPtrs interface for DirBlock. | [
"SetIndirectPtrInfo",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"DirBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L401-L406 |
159,644 | keybase/client | go/kbfs/data/block_types.go | TotalPlainSizeEstimate | func (db *DirBlock) TotalPlainSizeEstimate(
plainSize int, bsplit BlockSplitter) int {
if !db.IsIndirect() || len(db.IPtrs) == 0 {
return plainSize
}
// If the top block is indirect, it's too costly to estimate the
// sizes by checking the plain sizes of all the leafs. Instead
// use the following imperfect heuristics:
//
// * If there are N child pointers, and the first one is a direct
// pointer, assume N-1 of them are full.
//
// * If there are N child pointers, and the first one is an
// indirect pointer, just give up and max out at the maximum
// number of indirect pointers in a block, assuming that at
// least one indirect block is full of pointers when there are
// at least 2 indirect levels in the tree.
//
// This isn't great since it overestimates in many cases
// (especially when removing entries), and can vastly unerestimate
// if there are more than 2 levels of indirection. But it seems
// unlikely that directory byte size matters for anything in real
// life. Famous last words, of course...
if db.IPtrs[0].DirectType == DirectBlock {
return MaxBlockSizeBytesDefault * (len(db.IPtrs) - 1)
}
return MaxBlockSizeBytesDefault * bsplit.MaxPtrsPerBlock()
} | go | func (db *DirBlock) TotalPlainSizeEstimate(
plainSize int, bsplit BlockSplitter) int {
if !db.IsIndirect() || len(db.IPtrs) == 0 {
return plainSize
}
// If the top block is indirect, it's too costly to estimate the
// sizes by checking the plain sizes of all the leafs. Instead
// use the following imperfect heuristics:
//
// * If there are N child pointers, and the first one is a direct
// pointer, assume N-1 of them are full.
//
// * If there are N child pointers, and the first one is an
// indirect pointer, just give up and max out at the maximum
// number of indirect pointers in a block, assuming that at
// least one indirect block is full of pointers when there are
// at least 2 indirect levels in the tree.
//
// This isn't great since it overestimates in many cases
// (especially when removing entries), and can vastly unerestimate
// if there are more than 2 levels of indirection. But it seems
// unlikely that directory byte size matters for anything in real
// life. Famous last words, of course...
if db.IPtrs[0].DirectType == DirectBlock {
return MaxBlockSizeBytesDefault * (len(db.IPtrs) - 1)
}
return MaxBlockSizeBytesDefault * bsplit.MaxPtrsPerBlock()
} | [
"func",
"(",
"db",
"*",
"DirBlock",
")",
"TotalPlainSizeEstimate",
"(",
"plainSize",
"int",
",",
"bsplit",
"BlockSplitter",
")",
"int",
"{",
"if",
"!",
"db",
".",
"IsIndirect",
"(",
")",
"||",
"len",
"(",
"db",
".",
"IPtrs",
")",
"==",
"0",
"{",
"return",
"plainSize",
"\n",
"}",
"\n\n",
"// If the top block is indirect, it's too costly to estimate the",
"// sizes by checking the plain sizes of all the leafs. Instead",
"// use the following imperfect heuristics:",
"//",
"// * If there are N child pointers, and the first one is a direct",
"// pointer, assume N-1 of them are full.",
"//",
"// * If there are N child pointers, and the first one is an",
"// indirect pointer, just give up and max out at the maximum",
"// number of indirect pointers in a block, assuming that at",
"// least one indirect block is full of pointers when there are",
"// at least 2 indirect levels in the tree.",
"//",
"// This isn't great since it overestimates in many cases",
"// (especially when removing entries), and can vastly unerestimate",
"// if there are more than 2 levels of indirection. But it seems",
"// unlikely that directory byte size matters for anything in real",
"// life. Famous last words, of course...",
"if",
"db",
".",
"IPtrs",
"[",
"0",
"]",
".",
"DirectType",
"==",
"DirectBlock",
"{",
"return",
"MaxBlockSizeBytesDefault",
"*",
"(",
"len",
"(",
"db",
".",
"IPtrs",
")",
"-",
"1",
")",
"\n",
"}",
"\n",
"return",
"MaxBlockSizeBytesDefault",
"*",
"bsplit",
".",
"MaxPtrsPerBlock",
"(",
")",
"\n",
"}"
] | // TotalPlainSizeEstimate returns an estimate of the plaintext size of
// this directory block. | [
"TotalPlainSizeEstimate",
"returns",
"an",
"estimate",
"of",
"the",
"plaintext",
"size",
"of",
"this",
"directory",
"block",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L410-L438 |
159,645 | keybase/client | go/kbfs/data/block_types.go | NewFileBlockWithPtrs | func NewFileBlockWithPtrs(isInd bool) BlockWithPtrs {
fb := NewFileBlock().(*FileBlock)
fb.IsInd = isInd
return fb
} | go | func NewFileBlockWithPtrs(isInd bool) BlockWithPtrs {
fb := NewFileBlock().(*FileBlock)
fb.IsInd = isInd
return fb
} | [
"func",
"NewFileBlockWithPtrs",
"(",
"isInd",
"bool",
")",
"BlockWithPtrs",
"{",
"fb",
":=",
"NewFileBlock",
"(",
")",
".",
"(",
"*",
"FileBlock",
")",
"\n",
"fb",
".",
"IsInd",
"=",
"isInd",
"\n",
"return",
"fb",
"\n",
"}"
] | // NewFileBlockWithPtrs creates a new, empty FileBlock. | [
"NewFileBlockWithPtrs",
"creates",
"a",
"new",
"empty",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L463-L467 |
159,646 | keybase/client | go/kbfs/data/block_types.go | IsTail | func (fb *FileBlock) IsTail() bool {
if fb.IsInd {
return len(fb.IPtrs) == 0
}
return true
} | go | func (fb *FileBlock) IsTail() bool {
if fb.IsInd {
return len(fb.IPtrs) == 0
}
return true
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"IsTail",
"(",
")",
"bool",
"{",
"if",
"fb",
".",
"IsInd",
"{",
"return",
"len",
"(",
"fb",
".",
"IPtrs",
")",
"==",
"0",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // IsTail implements the Block interface for FileBlock. | [
"IsTail",
"implements",
"the",
"Block",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L480-L485 |
159,647 | keybase/client | go/kbfs/data/block_types.go | DataVersion | func (fb *FileBlock) DataVersion() Ver {
if !fb.IsInd {
return FirstValidVer
}
if len(fb.IPtrs) == 0 {
// This is a truncated file block that hasn't had its level of
// indirection removed.
return FirstValidVer
}
// If this is an indirect block, and none of its children are
// marked as direct blocks, then this must be a big file. Note
// that we do it this way, rather than returning on the first
// non-direct block, to support appending to existing files and
// making them big.
hasHoles := false
hasDirect := false
maxDirectType := UnknownDirectType
for i := range fb.IPtrs {
if maxDirectType != UnknownDirectType &&
fb.IPtrs[i].DirectType != UnknownDirectType &&
maxDirectType != fb.IPtrs[i].DirectType {
panic("Mixed data versions among indirect pointers")
}
if fb.IPtrs[i].DirectType > maxDirectType {
maxDirectType = fb.IPtrs[i].DirectType
}
if fb.IPtrs[i].DirectType == DirectBlock {
hasDirect = true
} else if fb.IPtrs[i].Holes {
hasHoles = true
}
// We can only safely break if both vars are definitely set to
// their final value.
if hasDirect && hasHoles {
break
}
}
if maxDirectType == UnknownDirectType {
panic("No known type for any indirect pointer")
}
if !hasDirect {
return AtLeastTwoLevelsOfChildrenVer
} else if hasHoles {
return ChildHolesVer
}
return FirstValidVer
} | go | func (fb *FileBlock) DataVersion() Ver {
if !fb.IsInd {
return FirstValidVer
}
if len(fb.IPtrs) == 0 {
// This is a truncated file block that hasn't had its level of
// indirection removed.
return FirstValidVer
}
// If this is an indirect block, and none of its children are
// marked as direct blocks, then this must be a big file. Note
// that we do it this way, rather than returning on the first
// non-direct block, to support appending to existing files and
// making them big.
hasHoles := false
hasDirect := false
maxDirectType := UnknownDirectType
for i := range fb.IPtrs {
if maxDirectType != UnknownDirectType &&
fb.IPtrs[i].DirectType != UnknownDirectType &&
maxDirectType != fb.IPtrs[i].DirectType {
panic("Mixed data versions among indirect pointers")
}
if fb.IPtrs[i].DirectType > maxDirectType {
maxDirectType = fb.IPtrs[i].DirectType
}
if fb.IPtrs[i].DirectType == DirectBlock {
hasDirect = true
} else if fb.IPtrs[i].Holes {
hasHoles = true
}
// We can only safely break if both vars are definitely set to
// their final value.
if hasDirect && hasHoles {
break
}
}
if maxDirectType == UnknownDirectType {
panic("No known type for any indirect pointer")
}
if !hasDirect {
return AtLeastTwoLevelsOfChildrenVer
} else if hasHoles {
return ChildHolesVer
}
return FirstValidVer
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"DataVersion",
"(",
")",
"Ver",
"{",
"if",
"!",
"fb",
".",
"IsInd",
"{",
"return",
"FirstValidVer",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"fb",
".",
"IPtrs",
")",
"==",
"0",
"{",
"// This is a truncated file block that hasn't had its level of",
"// indirection removed.",
"return",
"FirstValidVer",
"\n",
"}",
"\n\n",
"// If this is an indirect block, and none of its children are",
"// marked as direct blocks, then this must be a big file. Note",
"// that we do it this way, rather than returning on the first",
"// non-direct block, to support appending to existing files and",
"// making them big.",
"hasHoles",
":=",
"false",
"\n",
"hasDirect",
":=",
"false",
"\n",
"maxDirectType",
":=",
"UnknownDirectType",
"\n",
"for",
"i",
":=",
"range",
"fb",
".",
"IPtrs",
"{",
"if",
"maxDirectType",
"!=",
"UnknownDirectType",
"&&",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"DirectType",
"!=",
"UnknownDirectType",
"&&",
"maxDirectType",
"!=",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"DirectType",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"DirectType",
">",
"maxDirectType",
"{",
"maxDirectType",
"=",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"DirectType",
"\n",
"}",
"\n\n",
"if",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"DirectType",
"==",
"DirectBlock",
"{",
"hasDirect",
"=",
"true",
"\n",
"}",
"else",
"if",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"Holes",
"{",
"hasHoles",
"=",
"true",
"\n",
"}",
"\n",
"// We can only safely break if both vars are definitely set to",
"// their final value.",
"if",
"hasDirect",
"&&",
"hasHoles",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"maxDirectType",
"==",
"UnknownDirectType",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"hasDirect",
"{",
"return",
"AtLeastTwoLevelsOfChildrenVer",
"\n",
"}",
"else",
"if",
"hasHoles",
"{",
"return",
"ChildHolesVer",
"\n",
"}",
"\n",
"return",
"FirstValidVer",
"\n",
"}"
] | // DataVersion returns data version for this block, which is assumed
// to have been modified locally. | [
"DataVersion",
"returns",
"data",
"version",
"for",
"this",
"block",
"which",
"is",
"assumed",
"to",
"have",
"been",
"modified",
"locally",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L489-L540 |
159,648 | keybase/client | go/kbfs/data/block_types.go | Set | func (fb *FileBlock) Set(other Block) {
otherFb := other.(*FileBlock)
fbCopy := otherFb.DeepCopy()
fb.Contents = fbCopy.Contents
fb.IPtrs = fbCopy.IPtrs
fb.ToCommonBlock().Set(fbCopy.ToCommonBlock())
// Ensure that the Set is complete from Go's perspective by calculating the
// hash on the new FileBlock if the old one has been set. This is mainly so
// tests can blindly compare that blocks are equivalent.
h := func() *kbfshash.RawDefaultHash {
otherFb.cacheMtx.RLock()
defer otherFb.cacheMtx.RUnlock()
return otherFb.hash
}()
if h != nil {
_ = fb.GetHash()
}
} | go | func (fb *FileBlock) Set(other Block) {
otherFb := other.(*FileBlock)
fbCopy := otherFb.DeepCopy()
fb.Contents = fbCopy.Contents
fb.IPtrs = fbCopy.IPtrs
fb.ToCommonBlock().Set(fbCopy.ToCommonBlock())
// Ensure that the Set is complete from Go's perspective by calculating the
// hash on the new FileBlock if the old one has been set. This is mainly so
// tests can blindly compare that blocks are equivalent.
h := func() *kbfshash.RawDefaultHash {
otherFb.cacheMtx.RLock()
defer otherFb.cacheMtx.RUnlock()
return otherFb.hash
}()
if h != nil {
_ = fb.GetHash()
}
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"Set",
"(",
"other",
"Block",
")",
"{",
"otherFb",
":=",
"other",
".",
"(",
"*",
"FileBlock",
")",
"\n",
"fbCopy",
":=",
"otherFb",
".",
"DeepCopy",
"(",
")",
"\n",
"fb",
".",
"Contents",
"=",
"fbCopy",
".",
"Contents",
"\n",
"fb",
".",
"IPtrs",
"=",
"fbCopy",
".",
"IPtrs",
"\n",
"fb",
".",
"ToCommonBlock",
"(",
")",
".",
"Set",
"(",
"fbCopy",
".",
"ToCommonBlock",
"(",
")",
")",
"\n",
"// Ensure that the Set is complete from Go's perspective by calculating the",
"// hash on the new FileBlock if the old one has been set. This is mainly so",
"// tests can blindly compare that blocks are equivalent.",
"h",
":=",
"func",
"(",
")",
"*",
"kbfshash",
".",
"RawDefaultHash",
"{",
"otherFb",
".",
"cacheMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"otherFb",
".",
"cacheMtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"otherFb",
".",
"hash",
"\n",
"}",
"(",
")",
"\n",
"if",
"h",
"!=",
"nil",
"{",
"_",
"=",
"fb",
".",
"GetHash",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // Set implements the Block interface for FileBlock | [
"Set",
"implements",
"the",
"Block",
"interface",
"for",
"FileBlock"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L548-L565 |
159,649 | keybase/client | go/kbfs/data/block_types.go | DeepCopy | func (fb *FileBlock) DeepCopy() *FileBlock {
var contentsCopy []byte
if fb.Contents != nil {
contentsCopy = make([]byte, len(fb.Contents))
copy(contentsCopy, fb.Contents)
}
var iptrsCopy []IndirectFilePtr
if fb.IPtrs != nil {
iptrsCopy = make([]IndirectFilePtr, len(fb.IPtrs))
copy(iptrsCopy, fb.IPtrs)
}
return &FileBlock{
CommonBlock: fb.CommonBlock.DeepCopy(),
Contents: contentsCopy,
IPtrs: iptrsCopy,
}
} | go | func (fb *FileBlock) DeepCopy() *FileBlock {
var contentsCopy []byte
if fb.Contents != nil {
contentsCopy = make([]byte, len(fb.Contents))
copy(contentsCopy, fb.Contents)
}
var iptrsCopy []IndirectFilePtr
if fb.IPtrs != nil {
iptrsCopy = make([]IndirectFilePtr, len(fb.IPtrs))
copy(iptrsCopy, fb.IPtrs)
}
return &FileBlock{
CommonBlock: fb.CommonBlock.DeepCopy(),
Contents: contentsCopy,
IPtrs: iptrsCopy,
}
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"DeepCopy",
"(",
")",
"*",
"FileBlock",
"{",
"var",
"contentsCopy",
"[",
"]",
"byte",
"\n",
"if",
"fb",
".",
"Contents",
"!=",
"nil",
"{",
"contentsCopy",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"fb",
".",
"Contents",
")",
")",
"\n",
"copy",
"(",
"contentsCopy",
",",
"fb",
".",
"Contents",
")",
"\n",
"}",
"\n",
"var",
"iptrsCopy",
"[",
"]",
"IndirectFilePtr",
"\n",
"if",
"fb",
".",
"IPtrs",
"!=",
"nil",
"{",
"iptrsCopy",
"=",
"make",
"(",
"[",
"]",
"IndirectFilePtr",
",",
"len",
"(",
"fb",
".",
"IPtrs",
")",
")",
"\n",
"copy",
"(",
"iptrsCopy",
",",
"fb",
".",
"IPtrs",
")",
"\n",
"}",
"\n",
"return",
"&",
"FileBlock",
"{",
"CommonBlock",
":",
"fb",
".",
"CommonBlock",
".",
"DeepCopy",
"(",
")",
",",
"Contents",
":",
"contentsCopy",
",",
"IPtrs",
":",
"iptrsCopy",
",",
"}",
"\n",
"}"
] | // DeepCopy makes a complete copy of a FileBlock | [
"DeepCopy",
"makes",
"a",
"complete",
"copy",
"of",
"a",
"FileBlock"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L568-L584 |
159,650 | keybase/client | go/kbfs/data/block_types.go | GetHash | func (fb *FileBlock) GetHash() kbfshash.RawDefaultHash {
h := func() *kbfshash.RawDefaultHash {
fb.cacheMtx.RLock()
defer fb.cacheMtx.RUnlock()
return fb.hash
}()
if h != nil {
return *h
}
_, hash := kbfshash.DoRawDefaultHash(fb.Contents)
fb.cacheMtx.Lock()
defer fb.cacheMtx.Unlock()
fb.hash = &hash
return *fb.hash
} | go | func (fb *FileBlock) GetHash() kbfshash.RawDefaultHash {
h := func() *kbfshash.RawDefaultHash {
fb.cacheMtx.RLock()
defer fb.cacheMtx.RUnlock()
return fb.hash
}()
if h != nil {
return *h
}
_, hash := kbfshash.DoRawDefaultHash(fb.Contents)
fb.cacheMtx.Lock()
defer fb.cacheMtx.Unlock()
fb.hash = &hash
return *fb.hash
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"GetHash",
"(",
")",
"kbfshash",
".",
"RawDefaultHash",
"{",
"h",
":=",
"func",
"(",
")",
"*",
"kbfshash",
".",
"RawDefaultHash",
"{",
"fb",
".",
"cacheMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"fb",
".",
"cacheMtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"fb",
".",
"hash",
"\n",
"}",
"(",
")",
"\n",
"if",
"h",
"!=",
"nil",
"{",
"return",
"*",
"h",
"\n",
"}",
"\n",
"_",
",",
"hash",
":=",
"kbfshash",
".",
"DoRawDefaultHash",
"(",
"fb",
".",
"Contents",
")",
"\n",
"fb",
".",
"cacheMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fb",
".",
"cacheMtx",
".",
"Unlock",
"(",
")",
"\n",
"fb",
".",
"hash",
"=",
"&",
"hash",
"\n",
"return",
"*",
"fb",
".",
"hash",
"\n",
"}"
] | // GetHash returns the hash of this FileBlock. If the hash is nil, it first
// calculates it. | [
"GetHash",
"returns",
"the",
"hash",
"of",
"this",
"FileBlock",
".",
"If",
"the",
"hash",
"is",
"nil",
"it",
"first",
"calculates",
"it",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L588-L602 |
159,651 | keybase/client | go/kbfs/data/block_types.go | OffsetExceedsData | func (fb *FileBlock) OffsetExceedsData(startOff, off Offset) bool {
if fb.IsInd {
panic("OffsetExceedsData called on an indirect file block")
}
if len(fb.Contents) == 0 {
return false
}
offI, ok := off.(Int64Offset)
if !ok {
panic(fmt.Sprintf("Bad offset of type %T passed to FileBlock", off))
}
startOffI, ok := startOff.(Int64Offset)
if !ok {
panic(fmt.Sprintf("Bad offset of type %T passed to FileBlock",
startOff))
}
return int64(offI) >= int64(startOffI)+int64(len(fb.Contents))
} | go | func (fb *FileBlock) OffsetExceedsData(startOff, off Offset) bool {
if fb.IsInd {
panic("OffsetExceedsData called on an indirect file block")
}
if len(fb.Contents) == 0 {
return false
}
offI, ok := off.(Int64Offset)
if !ok {
panic(fmt.Sprintf("Bad offset of type %T passed to FileBlock", off))
}
startOffI, ok := startOff.(Int64Offset)
if !ok {
panic(fmt.Sprintf("Bad offset of type %T passed to FileBlock",
startOff))
}
return int64(offI) >= int64(startOffI)+int64(len(fb.Contents))
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"OffsetExceedsData",
"(",
"startOff",
",",
"off",
"Offset",
")",
"bool",
"{",
"if",
"fb",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"fb",
".",
"Contents",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"offI",
",",
"ok",
":=",
"off",
".",
"(",
"Int64Offset",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"off",
")",
")",
"\n",
"}",
"\n",
"startOffI",
",",
"ok",
":=",
"startOff",
".",
"(",
"Int64Offset",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"startOff",
")",
")",
"\n",
"}",
"\n",
"return",
"int64",
"(",
"offI",
")",
">=",
"int64",
"(",
"startOffI",
")",
"+",
"int64",
"(",
"len",
"(",
"fb",
".",
"Contents",
")",
")",
"\n",
"}"
] | // OffsetExceedsData implements the Block interface for FileBlock. | [
"OffsetExceedsData",
"implements",
"the",
"Block",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L605-L624 |
159,652 | keybase/client | go/kbfs/data/block_types.go | NumIndirectPtrs | func (fb *FileBlock) NumIndirectPtrs() int {
if !fb.IsInd {
panic("NumIndirectPtrs called on a direct file block")
}
return len(fb.IPtrs)
} | go | func (fb *FileBlock) NumIndirectPtrs() int {
if !fb.IsInd {
panic("NumIndirectPtrs called on a direct file block")
}
return len(fb.IPtrs)
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"NumIndirectPtrs",
"(",
")",
"int",
"{",
"if",
"!",
"fb",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"len",
"(",
"fb",
".",
"IPtrs",
")",
"\n",
"}"
] | // NumIndirectPtrs implements the BlockWithPtrs interface for FileBlock. | [
"NumIndirectPtrs",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L637-L642 |
159,653 | keybase/client | go/kbfs/data/block_types.go | IndirectPtr | func (fb *FileBlock) IndirectPtr(i int) (BlockInfo, Offset) {
if !fb.IsInd {
panic("IndirectPtr called on a direct file block")
}
iptr := fb.IPtrs[i]
return iptr.BlockInfo, iptr.Off
} | go | func (fb *FileBlock) IndirectPtr(i int) (BlockInfo, Offset) {
if !fb.IsInd {
panic("IndirectPtr called on a direct file block")
}
iptr := fb.IPtrs[i]
return iptr.BlockInfo, iptr.Off
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"IndirectPtr",
"(",
"i",
"int",
")",
"(",
"BlockInfo",
",",
"Offset",
")",
"{",
"if",
"!",
"fb",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"iptr",
":=",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
"\n",
"return",
"iptr",
".",
"BlockInfo",
",",
"iptr",
".",
"Off",
"\n",
"}"
] | // IndirectPtr implements the BlockWithPtrs interface for FileBlock. | [
"IndirectPtr",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L645-L651 |
159,654 | keybase/client | go/kbfs/data/block_types.go | ClearIndirectPtrSize | func (fb *FileBlock) ClearIndirectPtrSize(i int) {
if !fb.IsInd {
panic("ClearIndirectPtrSize called on a direct file block")
}
fb.IPtrs[i].EncodedSize = 0
} | go | func (fb *FileBlock) ClearIndirectPtrSize(i int) {
if !fb.IsInd {
panic("ClearIndirectPtrSize called on a direct file block")
}
fb.IPtrs[i].EncodedSize = 0
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"ClearIndirectPtrSize",
"(",
"i",
"int",
")",
"{",
"if",
"!",
"fb",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"EncodedSize",
"=",
"0",
"\n",
"}"
] | // ClearIndirectPtrSize implements the BlockWithPtrs interface for FileBlock. | [
"ClearIndirectPtrSize",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L673-L678 |
159,655 | keybase/client | go/kbfs/data/block_types.go | SetIndirectPtrType | func (fb *FileBlock) SetIndirectPtrType(i int, dt BlockDirectType) {
if !fb.IsInd {
panic("SetIndirectPtrType called on a direct file block")
}
fb.IPtrs[i].DirectType = dt
} | go | func (fb *FileBlock) SetIndirectPtrType(i int, dt BlockDirectType) {
if !fb.IsInd {
panic("SetIndirectPtrType called on a direct file block")
}
fb.IPtrs[i].DirectType = dt
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"SetIndirectPtrType",
"(",
"i",
"int",
",",
"dt",
"BlockDirectType",
")",
"{",
"if",
"!",
"fb",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"DirectType",
"=",
"dt",
"\n",
"}"
] | // SetIndirectPtrType implements the BlockWithPtrs interface for FileBlock. | [
"SetIndirectPtrType",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L681-L686 |
159,656 | keybase/client | go/kbfs/data/block_types.go | SwapIndirectPtrs | func (fb *FileBlock) SwapIndirectPtrs(i int, other BlockWithPtrs, otherI int) {
otherFB, ok := other.(*FileBlock)
if !ok {
panic(fmt.Sprintf(
"SwapIndirectPtrs cannot swap between block types: %T", other))
}
fb.IPtrs[i], otherFB.IPtrs[otherI] = otherFB.IPtrs[otherI], fb.IPtrs[i]
} | go | func (fb *FileBlock) SwapIndirectPtrs(i int, other BlockWithPtrs, otherI int) {
otherFB, ok := other.(*FileBlock)
if !ok {
panic(fmt.Sprintf(
"SwapIndirectPtrs cannot swap between block types: %T", other))
}
fb.IPtrs[i], otherFB.IPtrs[otherI] = otherFB.IPtrs[otherI], fb.IPtrs[i]
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"SwapIndirectPtrs",
"(",
"i",
"int",
",",
"other",
"BlockWithPtrs",
",",
"otherI",
"int",
")",
"{",
"otherFB",
",",
"ok",
":=",
"other",
".",
"(",
"*",
"FileBlock",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"other",
")",
")",
"\n",
"}",
"\n\n",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
",",
"otherFB",
".",
"IPtrs",
"[",
"otherI",
"]",
"=",
"otherFB",
".",
"IPtrs",
"[",
"otherI",
"]",
",",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
"\n",
"}"
] | // SwapIndirectPtrs implements the BlockWithPtrs interface for FileBlock. | [
"SwapIndirectPtrs",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L689-L697 |
159,657 | keybase/client | go/kbfs/data/block_types.go | SetIndirectPtrOff | func (fb *FileBlock) SetIndirectPtrOff(i int, off Offset) {
if !fb.IsInd {
panic("SetIndirectPtrOff called on a direct file block")
}
iOff, ok := off.(Int64Offset)
if !ok {
panic(fmt.Sprintf("SetIndirectPtrOff called on a file block "+
"with a %T offset", off))
}
fb.IPtrs[i].Off = iOff
} | go | func (fb *FileBlock) SetIndirectPtrOff(i int, off Offset) {
if !fb.IsInd {
panic("SetIndirectPtrOff called on a direct file block")
}
iOff, ok := off.(Int64Offset)
if !ok {
panic(fmt.Sprintf("SetIndirectPtrOff called on a file block "+
"with a %T offset", off))
}
fb.IPtrs[i].Off = iOff
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"SetIndirectPtrOff",
"(",
"i",
"int",
",",
"off",
"Offset",
")",
"{",
"if",
"!",
"fb",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"iOff",
",",
"ok",
":=",
"off",
".",
"(",
"Int64Offset",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"off",
")",
")",
"\n",
"}",
"\n",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"Off",
"=",
"iOff",
"\n",
"}"
] | // SetIndirectPtrOff implements the BlockWithPtrs interface for FileBlock. | [
"SetIndirectPtrOff",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L700-L710 |
159,658 | keybase/client | go/kbfs/data/block_types.go | SetIndirectPtrInfo | func (fb *FileBlock) SetIndirectPtrInfo(i int, info BlockInfo) {
if !fb.IsInd {
panic("SetIndirectPtrInfo called on a direct file block")
}
fb.IPtrs[i].BlockInfo = info
} | go | func (fb *FileBlock) SetIndirectPtrInfo(i int, info BlockInfo) {
if !fb.IsInd {
panic("SetIndirectPtrInfo called on a direct file block")
}
fb.IPtrs[i].BlockInfo = info
} | [
"func",
"(",
"fb",
"*",
"FileBlock",
")",
"SetIndirectPtrInfo",
"(",
"i",
"int",
",",
"info",
"BlockInfo",
")",
"{",
"if",
"!",
"fb",
".",
"IsInd",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"fb",
".",
"IPtrs",
"[",
"i",
"]",
".",
"BlockInfo",
"=",
"info",
"\n",
"}"
] | // SetIndirectPtrInfo implements the BlockWithPtrs interface for FileBlock. | [
"SetIndirectPtrInfo",
"implements",
"the",
"BlockWithPtrs",
"interface",
"for",
"FileBlock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/block_types.go#L713-L718 |
159,659 | keybase/client | go/protocol/keybase1/tlf_keys.go | GetTLFCryptKeys | func (c TlfKeysClient) GetTLFCryptKeys(ctx context.Context, query TLFQuery) (res GetTLFCryptKeysRes, err error) {
__arg := GetTLFCryptKeysArg{Query: query}
err = c.Cli.Call(ctx, "keybase.1.tlfKeys.getTLFCryptKeys", []interface{}{__arg}, &res)
return
} | go | func (c TlfKeysClient) GetTLFCryptKeys(ctx context.Context, query TLFQuery) (res GetTLFCryptKeysRes, err error) {
__arg := GetTLFCryptKeysArg{Query: query}
err = c.Cli.Call(ctx, "keybase.1.tlfKeys.getTLFCryptKeys", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"TlfKeysClient",
")",
"GetTLFCryptKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"TLFQuery",
")",
"(",
"res",
"GetTLFCryptKeysRes",
",",
"err",
"error",
")",
"{",
"__arg",
":=",
"GetTLFCryptKeysArg",
"{",
"Query",
":",
"query",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // getTLFCryptKeys returns TLF crypt keys from all generations and the TLF ID.
// TLF ID should not be cached or stored persistently. | [
"getTLFCryptKeys",
"returns",
"TLF",
"crypt",
"keys",
"from",
"all",
"generations",
"and",
"the",
"TLF",
"ID",
".",
"TLF",
"ID",
"should",
"not",
"be",
"cached",
"or",
"stored",
"persistently",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/tlf_keys.go#L241-L245 |
159,660 | keybase/client | go/protocol/keybase1/tlf_keys.go | GetPublicCanonicalTLFNameAndID | func (c TlfKeysClient) GetPublicCanonicalTLFNameAndID(ctx context.Context, query TLFQuery) (res CanonicalTLFNameAndIDWithBreaks, err error) {
__arg := GetPublicCanonicalTLFNameAndIDArg{Query: query}
err = c.Cli.Call(ctx, "keybase.1.tlfKeys.getPublicCanonicalTLFNameAndID", []interface{}{__arg}, &res)
return
} | go | func (c TlfKeysClient) GetPublicCanonicalTLFNameAndID(ctx context.Context, query TLFQuery) (res CanonicalTLFNameAndIDWithBreaks, err error) {
__arg := GetPublicCanonicalTLFNameAndIDArg{Query: query}
err = c.Cli.Call(ctx, "keybase.1.tlfKeys.getPublicCanonicalTLFNameAndID", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"TlfKeysClient",
")",
"GetPublicCanonicalTLFNameAndID",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"TLFQuery",
")",
"(",
"res",
"CanonicalTLFNameAndIDWithBreaks",
",",
"err",
"error",
")",
"{",
"__arg",
":=",
"GetPublicCanonicalTLFNameAndIDArg",
"{",
"Query",
":",
"query",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // getPublicCanonicalTLFNameAndID return the canonical name and TLFID for tlfName.
// TLF ID should not be cached or stored persistently. | [
"getPublicCanonicalTLFNameAndID",
"return",
"the",
"canonical",
"name",
"and",
"TLFID",
"for",
"tlfName",
".",
"TLF",
"ID",
"should",
"not",
"be",
"cached",
"or",
"stored",
"persistently",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/tlf_keys.go#L249-L253 |
159,661 | keybase/client | go/engine/device_history.go | NewDeviceHistory | func NewDeviceHistory(g *libkb.GlobalContext, username string) *DeviceHistory {
return &DeviceHistory{
Contextified: libkb.NewContextified(g),
username: username,
}
} | go | func NewDeviceHistory(g *libkb.GlobalContext, username string) *DeviceHistory {
return &DeviceHistory{
Contextified: libkb.NewContextified(g),
username: username,
}
} | [
"func",
"NewDeviceHistory",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"username",
"string",
")",
"*",
"DeviceHistory",
"{",
"return",
"&",
"DeviceHistory",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"username",
":",
"username",
",",
"}",
"\n",
"}"
] | // NewDeviceHistory creates a DeviceHistory engine to lookup the
// device history for username. | [
"NewDeviceHistory",
"creates",
"a",
"DeviceHistory",
"engine",
"to",
"lookup",
"the",
"device",
"history",
"for",
"username",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/device_history.go#L25-L30 |
159,662 | keybase/client | go/engine/device_history.go | NewDeviceHistorySelf | func NewDeviceHistorySelf(g *libkb.GlobalContext) *DeviceHistory {
return &DeviceHistory{
Contextified: libkb.NewContextified(g),
}
} | go | func NewDeviceHistorySelf(g *libkb.GlobalContext) *DeviceHistory {
return &DeviceHistory{
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewDeviceHistorySelf",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"*",
"DeviceHistory",
"{",
"return",
"&",
"DeviceHistory",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"}"
] | // NewDeviceHistorySelf creates a DeviceHistory engine to lookup
// the device history of the current user. | [
"NewDeviceHistorySelf",
"creates",
"a",
"DeviceHistory",
"engine",
"to",
"lookup",
"the",
"device",
"history",
"of",
"the",
"current",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/device_history.go#L34-L38 |
159,663 | keybase/client | go/engine/device_history.go | Prereqs | func (e *DeviceHistory) Prereqs() Prereqs {
if len(e.username) > 0 {
return Prereqs{}
}
return Prereqs{Device: true}
} | go | func (e *DeviceHistory) Prereqs() Prereqs {
if len(e.username) > 0 {
return Prereqs{}
}
return Prereqs{Device: true}
} | [
"func",
"(",
"e",
"*",
"DeviceHistory",
")",
"Prereqs",
"(",
")",
"Prereqs",
"{",
"if",
"len",
"(",
"e",
".",
"username",
")",
">",
"0",
"{",
"return",
"Prereqs",
"{",
"}",
"\n",
"}",
"\n",
"return",
"Prereqs",
"{",
"Device",
":",
"true",
"}",
"\n",
"}"
] | // GetPrereqs returns the engine prereqs. | [
"GetPrereqs",
"returns",
"the",
"engine",
"prereqs",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/device_history.go#L46-L51 |
159,664 | keybase/client | go/kbfs/libkbfs/block_ops.go | NewBlockOpsStandard | func NewBlockOpsStandard(
config blockOpsConfig, queueSize, prefetchQueueSize int,
throttledPrefetchPeriod time.Duration) *BlockOpsStandard {
bg := &realBlockGetter{config: config}
qConfig := &realBlockRetrievalConfig{
blockRetrievalPartialConfig: config,
bg: bg,
}
q := newBlockRetrievalQueue(
queueSize, prefetchQueueSize, throttledPrefetchPeriod, qConfig)
bops := &BlockOpsStandard{
config: config,
log: traceLogger{config.MakeLogger("")},
queue: q,
}
return bops
} | go | func NewBlockOpsStandard(
config blockOpsConfig, queueSize, prefetchQueueSize int,
throttledPrefetchPeriod time.Duration) *BlockOpsStandard {
bg := &realBlockGetter{config: config}
qConfig := &realBlockRetrievalConfig{
blockRetrievalPartialConfig: config,
bg: bg,
}
q := newBlockRetrievalQueue(
queueSize, prefetchQueueSize, throttledPrefetchPeriod, qConfig)
bops := &BlockOpsStandard{
config: config,
log: traceLogger{config.MakeLogger("")},
queue: q,
}
return bops
} | [
"func",
"NewBlockOpsStandard",
"(",
"config",
"blockOpsConfig",
",",
"queueSize",
",",
"prefetchQueueSize",
"int",
",",
"throttledPrefetchPeriod",
"time",
".",
"Duration",
")",
"*",
"BlockOpsStandard",
"{",
"bg",
":=",
"&",
"realBlockGetter",
"{",
"config",
":",
"config",
"}",
"\n",
"qConfig",
":=",
"&",
"realBlockRetrievalConfig",
"{",
"blockRetrievalPartialConfig",
":",
"config",
",",
"bg",
":",
"bg",
",",
"}",
"\n",
"q",
":=",
"newBlockRetrievalQueue",
"(",
"queueSize",
",",
"prefetchQueueSize",
",",
"throttledPrefetchPeriod",
",",
"qConfig",
")",
"\n",
"bops",
":=",
"&",
"BlockOpsStandard",
"{",
"config",
":",
"config",
",",
"log",
":",
"traceLogger",
"{",
"config",
".",
"MakeLogger",
"(",
"\"",
"\"",
")",
"}",
",",
"queue",
":",
"q",
",",
"}",
"\n",
"return",
"bops",
"\n",
"}"
] | // NewBlockOpsStandard creates a new BlockOpsStandard | [
"NewBlockOpsStandard",
"creates",
"a",
"new",
"BlockOpsStandard"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops.go#L46-L62 |
159,665 | keybase/client | go/kbfs/libkbfs/block_ops.go | Get | func (b *BlockOpsStandard) Get(ctx context.Context, kmd libkey.KeyMetadata,
blockPtr data.BlockPointer, block data.Block, lifetime data.BlockCacheLifetime) error {
// Check the journal explicitly first, so we don't get stuck in
// the block-fetching queue.
if journalBServer, ok := b.config.BlockServer().(journalBlockServer); ok {
data, serverHalf, found, err := journalBServer.getBlockFromJournal(
ctx, kmd.TlfID(), blockPtr.ID)
if err != nil {
return err
}
if found {
return assembleBlock(
ctx, b.config.keyGetter(), b.config.Codec(),
b.config.cryptoPure(), kmd, blockPtr, block, data, serverHalf)
}
}
b.log.LazyTrace(ctx, "BOps: Requesting %s", blockPtr.ID)
errCh := b.queue.Request(
ctx, defaultOnDemandRequestPriority, kmd,
blockPtr, block, lifetime, b.config.Mode().DefaultBlockRequestAction())
err := <-errCh
b.log.LazyTrace(ctx, "BOps: Request fulfilled for %s (err=%v)", blockPtr.ID, err)
return err
} | go | func (b *BlockOpsStandard) Get(ctx context.Context, kmd libkey.KeyMetadata,
blockPtr data.BlockPointer, block data.Block, lifetime data.BlockCacheLifetime) error {
// Check the journal explicitly first, so we don't get stuck in
// the block-fetching queue.
if journalBServer, ok := b.config.BlockServer().(journalBlockServer); ok {
data, serverHalf, found, err := journalBServer.getBlockFromJournal(
ctx, kmd.TlfID(), blockPtr.ID)
if err != nil {
return err
}
if found {
return assembleBlock(
ctx, b.config.keyGetter(), b.config.Codec(),
b.config.cryptoPure(), kmd, blockPtr, block, data, serverHalf)
}
}
b.log.LazyTrace(ctx, "BOps: Requesting %s", blockPtr.ID)
errCh := b.queue.Request(
ctx, defaultOnDemandRequestPriority, kmd,
blockPtr, block, lifetime, b.config.Mode().DefaultBlockRequestAction())
err := <-errCh
b.log.LazyTrace(ctx, "BOps: Request fulfilled for %s (err=%v)", blockPtr.ID, err)
return err
} | [
"func",
"(",
"b",
"*",
"BlockOpsStandard",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"kmd",
"libkey",
".",
"KeyMetadata",
",",
"blockPtr",
"data",
".",
"BlockPointer",
",",
"block",
"data",
".",
"Block",
",",
"lifetime",
"data",
".",
"BlockCacheLifetime",
")",
"error",
"{",
"// Check the journal explicitly first, so we don't get stuck in",
"// the block-fetching queue.",
"if",
"journalBServer",
",",
"ok",
":=",
"b",
".",
"config",
".",
"BlockServer",
"(",
")",
".",
"(",
"journalBlockServer",
")",
";",
"ok",
"{",
"data",
",",
"serverHalf",
",",
"found",
",",
"err",
":=",
"journalBServer",
".",
"getBlockFromJournal",
"(",
"ctx",
",",
"kmd",
".",
"TlfID",
"(",
")",
",",
"blockPtr",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"found",
"{",
"return",
"assembleBlock",
"(",
"ctx",
",",
"b",
".",
"config",
".",
"keyGetter",
"(",
")",
",",
"b",
".",
"config",
".",
"Codec",
"(",
")",
",",
"b",
".",
"config",
".",
"cryptoPure",
"(",
")",
",",
"kmd",
",",
"blockPtr",
",",
"block",
",",
"data",
",",
"serverHalf",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"b",
".",
"log",
".",
"LazyTrace",
"(",
"ctx",
",",
"\"",
"\"",
",",
"blockPtr",
".",
"ID",
")",
"\n\n",
"errCh",
":=",
"b",
".",
"queue",
".",
"Request",
"(",
"ctx",
",",
"defaultOnDemandRequestPriority",
",",
"kmd",
",",
"blockPtr",
",",
"block",
",",
"lifetime",
",",
"b",
".",
"config",
".",
"Mode",
"(",
")",
".",
"DefaultBlockRequestAction",
"(",
")",
")",
"\n",
"err",
":=",
"<-",
"errCh",
"\n\n",
"b",
".",
"log",
".",
"LazyTrace",
"(",
"ctx",
",",
"\"",
"\"",
",",
"blockPtr",
".",
"ID",
",",
"err",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] | // Get implements the BlockOps interface for BlockOpsStandard. | [
"Get",
"implements",
"the",
"BlockOps",
"interface",
"for",
"BlockOpsStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops.go#L65-L92 |
159,666 | keybase/client | go/kbfs/libkbfs/block_ops.go | GetEncodedSize | func (b *BlockOpsStandard) GetEncodedSize(ctx context.Context, kmd libkey.KeyMetadata,
blockPtr data.BlockPointer) (uint32, keybase1.BlockStatus, error) {
// Check the journal explicitly first, so we don't get stuck in
// the block-fetching queue.
if journalBServer, ok := b.config.BlockServer().(journalBlockServer); ok {
size, found, err := journalBServer.getBlockSizeFromJournal(
ctx, kmd.TlfID(), blockPtr.ID)
if err != nil {
return 0, 0, err
}
if found && size > 0 {
return size, keybase1.BlockStatus_LIVE, nil
}
}
return b.config.BlockServer().GetEncodedSize(
ctx, kmd.TlfID(), blockPtr.ID, blockPtr.Context)
} | go | func (b *BlockOpsStandard) GetEncodedSize(ctx context.Context, kmd libkey.KeyMetadata,
blockPtr data.BlockPointer) (uint32, keybase1.BlockStatus, error) {
// Check the journal explicitly first, so we don't get stuck in
// the block-fetching queue.
if journalBServer, ok := b.config.BlockServer().(journalBlockServer); ok {
size, found, err := journalBServer.getBlockSizeFromJournal(
ctx, kmd.TlfID(), blockPtr.ID)
if err != nil {
return 0, 0, err
}
if found && size > 0 {
return size, keybase1.BlockStatus_LIVE, nil
}
}
return b.config.BlockServer().GetEncodedSize(
ctx, kmd.TlfID(), blockPtr.ID, blockPtr.Context)
} | [
"func",
"(",
"b",
"*",
"BlockOpsStandard",
")",
"GetEncodedSize",
"(",
"ctx",
"context",
".",
"Context",
",",
"kmd",
"libkey",
".",
"KeyMetadata",
",",
"blockPtr",
"data",
".",
"BlockPointer",
")",
"(",
"uint32",
",",
"keybase1",
".",
"BlockStatus",
",",
"error",
")",
"{",
"// Check the journal explicitly first, so we don't get stuck in",
"// the block-fetching queue.",
"if",
"journalBServer",
",",
"ok",
":=",
"b",
".",
"config",
".",
"BlockServer",
"(",
")",
".",
"(",
"journalBlockServer",
")",
";",
"ok",
"{",
"size",
",",
"found",
",",
"err",
":=",
"journalBServer",
".",
"getBlockSizeFromJournal",
"(",
"ctx",
",",
"kmd",
".",
"TlfID",
"(",
")",
",",
"blockPtr",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"if",
"found",
"&&",
"size",
">",
"0",
"{",
"return",
"size",
",",
"keybase1",
".",
"BlockStatus_LIVE",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"b",
".",
"config",
".",
"BlockServer",
"(",
")",
".",
"GetEncodedSize",
"(",
"ctx",
",",
"kmd",
".",
"TlfID",
"(",
")",
",",
"blockPtr",
".",
"ID",
",",
"blockPtr",
".",
"Context",
")",
"\n",
"}"
] | // GetEncodedSize implements the BlockOps interface for
// BlockOpsStandard. | [
"GetEncodedSize",
"implements",
"the",
"BlockOps",
"interface",
"for",
"BlockOpsStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops.go#L96-L113 |
159,667 | keybase/client | go/kbfs/libkbfs/block_ops.go | Ready | func (b *BlockOpsStandard) Ready(ctx context.Context, kmd libkey.KeyMetadata,
block data.Block) (id kbfsblock.ID, plainSize int, readyBlockData data.ReadyBlockData,
err error) {
defer func() {
if err != nil {
id = kbfsblock.ID{}
plainSize = 0
readyBlockData = data.ReadyBlockData{}
}
}()
crypto := b.config.cryptoPure()
tlfCryptKey, err := b.config.keyGetter().
GetTLFCryptKeyForEncryption(ctx, kmd)
if err != nil {
return
}
// New server key half for the block.
serverHalf, err := crypto.MakeRandomBlockCryptKeyServerHalf()
if err != nil {
return
}
plainSize, encryptedBlock, err := crypto.EncryptBlock(
block, tlfCryptKey, serverHalf)
if err != nil {
return
}
buf, err := b.config.Codec().Encode(encryptedBlock)
if err != nil {
return
}
readyBlockData = data.ReadyBlockData{
Buf: buf,
ServerHalf: serverHalf,
}
encodedSize := readyBlockData.GetEncodedSize()
if encodedSize < plainSize {
err = TooLowByteCountError{
ExpectedMinByteCount: plainSize,
ByteCount: encodedSize,
}
return
}
id, err = kbfsblock.MakePermanentID(buf, encryptedBlock.Version)
if err != nil {
return
}
// Cache the encoded size.
block.SetEncodedSize(uint32(encodedSize))
return
} | go | func (b *BlockOpsStandard) Ready(ctx context.Context, kmd libkey.KeyMetadata,
block data.Block) (id kbfsblock.ID, plainSize int, readyBlockData data.ReadyBlockData,
err error) {
defer func() {
if err != nil {
id = kbfsblock.ID{}
plainSize = 0
readyBlockData = data.ReadyBlockData{}
}
}()
crypto := b.config.cryptoPure()
tlfCryptKey, err := b.config.keyGetter().
GetTLFCryptKeyForEncryption(ctx, kmd)
if err != nil {
return
}
// New server key half for the block.
serverHalf, err := crypto.MakeRandomBlockCryptKeyServerHalf()
if err != nil {
return
}
plainSize, encryptedBlock, err := crypto.EncryptBlock(
block, tlfCryptKey, serverHalf)
if err != nil {
return
}
buf, err := b.config.Codec().Encode(encryptedBlock)
if err != nil {
return
}
readyBlockData = data.ReadyBlockData{
Buf: buf,
ServerHalf: serverHalf,
}
encodedSize := readyBlockData.GetEncodedSize()
if encodedSize < plainSize {
err = TooLowByteCountError{
ExpectedMinByteCount: plainSize,
ByteCount: encodedSize,
}
return
}
id, err = kbfsblock.MakePermanentID(buf, encryptedBlock.Version)
if err != nil {
return
}
// Cache the encoded size.
block.SetEncodedSize(uint32(encodedSize))
return
} | [
"func",
"(",
"b",
"*",
"BlockOpsStandard",
")",
"Ready",
"(",
"ctx",
"context",
".",
"Context",
",",
"kmd",
"libkey",
".",
"KeyMetadata",
",",
"block",
"data",
".",
"Block",
")",
"(",
"id",
"kbfsblock",
".",
"ID",
",",
"plainSize",
"int",
",",
"readyBlockData",
"data",
".",
"ReadyBlockData",
",",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"id",
"=",
"kbfsblock",
".",
"ID",
"{",
"}",
"\n",
"plainSize",
"=",
"0",
"\n",
"readyBlockData",
"=",
"data",
".",
"ReadyBlockData",
"{",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"crypto",
":=",
"b",
".",
"config",
".",
"cryptoPure",
"(",
")",
"\n\n",
"tlfCryptKey",
",",
"err",
":=",
"b",
".",
"config",
".",
"keyGetter",
"(",
")",
".",
"GetTLFCryptKeyForEncryption",
"(",
"ctx",
",",
"kmd",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"// New server key half for the block.",
"serverHalf",
",",
"err",
":=",
"crypto",
".",
"MakeRandomBlockCryptKeyServerHalf",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"plainSize",
",",
"encryptedBlock",
",",
"err",
":=",
"crypto",
".",
"EncryptBlock",
"(",
"block",
",",
"tlfCryptKey",
",",
"serverHalf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"buf",
",",
"err",
":=",
"b",
".",
"config",
".",
"Codec",
"(",
")",
".",
"Encode",
"(",
"encryptedBlock",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"readyBlockData",
"=",
"data",
".",
"ReadyBlockData",
"{",
"Buf",
":",
"buf",
",",
"ServerHalf",
":",
"serverHalf",
",",
"}",
"\n\n",
"encodedSize",
":=",
"readyBlockData",
".",
"GetEncodedSize",
"(",
")",
"\n",
"if",
"encodedSize",
"<",
"plainSize",
"{",
"err",
"=",
"TooLowByteCountError",
"{",
"ExpectedMinByteCount",
":",
"plainSize",
",",
"ByteCount",
":",
"encodedSize",
",",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"id",
",",
"err",
"=",
"kbfsblock",
".",
"MakePermanentID",
"(",
"buf",
",",
"encryptedBlock",
".",
"Version",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"// Cache the encoded size.",
"block",
".",
"SetEncodedSize",
"(",
"uint32",
"(",
"encodedSize",
")",
")",
"\n\n",
"return",
"\n",
"}"
] | // Ready implements the BlockOps interface for BlockOpsStandard. | [
"Ready",
"implements",
"the",
"BlockOps",
"interface",
"for",
"BlockOpsStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops.go#L116-L175 |
159,668 | keybase/client | go/kbfs/libkbfs/block_ops.go | Delete | func (b *BlockOpsStandard) Delete(ctx context.Context, tlfID tlf.ID,
ptrs []data.BlockPointer) (liveCounts map[kbfsblock.ID]int, err error) {
contexts := make(kbfsblock.ContextMap)
for _, ptr := range ptrs {
contexts[ptr.ID] = append(contexts[ptr.ID], ptr.Context)
}
return b.config.BlockServer().RemoveBlockReferences(ctx, tlfID, contexts)
} | go | func (b *BlockOpsStandard) Delete(ctx context.Context, tlfID tlf.ID,
ptrs []data.BlockPointer) (liveCounts map[kbfsblock.ID]int, err error) {
contexts := make(kbfsblock.ContextMap)
for _, ptr := range ptrs {
contexts[ptr.ID] = append(contexts[ptr.ID], ptr.Context)
}
return b.config.BlockServer().RemoveBlockReferences(ctx, tlfID, contexts)
} | [
"func",
"(",
"b",
"*",
"BlockOpsStandard",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"ptrs",
"[",
"]",
"data",
".",
"BlockPointer",
")",
"(",
"liveCounts",
"map",
"[",
"kbfsblock",
".",
"ID",
"]",
"int",
",",
"err",
"error",
")",
"{",
"contexts",
":=",
"make",
"(",
"kbfsblock",
".",
"ContextMap",
")",
"\n",
"for",
"_",
",",
"ptr",
":=",
"range",
"ptrs",
"{",
"contexts",
"[",
"ptr",
".",
"ID",
"]",
"=",
"append",
"(",
"contexts",
"[",
"ptr",
".",
"ID",
"]",
",",
"ptr",
".",
"Context",
")",
"\n",
"}",
"\n",
"return",
"b",
".",
"config",
".",
"BlockServer",
"(",
")",
".",
"RemoveBlockReferences",
"(",
"ctx",
",",
"tlfID",
",",
"contexts",
")",
"\n",
"}"
] | // Delete implements the BlockOps interface for BlockOpsStandard. | [
"Delete",
"implements",
"the",
"BlockOps",
"interface",
"for",
"BlockOpsStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops.go#L178-L185 |
159,669 | keybase/client | go/kbfs/libkbfs/block_ops.go | Archive | func (b *BlockOpsStandard) Archive(ctx context.Context, tlfID tlf.ID,
ptrs []data.BlockPointer) error {
contexts := make(kbfsblock.ContextMap)
for _, ptr := range ptrs {
contexts[ptr.ID] = append(contexts[ptr.ID], ptr.Context)
}
return b.config.BlockServer().ArchiveBlockReferences(ctx, tlfID, contexts)
} | go | func (b *BlockOpsStandard) Archive(ctx context.Context, tlfID tlf.ID,
ptrs []data.BlockPointer) error {
contexts := make(kbfsblock.ContextMap)
for _, ptr := range ptrs {
contexts[ptr.ID] = append(contexts[ptr.ID], ptr.Context)
}
return b.config.BlockServer().ArchiveBlockReferences(ctx, tlfID, contexts)
} | [
"func",
"(",
"b",
"*",
"BlockOpsStandard",
")",
"Archive",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"ptrs",
"[",
"]",
"data",
".",
"BlockPointer",
")",
"error",
"{",
"contexts",
":=",
"make",
"(",
"kbfsblock",
".",
"ContextMap",
")",
"\n",
"for",
"_",
",",
"ptr",
":=",
"range",
"ptrs",
"{",
"contexts",
"[",
"ptr",
".",
"ID",
"]",
"=",
"append",
"(",
"contexts",
"[",
"ptr",
".",
"ID",
"]",
",",
"ptr",
".",
"Context",
")",
"\n",
"}",
"\n\n",
"return",
"b",
".",
"config",
".",
"BlockServer",
"(",
")",
".",
"ArchiveBlockReferences",
"(",
"ctx",
",",
"tlfID",
",",
"contexts",
")",
"\n",
"}"
] | // Archive implements the BlockOps interface for BlockOpsStandard. | [
"Archive",
"implements",
"the",
"BlockOps",
"interface",
"for",
"BlockOpsStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops.go#L188-L196 |
159,670 | keybase/client | go/kbfs/libkbfs/block_ops.go | TogglePrefetcher | func (b *BlockOpsStandard) TogglePrefetcher(enable bool) <-chan struct{} {
return b.queue.TogglePrefetcher(enable, nil, nil)
} | go | func (b *BlockOpsStandard) TogglePrefetcher(enable bool) <-chan struct{} {
return b.queue.TogglePrefetcher(enable, nil, nil)
} | [
"func",
"(",
"b",
"*",
"BlockOpsStandard",
")",
"TogglePrefetcher",
"(",
"enable",
"bool",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"return",
"b",
".",
"queue",
".",
"TogglePrefetcher",
"(",
"enable",
",",
"nil",
",",
"nil",
")",
"\n",
"}"
] | // TogglePrefetcher implements the BlockOps interface for BlockOpsStandard. | [
"TogglePrefetcher",
"implements",
"the",
"BlockOps",
"interface",
"for",
"BlockOpsStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops.go#L211-L213 |
159,671 | keybase/client | go/kbfs/libkbfs/block_ops.go | Shutdown | func (b *BlockOpsStandard) Shutdown(ctx context.Context) error {
// Block on the queue being done.
select {
case <-b.queue.Shutdown():
return nil
case <-ctx.Done():
return errors.WithStack(ctx.Err())
}
} | go | func (b *BlockOpsStandard) Shutdown(ctx context.Context) error {
// Block on the queue being done.
select {
case <-b.queue.Shutdown():
return nil
case <-ctx.Done():
return errors.WithStack(ctx.Err())
}
} | [
"func",
"(",
"b",
"*",
"BlockOpsStandard",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"// Block on the queue being done.",
"select",
"{",
"case",
"<-",
"b",
".",
"queue",
".",
"Shutdown",
"(",
")",
":",
"return",
"nil",
"\n",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"errors",
".",
"WithStack",
"(",
"ctx",
".",
"Err",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Shutdown implements the BlockOps interface for BlockOpsStandard. | [
"Shutdown",
"implements",
"the",
"BlockOps",
"interface",
"for",
"BlockOpsStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_ops.go#L226-L234 |
159,672 | keybase/client | go/kbfs/libkbfs/reporter_simple.go | NewReporterSimple | func NewReporterSimple(clock Clock, maxErrors int) *ReporterSimple {
rs := &ReporterSimple{
clock: clock,
maxErrors: maxErrors,
currErrorIndex: -1,
}
if maxErrors >= 1 {
rs.errors = make([]ReportedError, maxErrors)
}
return rs
} | go | func NewReporterSimple(clock Clock, maxErrors int) *ReporterSimple {
rs := &ReporterSimple{
clock: clock,
maxErrors: maxErrors,
currErrorIndex: -1,
}
if maxErrors >= 1 {
rs.errors = make([]ReportedError, maxErrors)
}
return rs
} | [
"func",
"NewReporterSimple",
"(",
"clock",
"Clock",
",",
"maxErrors",
"int",
")",
"*",
"ReporterSimple",
"{",
"rs",
":=",
"&",
"ReporterSimple",
"{",
"clock",
":",
"clock",
",",
"maxErrors",
":",
"maxErrors",
",",
"currErrorIndex",
":",
"-",
"1",
",",
"}",
"\n\n",
"if",
"maxErrors",
">=",
"1",
"{",
"rs",
".",
"errors",
"=",
"make",
"(",
"[",
"]",
"ReportedError",
",",
"maxErrors",
")",
"\n",
"}",
"\n\n",
"return",
"rs",
"\n",
"}"
] | // NewReporterSimple creates a new ReporterSimple. | [
"NewReporterSimple",
"creates",
"a",
"new",
"ReporterSimple",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/reporter_simple.go#L30-L42 |
159,673 | keybase/client | go/kbfs/libkbfs/reporter_simple.go | ReportErr | func (r *ReporterSimple) ReportErr(ctx context.Context,
_ tlf.CanonicalName, _ tlf.Type, _ ErrorModeType, err error) {
r.lock.Lock()
defer r.lock.Unlock()
stack := make([]uintptr, 20)
n := runtime.Callers(2, stack)
re := ReportedError{
Time: r.clock.Now(),
Error: err,
Stack: stack[:n],
}
r.currErrorIndex++
if r.maxErrors < 1 {
r.errors = append(r.errors, re)
} else {
if r.currErrorIndex == r.maxErrors {
r.currErrorIndex = 0
r.filledOnce = true
}
r.errors[r.currErrorIndex] = re
}
} | go | func (r *ReporterSimple) ReportErr(ctx context.Context,
_ tlf.CanonicalName, _ tlf.Type, _ ErrorModeType, err error) {
r.lock.Lock()
defer r.lock.Unlock()
stack := make([]uintptr, 20)
n := runtime.Callers(2, stack)
re := ReportedError{
Time: r.clock.Now(),
Error: err,
Stack: stack[:n],
}
r.currErrorIndex++
if r.maxErrors < 1 {
r.errors = append(r.errors, re)
} else {
if r.currErrorIndex == r.maxErrors {
r.currErrorIndex = 0
r.filledOnce = true
}
r.errors[r.currErrorIndex] = re
}
} | [
"func",
"(",
"r",
"*",
"ReporterSimple",
")",
"ReportErr",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"tlf",
".",
"CanonicalName",
",",
"_",
"tlf",
".",
"Type",
",",
"_",
"ErrorModeType",
",",
"err",
"error",
")",
"{",
"r",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"stack",
":=",
"make",
"(",
"[",
"]",
"uintptr",
",",
"20",
")",
"\n",
"n",
":=",
"runtime",
".",
"Callers",
"(",
"2",
",",
"stack",
")",
"\n",
"re",
":=",
"ReportedError",
"{",
"Time",
":",
"r",
".",
"clock",
".",
"Now",
"(",
")",
",",
"Error",
":",
"err",
",",
"Stack",
":",
"stack",
"[",
":",
"n",
"]",
",",
"}",
"\n",
"r",
".",
"currErrorIndex",
"++",
"\n",
"if",
"r",
".",
"maxErrors",
"<",
"1",
"{",
"r",
".",
"errors",
"=",
"append",
"(",
"r",
".",
"errors",
",",
"re",
")",
"\n",
"}",
"else",
"{",
"if",
"r",
".",
"currErrorIndex",
"==",
"r",
".",
"maxErrors",
"{",
"r",
".",
"currErrorIndex",
"=",
"0",
"\n",
"r",
".",
"filledOnce",
"=",
"true",
"\n",
"}",
"\n",
"r",
".",
"errors",
"[",
"r",
".",
"currErrorIndex",
"]",
"=",
"re",
"\n",
"}",
"\n\n",
"}"
] | // ReportErr implements the Reporter interface for ReporterSimple. | [
"ReportErr",
"implements",
"the",
"Reporter",
"interface",
"for",
"ReporterSimple",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/reporter_simple.go#L45-L68 |
159,674 | keybase/client | go/kbfs/libkbfs/reporter_simple.go | AllKnownErrors | func (r *ReporterSimple) AllKnownErrors() []ReportedError {
r.lock.RLock()
defer r.lock.RUnlock()
if !r.filledOnce {
// deep copy since r.errors shouldn't be read without the lock.
errors := make([]ReportedError, r.currErrorIndex+1)
copy(errors, r.errors[:r.currErrorIndex+1])
return errors
}
errors := make([]ReportedError, r.maxErrors)
s := r.currErrorIndex + 1
t := r.maxErrors - s
copy(errors[:t], r.errors[s:])
copy(errors[t:], r.errors[:s])
return errors
} | go | func (r *ReporterSimple) AllKnownErrors() []ReportedError {
r.lock.RLock()
defer r.lock.RUnlock()
if !r.filledOnce {
// deep copy since r.errors shouldn't be read without the lock.
errors := make([]ReportedError, r.currErrorIndex+1)
copy(errors, r.errors[:r.currErrorIndex+1])
return errors
}
errors := make([]ReportedError, r.maxErrors)
s := r.currErrorIndex + 1
t := r.maxErrors - s
copy(errors[:t], r.errors[s:])
copy(errors[t:], r.errors[:s])
return errors
} | [
"func",
"(",
"r",
"*",
"ReporterSimple",
")",
"AllKnownErrors",
"(",
")",
"[",
"]",
"ReportedError",
"{",
"r",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"r",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"!",
"r",
".",
"filledOnce",
"{",
"// deep copy since r.errors shouldn't be read without the lock.",
"errors",
":=",
"make",
"(",
"[",
"]",
"ReportedError",
",",
"r",
".",
"currErrorIndex",
"+",
"1",
")",
"\n",
"copy",
"(",
"errors",
",",
"r",
".",
"errors",
"[",
":",
"r",
".",
"currErrorIndex",
"+",
"1",
"]",
")",
"\n",
"return",
"errors",
"\n",
"}",
"\n\n",
"errors",
":=",
"make",
"(",
"[",
"]",
"ReportedError",
",",
"r",
".",
"maxErrors",
")",
"\n",
"s",
":=",
"r",
".",
"currErrorIndex",
"+",
"1",
"\n",
"t",
":=",
"r",
".",
"maxErrors",
"-",
"s",
"\n",
"copy",
"(",
"errors",
"[",
":",
"t",
"]",
",",
"r",
".",
"errors",
"[",
"s",
":",
"]",
")",
"\n",
"copy",
"(",
"errors",
"[",
"t",
":",
"]",
",",
"r",
".",
"errors",
"[",
":",
"s",
"]",
")",
"\n",
"return",
"errors",
"\n",
"}"
] | // AllKnownErrors implements the Reporter interface for ReporterSimple. | [
"AllKnownErrors",
"implements",
"the",
"Reporter",
"interface",
"for",
"ReporterSimple",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/reporter_simple.go#L71-L88 |
159,675 | keybase/client | go/engine/device_wrap.go | NewDeviceWrap | func NewDeviceWrap(g *libkb.GlobalContext, args *DeviceWrapArgs) *DeviceWrap {
return &DeviceWrap{
args: args,
Contextified: libkb.NewContextified(g),
}
} | go | func NewDeviceWrap(g *libkb.GlobalContext, args *DeviceWrapArgs) *DeviceWrap {
return &DeviceWrap{
args: args,
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewDeviceWrap",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"args",
"*",
"DeviceWrapArgs",
")",
"*",
"DeviceWrap",
"{",
"return",
"&",
"DeviceWrap",
"{",
"args",
":",
"args",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"}"
] | // NewDeviceWrap creates a DeviceWrap engine. | [
"NewDeviceWrap",
"creates",
"a",
"DeviceWrap",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/device_wrap.go#L37-L42 |
159,676 | keybase/client | go/engine/device_wrap.go | SwitchConfigAndActiveDevice | func (e *DeviceWrap) SwitchConfigAndActiveDevice(m libkb.MetaContext) (err error) {
defer m.Trace("DeviceWrap#SetActiveDevice", func() error { return err })()
if err = e.refreshMe(m); err != nil {
return err
}
salt, err := e.args.Me.GetSalt()
if err != nil {
return err
}
me := e.args.Me
// Atomically swap to the new config and active device
if err := m.SwitchUserNewConfigActiveDevice(me.ToUserVersion(), me.GetNormalizedName(), salt,
e.deviceID, e.signingKey, e.encryptionKey, e.args.DeviceName); err != nil {
return err
}
// Sync down secrets for future offline login attempts to work.
// This will largely just download what we just uploaded, but it's
// easy to do this way.
_, w := m.ActiveDevice().SyncSecrets(m)
if w != nil {
m.Warning("Error sync secrets: %s", w.Error())
}
return nil
} | go | func (e *DeviceWrap) SwitchConfigAndActiveDevice(m libkb.MetaContext) (err error) {
defer m.Trace("DeviceWrap#SetActiveDevice", func() error { return err })()
if err = e.refreshMe(m); err != nil {
return err
}
salt, err := e.args.Me.GetSalt()
if err != nil {
return err
}
me := e.args.Me
// Atomically swap to the new config and active device
if err := m.SwitchUserNewConfigActiveDevice(me.ToUserVersion(), me.GetNormalizedName(), salt,
e.deviceID, e.signingKey, e.encryptionKey, e.args.DeviceName); err != nil {
return err
}
// Sync down secrets for future offline login attempts to work.
// This will largely just download what we just uploaded, but it's
// easy to do this way.
_, w := m.ActiveDevice().SyncSecrets(m)
if w != nil {
m.Warning("Error sync secrets: %s", w.Error())
}
return nil
} | [
"func",
"(",
"e",
"*",
"DeviceWrap",
")",
"SwitchConfigAndActiveDevice",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"if",
"err",
"=",
"e",
".",
"refreshMe",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"salt",
",",
"err",
":=",
"e",
".",
"args",
".",
"Me",
".",
"GetSalt",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"me",
":=",
"e",
".",
"args",
".",
"Me",
"\n",
"// Atomically swap to the new config and active device",
"if",
"err",
":=",
"m",
".",
"SwitchUserNewConfigActiveDevice",
"(",
"me",
".",
"ToUserVersion",
"(",
")",
",",
"me",
".",
"GetNormalizedName",
"(",
")",
",",
"salt",
",",
"e",
".",
"deviceID",
",",
"e",
".",
"signingKey",
",",
"e",
".",
"encryptionKey",
",",
"e",
".",
"args",
".",
"DeviceName",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Sync down secrets for future offline login attempts to work.",
"// This will largely just download what we just uploaded, but it's",
"// easy to do this way.",
"_",
",",
"w",
":=",
"m",
".",
"ActiveDevice",
"(",
")",
".",
"SyncSecrets",
"(",
"m",
")",
"\n",
"if",
"w",
"!=",
"nil",
"{",
"m",
".",
"Warning",
"(",
"\"",
"\"",
",",
"w",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // SwitchConfigAndActiveDevice changes active device to the one
// generated by DeviceWrap. It switches UserConfig and sets global
// ActiveDevice. | [
"SwitchConfigAndActiveDevice",
"changes",
"active",
"device",
"to",
"the",
"one",
"generated",
"by",
"DeviceWrap",
".",
"It",
"switches",
"UserConfig",
"and",
"sets",
"global",
"ActiveDevice",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/device_wrap.go#L128-L154 |
159,677 | keybase/client | go/kbfs/libfuse/profilelist.go | Remove | func (ProfileList) Remove(_ context.Context, req *fuse.RemoveRequest) (err error) {
return fuse.EPERM
} | go | func (ProfileList) Remove(_ context.Context, req *fuse.RemoveRequest) (err error) {
return fuse.EPERM
} | [
"func",
"(",
"ProfileList",
")",
"Remove",
"(",
"_",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"RemoveRequest",
")",
"(",
"err",
"error",
")",
"{",
"return",
"fuse",
".",
"EPERM",
"\n",
"}"
] | // Remove implements the fs.NodeRemover interface for ProfileList. | [
"Remove",
"implements",
"the",
"fs",
".",
"NodeRemover",
"interface",
"for",
"ProfileList",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/profilelist.go#L178-L180 |
159,678 | keybase/client | go/libkb/sync_secret.go | FindActiveKey | func (ss *SecretSyncer) FindActiveKey(ckf *ComputedKeyFamily) (ret *SKB, err error) {
ss.Lock()
defer ss.Unlock()
if ss.keys == nil {
return nil, nil
}
for _, key := range ss.keys.PrivateKeys {
if ret, _ = key.FindActiveKey(ss.G(), ckf); ret != nil {
return
}
}
return
} | go | func (ss *SecretSyncer) FindActiveKey(ckf *ComputedKeyFamily) (ret *SKB, err error) {
ss.Lock()
defer ss.Unlock()
if ss.keys == nil {
return nil, nil
}
for _, key := range ss.keys.PrivateKeys {
if ret, _ = key.FindActiveKey(ss.G(), ckf); ret != nil {
return
}
}
return
} | [
"func",
"(",
"ss",
"*",
"SecretSyncer",
")",
"FindActiveKey",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"(",
"ret",
"*",
"SKB",
",",
"err",
"error",
")",
"{",
"ss",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ss",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"ss",
".",
"keys",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"ss",
".",
"keys",
".",
"PrivateKeys",
"{",
"if",
"ret",
",",
"_",
"=",
"key",
".",
"FindActiveKey",
"(",
"ss",
".",
"G",
"(",
")",
",",
"ckf",
")",
";",
"ret",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // FindActiveKey examines the synced keys, looking for one that's currently active.
// Returns ret=nil if none was found. | [
"FindActiveKey",
"examines",
"the",
"synced",
"keys",
"looking",
"for",
"one",
"that",
"s",
"currently",
"active",
".",
"Returns",
"ret",
"=",
"nil",
"if",
"none",
"was",
"found",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sync_secret.go#L175-L188 |
159,679 | keybase/client | go/libkb/sync_secret.go | AllActiveKeys | func (ss *SecretSyncer) AllActiveKeys(ckf *ComputedKeyFamily) []*SKB {
ss.Lock()
defer ss.Unlock()
var res []*SKB
for _, key := range ss.keys.PrivateKeys {
if ret, _ := key.FindActiveKey(ss.G(), ckf); ret != nil {
res = append(res, ret)
}
}
return res
} | go | func (ss *SecretSyncer) AllActiveKeys(ckf *ComputedKeyFamily) []*SKB {
ss.Lock()
defer ss.Unlock()
var res []*SKB
for _, key := range ss.keys.PrivateKeys {
if ret, _ := key.FindActiveKey(ss.G(), ckf); ret != nil {
res = append(res, ret)
}
}
return res
} | [
"func",
"(",
"ss",
"*",
"SecretSyncer",
")",
"AllActiveKeys",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"[",
"]",
"*",
"SKB",
"{",
"ss",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ss",
".",
"Unlock",
"(",
")",
"\n",
"var",
"res",
"[",
"]",
"*",
"SKB",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"ss",
".",
"keys",
".",
"PrivateKeys",
"{",
"if",
"ret",
",",
"_",
":=",
"key",
".",
"FindActiveKey",
"(",
"ss",
".",
"G",
"(",
")",
",",
"ckf",
")",
";",
"ret",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"ret",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] | // AllActiveKeys returns all the active synced PGP keys. | [
"AllActiveKeys",
"returns",
"all",
"the",
"active",
"synced",
"PGP",
"keys",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sync_secret.go#L191-L201 |
159,680 | keybase/client | go/libkb/sync_secret.go | IsDeviceNameTaken | func (ss *SecretSyncer) IsDeviceNameTaken(name string, includeTypesSet DeviceTypeSet) bool {
devs, err := ss.ActiveDevices(includeTypesSet)
if err != nil {
return false
}
for _, v := range devs {
if NameCmp(v.Description, name) {
return true
}
}
return false
} | go | func (ss *SecretSyncer) IsDeviceNameTaken(name string, includeTypesSet DeviceTypeSet) bool {
devs, err := ss.ActiveDevices(includeTypesSet)
if err != nil {
return false
}
for _, v := range devs {
if NameCmp(v.Description, name) {
return true
}
}
return false
} | [
"func",
"(",
"ss",
"*",
"SecretSyncer",
")",
"IsDeviceNameTaken",
"(",
"name",
"string",
",",
"includeTypesSet",
"DeviceTypeSet",
")",
"bool",
"{",
"devs",
",",
"err",
":=",
"ss",
".",
"ActiveDevices",
"(",
"includeTypesSet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"devs",
"{",
"if",
"NameCmp",
"(",
"v",
".",
"Description",
",",
"name",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsDeviceNameTaken returns true if a desktop or mobile device is
// using a name already. | [
"IsDeviceNameTaken",
"returns",
"true",
"if",
"a",
"desktop",
"or",
"mobile",
"device",
"is",
"using",
"a",
"name",
"already",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sync_secret.go#L275-L286 |
159,681 | keybase/client | go/libkb/sync_secret.go | HasActiveDevice | func (ss *SecretSyncer) HasActiveDevice(includeTypesSet DeviceTypeSet) (bool, error) {
devs, err := ss.ActiveDevices(includeTypesSet)
if err != nil {
return false, err
}
return len(devs) > 0, nil
} | go | func (ss *SecretSyncer) HasActiveDevice(includeTypesSet DeviceTypeSet) (bool, error) {
devs, err := ss.ActiveDevices(includeTypesSet)
if err != nil {
return false, err
}
return len(devs) > 0, nil
} | [
"func",
"(",
"ss",
"*",
"SecretSyncer",
")",
"HasActiveDevice",
"(",
"includeTypesSet",
"DeviceTypeSet",
")",
"(",
"bool",
",",
"error",
")",
"{",
"devs",
",",
"err",
":=",
"ss",
".",
"ActiveDevices",
"(",
"includeTypesSet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"len",
"(",
"devs",
")",
">",
"0",
",",
"nil",
"\n",
"}"
] | // HasActiveDevice returns true if there is an active desktop or
// mobile device available. | [
"HasActiveDevice",
"returns",
"true",
"if",
"there",
"is",
"an",
"active",
"desktop",
"or",
"mobile",
"device",
"available",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sync_secret.go#L290-L296 |
159,682 | keybase/client | go/libkb/sync_secret.go | ActiveDevices | func (ss *SecretSyncer) ActiveDevices(includeTypesSet DeviceTypeSet) (DeviceKeyMap, error) {
ss.Lock()
defer ss.Unlock()
if ss.keys == nil {
return nil, fmt.Errorf("no keys")
}
if includeTypesSet == nil {
return nil, fmt.Errorf("need valid includeTypesSet")
}
res := make(DeviceKeyMap)
for k, v := range ss.keys.Devices {
if v.Status != DeviceStatusActive {
continue
}
if includeTypesSet[v.Type] {
res[k] = v
}
}
return res, nil
} | go | func (ss *SecretSyncer) ActiveDevices(includeTypesSet DeviceTypeSet) (DeviceKeyMap, error) {
ss.Lock()
defer ss.Unlock()
if ss.keys == nil {
return nil, fmt.Errorf("no keys")
}
if includeTypesSet == nil {
return nil, fmt.Errorf("need valid includeTypesSet")
}
res := make(DeviceKeyMap)
for k, v := range ss.keys.Devices {
if v.Status != DeviceStatusActive {
continue
}
if includeTypesSet[v.Type] {
res[k] = v
}
}
return res, nil
} | [
"func",
"(",
"ss",
"*",
"SecretSyncer",
")",
"ActiveDevices",
"(",
"includeTypesSet",
"DeviceTypeSet",
")",
"(",
"DeviceKeyMap",
",",
"error",
")",
"{",
"ss",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ss",
".",
"Unlock",
"(",
")",
"\n",
"if",
"ss",
".",
"keys",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"includeTypesSet",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"res",
":=",
"make",
"(",
"DeviceKeyMap",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"ss",
".",
"keys",
".",
"Devices",
"{",
"if",
"v",
".",
"Status",
"!=",
"DeviceStatusActive",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"includeTypesSet",
"[",
"v",
".",
"Type",
"]",
"{",
"res",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] | // ActiveDevices returns all the active desktop and mobile devices. | [
"ActiveDevices",
"returns",
"all",
"the",
"active",
"desktop",
"and",
"mobile",
"devices",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sync_secret.go#L299-L321 |
159,683 | keybase/client | go/libkb/sync_secret.go | cachedSyncedSecretsOutOfDate | func (ss *SecretSyncer) cachedSyncedSecretsOutOfDate(cached *ServerPrivateKeys) bool {
for _, dev := range cached.Devices {
if dev.LastUsedTime == 0 {
ss.G().Log.Debug("cachedSyncedSecretsOutOfDate noticed a cached device with no last used time")
return true
}
}
return false
} | go | func (ss *SecretSyncer) cachedSyncedSecretsOutOfDate(cached *ServerPrivateKeys) bool {
for _, dev := range cached.Devices {
if dev.LastUsedTime == 0 {
ss.G().Log.Debug("cachedSyncedSecretsOutOfDate noticed a cached device with no last used time")
return true
}
}
return false
} | [
"func",
"(",
"ss",
"*",
"SecretSyncer",
")",
"cachedSyncedSecretsOutOfDate",
"(",
"cached",
"*",
"ServerPrivateKeys",
")",
"bool",
"{",
"for",
"_",
",",
"dev",
":=",
"range",
"cached",
".",
"Devices",
"{",
"if",
"dev",
".",
"LastUsedTime",
"==",
"0",
"{",
"ss",
".",
"G",
"(",
")",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // As we add more fields to the data we're caching here, we need to detect the
// cases where our cached data is missing the new fields. We can extend this
// function with more cases as we add more fields. | [
"As",
"we",
"add",
"more",
"fields",
"to",
"the",
"data",
"we",
"re",
"caching",
"here",
"we",
"need",
"to",
"detect",
"the",
"cases",
"where",
"our",
"cached",
"data",
"is",
"missing",
"the",
"new",
"fields",
".",
"We",
"can",
"extend",
"this",
"function",
"with",
"more",
"cases",
"as",
"we",
"add",
"more",
"fields",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/sync_secret.go#L335-L343 |
159,684 | keybase/client | go/kbfs/libkbfs/connection_status.go | Init | func (kcs *kbfsCurrentStatus) Init() {
kcs.failingServices = map[string]error{}
kcs.invalidateChan = make(chan StatusUpdate)
} | go | func (kcs *kbfsCurrentStatus) Init() {
kcs.failingServices = map[string]error{}
kcs.invalidateChan = make(chan StatusUpdate)
} | [
"func",
"(",
"kcs",
"*",
"kbfsCurrentStatus",
")",
"Init",
"(",
")",
"{",
"kcs",
".",
"failingServices",
"=",
"map",
"[",
"string",
"]",
"error",
"{",
"}",
"\n",
"kcs",
".",
"invalidateChan",
"=",
"make",
"(",
"chan",
"StatusUpdate",
")",
"\n",
"}"
] | // Init inits the kbfsCurrentStatus. | [
"Init",
"inits",
"the",
"kbfsCurrentStatus",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/connection_status.go#L31-L34 |
159,685 | keybase/client | go/kbfs/libkbfs/connection_status.go | CurrentStatus | func (kcs *kbfsCurrentStatus) CurrentStatus() (map[string]error, chan StatusUpdate) {
kcs.lock.Lock()
defer kcs.lock.Unlock()
res := map[string]error{}
for k, v := range kcs.failingServices {
res[k] = v
}
return res, kcs.invalidateChan
} | go | func (kcs *kbfsCurrentStatus) CurrentStatus() (map[string]error, chan StatusUpdate) {
kcs.lock.Lock()
defer kcs.lock.Unlock()
res := map[string]error{}
for k, v := range kcs.failingServices {
res[k] = v
}
return res, kcs.invalidateChan
} | [
"func",
"(",
"kcs",
"*",
"kbfsCurrentStatus",
")",
"CurrentStatus",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"error",
",",
"chan",
"StatusUpdate",
")",
"{",
"kcs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"kcs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"res",
":=",
"map",
"[",
"string",
"]",
"error",
"{",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"kcs",
".",
"failingServices",
"{",
"res",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"res",
",",
"kcs",
".",
"invalidateChan",
"\n",
"}"
] | // CurrentStatus returns a copy of the current status. | [
"CurrentStatus",
"returns",
"a",
"copy",
"of",
"the",
"current",
"status",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/connection_status.go#L37-L46 |
159,686 | keybase/client | go/kbfs/libkbfs/connection_status.go | PushConnectionStatusChange | func (kcs *kbfsCurrentStatus) PushConnectionStatusChange(service string, err error) {
kcs.lock.Lock()
defer kcs.lock.Unlock()
if err != nil {
// Exit early if the service is already failed, to avoid an
// invalidation.
_, errExisted := kcs.failingServices[service]
kcs.failingServices[service] = err
if errExisted {
return
}
} else {
// Potentially exit early if nothing changes.
_, exist := kcs.failingServices[service]
if !exist {
return
}
delete(kcs.failingServices, service)
}
close(kcs.invalidateChan)
kcs.invalidateChan = make(chan StatusUpdate)
} | go | func (kcs *kbfsCurrentStatus) PushConnectionStatusChange(service string, err error) {
kcs.lock.Lock()
defer kcs.lock.Unlock()
if err != nil {
// Exit early if the service is already failed, to avoid an
// invalidation.
_, errExisted := kcs.failingServices[service]
kcs.failingServices[service] = err
if errExisted {
return
}
} else {
// Potentially exit early if nothing changes.
_, exist := kcs.failingServices[service]
if !exist {
return
}
delete(kcs.failingServices, service)
}
close(kcs.invalidateChan)
kcs.invalidateChan = make(chan StatusUpdate)
} | [
"func",
"(",
"kcs",
"*",
"kbfsCurrentStatus",
")",
"PushConnectionStatusChange",
"(",
"service",
"string",
",",
"err",
"error",
")",
"{",
"kcs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"kcs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"// Exit early if the service is already failed, to avoid an",
"// invalidation.",
"_",
",",
"errExisted",
":=",
"kcs",
".",
"failingServices",
"[",
"service",
"]",
"\n",
"kcs",
".",
"failingServices",
"[",
"service",
"]",
"=",
"err",
"\n",
"if",
"errExisted",
"{",
"return",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// Potentially exit early if nothing changes.",
"_",
",",
"exist",
":=",
"kcs",
".",
"failingServices",
"[",
"service",
"]",
"\n",
"if",
"!",
"exist",
"{",
"return",
"\n",
"}",
"\n",
"delete",
"(",
"kcs",
".",
"failingServices",
",",
"service",
")",
"\n",
"}",
"\n\n",
"close",
"(",
"kcs",
".",
"invalidateChan",
")",
"\n",
"kcs",
".",
"invalidateChan",
"=",
"make",
"(",
"chan",
"StatusUpdate",
")",
"\n",
"}"
] | // PushConnectionStatusChange pushes a change to the connection status of one of the services. | [
"PushConnectionStatusChange",
"pushes",
"a",
"change",
"to",
"the",
"connection",
"status",
"of",
"one",
"of",
"the",
"services",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/connection_status.go#L49-L72 |
159,687 | keybase/client | go/engine/prove.go | NewProve | func NewProve(g *libkb.GlobalContext, arg *keybase1.StartProofArg) *Prove {
if arg.SigVersion == nil || libkb.SigVersion(*arg.SigVersion) == libkb.KeybaseNullSigVersion {
tmp := keybase1.SigVersion(libkb.GetDefaultSigVersion(g))
arg.SigVersion = &tmp
}
return &Prove{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | go | func NewProve(g *libkb.GlobalContext, arg *keybase1.StartProofArg) *Prove {
if arg.SigVersion == nil || libkb.SigVersion(*arg.SigVersion) == libkb.KeybaseNullSigVersion {
tmp := keybase1.SigVersion(libkb.GetDefaultSigVersion(g))
arg.SigVersion = &tmp
}
return &Prove{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewProve",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"arg",
"*",
"keybase1",
".",
"StartProofArg",
")",
"*",
"Prove",
"{",
"if",
"arg",
".",
"SigVersion",
"==",
"nil",
"||",
"libkb",
".",
"SigVersion",
"(",
"*",
"arg",
".",
"SigVersion",
")",
"==",
"libkb",
".",
"KeybaseNullSigVersion",
"{",
"tmp",
":=",
"keybase1",
".",
"SigVersion",
"(",
"libkb",
".",
"GetDefaultSigVersion",
"(",
"g",
")",
")",
"\n",
"arg",
".",
"SigVersion",
"=",
"&",
"tmp",
"\n",
"}",
"\n",
"return",
"&",
"Prove",
"{",
"arg",
":",
"arg",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"}"
] | // NewProve makes a new Prove Engine given an RPC-friendly ProveArg. | [
"NewProve",
"makes",
"a",
"new",
"Prove",
"Engine",
"given",
"an",
"RPC",
"-",
"friendly",
"ProveArg",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/prove.go#L39-L48 |
159,688 | keybase/client | go/engine/prove.go | promptPostedLoop | func (p *Prove) promptPostedLoop(m libkb.MetaContext) (err error) {
found := false
for i := 0; ; i++ {
var retry bool
var status keybase1.ProofStatus
var warn *libkb.Markup
retry, err = m.UIs().ProveUI.OkToCheck(m.Ctx(), keybase1.OkToCheckArg{
Name: p.serviceType.DisplayName(),
Attempt: i,
})
if !retry || err != nil {
break
}
found, status, _, err = libkb.CheckPosted(m, p.sigID)
if found || err != nil {
break
}
warn, err = p.serviceType.RecheckProofPosting(i, status, p.remoteNameNormalized)
if warn != nil {
uierr := m.UIs().ProveUI.DisplayRecheckWarning(m.Ctx(), keybase1.DisplayRecheckWarningArg{
Text: warn.Export(),
})
if uierr != nil {
m.Warning("prove ui DisplayRecheckWarning call error: %s", uierr)
}
}
if err != nil {
break
}
}
if !found && err == nil {
err = libkb.ProofNotYetAvailableError{}
}
return err
} | go | func (p *Prove) promptPostedLoop(m libkb.MetaContext) (err error) {
found := false
for i := 0; ; i++ {
var retry bool
var status keybase1.ProofStatus
var warn *libkb.Markup
retry, err = m.UIs().ProveUI.OkToCheck(m.Ctx(), keybase1.OkToCheckArg{
Name: p.serviceType.DisplayName(),
Attempt: i,
})
if !retry || err != nil {
break
}
found, status, _, err = libkb.CheckPosted(m, p.sigID)
if found || err != nil {
break
}
warn, err = p.serviceType.RecheckProofPosting(i, status, p.remoteNameNormalized)
if warn != nil {
uierr := m.UIs().ProveUI.DisplayRecheckWarning(m.Ctx(), keybase1.DisplayRecheckWarningArg{
Text: warn.Export(),
})
if uierr != nil {
m.Warning("prove ui DisplayRecheckWarning call error: %s", uierr)
}
}
if err != nil {
break
}
}
if !found && err == nil {
err = libkb.ProofNotYetAvailableError{}
}
return err
} | [
"func",
"(",
"p",
"*",
"Prove",
")",
"promptPostedLoop",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"err",
"error",
")",
"{",
"found",
":=",
"false",
"\n",
"for",
"i",
":=",
"0",
";",
";",
"i",
"++",
"{",
"var",
"retry",
"bool",
"\n",
"var",
"status",
"keybase1",
".",
"ProofStatus",
"\n",
"var",
"warn",
"*",
"libkb",
".",
"Markup",
"\n",
"retry",
",",
"err",
"=",
"m",
".",
"UIs",
"(",
")",
".",
"ProveUI",
".",
"OkToCheck",
"(",
"m",
".",
"Ctx",
"(",
")",
",",
"keybase1",
".",
"OkToCheckArg",
"{",
"Name",
":",
"p",
".",
"serviceType",
".",
"DisplayName",
"(",
")",
",",
"Attempt",
":",
"i",
",",
"}",
")",
"\n",
"if",
"!",
"retry",
"||",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"found",
",",
"status",
",",
"_",
",",
"err",
"=",
"libkb",
".",
"CheckPosted",
"(",
"m",
",",
"p",
".",
"sigID",
")",
"\n",
"if",
"found",
"||",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"warn",
",",
"err",
"=",
"p",
".",
"serviceType",
".",
"RecheckProofPosting",
"(",
"i",
",",
"status",
",",
"p",
".",
"remoteNameNormalized",
")",
"\n",
"if",
"warn",
"!=",
"nil",
"{",
"uierr",
":=",
"m",
".",
"UIs",
"(",
")",
".",
"ProveUI",
".",
"DisplayRecheckWarning",
"(",
"m",
".",
"Ctx",
"(",
")",
",",
"keybase1",
".",
"DisplayRecheckWarningArg",
"{",
"Text",
":",
"warn",
".",
"Export",
"(",
")",
",",
"}",
")",
"\n",
"if",
"uierr",
"!=",
"nil",
"{",
"m",
".",
"Warning",
"(",
"\"",
"\"",
",",
"uierr",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"found",
"&&",
"err",
"==",
"nil",
"{",
"err",
"=",
"libkb",
".",
"ProofNotYetAvailableError",
"{",
"}",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] | // Keep asking the user whether they posted the proof
// until it works or they give up. | [
"Keep",
"asking",
"the",
"user",
"whether",
"they",
"posted",
"the",
"proof",
"until",
"it",
"works",
"or",
"they",
"give",
"up",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/prove.go#L292-L327 |
159,689 | keybase/client | go/engine/prove.go | verifyLoop | func (p *Prove) verifyLoop(m libkb.MetaContext) (err error) {
timeout := time.Hour
m, cancel := m.WithTimeout(timeout)
defer cancel()
uierr := m.UIs().ProveUI.Checking(m.Ctx(), keybase1.CheckingArg{
Name: p.serviceType.DisplayName(),
})
if uierr != nil {
m.Warning("prove ui Checking call error: %s", uierr)
}
for i := 0; ; i++ {
if shouldContinue, uierr := m.UIs().ProveUI.ContinueChecking(m.Ctx(), 0); !shouldContinue || uierr != nil {
if uierr != nil {
m.Warning("prove ui ContinueChecking call error: %s", uierr)
}
return libkb.CanceledError{}
}
found, status, _, err := libkb.CheckPosted(m, p.sigID)
if err != nil {
return err
}
m.Debug("Prove.verifyLoop round:%v found:%v status:%v", i, found, status)
if found {
return nil
}
wakeAt := m.G().Clock().Now().Add(2 * time.Second)
err = libkb.SleepUntilWithContext(m.Ctx(), m.G().Clock(), wakeAt)
if err != nil {
if err == context.DeadlineExceeded {
return fmt.Errorf("Timed out looking a proof after %v", timeout)
}
return err
}
}
} | go | func (p *Prove) verifyLoop(m libkb.MetaContext) (err error) {
timeout := time.Hour
m, cancel := m.WithTimeout(timeout)
defer cancel()
uierr := m.UIs().ProveUI.Checking(m.Ctx(), keybase1.CheckingArg{
Name: p.serviceType.DisplayName(),
})
if uierr != nil {
m.Warning("prove ui Checking call error: %s", uierr)
}
for i := 0; ; i++ {
if shouldContinue, uierr := m.UIs().ProveUI.ContinueChecking(m.Ctx(), 0); !shouldContinue || uierr != nil {
if uierr != nil {
m.Warning("prove ui ContinueChecking call error: %s", uierr)
}
return libkb.CanceledError{}
}
found, status, _, err := libkb.CheckPosted(m, p.sigID)
if err != nil {
return err
}
m.Debug("Prove.verifyLoop round:%v found:%v status:%v", i, found, status)
if found {
return nil
}
wakeAt := m.G().Clock().Now().Add(2 * time.Second)
err = libkb.SleepUntilWithContext(m.Ctx(), m.G().Clock(), wakeAt)
if err != nil {
if err == context.DeadlineExceeded {
return fmt.Errorf("Timed out looking a proof after %v", timeout)
}
return err
}
}
} | [
"func",
"(",
"p",
"*",
"Prove",
")",
"verifyLoop",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"err",
"error",
")",
"{",
"timeout",
":=",
"time",
".",
"Hour",
"\n",
"m",
",",
"cancel",
":=",
"m",
".",
"WithTimeout",
"(",
"timeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"uierr",
":=",
"m",
".",
"UIs",
"(",
")",
".",
"ProveUI",
".",
"Checking",
"(",
"m",
".",
"Ctx",
"(",
")",
",",
"keybase1",
".",
"CheckingArg",
"{",
"Name",
":",
"p",
".",
"serviceType",
".",
"DisplayName",
"(",
")",
",",
"}",
")",
"\n",
"if",
"uierr",
"!=",
"nil",
"{",
"m",
".",
"Warning",
"(",
"\"",
"\"",
",",
"uierr",
")",
"\n",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
";",
"i",
"++",
"{",
"if",
"shouldContinue",
",",
"uierr",
":=",
"m",
".",
"UIs",
"(",
")",
".",
"ProveUI",
".",
"ContinueChecking",
"(",
"m",
".",
"Ctx",
"(",
")",
",",
"0",
")",
";",
"!",
"shouldContinue",
"||",
"uierr",
"!=",
"nil",
"{",
"if",
"uierr",
"!=",
"nil",
"{",
"m",
".",
"Warning",
"(",
"\"",
"\"",
",",
"uierr",
")",
"\n",
"}",
"\n",
"return",
"libkb",
".",
"CanceledError",
"{",
"}",
"\n",
"}",
"\n",
"found",
",",
"status",
",",
"_",
",",
"err",
":=",
"libkb",
".",
"CheckPosted",
"(",
"m",
",",
"p",
".",
"sigID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"i",
",",
"found",
",",
"status",
")",
"\n",
"if",
"found",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"wakeAt",
":=",
"m",
".",
"G",
"(",
")",
".",
"Clock",
"(",
")",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"2",
"*",
"time",
".",
"Second",
")",
"\n",
"err",
"=",
"libkb",
".",
"SleepUntilWithContext",
"(",
"m",
".",
"Ctx",
"(",
")",
",",
"m",
".",
"G",
"(",
")",
".",
"Clock",
"(",
")",
",",
"wakeAt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"context",
".",
"DeadlineExceeded",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"timeout",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // Poll until the proof succeeds, limited to an hour. | [
"Poll",
"until",
"the",
"proof",
"succeeds",
"limited",
"to",
"an",
"hour",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/prove.go#L330-L364 |
159,690 | keybase/client | go/engine/prove.go | Run | func (p *Prove) Run(m libkb.MetaContext) (err error) {
defer m.Trace("ProofEngine.Run", func() error { return err })()
stage := func(s string) {
m.Debug("| ProofEngine.Run() %s", s)
}
stage("GetServiceType")
if err = p.getServiceType(m); err != nil {
return err
}
stage("LoadMe")
if err = p.loadMe(m); err != nil {
return err
}
stage("CheckExists1")
if err = p.checkExists1(m); err != nil {
return err
}
stage("PromptRemoteName")
if err = p.promptRemoteName(m); err != nil {
return err
}
stage("CheckExists2")
if err = p.checkExists2(m); err != nil {
return err
}
stage("DoPrechecks")
if err = p.doPrechecks(m); err != nil {
return err
}
stage("DoWarnings")
if err = p.doWarnings(m); err != nil {
return err
}
m.G().LocalSigchainGuard().Set(m.Ctx(), "Prove")
defer m.G().LocalSigchainGuard().Clear(m.Ctx(), "Prove")
stage("GenerateProof")
if err = p.generateProof(m); err != nil {
return err
}
stage("PostProofToServer")
if err = p.postProofToServer(m); err != nil {
return err
}
m.G().LocalSigchainGuard().Clear(m.Ctx(), "Prove")
stage("CheckProofText")
if err = p.checkProofText(m); err != nil {
return err
}
stage("InstructAction")
if err = p.instructAction(m); err != nil {
return err
}
if !p.arg.PromptPosted {
m.Debug("PromptPosted not set, prove run finished")
return nil
}
stage("CheckStart")
if p.serviceParameters == nil {
stage("PromptPostedLoop")
if err = p.promptPostedLoop(m); err != nil {
return err
}
} else {
stage("VerifyLoop")
if err = p.verifyLoop(m); err != nil {
return err
}
}
m.UIs().LogUI.Notice("Success!")
return nil
} | go | func (p *Prove) Run(m libkb.MetaContext) (err error) {
defer m.Trace("ProofEngine.Run", func() error { return err })()
stage := func(s string) {
m.Debug("| ProofEngine.Run() %s", s)
}
stage("GetServiceType")
if err = p.getServiceType(m); err != nil {
return err
}
stage("LoadMe")
if err = p.loadMe(m); err != nil {
return err
}
stage("CheckExists1")
if err = p.checkExists1(m); err != nil {
return err
}
stage("PromptRemoteName")
if err = p.promptRemoteName(m); err != nil {
return err
}
stage("CheckExists2")
if err = p.checkExists2(m); err != nil {
return err
}
stage("DoPrechecks")
if err = p.doPrechecks(m); err != nil {
return err
}
stage("DoWarnings")
if err = p.doWarnings(m); err != nil {
return err
}
m.G().LocalSigchainGuard().Set(m.Ctx(), "Prove")
defer m.G().LocalSigchainGuard().Clear(m.Ctx(), "Prove")
stage("GenerateProof")
if err = p.generateProof(m); err != nil {
return err
}
stage("PostProofToServer")
if err = p.postProofToServer(m); err != nil {
return err
}
m.G().LocalSigchainGuard().Clear(m.Ctx(), "Prove")
stage("CheckProofText")
if err = p.checkProofText(m); err != nil {
return err
}
stage("InstructAction")
if err = p.instructAction(m); err != nil {
return err
}
if !p.arg.PromptPosted {
m.Debug("PromptPosted not set, prove run finished")
return nil
}
stage("CheckStart")
if p.serviceParameters == nil {
stage("PromptPostedLoop")
if err = p.promptPostedLoop(m); err != nil {
return err
}
} else {
stage("VerifyLoop")
if err = p.verifyLoop(m); err != nil {
return err
}
}
m.UIs().LogUI.Notice("Success!")
return nil
} | [
"func",
"(",
"p",
"*",
"Prove",
")",
"Run",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"stage",
":=",
"func",
"(",
"s",
"string",
")",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"getServiceType",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"loadMe",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"checkExists1",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"promptRemoteName",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"checkExists2",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"doPrechecks",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"doWarnings",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"m",
".",
"G",
"(",
")",
".",
"LocalSigchainGuard",
"(",
")",
".",
"Set",
"(",
"m",
".",
"Ctx",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"defer",
"m",
".",
"G",
"(",
")",
".",
"LocalSigchainGuard",
"(",
")",
".",
"Clear",
"(",
"m",
".",
"Ctx",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"generateProof",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"postProofToServer",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"m",
".",
"G",
"(",
")",
".",
"LocalSigchainGuard",
"(",
")",
".",
"Clear",
"(",
"m",
".",
"Ctx",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"checkProofText",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"instructAction",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"!",
"p",
".",
"arg",
".",
"PromptPosted",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"p",
".",
"serviceParameters",
"==",
"nil",
"{",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"promptPostedLoop",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"stage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"p",
".",
"verifyLoop",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"m",
".",
"UIs",
"(",
")",
".",
"LogUI",
".",
"Notice",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Run runs the Prove engine, performing all steps of the proof process. | [
"Run",
"runs",
"the",
"Prove",
"engine",
"performing",
"all",
"steps",
"of",
"the",
"proof",
"process",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/prove.go#L394-L468 |
159,691 | keybase/client | go/pvl/init.go | NewPvlSourceAndInstall | func NewPvlSourceAndInstall(g *libkb.GlobalContext) libkb.MerkleStore {
supportedVersion := keybase1.MerkleStoreSupportedVersion(SupportedVersion)
tag := "pvl"
endpoint := "merkle/pvl"
getHash := func(root libkb.MerkleRoot) string {
return root.PvlHash()
}
kitFilename := g.Env.GetPvlKitFilename()
s := merklestore.NewMerkleStore(g, tag, endpoint, kitFilename, supportedVersion, getHash)
g.SetPvlSource(s)
return s
} | go | func NewPvlSourceAndInstall(g *libkb.GlobalContext) libkb.MerkleStore {
supportedVersion := keybase1.MerkleStoreSupportedVersion(SupportedVersion)
tag := "pvl"
endpoint := "merkle/pvl"
getHash := func(root libkb.MerkleRoot) string {
return root.PvlHash()
}
kitFilename := g.Env.GetPvlKitFilename()
s := merklestore.NewMerkleStore(g, tag, endpoint, kitFilename, supportedVersion, getHash)
g.SetPvlSource(s)
return s
} | [
"func",
"NewPvlSourceAndInstall",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"libkb",
".",
"MerkleStore",
"{",
"supportedVersion",
":=",
"keybase1",
".",
"MerkleStoreSupportedVersion",
"(",
"SupportedVersion",
")",
"\n",
"tag",
":=",
"\"",
"\"",
"\n",
"endpoint",
":=",
"\"",
"\"",
"\n",
"getHash",
":=",
"func",
"(",
"root",
"libkb",
".",
"MerkleRoot",
")",
"string",
"{",
"return",
"root",
".",
"PvlHash",
"(",
")",
"\n",
"}",
"\n",
"kitFilename",
":=",
"g",
".",
"Env",
".",
"GetPvlKitFilename",
"(",
")",
"\n",
"s",
":=",
"merklestore",
".",
"NewMerkleStore",
"(",
"g",
",",
"tag",
",",
"endpoint",
",",
"kitFilename",
",",
"supportedVersion",
",",
"getHash",
")",
"\n",
"g",
".",
"SetPvlSource",
"(",
"s",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // NewPvlSource creates a new source and installs it into G. | [
"NewPvlSource",
"creates",
"a",
"new",
"source",
"and",
"installs",
"it",
"into",
"G",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/init.go#L10-L21 |
159,692 | keybase/client | go/libkb/tmpfile.go | TempFileName | func TempFileName(prefix string) (tmp string, err error) {
tmp, err = RandString(prefix, 20)
return
} | go | func TempFileName(prefix string) (tmp string, err error) {
tmp, err = RandString(prefix, 20)
return
} | [
"func",
"TempFileName",
"(",
"prefix",
"string",
")",
"(",
"tmp",
"string",
",",
"err",
"error",
")",
"{",
"tmp",
",",
"err",
"=",
"RandString",
"(",
"prefix",
",",
"20",
")",
"\n",
"return",
"\n",
"}"
] | // TempFileName returns a temporary random filename | [
"TempFileName",
"returns",
"a",
"temporary",
"random",
"filename"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/tmpfile.go#L38-L41 |
159,693 | keybase/client | go/auth/credential_authority.go | String | func (ca checkArg) String() string {
return fmt.Sprintf("{uid: %s, username: %s, kid: %s, sibkeys: %v, subkeys: %v}",
ca.uid, ca.username, ca.kid, ca.sibkeys, ca.subkeys)
} | go | func (ca checkArg) String() string {
return fmt.Sprintf("{uid: %s, username: %s, kid: %s, sibkeys: %v, subkeys: %v}",
ca.uid, ca.username, ca.kid, ca.sibkeys, ca.subkeys)
} | [
"func",
"(",
"ca",
"checkArg",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ca",
".",
"uid",
",",
"ca",
".",
"username",
",",
"ca",
".",
"kid",
",",
"ca",
".",
"sibkeys",
",",
"ca",
".",
"subkeys",
")",
"\n",
"}"
] | // String implements the Stringer interface for checkArg. | [
"String",
"implements",
"the",
"Stringer",
"interface",
"for",
"checkArg",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/credential_authority.go#L45-L48 |
159,694 | keybase/client | go/auth/credential_authority.go | String | func (uw userWrapper) String() string {
return fmt.Sprintf("{user: %s, atime: %s}", uw.u, uw.atime)
} | go | func (uw userWrapper) String() string {
return fmt.Sprintf("{user: %s, atime: %s}", uw.u, uw.atime)
} | [
"func",
"(",
"uw",
"userWrapper",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"uw",
".",
"u",
",",
"uw",
".",
"atime",
")",
"\n",
"}"
] | // String implements the Stringer interface for userWrapper. | [
"String",
"implements",
"the",
"Stringer",
"interface",
"for",
"userWrapper",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/credential_authority.go#L60-L62 |
159,695 | keybase/client | go/auth/credential_authority.go | String | func (ci cleanItem) String() string {
return fmt.Sprintf("{uid: %s, ctime: %s}", ci.uid, ci.ctime)
} | go | func (ci cleanItem) String() string {
return fmt.Sprintf("{uid: %s, ctime: %s}", ci.uid, ci.ctime)
} | [
"func",
"(",
"ci",
"cleanItem",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ci",
".",
"uid",
",",
"ci",
".",
"ctime",
")",
"\n",
"}"
] | // String implements the Stringer interface for cleanItem. | [
"String",
"implements",
"the",
"Stringer",
"interface",
"for",
"cleanItem",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/credential_authority.go#L73-L75 |
159,696 | keybase/client | go/auth/credential_authority.go | String | func (u user) String() string {
return fmt.Sprintf("{uid: %s, username: %s, sibkeys: %v, subkeys: %v, isOK: %v, ctime: %s, isDeleted: %v}",
u.uid, u.username, u.sibkeys, u.subkeys, u.isOK, u.ctime, u.isDeleted)
} | go | func (u user) String() string {
return fmt.Sprintf("{uid: %s, username: %s, sibkeys: %v, subkeys: %v, isOK: %v, ctime: %s, isDeleted: %v}",
u.uid, u.username, u.sibkeys, u.subkeys, u.isOK, u.ctime, u.isDeleted)
} | [
"func",
"(",
"u",
"user",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"u",
".",
"uid",
",",
"u",
".",
"username",
",",
"u",
".",
"sibkeys",
",",
"u",
".",
"subkeys",
",",
"u",
".",
"isOK",
",",
"u",
".",
"ctime",
",",
"u",
".",
"isDeleted",
")",
"\n",
"}"
] | // String implements the stringer interface for user. | [
"String",
"implements",
"the",
"stringer",
"interface",
"for",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/credential_authority.go#L94-L97 |
159,697 | keybase/client | go/auth/credential_authority.go | newUser | func newUser(uid keybase1.UID, ca *CredentialAuthority) *user {
ca.log.Debug("newUser, uid %s", uid)
ret := &user{
uid: uid,
sibkeys: make(map[keybase1.KID]struct{}),
subkeys: make(map[keybase1.KID]struct{}),
ca: ca,
checkCh: make(chan checkArg),
stopCh: make(chan struct{}),
}
go ret.run()
return ret
} | go | func newUser(uid keybase1.UID, ca *CredentialAuthority) *user {
ca.log.Debug("newUser, uid %s", uid)
ret := &user{
uid: uid,
sibkeys: make(map[keybase1.KID]struct{}),
subkeys: make(map[keybase1.KID]struct{}),
ca: ca,
checkCh: make(chan checkArg),
stopCh: make(chan struct{}),
}
go ret.run()
return ret
} | [
"func",
"newUser",
"(",
"uid",
"keybase1",
".",
"UID",
",",
"ca",
"*",
"CredentialAuthority",
")",
"*",
"user",
"{",
"ca",
".",
"log",
".",
"Debug",
"(",
"\"",
"\"",
",",
"uid",
")",
"\n",
"ret",
":=",
"&",
"user",
"{",
"uid",
":",
"uid",
",",
"sibkeys",
":",
"make",
"(",
"map",
"[",
"keybase1",
".",
"KID",
"]",
"struct",
"{",
"}",
")",
",",
"subkeys",
":",
"make",
"(",
"map",
"[",
"keybase1",
".",
"KID",
"]",
"struct",
"{",
"}",
")",
",",
"ca",
":",
"ca",
",",
"checkCh",
":",
"make",
"(",
"chan",
"checkArg",
")",
",",
"stopCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"go",
"ret",
".",
"run",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // newUser makes a new user with the given UID for use in the given
// CredentialAuthority. This constructor sets up the necessary maps and
// channels to make the user work as expected. | [
"newUser",
"makes",
"a",
"new",
"user",
"with",
"the",
"given",
"UID",
"for",
"use",
"in",
"the",
"given",
"CredentialAuthority",
".",
"This",
"constructor",
"sets",
"up",
"the",
"necessary",
"maps",
"and",
"channels",
"to",
"make",
"the",
"user",
"work",
"as",
"expected",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/credential_authority.go#L102-L114 |
159,698 | keybase/client | go/auth/credential_authority.go | NewCredentialAuthority | func NewCredentialAuthority(log logger.Logger, api UserKeyAPIer) *CredentialAuthority {
return newCredentialAuthorityWithEngine(log, api, newStandardEngine())
} | go | func NewCredentialAuthority(log logger.Logger, api UserKeyAPIer) *CredentialAuthority {
return newCredentialAuthorityWithEngine(log, api, newStandardEngine())
} | [
"func",
"NewCredentialAuthority",
"(",
"log",
"logger",
".",
"Logger",
",",
"api",
"UserKeyAPIer",
")",
"*",
"CredentialAuthority",
"{",
"return",
"newCredentialAuthorityWithEngine",
"(",
"log",
",",
"api",
",",
"newStandardEngine",
"(",
")",
")",
"\n",
"}"
] | // NewCredentialAuthority makes a new signleton CredentialAuthority an start it running. It takes as input
// a logger and an API for making keybase API calls | [
"NewCredentialAuthority",
"makes",
"a",
"new",
"signleton",
"CredentialAuthority",
"an",
"start",
"it",
"running",
".",
"It",
"takes",
"as",
"input",
"a",
"logger",
"and",
"an",
"API",
"for",
"making",
"keybase",
"API",
"calls"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/credential_authority.go#L168-L170 |
159,699 | keybase/client | go/auth/credential_authority.go | newCredentialAuthorityWithEngine | func newCredentialAuthorityWithEngine(log logger.Logger, api UserKeyAPIer, eng engine) *CredentialAuthority {
ret := &CredentialAuthority{
log: log,
api: api,
invalidateCh: make(chan keybase1.UID, 100),
checkCh: make(chan checkArg),
shutdownCh: make(chan struct{}),
users: make(map[keybase1.UID](*userWrapper)),
cleanItemCh: make(chan cleanItem),
eng: eng,
}
ret.run()
return ret
} | go | func newCredentialAuthorityWithEngine(log logger.Logger, api UserKeyAPIer, eng engine) *CredentialAuthority {
ret := &CredentialAuthority{
log: log,
api: api,
invalidateCh: make(chan keybase1.UID, 100),
checkCh: make(chan checkArg),
shutdownCh: make(chan struct{}),
users: make(map[keybase1.UID](*userWrapper)),
cleanItemCh: make(chan cleanItem),
eng: eng,
}
ret.run()
return ret
} | [
"func",
"newCredentialAuthorityWithEngine",
"(",
"log",
"logger",
".",
"Logger",
",",
"api",
"UserKeyAPIer",
",",
"eng",
"engine",
")",
"*",
"CredentialAuthority",
"{",
"ret",
":=",
"&",
"CredentialAuthority",
"{",
"log",
":",
"log",
",",
"api",
":",
"api",
",",
"invalidateCh",
":",
"make",
"(",
"chan",
"keybase1",
".",
"UID",
",",
"100",
")",
",",
"checkCh",
":",
"make",
"(",
"chan",
"checkArg",
")",
",",
"shutdownCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"users",
":",
"make",
"(",
"map",
"[",
"keybase1",
".",
"UID",
"]",
"(",
"*",
"userWrapper",
")",
")",
",",
"cleanItemCh",
":",
"make",
"(",
"chan",
"cleanItem",
")",
",",
"eng",
":",
"eng",
",",
"}",
"\n",
"ret",
".",
"run",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // newCredentialAuthoirutyWithEngine is an internal call that can specify the non-standard
// engine. We'd only need to call this directly from testing to specify a testingEngine. | [
"newCredentialAuthoirutyWithEngine",
"is",
"an",
"internal",
"call",
"that",
"can",
"specify",
"the",
"non",
"-",
"standard",
"engine",
".",
"We",
"d",
"only",
"need",
"to",
"call",
"this",
"directly",
"from",
"testing",
"to",
"specify",
"a",
"testingEngine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/credential_authority.go#L174-L187 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.