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
|
---|---|---|---|---|---|---|---|---|---|---|---|
158,700 | keybase/client | go/kbfs/libkbfs/tlf_journal.go | getBlockDeferredGCRange | func (j *tlfJournal) getBlockDeferredGCRange() (
blockJournal *blockJournal, length int,
earliest, latest journalOrdinal, err error) {
j.journalLock.Lock()
defer j.journalLock.Unlock()
if err := j.checkEnabledLocked(); err != nil {
return nil, 0, 0, 0, err
}
length, earliest, latest, err = j.blockJournal.getDeferredGCRange()
if err != nil {
return nil, 0, 0, 0, err
}
return j.blockJournal, length, earliest, latest, nil
} | go | func (j *tlfJournal) getBlockDeferredGCRange() (
blockJournal *blockJournal, length int,
earliest, latest journalOrdinal, err error) {
j.journalLock.Lock()
defer j.journalLock.Unlock()
if err := j.checkEnabledLocked(); err != nil {
return nil, 0, 0, 0, err
}
length, earliest, latest, err = j.blockJournal.getDeferredGCRange()
if err != nil {
return nil, 0, 0, 0, err
}
return j.blockJournal, length, earliest, latest, nil
} | [
"func",
"(",
"j",
"*",
"tlfJournal",
")",
"getBlockDeferredGCRange",
"(",
")",
"(",
"blockJournal",
"*",
"blockJournal",
",",
"length",
"int",
",",
"earliest",
",",
"latest",
"journalOrdinal",
",",
"err",
"error",
")",
"{",
"j",
".",
"journalLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"j",
".",
"journalLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"err",
":=",
"j",
".",
"checkEnabledLocked",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"0",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"length",
",",
"earliest",
",",
"latest",
",",
"err",
"=",
"j",
".",
"blockJournal",
".",
"getDeferredGCRange",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"0",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
"j",
".",
"blockJournal",
",",
"length",
",",
"earliest",
",",
"latest",
",",
"nil",
"\n",
"}"
] | // getBlockDeferredGCRange wraps blockJournal.getDeferredGCRange. The
// returned blockJournal should be used instead of j.blockJournal, as
// we want to call blockJournal.doGC outside of journalLock. | [
"getBlockDeferredGCRange",
"wraps",
"blockJournal",
".",
"getDeferredGCRange",
".",
"The",
"returned",
"blockJournal",
"should",
"be",
"used",
"instead",
"of",
"j",
".",
"blockJournal",
"as",
"we",
"want",
"to",
"call",
"blockJournal",
".",
"doGC",
"outside",
"of",
"journalLock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/tlf_journal.go#L1372-L1385 |
158,701 | keybase/client | go/kbfs/libkbfs/tlf_journal.go | getUnflushedPathMDInfos | func (j *tlfJournal) getUnflushedPathMDInfos(ctx context.Context,
ibrmds []ImmutableBareRootMetadata) ([]unflushedPathMDInfo, error) {
if len(ibrmds) == 0 {
return nil, nil
}
ibrmdBareHandle, err := ibrmds[0].MakeBareTlfHandleWithExtra()
if err != nil {
return nil, err
}
handle, err := tlfhandle.MakeHandle(
ctx, ibrmdBareHandle, j.tlfID.Type(), j.config.resolver(),
j.config.usernameGetter(), tlfhandle.ConstIDGetter{ID: j.tlfID},
j.config.OfflineAvailabilityForID(j.tlfID))
if err != nil {
return nil, err
}
mdInfos := make([]unflushedPathMDInfo, 0, len(ibrmds))
for _, ibrmd := range ibrmds {
// TODO: Avoid having to do this type assertion and
// convert to RootMetadata.
brmd, ok := ibrmd.RootMetadata.(kbfsmd.MutableRootMetadata)
if !ok {
return nil, kbfsmd.MutableRootMetadataNoImplError{}
}
rmd := makeRootMetadata(brmd, ibrmd.extra, handle)
// Assume, since journal is running, that we're in default mode.
mode := NewInitModeFromType(InitDefault)
pmd, err := decryptMDPrivateData(
ctx, j.config.Codec(), j.config.Crypto(),
j.config.BlockCache(), j.config.BlockOps(),
j.config.mdDecryptionKeyGetter(), j.config.teamMembershipChecker(),
j.config, mode, j.uid, rmd.GetSerializedPrivateMetadata(), rmd,
rmd, j.log)
if err != nil {
return nil, err
}
rmd.data = pmd
mdInfo := unflushedPathMDInfo{
revision: ibrmd.RevisionNumber(),
kmd: rmd,
pmd: pmd,
localTimestamp: ibrmd.localTimestamp,
}
mdInfos = append(mdInfos, mdInfo)
}
return mdInfos, nil
} | go | func (j *tlfJournal) getUnflushedPathMDInfos(ctx context.Context,
ibrmds []ImmutableBareRootMetadata) ([]unflushedPathMDInfo, error) {
if len(ibrmds) == 0 {
return nil, nil
}
ibrmdBareHandle, err := ibrmds[0].MakeBareTlfHandleWithExtra()
if err != nil {
return nil, err
}
handle, err := tlfhandle.MakeHandle(
ctx, ibrmdBareHandle, j.tlfID.Type(), j.config.resolver(),
j.config.usernameGetter(), tlfhandle.ConstIDGetter{ID: j.tlfID},
j.config.OfflineAvailabilityForID(j.tlfID))
if err != nil {
return nil, err
}
mdInfos := make([]unflushedPathMDInfo, 0, len(ibrmds))
for _, ibrmd := range ibrmds {
// TODO: Avoid having to do this type assertion and
// convert to RootMetadata.
brmd, ok := ibrmd.RootMetadata.(kbfsmd.MutableRootMetadata)
if !ok {
return nil, kbfsmd.MutableRootMetadataNoImplError{}
}
rmd := makeRootMetadata(brmd, ibrmd.extra, handle)
// Assume, since journal is running, that we're in default mode.
mode := NewInitModeFromType(InitDefault)
pmd, err := decryptMDPrivateData(
ctx, j.config.Codec(), j.config.Crypto(),
j.config.BlockCache(), j.config.BlockOps(),
j.config.mdDecryptionKeyGetter(), j.config.teamMembershipChecker(),
j.config, mode, j.uid, rmd.GetSerializedPrivateMetadata(), rmd,
rmd, j.log)
if err != nil {
return nil, err
}
rmd.data = pmd
mdInfo := unflushedPathMDInfo{
revision: ibrmd.RevisionNumber(),
kmd: rmd,
pmd: pmd,
localTimestamp: ibrmd.localTimestamp,
}
mdInfos = append(mdInfos, mdInfo)
}
return mdInfos, nil
} | [
"func",
"(",
"j",
"*",
"tlfJournal",
")",
"getUnflushedPathMDInfos",
"(",
"ctx",
"context",
".",
"Context",
",",
"ibrmds",
"[",
"]",
"ImmutableBareRootMetadata",
")",
"(",
"[",
"]",
"unflushedPathMDInfo",
",",
"error",
")",
"{",
"if",
"len",
"(",
"ibrmds",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"ibrmdBareHandle",
",",
"err",
":=",
"ibrmds",
"[",
"0",
"]",
".",
"MakeBareTlfHandleWithExtra",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"handle",
",",
"err",
":=",
"tlfhandle",
".",
"MakeHandle",
"(",
"ctx",
",",
"ibrmdBareHandle",
",",
"j",
".",
"tlfID",
".",
"Type",
"(",
")",
",",
"j",
".",
"config",
".",
"resolver",
"(",
")",
",",
"j",
".",
"config",
".",
"usernameGetter",
"(",
")",
",",
"tlfhandle",
".",
"ConstIDGetter",
"{",
"ID",
":",
"j",
".",
"tlfID",
"}",
",",
"j",
".",
"config",
".",
"OfflineAvailabilityForID",
"(",
"j",
".",
"tlfID",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"mdInfos",
":=",
"make",
"(",
"[",
"]",
"unflushedPathMDInfo",
",",
"0",
",",
"len",
"(",
"ibrmds",
")",
")",
"\n\n",
"for",
"_",
",",
"ibrmd",
":=",
"range",
"ibrmds",
"{",
"// TODO: Avoid having to do this type assertion and",
"// convert to RootMetadata.",
"brmd",
",",
"ok",
":=",
"ibrmd",
".",
"RootMetadata",
".",
"(",
"kbfsmd",
".",
"MutableRootMetadata",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"kbfsmd",
".",
"MutableRootMetadataNoImplError",
"{",
"}",
"\n",
"}",
"\n",
"rmd",
":=",
"makeRootMetadata",
"(",
"brmd",
",",
"ibrmd",
".",
"extra",
",",
"handle",
")",
"\n\n",
"// Assume, since journal is running, that we're in default mode.",
"mode",
":=",
"NewInitModeFromType",
"(",
"InitDefault",
")",
"\n",
"pmd",
",",
"err",
":=",
"decryptMDPrivateData",
"(",
"ctx",
",",
"j",
".",
"config",
".",
"Codec",
"(",
")",
",",
"j",
".",
"config",
".",
"Crypto",
"(",
")",
",",
"j",
".",
"config",
".",
"BlockCache",
"(",
")",
",",
"j",
".",
"config",
".",
"BlockOps",
"(",
")",
",",
"j",
".",
"config",
".",
"mdDecryptionKeyGetter",
"(",
")",
",",
"j",
".",
"config",
".",
"teamMembershipChecker",
"(",
")",
",",
"j",
".",
"config",
",",
"mode",
",",
"j",
".",
"uid",
",",
"rmd",
".",
"GetSerializedPrivateMetadata",
"(",
")",
",",
"rmd",
",",
"rmd",
",",
"j",
".",
"log",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"rmd",
".",
"data",
"=",
"pmd",
"\n\n",
"mdInfo",
":=",
"unflushedPathMDInfo",
"{",
"revision",
":",
"ibrmd",
".",
"RevisionNumber",
"(",
")",
",",
"kmd",
":",
"rmd",
",",
"pmd",
":",
"pmd",
",",
"localTimestamp",
":",
"ibrmd",
".",
"localTimestamp",
",",
"}",
"\n",
"mdInfos",
"=",
"append",
"(",
"mdInfos",
",",
"mdInfo",
")",
"\n",
"}",
"\n",
"return",
"mdInfos",
",",
"nil",
"\n",
"}"
] | // getUnflushedPathMDInfos converts the given list of bare root
// metadatas into unflushedPathMDInfo objects. The caller must NOT
// hold `j.journalLock`, because blocks from the journal may need to
// be read as part of the decryption. | [
"getUnflushedPathMDInfos",
"converts",
"the",
"given",
"list",
"of",
"bare",
"root",
"metadatas",
"into",
"unflushedPathMDInfo",
"objects",
".",
"The",
"caller",
"must",
"NOT",
"hold",
"j",
".",
"journalLock",
"because",
"blocks",
"from",
"the",
"journal",
"may",
"need",
"to",
"be",
"read",
"as",
"part",
"of",
"the",
"decryption",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/tlf_journal.go#L1748-L1800 |
158,702 | keybase/client | go/kbfs/libkbfs/tlf_journal.go | disable | func (j *tlfJournal) disable() (wasEnabled bool, err error) {
j.journalLock.Lock()
defer j.journalLock.Unlock()
err = j.checkEnabledLocked()
switch errors.Cause(err).(type) {
case nil:
// Continue.
break
case errTLFJournalDisabled:
// Already disabled.
return false, nil
default:
return false, err
}
blockEntryCount := j.blockJournal.length()
mdEntryCount := j.mdJournal.length()
// You can only disable an empty journal.
if blockEntryCount > 0 || mdEntryCount > 0 {
return false, errors.WithStack(errTLFJournalNotEmpty{})
}
j.disabled = true
return true, nil
} | go | func (j *tlfJournal) disable() (wasEnabled bool, err error) {
j.journalLock.Lock()
defer j.journalLock.Unlock()
err = j.checkEnabledLocked()
switch errors.Cause(err).(type) {
case nil:
// Continue.
break
case errTLFJournalDisabled:
// Already disabled.
return false, nil
default:
return false, err
}
blockEntryCount := j.blockJournal.length()
mdEntryCount := j.mdJournal.length()
// You can only disable an empty journal.
if blockEntryCount > 0 || mdEntryCount > 0 {
return false, errors.WithStack(errTLFJournalNotEmpty{})
}
j.disabled = true
return true, nil
} | [
"func",
"(",
"j",
"*",
"tlfJournal",
")",
"disable",
"(",
")",
"(",
"wasEnabled",
"bool",
",",
"err",
"error",
")",
"{",
"j",
".",
"journalLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"j",
".",
"journalLock",
".",
"Unlock",
"(",
")",
"\n",
"err",
"=",
"j",
".",
"checkEnabledLocked",
"(",
")",
"\n",
"switch",
"errors",
".",
"Cause",
"(",
"err",
")",
".",
"(",
"type",
")",
"{",
"case",
"nil",
":",
"// Continue.",
"break",
"\n",
"case",
"errTLFJournalDisabled",
":",
"// Already disabled.",
"return",
"false",
",",
"nil",
"\n",
"default",
":",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"blockEntryCount",
":=",
"j",
".",
"blockJournal",
".",
"length",
"(",
")",
"\n",
"mdEntryCount",
":=",
"j",
".",
"mdJournal",
".",
"length",
"(",
")",
"\n\n",
"// You can only disable an empty journal.",
"if",
"blockEntryCount",
">",
"0",
"||",
"mdEntryCount",
">",
"0",
"{",
"return",
"false",
",",
"errors",
".",
"WithStack",
"(",
"errTLFJournalNotEmpty",
"{",
"}",
")",
"\n",
"}",
"\n\n",
"j",
".",
"disabled",
"=",
"true",
"\n",
"return",
"true",
",",
"nil",
"\n",
"}"
] | // disable prevents new operations from hitting the journal. Will
// fail unless the journal is completely empty. | [
"disable",
"prevents",
"new",
"operations",
"from",
"hitting",
"the",
"journal",
".",
"Will",
"fail",
"unless",
"the",
"journal",
"is",
"completely",
"empty",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/tlf_journal.go#L1936-L1961 |
158,703 | keybase/client | go/kbfs/libkbfs/tlf_journal.go | Error | func (e *ErrDiskLimitTimeout) Error() string {
return fmt.Sprintf("Disk limit timeout of %s reached; requested %d bytes and %d files, %d bytes and %d files available: %+v",
e.timeout, e.requestedBytes, e.requestedFiles,
e.availableBytes, e.availableFiles, e.err)
} | go | func (e *ErrDiskLimitTimeout) Error() string {
return fmt.Sprintf("Disk limit timeout of %s reached; requested %d bytes and %d files, %d bytes and %d files available: %+v",
e.timeout, e.requestedBytes, e.requestedFiles,
e.availableBytes, e.availableFiles, e.err)
} | [
"func",
"(",
"e",
"*",
"ErrDiskLimitTimeout",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"timeout",
",",
"e",
".",
"requestedBytes",
",",
"e",
".",
"requestedFiles",
",",
"e",
".",
"availableBytes",
",",
"e",
".",
"availableFiles",
",",
"e",
".",
"err",
")",
"\n",
"}"
] | // Error implements the error interface for ErrDiskLimitTimeout. It
// has a pointer receiver because `block_util.go` need to
// modify it in some cases while preserving any stacks attached to it
// via the `errors` package. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"ErrDiskLimitTimeout",
".",
"It",
"has",
"a",
"pointer",
"receiver",
"because",
"block_util",
".",
"go",
"need",
"to",
"modify",
"it",
"in",
"some",
"cases",
"while",
"preserving",
"any",
"stacks",
"attached",
"to",
"it",
"via",
"the",
"errors",
"package",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/tlf_journal.go#L2041-L2045 |
158,704 | keybase/client | go/libkb/special_keys.go | NewSpecialKeyRing | func NewSpecialKeyRing(v []keybase1.KID, g *GlobalContext) *SpecialKeyRing {
ret := &SpecialKeyRing{
keys: make(map[keybase1.KID]GenericKey),
validKIDs: make(map[keybase1.KID]bool),
Contextified: NewContextified(g),
}
for _, kid := range v {
if key, _ := ImportKeypairFromKID(kid); key != nil {
ret.keys[kid] = key
}
ret.validKIDs[kid] = true
}
return ret
} | go | func NewSpecialKeyRing(v []keybase1.KID, g *GlobalContext) *SpecialKeyRing {
ret := &SpecialKeyRing{
keys: make(map[keybase1.KID]GenericKey),
validKIDs: make(map[keybase1.KID]bool),
Contextified: NewContextified(g),
}
for _, kid := range v {
if key, _ := ImportKeypairFromKID(kid); key != nil {
ret.keys[kid] = key
}
ret.validKIDs[kid] = true
}
return ret
} | [
"func",
"NewSpecialKeyRing",
"(",
"v",
"[",
"]",
"keybase1",
".",
"KID",
",",
"g",
"*",
"GlobalContext",
")",
"*",
"SpecialKeyRing",
"{",
"ret",
":=",
"&",
"SpecialKeyRing",
"{",
"keys",
":",
"make",
"(",
"map",
"[",
"keybase1",
".",
"KID",
"]",
"GenericKey",
")",
",",
"validKIDs",
":",
"make",
"(",
"map",
"[",
"keybase1",
".",
"KID",
"]",
"bool",
")",
",",
"Contextified",
":",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"for",
"_",
",",
"kid",
":=",
"range",
"v",
"{",
"if",
"key",
",",
"_",
":=",
"ImportKeypairFromKID",
"(",
"kid",
")",
";",
"key",
"!=",
"nil",
"{",
"ret",
".",
"keys",
"[",
"kid",
"]",
"=",
"key",
"\n",
"}",
"\n",
"ret",
".",
"validKIDs",
"[",
"kid",
"]",
"=",
"true",
"\n",
"}",
"\n",
"return",
"ret",
"\n\n",
"}"
] | // NewSpecialKeyRing allocates a new SpecialKeyRing with the given
// vector of KIDs. For NaCl keys, it will actually import those
// keys into the Keyring. | [
"NewSpecialKeyRing",
"allocates",
"a",
"new",
"SpecialKeyRing",
"with",
"the",
"given",
"vector",
"of",
"KIDs",
".",
"For",
"NaCl",
"keys",
"it",
"will",
"actually",
"import",
"those",
"keys",
"into",
"the",
"Keyring",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/special_keys.go#L25-L39 |
158,705 | keybase/client | go/engine/revoke.go | getPukReceivers | func (e *RevokeEngine) getPukReceivers(m libkb.MetaContext, me *libkb.User, exclude []keybase1.KID) (res []libkb.NaclDHKeyPair, err error) {
excludeMap := make(map[keybase1.KID]bool)
for _, kid := range exclude {
excludeMap[kid] = true
}
ckf := me.GetComputedKeyFamily()
for _, dev := range ckf.GetAllActiveDevices() {
keyGeneric, err := ckf.GetEncryptionSubkeyForDevice(dev.ID)
if err != nil {
return nil, err
}
if !excludeMap[keyGeneric.GetKID()] {
key, ok := keyGeneric.(libkb.NaclDHKeyPair)
if !ok {
return nil, fmt.Errorf("Unexpected encryption key type: %T", keyGeneric)
}
res = append(res, key)
}
}
return res, nil
} | go | func (e *RevokeEngine) getPukReceivers(m libkb.MetaContext, me *libkb.User, exclude []keybase1.KID) (res []libkb.NaclDHKeyPair, err error) {
excludeMap := make(map[keybase1.KID]bool)
for _, kid := range exclude {
excludeMap[kid] = true
}
ckf := me.GetComputedKeyFamily()
for _, dev := range ckf.GetAllActiveDevices() {
keyGeneric, err := ckf.GetEncryptionSubkeyForDevice(dev.ID)
if err != nil {
return nil, err
}
if !excludeMap[keyGeneric.GetKID()] {
key, ok := keyGeneric.(libkb.NaclDHKeyPair)
if !ok {
return nil, fmt.Errorf("Unexpected encryption key type: %T", keyGeneric)
}
res = append(res, key)
}
}
return res, nil
} | [
"func",
"(",
"e",
"*",
"RevokeEngine",
")",
"getPukReceivers",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"me",
"*",
"libkb",
".",
"User",
",",
"exclude",
"[",
"]",
"keybase1",
".",
"KID",
")",
"(",
"res",
"[",
"]",
"libkb",
".",
"NaclDHKeyPair",
",",
"err",
"error",
")",
"{",
"excludeMap",
":=",
"make",
"(",
"map",
"[",
"keybase1",
".",
"KID",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"kid",
":=",
"range",
"exclude",
"{",
"excludeMap",
"[",
"kid",
"]",
"=",
"true",
"\n",
"}",
"\n\n",
"ckf",
":=",
"me",
".",
"GetComputedKeyFamily",
"(",
")",
"\n\n",
"for",
"_",
",",
"dev",
":=",
"range",
"ckf",
".",
"GetAllActiveDevices",
"(",
")",
"{",
"keyGeneric",
",",
"err",
":=",
"ckf",
".",
"GetEncryptionSubkeyForDevice",
"(",
"dev",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"excludeMap",
"[",
"keyGeneric",
".",
"GetKID",
"(",
")",
"]",
"{",
"key",
",",
"ok",
":=",
"keyGeneric",
".",
"(",
"libkb",
".",
"NaclDHKeyPair",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"keyGeneric",
")",
"\n",
"}",
"\n",
"res",
"=",
"append",
"(",
"res",
",",
"key",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] | // Get the receivers of the new per-user-key boxes.
// Includes all device subkeys except any being revoked by this engine. | [
"Get",
"the",
"receivers",
"of",
"the",
"new",
"per",
"-",
"user",
"-",
"key",
"boxes",
".",
"Includes",
"all",
"device",
"subkeys",
"except",
"any",
"being",
"revoked",
"by",
"this",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/revoke.go#L377-L399 |
158,706 | keybase/client | go/kbfs/libfs/archive_util.go | BranchNameFromArchiveRefDir | func BranchNameFromArchiveRefDir(dir string) (data.BranchName, bool) {
if !strings.HasPrefix(dir, ArchivedRevDirPrefix) {
return "", false
}
rev, err := strconv.ParseInt(dir[len(ArchivedRevDirPrefix):], 10, 64)
if err != nil {
return "", false
}
return data.MakeRevBranchName(kbfsmd.Revision(rev)), true
} | go | func BranchNameFromArchiveRefDir(dir string) (data.BranchName, bool) {
if !strings.HasPrefix(dir, ArchivedRevDirPrefix) {
return "", false
}
rev, err := strconv.ParseInt(dir[len(ArchivedRevDirPrefix):], 10, 64)
if err != nil {
return "", false
}
return data.MakeRevBranchName(kbfsmd.Revision(rev)), true
} | [
"func",
"BranchNameFromArchiveRefDir",
"(",
"dir",
"string",
")",
"(",
"data",
".",
"BranchName",
",",
"bool",
")",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"dir",
",",
"ArchivedRevDirPrefix",
")",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n\n",
"rev",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"dir",
"[",
"len",
"(",
"ArchivedRevDirPrefix",
")",
":",
"]",
",",
"10",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n\n",
"return",
"data",
".",
"MakeRevBranchName",
"(",
"kbfsmd",
".",
"Revision",
"(",
"rev",
")",
")",
",",
"true",
"\n",
"}"
] | // BranchNameFromArchiveRefDir returns a branch name and true if the
// given directory name is specifying an archived revision with a
// revision number. | [
"BranchNameFromArchiveRefDir",
"returns",
"a",
"branch",
"name",
"and",
"true",
"if",
"the",
"given",
"directory",
"name",
"is",
"specifying",
"an",
"archived",
"revision",
"with",
"a",
"revision",
"number",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/archive_util.go#L23-L34 |
158,707 | keybase/client | go/kbfs/libfs/archive_util.go | FileDataFromRelativeTimeString | func FileDataFromRelativeTimeString(
ctx context.Context, config libkbfs.Config, h *tlfhandle.Handle,
filename string) ([]byte, bool, error) {
if !strings.HasPrefix(filename, ArchivedRelTimeFilePrefix) {
return nil, false, nil
}
rev, err := RevFromRelativeTimeString(
ctx, config, h, filename[len(ArchivedRelTimeFilePrefix):])
if err != nil {
return nil, false, err
}
return []byte(ArchivedRevDirPrefix + strconv.FormatInt(int64(rev), 10)),
true, nil
} | go | func FileDataFromRelativeTimeString(
ctx context.Context, config libkbfs.Config, h *tlfhandle.Handle,
filename string) ([]byte, bool, error) {
if !strings.HasPrefix(filename, ArchivedRelTimeFilePrefix) {
return nil, false, nil
}
rev, err := RevFromRelativeTimeString(
ctx, config, h, filename[len(ArchivedRelTimeFilePrefix):])
if err != nil {
return nil, false, err
}
return []byte(ArchivedRevDirPrefix + strconv.FormatInt(int64(rev), 10)),
true, nil
} | [
"func",
"FileDataFromRelativeTimeString",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"libkbfs",
".",
"Config",
",",
"h",
"*",
"tlfhandle",
".",
"Handle",
",",
"filename",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
",",
"error",
")",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"filename",
",",
"ArchivedRelTimeFilePrefix",
")",
"{",
"return",
"nil",
",",
"false",
",",
"nil",
"\n",
"}",
"\n\n",
"rev",
",",
"err",
":=",
"RevFromRelativeTimeString",
"(",
"ctx",
",",
"config",
",",
"h",
",",
"filename",
"[",
"len",
"(",
"ArchivedRelTimeFilePrefix",
")",
":",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"[",
"]",
"byte",
"(",
"ArchivedRevDirPrefix",
"+",
"strconv",
".",
"FormatInt",
"(",
"int64",
"(",
"rev",
")",
",",
"10",
")",
")",
",",
"true",
",",
"nil",
"\n",
"}"
] | // FileDataFromRelativeTimeString returns a byte string containing the
// name of a revision-based archive directory, and true, if the given
// file name specifies a valid by-relative-time file name. The time
// is relative to the local clock. | [
"FileDataFromRelativeTimeString",
"returns",
"a",
"byte",
"string",
"containing",
"the",
"name",
"of",
"a",
"revision",
"-",
"based",
"archive",
"directory",
"and",
"true",
"if",
"the",
"given",
"file",
"name",
"specifies",
"a",
"valid",
"by",
"-",
"relative",
"-",
"time",
"file",
"name",
".",
"The",
"time",
"is",
"relative",
"to",
"the",
"local",
"clock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/archive_util.go#L89-L104 |
158,708 | keybase/client | go/engine/puk_upgrade_background.go | NewPerUserKeyUpgradeBackground | func NewPerUserKeyUpgradeBackground(g *libkb.GlobalContext, args *PerUserKeyUpgradeBackgroundArgs) *PerUserKeyUpgradeBackground {
task := NewBackgroundTask(g, &BackgroundTaskArgs{
Name: "PerUserKeyUpgradeBackground",
F: PerUserKeyUpgradeBackgroundRound,
Settings: PerUserKeyUpgradeBackgroundSettings,
testingMetaCh: args.testingMetaCh,
testingRoundResCh: args.testingRoundResCh,
})
return &PerUserKeyUpgradeBackground{
Contextified: libkb.NewContextified(g),
args: args,
// Install the task early so that Shutdown can be called before RunEngine.
task: task,
}
} | go | func NewPerUserKeyUpgradeBackground(g *libkb.GlobalContext, args *PerUserKeyUpgradeBackgroundArgs) *PerUserKeyUpgradeBackground {
task := NewBackgroundTask(g, &BackgroundTaskArgs{
Name: "PerUserKeyUpgradeBackground",
F: PerUserKeyUpgradeBackgroundRound,
Settings: PerUserKeyUpgradeBackgroundSettings,
testingMetaCh: args.testingMetaCh,
testingRoundResCh: args.testingRoundResCh,
})
return &PerUserKeyUpgradeBackground{
Contextified: libkb.NewContextified(g),
args: args,
// Install the task early so that Shutdown can be called before RunEngine.
task: task,
}
} | [
"func",
"NewPerUserKeyUpgradeBackground",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"args",
"*",
"PerUserKeyUpgradeBackgroundArgs",
")",
"*",
"PerUserKeyUpgradeBackground",
"{",
"task",
":=",
"NewBackgroundTask",
"(",
"g",
",",
"&",
"BackgroundTaskArgs",
"{",
"Name",
":",
"\"",
"\"",
",",
"F",
":",
"PerUserKeyUpgradeBackgroundRound",
",",
"Settings",
":",
"PerUserKeyUpgradeBackgroundSettings",
",",
"testingMetaCh",
":",
"args",
".",
"testingMetaCh",
",",
"testingRoundResCh",
":",
"args",
".",
"testingRoundResCh",
",",
"}",
")",
"\n",
"return",
"&",
"PerUserKeyUpgradeBackground",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"args",
":",
"args",
",",
"// Install the task early so that Shutdown can be called before RunEngine.",
"task",
":",
"task",
",",
"}",
"\n",
"}"
] | // NewPerUserKeyUpgradeBackground creates a PerUserKeyUpgradeBackground engine. | [
"NewPerUserKeyUpgradeBackground",
"creates",
"a",
"PerUserKeyUpgradeBackground",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/puk_upgrade_background.go#L42-L57 |
158,709 | keybase/client | go/libkb/lksec.go | NewLKSecForEncrypt | func NewLKSecForEncrypt(m MetaContext, ui SecretUI, uid keybase1.UID) (ret *LKSec, err error) {
m = m.WithUIs(UIs{SecretUI: ui})
pps, err := GetPassphraseStreamStored(m)
if err != nil {
return nil, err
}
ret = NewLKSec(pps, uid)
return ret, nil
} | go | func NewLKSecForEncrypt(m MetaContext, ui SecretUI, uid keybase1.UID) (ret *LKSec, err error) {
m = m.WithUIs(UIs{SecretUI: ui})
pps, err := GetPassphraseStreamStored(m)
if err != nil {
return nil, err
}
ret = NewLKSec(pps, uid)
return ret, nil
} | [
"func",
"NewLKSecForEncrypt",
"(",
"m",
"MetaContext",
",",
"ui",
"SecretUI",
",",
"uid",
"keybase1",
".",
"UID",
")",
"(",
"ret",
"*",
"LKSec",
",",
"err",
"error",
")",
"{",
"m",
"=",
"m",
".",
"WithUIs",
"(",
"UIs",
"{",
"SecretUI",
":",
"ui",
"}",
")",
"\n",
"pps",
",",
"err",
":=",
"GetPassphraseStreamStored",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ret",
"=",
"NewLKSec",
"(",
"pps",
",",
"uid",
")",
"\n",
"return",
"ret",
",",
"nil",
"\n",
"}"
] | // NewLKSForEncrypt gets a verified passphrase stream, and returns
// an LKS that works for encryption. | [
"NewLKSForEncrypt",
"gets",
"a",
"verified",
"passphrase",
"stream",
"and",
"returns",
"an",
"LKS",
"that",
"works",
"for",
"encryption",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/lksec.go#L464-L472 |
158,710 | keybase/client | go/libkb/lksec.go | EncryptClientHalfRecovery | func (s *LKSec) EncryptClientHalfRecovery(key GenericKey) (string, error) {
if s.clientHalf.IsNil() {
return "", errors.New("Nil LKS Client Half")
}
return key.EncryptToString(s.clientHalf.Bytes(), nil)
} | go | func (s *LKSec) EncryptClientHalfRecovery(key GenericKey) (string, error) {
if s.clientHalf.IsNil() {
return "", errors.New("Nil LKS Client Half")
}
return key.EncryptToString(s.clientHalf.Bytes(), nil)
} | [
"func",
"(",
"s",
"*",
"LKSec",
")",
"EncryptClientHalfRecovery",
"(",
"key",
"GenericKey",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"s",
".",
"clientHalf",
".",
"IsNil",
"(",
")",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"key",
".",
"EncryptToString",
"(",
"s",
".",
"clientHalf",
".",
"Bytes",
"(",
")",
",",
"nil",
")",
"\n",
"}"
] | // EncryptClientHalfRecovery takes the client half of the LKS secret
// and encrypts it for the given key. This is for recovery of passphrases
// on device recovery operations. | [
"EncryptClientHalfRecovery",
"takes",
"the",
"client",
"half",
"of",
"the",
"LKS",
"secret",
"and",
"encrypts",
"it",
"for",
"the",
"given",
"key",
".",
"This",
"is",
"for",
"recovery",
"of",
"passphrases",
"on",
"device",
"recovery",
"operations",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/lksec.go#L477-L482 |
158,711 | keybase/client | go/libkb/lksec.go | ToSKB | func (s *LKSec) ToSKB(m MetaContext, key GenericKey) (ret *SKB, err error) {
defer m.Trace("LKSec#ToSKB", func() error { return err })()
if s == nil {
return nil, errors.New("nil lks")
}
ret = NewSKBWithGlobalContext(m.G())
var publicKey RawPublicKey
var privateKey RawPrivateKey
publicKey, privateKey, err = key.ExportPublicAndPrivate()
if err != nil {
return nil, err
}
ret.Priv.Data, err = s.Encrypt(m, []byte(privateKey))
if err != nil {
return nil, err
}
ret.Priv.Encryption = LKSecVersion
ret.Priv.PassphraseGeneration = int(s.Generation())
ret.Pub = []byte(publicKey)
ret.Type = key.GetAlgoType()
ret.uid = s.uid
return ret, nil
} | go | func (s *LKSec) ToSKB(m MetaContext, key GenericKey) (ret *SKB, err error) {
defer m.Trace("LKSec#ToSKB", func() error { return err })()
if s == nil {
return nil, errors.New("nil lks")
}
ret = NewSKBWithGlobalContext(m.G())
var publicKey RawPublicKey
var privateKey RawPrivateKey
publicKey, privateKey, err = key.ExportPublicAndPrivate()
if err != nil {
return nil, err
}
ret.Priv.Data, err = s.Encrypt(m, []byte(privateKey))
if err != nil {
return nil, err
}
ret.Priv.Encryption = LKSecVersion
ret.Priv.PassphraseGeneration = int(s.Generation())
ret.Pub = []byte(publicKey)
ret.Type = key.GetAlgoType()
ret.uid = s.uid
return ret, nil
} | [
"func",
"(",
"s",
"*",
"LKSec",
")",
"ToSKB",
"(",
"m",
"MetaContext",
",",
"key",
"GenericKey",
")",
"(",
"ret",
"*",
"SKB",
",",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"if",
"s",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"ret",
"=",
"NewSKBWithGlobalContext",
"(",
"m",
".",
"G",
"(",
")",
")",
"\n\n",
"var",
"publicKey",
"RawPublicKey",
"\n",
"var",
"privateKey",
"RawPrivateKey",
"\n\n",
"publicKey",
",",
"privateKey",
",",
"err",
"=",
"key",
".",
"ExportPublicAndPrivate",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"ret",
".",
"Priv",
".",
"Data",
",",
"err",
"=",
"s",
".",
"Encrypt",
"(",
"m",
",",
"[",
"]",
"byte",
"(",
"privateKey",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ret",
".",
"Priv",
".",
"Encryption",
"=",
"LKSecVersion",
"\n",
"ret",
".",
"Priv",
".",
"PassphraseGeneration",
"=",
"int",
"(",
"s",
".",
"Generation",
"(",
")",
")",
"\n",
"ret",
".",
"Pub",
"=",
"[",
"]",
"byte",
"(",
"publicKey",
")",
"\n",
"ret",
".",
"Type",
"=",
"key",
".",
"GetAlgoType",
"(",
")",
"\n",
"ret",
".",
"uid",
"=",
"s",
".",
"uid",
"\n",
"return",
"ret",
",",
"nil",
"\n",
"}"
] | // ToSKB exports a generic key with the given LKSec to a SecretKeyBundle,
// performing all necessary encryption. | [
"ToSKB",
"exports",
"a",
"generic",
"key",
"with",
"the",
"given",
"LKSec",
"to",
"a",
"SecretKeyBundle",
"performing",
"all",
"necessary",
"encryption",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/lksec.go#L486-L511 |
158,712 | keybase/client | go/kbnm/hostmanifest/known_windows.go | writeJSON | func (w *whitelistRegistry) writeJSON(path string, app AppManifest) error {
// Write the file
fp, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return err
}
defer fp.Close()
encoder := json.NewEncoder(fp)
encoder.SetIndent("", " ")
if err := encoder.Encode(&app); err != nil {
return err
}
return fp.Sync()
} | go | func (w *whitelistRegistry) writeJSON(path string, app AppManifest) error {
// Write the file
fp, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return err
}
defer fp.Close()
encoder := json.NewEncoder(fp)
encoder.SetIndent("", " ")
if err := encoder.Encode(&app); err != nil {
return err
}
return fp.Sync()
} | [
"func",
"(",
"w",
"*",
"whitelistRegistry",
")",
"writeJSON",
"(",
"path",
"string",
",",
"app",
"AppManifest",
")",
"error",
"{",
"// Write the file",
"fp",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"path",
",",
"os",
".",
"O_CREATE",
"|",
"os",
".",
"O_WRONLY",
"|",
"os",
".",
"O_TRUNC",
",",
"0644",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"fp",
".",
"Close",
"(",
")",
"\n\n",
"encoder",
":=",
"json",
".",
"NewEncoder",
"(",
"fp",
")",
"\n",
"encoder",
".",
"SetIndent",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"encoder",
".",
"Encode",
"(",
"&",
"app",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"fp",
".",
"Sync",
"(",
")",
"\n",
"}"
] | // writeJSON writes the whitelist manifest JSON file adjacent to the app's
// binary. | [
"writeJSON",
"writes",
"the",
"whitelist",
"manifest",
"JSON",
"file",
"adjacent",
"to",
"the",
"app",
"s",
"binary",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbnm/hostmanifest/known_windows.go#L43-L58 |
158,713 | keybase/client | go/kbnm/hostmanifest/known_windows.go | Install | func (w *whitelistRegistry) Install(_ User, app AppManifest) error {
// We assume that the parentDir already exists, where the binary lives.
jsonPath, keyPath := w.paths(app)
if err := w.writeJSON(jsonPath, app); err != nil {
return err
}
scope := registry.CURRENT_USER
k, _, err := registry.CreateKey(scope, keyPath, registry.SET_VALUE|registry.CREATE_SUB_KEY|registry.WRITE)
if err != nil {
return err
}
defer k.Close()
return k.SetStringValue("", jsonPath)
} | go | func (w *whitelistRegistry) Install(_ User, app AppManifest) error {
// We assume that the parentDir already exists, where the binary lives.
jsonPath, keyPath := w.paths(app)
if err := w.writeJSON(jsonPath, app); err != nil {
return err
}
scope := registry.CURRENT_USER
k, _, err := registry.CreateKey(scope, keyPath, registry.SET_VALUE|registry.CREATE_SUB_KEY|registry.WRITE)
if err != nil {
return err
}
defer k.Close()
return k.SetStringValue("", jsonPath)
} | [
"func",
"(",
"w",
"*",
"whitelistRegistry",
")",
"Install",
"(",
"_",
"User",
",",
"app",
"AppManifest",
")",
"error",
"{",
"// We assume that the parentDir already exists, where the binary lives.",
"jsonPath",
",",
"keyPath",
":=",
"w",
".",
"paths",
"(",
"app",
")",
"\n",
"if",
"err",
":=",
"w",
".",
"writeJSON",
"(",
"jsonPath",
",",
"app",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"scope",
":=",
"registry",
".",
"CURRENT_USER",
"\n",
"k",
",",
"_",
",",
"err",
":=",
"registry",
".",
"CreateKey",
"(",
"scope",
",",
"keyPath",
",",
"registry",
".",
"SET_VALUE",
"|",
"registry",
".",
"CREATE_SUB_KEY",
"|",
"registry",
".",
"WRITE",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"k",
".",
"Close",
"(",
")",
"\n\n",
"return",
"k",
".",
"SetStringValue",
"(",
"\"",
"\"",
",",
"jsonPath",
")",
"\n",
"}"
] | // Install on Windows ignores the provided user and always installs in the
// CURRET_USER context, writing the JSON adjacent to the binary path. | [
"Install",
"on",
"Windows",
"ignores",
"the",
"provided",
"user",
"and",
"always",
"installs",
"in",
"the",
"CURRET_USER",
"context",
"writing",
"the",
"JSON",
"adjacent",
"to",
"the",
"binary",
"path",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbnm/hostmanifest/known_windows.go#L75-L90 |
158,714 | keybase/client | go/service/user.go | NewUserHandler | func NewUserHandler(xp rpc.Transporter, g *libkb.GlobalContext, chatG *globals.ChatContext, s *Service) *UserHandler {
return &UserHandler{
BaseHandler: NewBaseHandler(g, xp),
Contextified: libkb.NewContextified(g),
ChatContextified: globals.NewChatContextified(chatG),
service: s,
}
} | go | func NewUserHandler(xp rpc.Transporter, g *libkb.GlobalContext, chatG *globals.ChatContext, s *Service) *UserHandler {
return &UserHandler{
BaseHandler: NewBaseHandler(g, xp),
Contextified: libkb.NewContextified(g),
ChatContextified: globals.NewChatContextified(chatG),
service: s,
}
} | [
"func",
"NewUserHandler",
"(",
"xp",
"rpc",
".",
"Transporter",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"chatG",
"*",
"globals",
".",
"ChatContext",
",",
"s",
"*",
"Service",
")",
"*",
"UserHandler",
"{",
"return",
"&",
"UserHandler",
"{",
"BaseHandler",
":",
"NewBaseHandler",
"(",
"g",
",",
"xp",
")",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"ChatContextified",
":",
"globals",
".",
"NewChatContextified",
"(",
"chatG",
")",
",",
"service",
":",
"s",
",",
"}",
"\n",
"}"
] | // NewUserHandler creates a UserHandler for the xp transport. | [
"NewUserHandler",
"creates",
"a",
"UserHandler",
"for",
"the",
"xp",
"transport",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/user.go#L32-L39 |
158,715 | keybase/client | go/service/user.go | ListTrackers | func (h *UserHandler) ListTrackers(ctx context.Context, arg keybase1.ListTrackersArg) ([]keybase1.Tracker, error) {
eng := engine.NewListTrackers(h.G(), arg.Uid)
return h.listTrackers(ctx, arg.SessionID, eng)
} | go | func (h *UserHandler) ListTrackers(ctx context.Context, arg keybase1.ListTrackersArg) ([]keybase1.Tracker, error) {
eng := engine.NewListTrackers(h.G(), arg.Uid)
return h.listTrackers(ctx, arg.SessionID, eng)
} | [
"func",
"(",
"h",
"*",
"UserHandler",
")",
"ListTrackers",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"ListTrackersArg",
")",
"(",
"[",
"]",
"keybase1",
".",
"Tracker",
",",
"error",
")",
"{",
"eng",
":=",
"engine",
".",
"NewListTrackers",
"(",
"h",
".",
"G",
"(",
")",
",",
"arg",
".",
"Uid",
")",
"\n",
"return",
"h",
".",
"listTrackers",
"(",
"ctx",
",",
"arg",
".",
"SessionID",
",",
"eng",
")",
"\n",
"}"
] | // ListTrackers gets the list of trackers for a user by uid. | [
"ListTrackers",
"gets",
"the",
"list",
"of",
"trackers",
"for",
"a",
"user",
"by",
"uid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/user.go#L42-L45 |
158,716 | keybase/client | go/service/user.go | ListTrackersByName | func (h *UserHandler) ListTrackersByName(ctx context.Context, arg keybase1.ListTrackersByNameArg) ([]keybase1.Tracker, error) {
eng := engine.NewListTrackersByName(arg.Username)
return h.listTrackers(ctx, arg.SessionID, eng)
} | go | func (h *UserHandler) ListTrackersByName(ctx context.Context, arg keybase1.ListTrackersByNameArg) ([]keybase1.Tracker, error) {
eng := engine.NewListTrackersByName(arg.Username)
return h.listTrackers(ctx, arg.SessionID, eng)
} | [
"func",
"(",
"h",
"*",
"UserHandler",
")",
"ListTrackersByName",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"ListTrackersByNameArg",
")",
"(",
"[",
"]",
"keybase1",
".",
"Tracker",
",",
"error",
")",
"{",
"eng",
":=",
"engine",
".",
"NewListTrackersByName",
"(",
"arg",
".",
"Username",
")",
"\n",
"return",
"h",
".",
"listTrackers",
"(",
"ctx",
",",
"arg",
".",
"SessionID",
",",
"eng",
")",
"\n",
"}"
] | // ListTrackersByName gets the list of trackers for a user by
// username. | [
"ListTrackersByName",
"gets",
"the",
"list",
"of",
"trackers",
"for",
"a",
"user",
"by",
"username",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/user.go#L49-L52 |
158,717 | keybase/client | go/service/user.go | ListTrackersSelf | func (h *UserHandler) ListTrackersSelf(ctx context.Context, sessionID int) ([]keybase1.Tracker, error) {
eng := engine.NewListTrackersSelf()
return h.listTrackers(ctx, sessionID, eng)
} | go | func (h *UserHandler) ListTrackersSelf(ctx context.Context, sessionID int) ([]keybase1.Tracker, error) {
eng := engine.NewListTrackersSelf()
return h.listTrackers(ctx, sessionID, eng)
} | [
"func",
"(",
"h",
"*",
"UserHandler",
")",
"ListTrackersSelf",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"[",
"]",
"keybase1",
".",
"Tracker",
",",
"error",
")",
"{",
"eng",
":=",
"engine",
".",
"NewListTrackersSelf",
"(",
")",
"\n",
"return",
"h",
".",
"listTrackers",
"(",
"ctx",
",",
"sessionID",
",",
"eng",
")",
"\n",
"}"
] | // ListTrackersSelf gets the list of trackers for the logged in
// user. | [
"ListTrackersSelf",
"gets",
"the",
"list",
"of",
"trackers",
"for",
"the",
"logged",
"in",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/user.go#L56-L59 |
158,718 | keybase/client | go/chat/attachments/s3.go | PutS3 | func (a *S3Store) PutS3(ctx context.Context, r io.Reader, size int64, task *UploadTask, previous *AttachmentInfo) (res *PutS3Result, err error) {
defer a.Trace(ctx, func() error { return err }, "PutS3")()
region := a.regionFromParams(task.S3Params)
b := a.s3Conn(task.S3Signer, region, task.S3Params.AccessKey).Bucket(task.S3Params.Bucket)
multiPartUpload := size > minMultiSize
if multiPartUpload && a.env.GetAttachmentDisableMulti() {
a.Debug(ctx, "PutS3: multi part upload manually disabled, overriding for size: %v", size)
multiPartUpload = false
}
if !multiPartUpload {
if err := a.putSingle(ctx, r, size, task.S3Params, b, task.Progress); err != nil {
return nil, err
}
} else {
objectKey, err := a.putMultiPipeline(ctx, r, size, task, b, previous)
if err != nil {
return nil, err
}
task.S3Params.ObjectKey = objectKey
}
s3res := PutS3Result{
Region: task.S3Params.RegionName,
Endpoint: task.S3Params.RegionEndpoint,
Bucket: task.S3Params.Bucket,
Path: task.S3Params.ObjectKey,
Size: size,
}
return &s3res, nil
} | go | func (a *S3Store) PutS3(ctx context.Context, r io.Reader, size int64, task *UploadTask, previous *AttachmentInfo) (res *PutS3Result, err error) {
defer a.Trace(ctx, func() error { return err }, "PutS3")()
region := a.regionFromParams(task.S3Params)
b := a.s3Conn(task.S3Signer, region, task.S3Params.AccessKey).Bucket(task.S3Params.Bucket)
multiPartUpload := size > minMultiSize
if multiPartUpload && a.env.GetAttachmentDisableMulti() {
a.Debug(ctx, "PutS3: multi part upload manually disabled, overriding for size: %v", size)
multiPartUpload = false
}
if !multiPartUpload {
if err := a.putSingle(ctx, r, size, task.S3Params, b, task.Progress); err != nil {
return nil, err
}
} else {
objectKey, err := a.putMultiPipeline(ctx, r, size, task, b, previous)
if err != nil {
return nil, err
}
task.S3Params.ObjectKey = objectKey
}
s3res := PutS3Result{
Region: task.S3Params.RegionName,
Endpoint: task.S3Params.RegionEndpoint,
Bucket: task.S3Params.Bucket,
Path: task.S3Params.ObjectKey,
Size: size,
}
return &s3res, nil
} | [
"func",
"(",
"a",
"*",
"S3Store",
")",
"PutS3",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"io",
".",
"Reader",
",",
"size",
"int64",
",",
"task",
"*",
"UploadTask",
",",
"previous",
"*",
"AttachmentInfo",
")",
"(",
"res",
"*",
"PutS3Result",
",",
"err",
"error",
")",
"{",
"defer",
"a",
".",
"Trace",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
",",
"\"",
"\"",
")",
"(",
")",
"\n",
"region",
":=",
"a",
".",
"regionFromParams",
"(",
"task",
".",
"S3Params",
")",
"\n",
"b",
":=",
"a",
".",
"s3Conn",
"(",
"task",
".",
"S3Signer",
",",
"region",
",",
"task",
".",
"S3Params",
".",
"AccessKey",
")",
".",
"Bucket",
"(",
"task",
".",
"S3Params",
".",
"Bucket",
")",
"\n\n",
"multiPartUpload",
":=",
"size",
">",
"minMultiSize",
"\n",
"if",
"multiPartUpload",
"&&",
"a",
".",
"env",
".",
"GetAttachmentDisableMulti",
"(",
")",
"{",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"size",
")",
"\n",
"multiPartUpload",
"=",
"false",
"\n",
"}",
"\n\n",
"if",
"!",
"multiPartUpload",
"{",
"if",
"err",
":=",
"a",
".",
"putSingle",
"(",
"ctx",
",",
"r",
",",
"size",
",",
"task",
".",
"S3Params",
",",
"b",
",",
"task",
".",
"Progress",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"objectKey",
",",
"err",
":=",
"a",
".",
"putMultiPipeline",
"(",
"ctx",
",",
"r",
",",
"size",
",",
"task",
",",
"b",
",",
"previous",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"task",
".",
"S3Params",
".",
"ObjectKey",
"=",
"objectKey",
"\n",
"}",
"\n\n",
"s3res",
":=",
"PutS3Result",
"{",
"Region",
":",
"task",
".",
"S3Params",
".",
"RegionName",
",",
"Endpoint",
":",
"task",
".",
"S3Params",
".",
"RegionEndpoint",
",",
"Bucket",
":",
"task",
".",
"S3Params",
".",
"Bucket",
",",
"Path",
":",
"task",
".",
"S3Params",
".",
"ObjectKey",
",",
"Size",
":",
"size",
",",
"}",
"\n",
"return",
"&",
"s3res",
",",
"nil",
"\n",
"}"
] | // PutS3 uploads the data in Reader r to S3. It chooses whether to use
// putSingle or putMultiPipeline based on the size of the object. | [
"PutS3",
"uploads",
"the",
"data",
"in",
"Reader",
"r",
"to",
"S3",
".",
"It",
"chooses",
"whether",
"to",
"use",
"putSingle",
"or",
"putMultiPipeline",
"based",
"on",
"the",
"size",
"of",
"the",
"object",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/s3.go#L85-L116 |
158,719 | keybase/client | go/chat/attachments/s3.go | putSingle | func (a *S3Store) putSingle(ctx context.Context, r io.Reader, size int64, params chat1.S3Params,
b s3.BucketInt, progress types.ProgressReporter) (err error) {
defer a.Trace(ctx, func() error { return err }, fmt.Sprintf("putSingle(size=%d)", size))()
progWriter := newProgressWriter(progress, size)
tee := io.TeeReader(r, progWriter)
if err := b.PutReader(ctx, params.ObjectKey, tee, size, "application/octet-stream", s3.ACL(params.Acl),
s3.Options{}); err != nil {
a.Debug(ctx, "putSingle: failed: %s", err)
return NewErrorWrapper("failed putSingle", err)
}
progWriter.Finish()
return nil
} | go | func (a *S3Store) putSingle(ctx context.Context, r io.Reader, size int64, params chat1.S3Params,
b s3.BucketInt, progress types.ProgressReporter) (err error) {
defer a.Trace(ctx, func() error { return err }, fmt.Sprintf("putSingle(size=%d)", size))()
progWriter := newProgressWriter(progress, size)
tee := io.TeeReader(r, progWriter)
if err := b.PutReader(ctx, params.ObjectKey, tee, size, "application/octet-stream", s3.ACL(params.Acl),
s3.Options{}); err != nil {
a.Debug(ctx, "putSingle: failed: %s", err)
return NewErrorWrapper("failed putSingle", err)
}
progWriter.Finish()
return nil
} | [
"func",
"(",
"a",
"*",
"S3Store",
")",
"putSingle",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"io",
".",
"Reader",
",",
"size",
"int64",
",",
"params",
"chat1",
".",
"S3Params",
",",
"b",
"s3",
".",
"BucketInt",
",",
"progress",
"types",
".",
"ProgressReporter",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"a",
".",
"Trace",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"size",
")",
")",
"(",
")",
"\n\n",
"progWriter",
":=",
"newProgressWriter",
"(",
"progress",
",",
"size",
")",
"\n",
"tee",
":=",
"io",
".",
"TeeReader",
"(",
"r",
",",
"progWriter",
")",
"\n\n",
"if",
"err",
":=",
"b",
".",
"PutReader",
"(",
"ctx",
",",
"params",
".",
"ObjectKey",
",",
"tee",
",",
"size",
",",
"\"",
"\"",
",",
"s3",
".",
"ACL",
"(",
"params",
".",
"Acl",
")",
",",
"s3",
".",
"Options",
"{",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"NewErrorWrapper",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"progWriter",
".",
"Finish",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // putSingle uploads data in r to S3 with the Put API. It has to be
// used for anything less than 5MB. It can be used for anything up
// to 5GB, but putMultiPipeline best for anything over 5MB. | [
"putSingle",
"uploads",
"data",
"in",
"r",
"to",
"S3",
"with",
"the",
"Put",
"API",
".",
"It",
"has",
"to",
"be",
"used",
"for",
"anything",
"less",
"than",
"5MB",
".",
"It",
"can",
"be",
"used",
"for",
"anything",
"up",
"to",
"5GB",
"but",
"putMultiPipeline",
"best",
"for",
"anything",
"over",
"5MB",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/s3.go#L121-L135 |
158,720 | keybase/client | go/chat/attachments/s3.go | makeBlockJobs | func (a *S3Store) makeBlockJobs(ctx context.Context, r io.Reader, blockCh chan job, stashKey StashKey, previous *AttachmentInfo) error {
var partNumber int
for {
partNumber++
block := make([]byte, blockSize)
// must call io.ReadFull to ensure full block read
n, err := io.ReadFull(r, block)
// io.ErrUnexpectedEOF will be returned for last partial block,
// which is ok.
if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
return err
}
if n < blockSize {
block = block[:n]
}
if n > 0 {
md5sum := md5.Sum(block)
md5hex := hex.EncodeToString(md5sum[:])
if previous != nil {
// resuming an upload, so check local stash record
// and abort on mismatch before adding a job for this block
// because if we don't it amounts to nonce reuse
lhash, found := previous.Parts[partNumber]
if found && lhash != md5hex {
a.Debug(ctx, "makeBlockJobs: part %d failed local part record verification", partNumber)
return ErrAbortOnPartMismatch
}
}
if err := a.addJob(ctx, blockCh, block, partNumber, md5hex); err != nil {
return err
}
}
if err == io.EOF || err == io.ErrUnexpectedEOF {
break
}
if a.blockLimit > 0 && partNumber >= a.blockLimit {
a.Debug(ctx, "makeBlockJobs: hit blockLimit of %d", a.blockLimit)
break
}
}
return nil
} | go | func (a *S3Store) makeBlockJobs(ctx context.Context, r io.Reader, blockCh chan job, stashKey StashKey, previous *AttachmentInfo) error {
var partNumber int
for {
partNumber++
block := make([]byte, blockSize)
// must call io.ReadFull to ensure full block read
n, err := io.ReadFull(r, block)
// io.ErrUnexpectedEOF will be returned for last partial block,
// which is ok.
if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
return err
}
if n < blockSize {
block = block[:n]
}
if n > 0 {
md5sum := md5.Sum(block)
md5hex := hex.EncodeToString(md5sum[:])
if previous != nil {
// resuming an upload, so check local stash record
// and abort on mismatch before adding a job for this block
// because if we don't it amounts to nonce reuse
lhash, found := previous.Parts[partNumber]
if found && lhash != md5hex {
a.Debug(ctx, "makeBlockJobs: part %d failed local part record verification", partNumber)
return ErrAbortOnPartMismatch
}
}
if err := a.addJob(ctx, blockCh, block, partNumber, md5hex); err != nil {
return err
}
}
if err == io.EOF || err == io.ErrUnexpectedEOF {
break
}
if a.blockLimit > 0 && partNumber >= a.blockLimit {
a.Debug(ctx, "makeBlockJobs: hit blockLimit of %d", a.blockLimit)
break
}
}
return nil
} | [
"func",
"(",
"a",
"*",
"S3Store",
")",
"makeBlockJobs",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"io",
".",
"Reader",
",",
"blockCh",
"chan",
"job",
",",
"stashKey",
"StashKey",
",",
"previous",
"*",
"AttachmentInfo",
")",
"error",
"{",
"var",
"partNumber",
"int",
"\n",
"for",
"{",
"partNumber",
"++",
"\n",
"block",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"blockSize",
")",
"\n",
"// must call io.ReadFull to ensure full block read",
"n",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"r",
",",
"block",
")",
"\n",
"// io.ErrUnexpectedEOF will be returned for last partial block,",
"// which is ok.",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"io",
".",
"ErrUnexpectedEOF",
"&&",
"err",
"!=",
"io",
".",
"EOF",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"n",
"<",
"blockSize",
"{",
"block",
"=",
"block",
"[",
":",
"n",
"]",
"\n",
"}",
"\n",
"if",
"n",
">",
"0",
"{",
"md5sum",
":=",
"md5",
".",
"Sum",
"(",
"block",
")",
"\n",
"md5hex",
":=",
"hex",
".",
"EncodeToString",
"(",
"md5sum",
"[",
":",
"]",
")",
"\n\n",
"if",
"previous",
"!=",
"nil",
"{",
"// resuming an upload, so check local stash record",
"// and abort on mismatch before adding a job for this block",
"// because if we don't it amounts to nonce reuse",
"lhash",
",",
"found",
":=",
"previous",
".",
"Parts",
"[",
"partNumber",
"]",
"\n",
"if",
"found",
"&&",
"lhash",
"!=",
"md5hex",
"{",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"partNumber",
")",
"\n",
"return",
"ErrAbortOnPartMismatch",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"a",
".",
"addJob",
"(",
"ctx",
",",
"blockCh",
",",
"block",
",",
"partNumber",
",",
"md5hex",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"||",
"err",
"==",
"io",
".",
"ErrUnexpectedEOF",
"{",
"break",
"\n",
"}",
"\n\n",
"if",
"a",
".",
"blockLimit",
">",
"0",
"&&",
"partNumber",
">=",
"a",
".",
"blockLimit",
"{",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"a",
".",
"blockLimit",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // makeBlockJobs reads ciphertext chunks from r and creates jobs that it puts onto blockCh.
// If this is a resumed upload, it verifies the blocks against the local stash before
// creating jobs. | [
"makeBlockJobs",
"reads",
"ciphertext",
"chunks",
"from",
"r",
"and",
"creates",
"jobs",
"that",
"it",
"puts",
"onto",
"blockCh",
".",
"If",
"this",
"is",
"a",
"resumed",
"upload",
"it",
"verifies",
"the",
"blocks",
"against",
"the",
"local",
"stash",
"before",
"creating",
"jobs",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/s3.go#L241-L285 |
158,721 | keybase/client | go/chat/attachments/s3.go | addJob | func (a *S3Store) addJob(ctx context.Context, blockCh chan job, block []byte, partNumber int, hash string) error {
// Create a job, unless the context has been canceled.
select {
case blockCh <- job{block: block, index: partNumber, hash: hash}:
return nil
case <-ctx.Done():
return ctx.Err()
}
} | go | func (a *S3Store) addJob(ctx context.Context, blockCh chan job, block []byte, partNumber int, hash string) error {
// Create a job, unless the context has been canceled.
select {
case blockCh <- job{block: block, index: partNumber, hash: hash}:
return nil
case <-ctx.Done():
return ctx.Err()
}
} | [
"func",
"(",
"a",
"*",
"S3Store",
")",
"addJob",
"(",
"ctx",
"context",
".",
"Context",
",",
"blockCh",
"chan",
"job",
",",
"block",
"[",
"]",
"byte",
",",
"partNumber",
"int",
",",
"hash",
"string",
")",
"error",
"{",
"// Create a job, unless the context has been canceled.",
"select",
"{",
"case",
"blockCh",
"<-",
"job",
"{",
"block",
":",
"block",
",",
"index",
":",
"partNumber",
",",
"hash",
":",
"hash",
"}",
":",
"return",
"nil",
"\n",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // addJob creates a job and puts it on blockCh, unless the blockCh isn't ready and the context has been canceled. | [
"addJob",
"creates",
"a",
"job",
"and",
"puts",
"it",
"on",
"blockCh",
"unless",
"the",
"blockCh",
"isn",
"t",
"ready",
"and",
"the",
"context",
"has",
"been",
"canceled",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/s3.go#L288-L296 |
158,722 | keybase/client | go/chat/attachments/s3.go | uploadPart | func (a *S3Store) uploadPart(ctx context.Context, task *UploadTask, b job, previous *AttachmentInfo, previousParts map[int]s3.Part, multi s3.MultiInt, retCh chan s3.Part) (err error) {
defer a.Trace(ctx, func() error { return err }, fmt.Sprintf("uploadPart(%d)", b.index))()
// check to see if this part has already been uploaded.
// for job `b` to be here, it has already passed local stash verification.
if previous != nil {
// check s3 previousParts for this block
p, ok := previousParts[b.index]
if ok && int(p.Size) == len(b.block) && p.ETag == b.etag() {
a.Debug(ctx, "uploadPart: part %d already uploaded to s3", b.index)
// part already uploaded, so put it in the retCh unless the context
// has been canceled
select {
case retCh <- p:
case <-ctx.Done():
return ctx.Err()
}
// nothing else to do
return nil
}
if p.Size > 0 {
// only abort if the part size from s3 is > 0.
a.Debug(ctx, "uploadPart: part %d s3 mismatch: size %d != expected %d or etag %s != expected %s",
b.index, p.Size, len(b.block), p.ETag, b.etag())
return ErrAbortOnPartMismatch
}
// this part doesn't exist on s3, so it needs to be uploaded
a.Debug(ctx, "uploadPart: part %d not uploaded to s3 by previous upload attempt", b.index)
}
// stash part info locally before attempting S3 put
// doing this before attempting the S3 put is important
// for security concerns.
if err := a.stash.RecordPart(task.stashKey(), b.index, b.hash); err != nil {
a.Debug(ctx, "uploadPart: StashRecordPart error: %s", err)
}
part, putErr := multi.PutPart(ctx, b.index, bytes.NewReader(b.block))
if putErr != nil {
return NewErrorWrapper(fmt.Sprintf("failed to put part %d", b.index), putErr)
}
// put the successfully uploaded part information in the retCh
// unless the context has been canceled.
select {
case retCh <- part:
case <-ctx.Done():
a.Debug(ctx, "uploadPart: upload part %d, context canceled", b.index)
return ctx.Err()
}
return nil
} | go | func (a *S3Store) uploadPart(ctx context.Context, task *UploadTask, b job, previous *AttachmentInfo, previousParts map[int]s3.Part, multi s3.MultiInt, retCh chan s3.Part) (err error) {
defer a.Trace(ctx, func() error { return err }, fmt.Sprintf("uploadPart(%d)", b.index))()
// check to see if this part has already been uploaded.
// for job `b` to be here, it has already passed local stash verification.
if previous != nil {
// check s3 previousParts for this block
p, ok := previousParts[b.index]
if ok && int(p.Size) == len(b.block) && p.ETag == b.etag() {
a.Debug(ctx, "uploadPart: part %d already uploaded to s3", b.index)
// part already uploaded, so put it in the retCh unless the context
// has been canceled
select {
case retCh <- p:
case <-ctx.Done():
return ctx.Err()
}
// nothing else to do
return nil
}
if p.Size > 0 {
// only abort if the part size from s3 is > 0.
a.Debug(ctx, "uploadPart: part %d s3 mismatch: size %d != expected %d or etag %s != expected %s",
b.index, p.Size, len(b.block), p.ETag, b.etag())
return ErrAbortOnPartMismatch
}
// this part doesn't exist on s3, so it needs to be uploaded
a.Debug(ctx, "uploadPart: part %d not uploaded to s3 by previous upload attempt", b.index)
}
// stash part info locally before attempting S3 put
// doing this before attempting the S3 put is important
// for security concerns.
if err := a.stash.RecordPart(task.stashKey(), b.index, b.hash); err != nil {
a.Debug(ctx, "uploadPart: StashRecordPart error: %s", err)
}
part, putErr := multi.PutPart(ctx, b.index, bytes.NewReader(b.block))
if putErr != nil {
return NewErrorWrapper(fmt.Sprintf("failed to put part %d", b.index), putErr)
}
// put the successfully uploaded part information in the retCh
// unless the context has been canceled.
select {
case retCh <- part:
case <-ctx.Done():
a.Debug(ctx, "uploadPart: upload part %d, context canceled", b.index)
return ctx.Err()
}
return nil
} | [
"func",
"(",
"a",
"*",
"S3Store",
")",
"uploadPart",
"(",
"ctx",
"context",
".",
"Context",
",",
"task",
"*",
"UploadTask",
",",
"b",
"job",
",",
"previous",
"*",
"AttachmentInfo",
",",
"previousParts",
"map",
"[",
"int",
"]",
"s3",
".",
"Part",
",",
"multi",
"s3",
".",
"MultiInt",
",",
"retCh",
"chan",
"s3",
".",
"Part",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"a",
".",
"Trace",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"index",
")",
")",
"(",
")",
"\n\n",
"// check to see if this part has already been uploaded.",
"// for job `b` to be here, it has already passed local stash verification.",
"if",
"previous",
"!=",
"nil",
"{",
"// check s3 previousParts for this block",
"p",
",",
"ok",
":=",
"previousParts",
"[",
"b",
".",
"index",
"]",
"\n",
"if",
"ok",
"&&",
"int",
"(",
"p",
".",
"Size",
")",
"==",
"len",
"(",
"b",
".",
"block",
")",
"&&",
"p",
".",
"ETag",
"==",
"b",
".",
"etag",
"(",
")",
"{",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"b",
".",
"index",
")",
"\n\n",
"// part already uploaded, so put it in the retCh unless the context",
"// has been canceled",
"select",
"{",
"case",
"retCh",
"<-",
"p",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"}",
"\n\n",
"// nothing else to do",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"p",
".",
"Size",
">",
"0",
"{",
"// only abort if the part size from s3 is > 0.",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"b",
".",
"index",
",",
"p",
".",
"Size",
",",
"len",
"(",
"b",
".",
"block",
")",
",",
"p",
".",
"ETag",
",",
"b",
".",
"etag",
"(",
")",
")",
"\n",
"return",
"ErrAbortOnPartMismatch",
"\n",
"}",
"\n\n",
"// this part doesn't exist on s3, so it needs to be uploaded",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"b",
".",
"index",
")",
"\n",
"}",
"\n\n",
"// stash part info locally before attempting S3 put",
"// doing this before attempting the S3 put is important",
"// for security concerns.",
"if",
"err",
":=",
"a",
".",
"stash",
".",
"RecordPart",
"(",
"task",
".",
"stashKey",
"(",
")",
",",
"b",
".",
"index",
",",
"b",
".",
"hash",
")",
";",
"err",
"!=",
"nil",
"{",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"part",
",",
"putErr",
":=",
"multi",
".",
"PutPart",
"(",
"ctx",
",",
"b",
".",
"index",
",",
"bytes",
".",
"NewReader",
"(",
"b",
".",
"block",
")",
")",
"\n",
"if",
"putErr",
"!=",
"nil",
"{",
"return",
"NewErrorWrapper",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"index",
")",
",",
"putErr",
")",
"\n",
"}",
"\n\n",
"// put the successfully uploaded part information in the retCh",
"// unless the context has been canceled.",
"select",
"{",
"case",
"retCh",
"<-",
"part",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"a",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"b",
".",
"index",
")",
"\n",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // uploadPart handles uploading a job to S3. The job `b` has already passed local stash verification.
// If this is a resumed upload, it checks the previous parts reported by S3 and will skip uploading
// any that already exist. | [
"uploadPart",
"handles",
"uploading",
"a",
"job",
"to",
"S3",
".",
"The",
"job",
"b",
"has",
"already",
"passed",
"local",
"stash",
"verification",
".",
"If",
"this",
"is",
"a",
"resumed",
"upload",
"it",
"checks",
"the",
"previous",
"parts",
"reported",
"by",
"S3",
"and",
"will",
"skip",
"uploading",
"any",
"that",
"already",
"exist",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/s3.go#L301-L357 |
158,723 | keybase/client | go/teams/box.go | Open | func (t *TeamBox) Open(encKey *libkb.NaclDHKeyPair) (keybase1.PerTeamKeySeed, error) {
var ret keybase1.PerTeamKeySeed
nonce, err := t.nonceBytes()
if err != nil {
return ret, err
}
ctext, err := t.ctextBytes()
if err != nil {
return ret, err
}
nei := &libkb.NaclEncryptionInfo{
Ciphertext: ctext,
EncryptionType: kbcrypto.KIDNaclDH,
Nonce: nonce,
Receiver: encKey.GetKID().ToBytes(),
Sender: t.SenderKID.ToBytes(),
}
plaintext, _, err := encKey.Decrypt(nei)
if err != nil {
return ret, err
}
return libkb.MakeByte32Soft(plaintext)
} | go | func (t *TeamBox) Open(encKey *libkb.NaclDHKeyPair) (keybase1.PerTeamKeySeed, error) {
var ret keybase1.PerTeamKeySeed
nonce, err := t.nonceBytes()
if err != nil {
return ret, err
}
ctext, err := t.ctextBytes()
if err != nil {
return ret, err
}
nei := &libkb.NaclEncryptionInfo{
Ciphertext: ctext,
EncryptionType: kbcrypto.KIDNaclDH,
Nonce: nonce,
Receiver: encKey.GetKID().ToBytes(),
Sender: t.SenderKID.ToBytes(),
}
plaintext, _, err := encKey.Decrypt(nei)
if err != nil {
return ret, err
}
return libkb.MakeByte32Soft(plaintext)
} | [
"func",
"(",
"t",
"*",
"TeamBox",
")",
"Open",
"(",
"encKey",
"*",
"libkb",
".",
"NaclDHKeyPair",
")",
"(",
"keybase1",
".",
"PerTeamKeySeed",
",",
"error",
")",
"{",
"var",
"ret",
"keybase1",
".",
"PerTeamKeySeed",
"\n\n",
"nonce",
",",
"err",
":=",
"t",
".",
"nonceBytes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ret",
",",
"err",
"\n",
"}",
"\n",
"ctext",
",",
"err",
":=",
"t",
".",
"ctextBytes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ret",
",",
"err",
"\n",
"}",
"\n",
"nei",
":=",
"&",
"libkb",
".",
"NaclEncryptionInfo",
"{",
"Ciphertext",
":",
"ctext",
",",
"EncryptionType",
":",
"kbcrypto",
".",
"KIDNaclDH",
",",
"Nonce",
":",
"nonce",
",",
"Receiver",
":",
"encKey",
".",
"GetKID",
"(",
")",
".",
"ToBytes",
"(",
")",
",",
"Sender",
":",
"t",
".",
"SenderKID",
".",
"ToBytes",
"(",
")",
",",
"}",
"\n\n",
"plaintext",
",",
"_",
",",
"err",
":=",
"encKey",
".",
"Decrypt",
"(",
"nei",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ret",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"libkb",
".",
"MakeByte32Soft",
"(",
"plaintext",
")",
"\n",
"}"
] | // Open decrypts Ctext using encKey. | [
"Open",
"decrypts",
"Ctext",
"using",
"encKey",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/box.go#L21-L46 |
158,724 | keybase/client | go/kbfs/libkbfs/count_meter.go | NewCountMeter | func NewCountMeter() *CountMeter {
m := &CountMeter{
counters: make([]int64, 16),
shutdownCh: make(chan struct{}),
}
go m.run()
return m
} | go | func NewCountMeter() *CountMeter {
m := &CountMeter{
counters: make([]int64, 16),
shutdownCh: make(chan struct{}),
}
go m.run()
return m
} | [
"func",
"NewCountMeter",
"(",
")",
"*",
"CountMeter",
"{",
"m",
":=",
"&",
"CountMeter",
"{",
"counters",
":",
"make",
"(",
"[",
"]",
"int64",
",",
"16",
")",
",",
"shutdownCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"go",
"m",
".",
"run",
"(",
")",
"\n\n",
"return",
"m",
"\n",
"}"
] | // NewCountMeter returns a new CountMeter. | [
"NewCountMeter",
"returns",
"a",
"new",
"CountMeter",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L61-L69 |
158,725 | keybase/client | go/kbfs/libkbfs/count_meter.go | Count | func (m *CountMeter) Count() int64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.overall
} | go | func (m *CountMeter) Count() int64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.overall
} | [
"func",
"(",
"m",
"*",
"CountMeter",
")",
"Count",
"(",
")",
"int64",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"m",
".",
"overall",
"\n",
"}"
] | // Count returns the overall count. | [
"Count",
"returns",
"the",
"overall",
"count",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L72-L76 |
158,726 | keybase/client | go/kbfs/libkbfs/count_meter.go | Mark | func (m *CountMeter) Mark(i int64) {
m.mtx.Lock()
defer m.mtx.Unlock()
m.counters[0] += i
m.overall += i
} | go | func (m *CountMeter) Mark(i int64) {
m.mtx.Lock()
defer m.mtx.Unlock()
m.counters[0] += i
m.overall += i
} | [
"func",
"(",
"m",
"*",
"CountMeter",
")",
"Mark",
"(",
"i",
"int64",
")",
"{",
"m",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"m",
".",
"counters",
"[",
"0",
"]",
"+=",
"i",
"\n",
"m",
".",
"overall",
"+=",
"i",
"\n",
"}"
] | // Mark ticks the counters. | [
"Mark",
"ticks",
"the",
"counters",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L79-L84 |
158,727 | keybase/client | go/kbfs/libkbfs/count_meter.go | Rate1 | func (m *CountMeter) Rate1() float64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.rate1()
} | go | func (m *CountMeter) Rate1() float64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.rate1()
} | [
"func",
"(",
"m",
"*",
"CountMeter",
")",
"Rate1",
"(",
")",
"float64",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"m",
".",
"rate1",
"(",
")",
"\n",
"}"
] | // Rate1 returns the number of ticks in the last 1 minute. | [
"Rate1",
"returns",
"the",
"number",
"of",
"ticks",
"in",
"the",
"last",
"1",
"minute",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L111-L115 |
158,728 | keybase/client | go/kbfs/libkbfs/count_meter.go | Rate5 | func (m *CountMeter) Rate5() float64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.rate5()
} | go | func (m *CountMeter) Rate5() float64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.rate5()
} | [
"func",
"(",
"m",
"*",
"CountMeter",
")",
"Rate5",
"(",
")",
"float64",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"m",
".",
"rate5",
"(",
")",
"\n",
"}"
] | // Rate5 returns the number of ticks in the last 5 minutes. | [
"Rate5",
"returns",
"the",
"number",
"of",
"ticks",
"in",
"the",
"last",
"5",
"minutes",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L118-L122 |
158,729 | keybase/client | go/kbfs/libkbfs/count_meter.go | Rate15 | func (m *CountMeter) Rate15() float64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.rate15()
} | go | func (m *CountMeter) Rate15() float64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.rate15()
} | [
"func",
"(",
"m",
"*",
"CountMeter",
")",
"Rate15",
"(",
")",
"float64",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"m",
".",
"rate15",
"(",
")",
"\n",
"}"
] | // Rate15 returns the number of ticks in the last 15 minutes. | [
"Rate15",
"returns",
"the",
"number",
"of",
"ticks",
"in",
"the",
"last",
"15",
"minutes",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L125-L129 |
158,730 | keybase/client | go/kbfs/libkbfs/count_meter.go | RateMean | func (m *CountMeter) RateMean() float64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.rateMean()
} | go | func (m *CountMeter) RateMean() float64 {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.rateMean()
} | [
"func",
"(",
"m",
"*",
"CountMeter",
")",
"RateMean",
"(",
")",
"float64",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"m",
".",
"rateMean",
"(",
")",
"\n",
"}"
] | // RateMean returns the overall count of ticks. | [
"RateMean",
"returns",
"the",
"overall",
"count",
"of",
"ticks",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L132-L136 |
158,731 | keybase/client | go/kbfs/libkbfs/count_meter.go | Snapshot | func (m *CountMeter) Snapshot() metrics.Meter {
m.mtx.RLock()
defer m.mtx.RUnlock()
return &MeterSnapshot{
m.overall,
m.rate1(),
m.rate5(),
m.rate15(),
m.rateMean(),
}
} | go | func (m *CountMeter) Snapshot() metrics.Meter {
m.mtx.RLock()
defer m.mtx.RUnlock()
return &MeterSnapshot{
m.overall,
m.rate1(),
m.rate5(),
m.rate15(),
m.rateMean(),
}
} | [
"func",
"(",
"m",
"*",
"CountMeter",
")",
"Snapshot",
"(",
")",
"metrics",
".",
"Meter",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"&",
"MeterSnapshot",
"{",
"m",
".",
"overall",
",",
"m",
".",
"rate1",
"(",
")",
",",
"m",
".",
"rate5",
"(",
")",
",",
"m",
".",
"rate15",
"(",
")",
",",
"m",
".",
"rateMean",
"(",
")",
",",
"}",
"\n",
"}"
] | // Snapshot returns the snapshot in time of this CountMeter. | [
"Snapshot",
"returns",
"the",
"snapshot",
"in",
"time",
"of",
"this",
"CountMeter",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L139-L149 |
158,732 | keybase/client | go/kbfs/libkbfs/count_meter.go | Shutdown | func (m *CountMeter) Shutdown() <-chan struct{} {
select {
case <-m.shutdownCh:
default:
close(m.shutdownCh)
}
return m.shutdownCh
} | go | func (m *CountMeter) Shutdown() <-chan struct{} {
select {
case <-m.shutdownCh:
default:
close(m.shutdownCh)
}
return m.shutdownCh
} | [
"func",
"(",
"m",
"*",
"CountMeter",
")",
"Shutdown",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"select",
"{",
"case",
"<-",
"m",
".",
"shutdownCh",
":",
"default",
":",
"close",
"(",
"m",
".",
"shutdownCh",
")",
"\n",
"}",
"\n",
"return",
"m",
".",
"shutdownCh",
"\n",
"}"
] | // Shutdown shuts down this CountMeter. | [
"Shutdown",
"shuts",
"down",
"this",
"CountMeter",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/count_meter.go#L152-L159 |
158,733 | keybase/client | go/kbfs/data/dir_data.go | NewDirData | func NewDirData(
dir Path, chargedTo keybase1.UserOrTeamID, bsplit BlockSplitter,
kmd libkey.KeyMetadata, getter dirBlockGetter, cacher dirtyBlockCacher,
log logger.Logger, vlog *libkb.VDebugLog) *DirData {
dd := &DirData{
getter: getter,
}
dd.tree = &blockTree{
file: dir,
chargedTo: chargedTo,
kmd: kmd,
bsplit: bsplit,
getter: dd.blockGetter,
cacher: cacher,
log: log,
vlog: vlog,
}
return dd
} | go | func NewDirData(
dir Path, chargedTo keybase1.UserOrTeamID, bsplit BlockSplitter,
kmd libkey.KeyMetadata, getter dirBlockGetter, cacher dirtyBlockCacher,
log logger.Logger, vlog *libkb.VDebugLog) *DirData {
dd := &DirData{
getter: getter,
}
dd.tree = &blockTree{
file: dir,
chargedTo: chargedTo,
kmd: kmd,
bsplit: bsplit,
getter: dd.blockGetter,
cacher: cacher,
log: log,
vlog: vlog,
}
return dd
} | [
"func",
"NewDirData",
"(",
"dir",
"Path",
",",
"chargedTo",
"keybase1",
".",
"UserOrTeamID",
",",
"bsplit",
"BlockSplitter",
",",
"kmd",
"libkey",
".",
"KeyMetadata",
",",
"getter",
"dirBlockGetter",
",",
"cacher",
"dirtyBlockCacher",
",",
"log",
"logger",
".",
"Logger",
",",
"vlog",
"*",
"libkb",
".",
"VDebugLog",
")",
"*",
"DirData",
"{",
"dd",
":=",
"&",
"DirData",
"{",
"getter",
":",
"getter",
",",
"}",
"\n",
"dd",
".",
"tree",
"=",
"&",
"blockTree",
"{",
"file",
":",
"dir",
",",
"chargedTo",
":",
"chargedTo",
",",
"kmd",
":",
"kmd",
",",
"bsplit",
":",
"bsplit",
",",
"getter",
":",
"dd",
".",
"blockGetter",
",",
"cacher",
":",
"cacher",
",",
"log",
":",
"log",
",",
"vlog",
":",
"vlog",
",",
"}",
"\n",
"return",
"dd",
"\n",
"}"
] | // NewDirData creates a new DirData instance. | [
"NewDirData",
"creates",
"a",
"new",
"DirData",
"instance",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L34-L52 |
158,734 | keybase/client | go/kbfs/data/dir_data.go | GetTopBlock | func (dd *DirData) GetTopBlock(ctx context.Context, rtype BlockReqType) (
*DirBlock, error) {
topBlock, _, err := dd.getter(
ctx, dd.tree.kmd, dd.rootBlockPointer(), dd.tree.file, rtype)
if err != nil {
return nil, err
}
return topBlock, nil
} | go | func (dd *DirData) GetTopBlock(ctx context.Context, rtype BlockReqType) (
*DirBlock, error) {
topBlock, _, err := dd.getter(
ctx, dd.tree.kmd, dd.rootBlockPointer(), dd.tree.file, rtype)
if err != nil {
return nil, err
}
return topBlock, nil
} | [
"func",
"(",
"dd",
"*",
"DirData",
")",
"GetTopBlock",
"(",
"ctx",
"context",
".",
"Context",
",",
"rtype",
"BlockReqType",
")",
"(",
"*",
"DirBlock",
",",
"error",
")",
"{",
"topBlock",
",",
"_",
",",
"err",
":=",
"dd",
".",
"getter",
"(",
"ctx",
",",
"dd",
".",
"tree",
".",
"kmd",
",",
"dd",
".",
"rootBlockPointer",
"(",
")",
",",
"dd",
".",
"tree",
".",
"file",
",",
"rtype",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"topBlock",
",",
"nil",
"\n",
"}"
] | // GetTopBlock returns the top-most block in this directory block tree. | [
"GetTopBlock",
"returns",
"the",
"top",
"-",
"most",
"block",
"in",
"this",
"directory",
"block",
"tree",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L72-L80 |
158,735 | keybase/client | go/kbfs/data/dir_data.go | GetChildren | func (dd *DirData) GetChildren(ctx context.Context) (
children map[string]EntryInfo, err error) {
topBlock, err := dd.GetTopBlock(ctx, BlockRead)
if err != nil {
return nil, err
}
_, blocks, _, err := dd.tree.getBlocksForOffsetRange(
ctx, dd.rootBlockPointer(), topBlock, topBlock.FirstOffset(), nil,
false, true)
if err != nil {
return nil, err
}
numEntries := 0
for _, b := range blocks {
numEntries += len(b.(*DirBlock).Children)
}
children = make(map[string]EntryInfo, numEntries)
for _, b := range blocks {
for k, de := range b.(*DirBlock).Children {
if hiddenEntries[k] {
continue
}
children[k] = de.EntryInfo
}
}
return children, nil
} | go | func (dd *DirData) GetChildren(ctx context.Context) (
children map[string]EntryInfo, err error) {
topBlock, err := dd.GetTopBlock(ctx, BlockRead)
if err != nil {
return nil, err
}
_, blocks, _, err := dd.tree.getBlocksForOffsetRange(
ctx, dd.rootBlockPointer(), topBlock, topBlock.FirstOffset(), nil,
false, true)
if err != nil {
return nil, err
}
numEntries := 0
for _, b := range blocks {
numEntries += len(b.(*DirBlock).Children)
}
children = make(map[string]EntryInfo, numEntries)
for _, b := range blocks {
for k, de := range b.(*DirBlock).Children {
if hiddenEntries[k] {
continue
}
children[k] = de.EntryInfo
}
}
return children, nil
} | [
"func",
"(",
"dd",
"*",
"DirData",
")",
"GetChildren",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"children",
"map",
"[",
"string",
"]",
"EntryInfo",
",",
"err",
"error",
")",
"{",
"topBlock",
",",
"err",
":=",
"dd",
".",
"GetTopBlock",
"(",
"ctx",
",",
"BlockRead",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"blocks",
",",
"_",
",",
"err",
":=",
"dd",
".",
"tree",
".",
"getBlocksForOffsetRange",
"(",
"ctx",
",",
"dd",
".",
"rootBlockPointer",
"(",
")",
",",
"topBlock",
",",
"topBlock",
".",
"FirstOffset",
"(",
")",
",",
"nil",
",",
"false",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"numEntries",
":=",
"0",
"\n",
"for",
"_",
",",
"b",
":=",
"range",
"blocks",
"{",
"numEntries",
"+=",
"len",
"(",
"b",
".",
"(",
"*",
"DirBlock",
")",
".",
"Children",
")",
"\n",
"}",
"\n",
"children",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"EntryInfo",
",",
"numEntries",
")",
"\n",
"for",
"_",
",",
"b",
":=",
"range",
"blocks",
"{",
"for",
"k",
",",
"de",
":=",
"range",
"b",
".",
"(",
"*",
"DirBlock",
")",
".",
"Children",
"{",
"if",
"hiddenEntries",
"[",
"k",
"]",
"{",
"continue",
"\n",
"}",
"\n",
"children",
"[",
"k",
"]",
"=",
"de",
".",
"EntryInfo",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"children",
",",
"nil",
"\n",
"}"
] | // GetChildren returns a map of all the child EntryInfos in this
// directory. | [
"GetChildren",
"returns",
"a",
"map",
"of",
"all",
"the",
"child",
"EntryInfos",
"in",
"this",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L84-L112 |
158,736 | keybase/client | go/kbfs/data/dir_data.go | Lookup | func (dd *DirData) Lookup(ctx context.Context, name string) (DirEntry, error) {
topBlock, err := dd.GetTopBlock(ctx, BlockRead)
if err != nil {
return DirEntry{}, err
}
off := StringOffset(name)
_, _, block, _, _, _, err := dd.tree.getBlockAtOffset(
ctx, topBlock, &off, BlockLookup)
if err != nil {
return DirEntry{}, err
}
de, ok := block.(*DirBlock).Children[name]
if !ok {
return DirEntry{}, idutil.NoSuchNameError{Name: name}
}
return de, nil
} | go | func (dd *DirData) Lookup(ctx context.Context, name string) (DirEntry, error) {
topBlock, err := dd.GetTopBlock(ctx, BlockRead)
if err != nil {
return DirEntry{}, err
}
off := StringOffset(name)
_, _, block, _, _, _, err := dd.tree.getBlockAtOffset(
ctx, topBlock, &off, BlockLookup)
if err != nil {
return DirEntry{}, err
}
de, ok := block.(*DirBlock).Children[name]
if !ok {
return DirEntry{}, idutil.NoSuchNameError{Name: name}
}
return de, nil
} | [
"func",
"(",
"dd",
"*",
"DirData",
")",
"Lookup",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"DirEntry",
",",
"error",
")",
"{",
"topBlock",
",",
"err",
":=",
"dd",
".",
"GetTopBlock",
"(",
"ctx",
",",
"BlockRead",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"DirEntry",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"off",
":=",
"StringOffset",
"(",
"name",
")",
"\n",
"_",
",",
"_",
",",
"block",
",",
"_",
",",
"_",
",",
"_",
",",
"err",
":=",
"dd",
".",
"tree",
".",
"getBlockAtOffset",
"(",
"ctx",
",",
"topBlock",
",",
"&",
"off",
",",
"BlockLookup",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"DirEntry",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"de",
",",
"ok",
":=",
"block",
".",
"(",
"*",
"DirBlock",
")",
".",
"Children",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"DirEntry",
"{",
"}",
",",
"idutil",
".",
"NoSuchNameError",
"{",
"Name",
":",
"name",
"}",
"\n",
"}",
"\n",
"return",
"de",
",",
"nil",
"\n",
"}"
] | // Lookup returns the DirEntry for the given entry named by `name` in
// this directory. | [
"Lookup",
"returns",
"the",
"DirEntry",
"for",
"the",
"given",
"entry",
"named",
"by",
"name",
"in",
"this",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L145-L163 |
158,737 | keybase/client | go/kbfs/data/dir_data.go | AddEntry | func (dd *DirData) AddEntry(
ctx context.Context, newName string, newDe DirEntry) (
unrefs []BlockInfo, err error) {
return dd.addEntryHelper(ctx, newName, newDe, true, false)
} | go | func (dd *DirData) AddEntry(
ctx context.Context, newName string, newDe DirEntry) (
unrefs []BlockInfo, err error) {
return dd.addEntryHelper(ctx, newName, newDe, true, false)
} | [
"func",
"(",
"dd",
"*",
"DirData",
")",
"AddEntry",
"(",
"ctx",
"context",
".",
"Context",
",",
"newName",
"string",
",",
"newDe",
"DirEntry",
")",
"(",
"unrefs",
"[",
"]",
"BlockInfo",
",",
"err",
"error",
")",
"{",
"return",
"dd",
".",
"addEntryHelper",
"(",
"ctx",
",",
"newName",
",",
"newDe",
",",
"true",
",",
"false",
")",
"\n",
"}"
] | // AddEntry adds a new entry to this directory. | [
"AddEntry",
"adds",
"a",
"new",
"entry",
"to",
"this",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L300-L304 |
158,738 | keybase/client | go/kbfs/data/dir_data.go | UpdateEntry | func (dd *DirData) UpdateEntry(
ctx context.Context, name string, newDe DirEntry) (
unrefs []BlockInfo, err error) {
return dd.addEntryHelper(ctx, name, newDe, false, true)
} | go | func (dd *DirData) UpdateEntry(
ctx context.Context, name string, newDe DirEntry) (
unrefs []BlockInfo, err error) {
return dd.addEntryHelper(ctx, name, newDe, false, true)
} | [
"func",
"(",
"dd",
"*",
"DirData",
")",
"UpdateEntry",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"newDe",
"DirEntry",
")",
"(",
"unrefs",
"[",
"]",
"BlockInfo",
",",
"err",
"error",
")",
"{",
"return",
"dd",
".",
"addEntryHelper",
"(",
"ctx",
",",
"name",
",",
"newDe",
",",
"false",
",",
"true",
")",
"\n",
"}"
] | // UpdateEntry updates an existing entry to this directory. | [
"UpdateEntry",
"updates",
"an",
"existing",
"entry",
"to",
"this",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L307-L311 |
158,739 | keybase/client | go/kbfs/data/dir_data.go | RemoveEntry | func (dd *DirData) RemoveEntry(ctx context.Context, name string) (
unrefs []BlockInfo, err error) {
topBlock, err := dd.GetTopBlock(ctx, BlockWrite)
if err != nil {
return nil, err
}
off := StringOffset(name)
ptr, parentBlocks, block, _, _, _, err := dd.tree.getBlockAtOffset(
ctx, topBlock, &off, BlockWrite)
if err != nil {
return nil, err
}
dblock := block.(*DirBlock)
if _, exists := dblock.Children[name]; !exists {
// Nothing to do.
return nil, nil
}
delete(dblock.Children, name)
// For now, just leave the block empty, at its current place in
// the tree. TODO: remove empty blocks all the way up the tree
// and shift parent pointers around as needed.
return dd.processModifiedBlock(ctx, ptr, parentBlocks, dblock)
} | go | func (dd *DirData) RemoveEntry(ctx context.Context, name string) (
unrefs []BlockInfo, err error) {
topBlock, err := dd.GetTopBlock(ctx, BlockWrite)
if err != nil {
return nil, err
}
off := StringOffset(name)
ptr, parentBlocks, block, _, _, _, err := dd.tree.getBlockAtOffset(
ctx, topBlock, &off, BlockWrite)
if err != nil {
return nil, err
}
dblock := block.(*DirBlock)
if _, exists := dblock.Children[name]; !exists {
// Nothing to do.
return nil, nil
}
delete(dblock.Children, name)
// For now, just leave the block empty, at its current place in
// the tree. TODO: remove empty blocks all the way up the tree
// and shift parent pointers around as needed.
return dd.processModifiedBlock(ctx, ptr, parentBlocks, dblock)
} | [
"func",
"(",
"dd",
"*",
"DirData",
")",
"RemoveEntry",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"unrefs",
"[",
"]",
"BlockInfo",
",",
"err",
"error",
")",
"{",
"topBlock",
",",
"err",
":=",
"dd",
".",
"GetTopBlock",
"(",
"ctx",
",",
"BlockWrite",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"off",
":=",
"StringOffset",
"(",
"name",
")",
"\n",
"ptr",
",",
"parentBlocks",
",",
"block",
",",
"_",
",",
"_",
",",
"_",
",",
"err",
":=",
"dd",
".",
"tree",
".",
"getBlockAtOffset",
"(",
"ctx",
",",
"topBlock",
",",
"&",
"off",
",",
"BlockWrite",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"dblock",
":=",
"block",
".",
"(",
"*",
"DirBlock",
")",
"\n\n",
"if",
"_",
",",
"exists",
":=",
"dblock",
".",
"Children",
"[",
"name",
"]",
";",
"!",
"exists",
"{",
"// Nothing to do.",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"delete",
"(",
"dblock",
".",
"Children",
",",
"name",
")",
"\n\n",
"// For now, just leave the block empty, at its current place in",
"// the tree. TODO: remove empty blocks all the way up the tree",
"// and shift parent pointers around as needed.",
"return",
"dd",
".",
"processModifiedBlock",
"(",
"ctx",
",",
"ptr",
",",
"parentBlocks",
",",
"dblock",
")",
"\n",
"}"
] | // RemoveEntry removes an entry from this directory. | [
"RemoveEntry",
"removes",
"an",
"entry",
"from",
"this",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L321-L346 |
158,740 | keybase/client | go/kbfs/data/dir_data.go | Ready | func (dd *DirData) Ready(ctx context.Context, id tlf.ID,
bcache BlockCache, dirtyBcache IsDirtyProvider,
rp ReadyProvider, bps BlockPutState,
topBlock *DirBlock) (map[BlockInfo]BlockPointer, error) {
return dd.tree.ready(
ctx, id, bcache, dirtyBcache, rp, bps, topBlock, nil)
} | go | func (dd *DirData) Ready(ctx context.Context, id tlf.ID,
bcache BlockCache, dirtyBcache IsDirtyProvider,
rp ReadyProvider, bps BlockPutState,
topBlock *DirBlock) (map[BlockInfo]BlockPointer, error) {
return dd.tree.ready(
ctx, id, bcache, dirtyBcache, rp, bps, topBlock, nil)
} | [
"func",
"(",
"dd",
"*",
"DirData",
")",
"Ready",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
",",
"bcache",
"BlockCache",
",",
"dirtyBcache",
"IsDirtyProvider",
",",
"rp",
"ReadyProvider",
",",
"bps",
"BlockPutState",
",",
"topBlock",
"*",
"DirBlock",
")",
"(",
"map",
"[",
"BlockInfo",
"]",
"BlockPointer",
",",
"error",
")",
"{",
"return",
"dd",
".",
"tree",
".",
"ready",
"(",
"ctx",
",",
"id",
",",
"bcache",
",",
"dirtyBcache",
",",
"rp",
",",
"bps",
",",
"topBlock",
",",
"nil",
")",
"\n",
"}"
] | // Ready readies all the dirty child blocks for a directory tree with
// an indirect top-block, and updates their block IDs in their parent
// block's list of indirect pointers. It returns a map pointing from
// the new block info from any readied block to its corresponding old
// block pointer. | [
"Ready",
"readies",
"all",
"the",
"dirty",
"child",
"blocks",
"for",
"a",
"directory",
"tree",
"with",
"an",
"indirect",
"top",
"-",
"block",
"and",
"updates",
"their",
"block",
"IDs",
"in",
"their",
"parent",
"block",
"s",
"list",
"of",
"indirect",
"pointers",
".",
"It",
"returns",
"a",
"map",
"pointing",
"from",
"the",
"new",
"block",
"info",
"from",
"any",
"readied",
"block",
"to",
"its",
"corresponding",
"old",
"block",
"pointer",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L353-L359 |
158,741 | keybase/client | go/kbfs/data/dir_data.go | GetIndirectDirBlockInfos | func (dd *DirData) GetIndirectDirBlockInfos(ctx context.Context) (
[]BlockInfo, error) {
return dd.tree.getIndirectBlockInfos(ctx)
} | go | func (dd *DirData) GetIndirectDirBlockInfos(ctx context.Context) (
[]BlockInfo, error) {
return dd.tree.getIndirectBlockInfos(ctx)
} | [
"func",
"(",
"dd",
"*",
"DirData",
")",
"GetIndirectDirBlockInfos",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"BlockInfo",
",",
"error",
")",
"{",
"return",
"dd",
".",
"tree",
".",
"getIndirectBlockInfos",
"(",
"ctx",
")",
"\n",
"}"
] | // GetIndirectDirBlockInfos returns all of the BlockInfos for blocks
// pointed to by indirect blocks within this directory tree. | [
"GetIndirectDirBlockInfos",
"returns",
"all",
"of",
"the",
"BlockInfos",
"for",
"blocks",
"pointed",
"to",
"by",
"indirect",
"blocks",
"within",
"this",
"directory",
"tree",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dir_data.go#L402-L405 |
158,742 | keybase/client | go/badges/badgestate.go | NewBadgeState | func NewBadgeState(log logger.Logger) *BadgeState {
return &BadgeState{
log: log,
inboxVers: chat1.InboxVers(0),
chatUnreadMap: make(map[string]keybase1.BadgeConversationInfo),
walletUnreadMap: make(map[stellar1.AccountID]int),
}
} | go | func NewBadgeState(log logger.Logger) *BadgeState {
return &BadgeState{
log: log,
inboxVers: chat1.InboxVers(0),
chatUnreadMap: make(map[string]keybase1.BadgeConversationInfo),
walletUnreadMap: make(map[stellar1.AccountID]int),
}
} | [
"func",
"NewBadgeState",
"(",
"log",
"logger",
".",
"Logger",
")",
"*",
"BadgeState",
"{",
"return",
"&",
"BadgeState",
"{",
"log",
":",
"log",
",",
"inboxVers",
":",
"chat1",
".",
"InboxVers",
"(",
"0",
")",
",",
"chatUnreadMap",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"keybase1",
".",
"BadgeConversationInfo",
")",
",",
"walletUnreadMap",
":",
"make",
"(",
"map",
"[",
"stellar1",
".",
"AccountID",
"]",
"int",
")",
",",
"}",
"\n",
"}"
] | // NewBadgeState creates a new empty BadgeState. | [
"NewBadgeState",
"creates",
"a",
"new",
"empty",
"BadgeState",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/badges/badgestate.go#L38-L45 |
158,743 | keybase/client | go/badges/badgestate.go | Export | func (b *BadgeState) Export() (keybase1.BadgeState, error) {
b.Lock()
defer b.Unlock()
b.state.Conversations = []keybase1.BadgeConversationInfo{}
for _, info := range b.chatUnreadMap {
b.state.Conversations = append(b.state.Conversations, info)
}
b.state.InboxVers = int(b.inboxVers)
b.state.UnreadWalletAccounts = []keybase1.WalletAccountInfo{}
for accountID, count := range b.walletUnreadMap {
info := keybase1.WalletAccountInfo{AccountID: string(accountID), NumUnread: count}
b.state.UnreadWalletAccounts = append(b.state.UnreadWalletAccounts, info)
}
return b.state, nil
} | go | func (b *BadgeState) Export() (keybase1.BadgeState, error) {
b.Lock()
defer b.Unlock()
b.state.Conversations = []keybase1.BadgeConversationInfo{}
for _, info := range b.chatUnreadMap {
b.state.Conversations = append(b.state.Conversations, info)
}
b.state.InboxVers = int(b.inboxVers)
b.state.UnreadWalletAccounts = []keybase1.WalletAccountInfo{}
for accountID, count := range b.walletUnreadMap {
info := keybase1.WalletAccountInfo{AccountID: string(accountID), NumUnread: count}
b.state.UnreadWalletAccounts = append(b.state.UnreadWalletAccounts, info)
}
return b.state, nil
} | [
"func",
"(",
"b",
"*",
"BadgeState",
")",
"Export",
"(",
")",
"(",
"keybase1",
".",
"BadgeState",
",",
"error",
")",
"{",
"b",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"Unlock",
"(",
")",
"\n\n",
"b",
".",
"state",
".",
"Conversations",
"=",
"[",
"]",
"keybase1",
".",
"BadgeConversationInfo",
"{",
"}",
"\n",
"for",
"_",
",",
"info",
":=",
"range",
"b",
".",
"chatUnreadMap",
"{",
"b",
".",
"state",
".",
"Conversations",
"=",
"append",
"(",
"b",
".",
"state",
".",
"Conversations",
",",
"info",
")",
"\n",
"}",
"\n",
"b",
".",
"state",
".",
"InboxVers",
"=",
"int",
"(",
"b",
".",
"inboxVers",
")",
"\n\n",
"b",
".",
"state",
".",
"UnreadWalletAccounts",
"=",
"[",
"]",
"keybase1",
".",
"WalletAccountInfo",
"{",
"}",
"\n",
"for",
"accountID",
",",
"count",
":=",
"range",
"b",
".",
"walletUnreadMap",
"{",
"info",
":=",
"keybase1",
".",
"WalletAccountInfo",
"{",
"AccountID",
":",
"string",
"(",
"accountID",
")",
",",
"NumUnread",
":",
"count",
"}",
"\n",
"b",
".",
"state",
".",
"UnreadWalletAccounts",
"=",
"append",
"(",
"b",
".",
"state",
".",
"UnreadWalletAccounts",
",",
"info",
")",
"\n",
"}",
"\n\n",
"return",
"b",
".",
"state",
",",
"nil",
"\n",
"}"
] | // Exports the state summary | [
"Exports",
"the",
"state",
"summary"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/badges/badgestate.go#L48-L65 |
158,744 | keybase/client | go/badges/badgestate.go | SetWalletAccountUnreadCount | func (b *BadgeState) SetWalletAccountUnreadCount(accountID stellar1.AccountID, unreadCount int) bool {
b.Lock()
existingCount := b.walletUnreadMap[accountID]
b.walletUnreadMap[accountID] = unreadCount
b.Unlock()
// did this call change the unread count for this accountID?
changed := unreadCount != existingCount
return changed
} | go | func (b *BadgeState) SetWalletAccountUnreadCount(accountID stellar1.AccountID, unreadCount int) bool {
b.Lock()
existingCount := b.walletUnreadMap[accountID]
b.walletUnreadMap[accountID] = unreadCount
b.Unlock()
// did this call change the unread count for this accountID?
changed := unreadCount != existingCount
return changed
} | [
"func",
"(",
"b",
"*",
"BadgeState",
")",
"SetWalletAccountUnreadCount",
"(",
"accountID",
"stellar1",
".",
"AccountID",
",",
"unreadCount",
"int",
")",
"bool",
"{",
"b",
".",
"Lock",
"(",
")",
"\n",
"existingCount",
":=",
"b",
".",
"walletUnreadMap",
"[",
"accountID",
"]",
"\n",
"b",
".",
"walletUnreadMap",
"[",
"accountID",
"]",
"=",
"unreadCount",
"\n",
"b",
".",
"Unlock",
"(",
")",
"\n\n",
"// did this call change the unread count for this accountID?",
"changed",
":=",
"unreadCount",
"!=",
"existingCount",
"\n\n",
"return",
"changed",
"\n",
"}"
] | // SetWalletAccountUnreadCount sets the unread count for a wallet account.
// It returns true if the call changed the unread count for accountID. | [
"SetWalletAccountUnreadCount",
"sets",
"the",
"unread",
"count",
"for",
"a",
"wallet",
"account",
".",
"It",
"returns",
"true",
"if",
"the",
"call",
"changed",
"the",
"unread",
"count",
"for",
"accountID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/badges/badgestate.go#L394-L404 |
158,745 | keybase/client | go/saltpackkeys/saltpack_recipient_keyfinder_engine.go | NewSaltpackRecipientKeyfinderEngineAsInterface | func NewSaltpackRecipientKeyfinderEngineAsInterface(arg libkb.SaltpackRecipientKeyfinderArg) libkb.SaltpackRecipientKeyfinderEngineInterface {
return &SaltpackRecipientKeyfinderEngine{
SaltpackUserKeyfinder: *engine.NewSaltpackUserKeyfinder(arg),
SymmetricEntityKeyMap: make(map[keybase1.TeamID](keybase1.TeamApplicationKey)),
}
} | go | func NewSaltpackRecipientKeyfinderEngineAsInterface(arg libkb.SaltpackRecipientKeyfinderArg) libkb.SaltpackRecipientKeyfinderEngineInterface {
return &SaltpackRecipientKeyfinderEngine{
SaltpackUserKeyfinder: *engine.NewSaltpackUserKeyfinder(arg),
SymmetricEntityKeyMap: make(map[keybase1.TeamID](keybase1.TeamApplicationKey)),
}
} | [
"func",
"NewSaltpackRecipientKeyfinderEngineAsInterface",
"(",
"arg",
"libkb",
".",
"SaltpackRecipientKeyfinderArg",
")",
"libkb",
".",
"SaltpackRecipientKeyfinderEngineInterface",
"{",
"return",
"&",
"SaltpackRecipientKeyfinderEngine",
"{",
"SaltpackUserKeyfinder",
":",
"*",
"engine",
".",
"NewSaltpackUserKeyfinder",
"(",
"arg",
")",
",",
"SymmetricEntityKeyMap",
":",
"make",
"(",
"map",
"[",
"keybase1",
".",
"TeamID",
"]",
"(",
"keybase1",
".",
"TeamApplicationKey",
")",
")",
",",
"}",
"\n",
"}"
] | // SaltpackRecipientKeyfinderEngine creates a SaltpackRecipientKeyfinderEngine engine. | [
"SaltpackRecipientKeyfinderEngine",
"creates",
"a",
"SaltpackRecipientKeyfinderEngine",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/saltpackkeys/saltpack_recipient_keyfinder_engine.go#L35-L40 |
158,746 | keybase/client | go/saltpackkeys/saltpack_recipient_keyfinder_engine.go | identifyAndAddUserRecipient | func (e *SaltpackRecipientKeyfinderEngine) identifyAndAddUserRecipient(m libkb.MetaContext, u string) (err error) {
upk, err := e.IdentifyUser(m, u) // For existing users
switch {
case err == nil:
// nothing to do here
case libkb.IsIdentifyProofError(err):
return fmt.Errorf("Cannot encrypt for %v as their account has changed since you last followed them (it might have been compromised!): please review their identity (with `keybase follow %v`) and then try again (err = %v)", u, u, err)
case libkb.IsNotFoundError(err) || libkb.IsResolutionNotFoundError(err):
// recipient is not a keybase user
expr, err := externals.AssertionParse(m.G(), u)
if err != nil {
m.Debug("error parsing assertion: %s", err)
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a keybase user or social assertion (err = %v)", u, err))
}
if _, err := expr.ToSocialAssertion(); err != nil {
m.Debug("not a social assertion: %s (%s), err: %+v", u, expr, err)
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a keybase user or social assertion (err = %v)", u, err))
}
if !m.ActiveDevice().Valid() {
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a registered user (cannot encrypt for users not yet on keybase unless you are logged in)", u))
}
if !e.Arg.UseEntityKeys {
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a registered user (you can remove `--no-entity-keys` for users not yet on keybase)", u))
}
if e.Arg.NoSelfEncrypt {
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a registered user (you can remove `--no-self-encrypt` for users not yet on keybase)", u))
}
m.Debug("%q is not an existing user, trying to create an implicit team", u)
err = e.lookupAndAddImplicitTeamKeys(m, u)
return err
case libkb.IsNoKeyError(err):
// User exists but has no keys. Just try adding implicit team keys.
return e.lookupAndAddImplicitTeamKeys(m, u)
default:
return fmt.Errorf("Error while adding keys for %v: %v", u, err)
}
err = e.AddDeviceAndPaperKeys(m, upk)
err2 := e.addPUKOrImplicitTeamKeys(m, upk)
// If we managed to add at least one key for upk, we are happy.
if (!(e.Arg.UseDeviceKeys || e.Arg.UsePaperKeys) || err != nil) && (!e.Arg.UseEntityKeys || err2 != nil) {
return libkb.PickFirstError(err, err2)
}
return nil
} | go | func (e *SaltpackRecipientKeyfinderEngine) identifyAndAddUserRecipient(m libkb.MetaContext, u string) (err error) {
upk, err := e.IdentifyUser(m, u) // For existing users
switch {
case err == nil:
// nothing to do here
case libkb.IsIdentifyProofError(err):
return fmt.Errorf("Cannot encrypt for %v as their account has changed since you last followed them (it might have been compromised!): please review their identity (with `keybase follow %v`) and then try again (err = %v)", u, u, err)
case libkb.IsNotFoundError(err) || libkb.IsResolutionNotFoundError(err):
// recipient is not a keybase user
expr, err := externals.AssertionParse(m.G(), u)
if err != nil {
m.Debug("error parsing assertion: %s", err)
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a keybase user or social assertion (err = %v)", u, err))
}
if _, err := expr.ToSocialAssertion(); err != nil {
m.Debug("not a social assertion: %s (%s), err: %+v", u, expr, err)
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a keybase user or social assertion (err = %v)", u, err))
}
if !m.ActiveDevice().Valid() {
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a registered user (cannot encrypt for users not yet on keybase unless you are logged in)", u))
}
if !e.Arg.UseEntityKeys {
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a registered user (you can remove `--no-entity-keys` for users not yet on keybase)", u))
}
if e.Arg.NoSelfEncrypt {
return libkb.NewRecipientNotFoundError(fmt.Sprintf("Cannot encrypt for %v: it is not a registered user (you can remove `--no-self-encrypt` for users not yet on keybase)", u))
}
m.Debug("%q is not an existing user, trying to create an implicit team", u)
err = e.lookupAndAddImplicitTeamKeys(m, u)
return err
case libkb.IsNoKeyError(err):
// User exists but has no keys. Just try adding implicit team keys.
return e.lookupAndAddImplicitTeamKeys(m, u)
default:
return fmt.Errorf("Error while adding keys for %v: %v", u, err)
}
err = e.AddDeviceAndPaperKeys(m, upk)
err2 := e.addPUKOrImplicitTeamKeys(m, upk)
// If we managed to add at least one key for upk, we are happy.
if (!(e.Arg.UseDeviceKeys || e.Arg.UsePaperKeys) || err != nil) && (!e.Arg.UseEntityKeys || err2 != nil) {
return libkb.PickFirstError(err, err2)
}
return nil
} | [
"func",
"(",
"e",
"*",
"SaltpackRecipientKeyfinderEngine",
")",
"identifyAndAddUserRecipient",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"u",
"string",
")",
"(",
"err",
"error",
")",
"{",
"upk",
",",
"err",
":=",
"e",
".",
"IdentifyUser",
"(",
"m",
",",
"u",
")",
"// For existing users",
"\n",
"switch",
"{",
"case",
"err",
"==",
"nil",
":",
"// nothing to do here",
"case",
"libkb",
".",
"IsIdentifyProofError",
"(",
"err",
")",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"u",
",",
"u",
",",
"err",
")",
"\n",
"case",
"libkb",
".",
"IsNotFoundError",
"(",
"err",
")",
"||",
"libkb",
".",
"IsResolutionNotFoundError",
"(",
"err",
")",
":",
"// recipient is not a keybase user",
"expr",
",",
"err",
":=",
"externals",
".",
"AssertionParse",
"(",
"m",
".",
"G",
"(",
")",
",",
"u",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"libkb",
".",
"NewRecipientNotFoundError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"u",
",",
"err",
")",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"expr",
".",
"ToSocialAssertion",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"u",
",",
"expr",
",",
"err",
")",
"\n",
"return",
"libkb",
".",
"NewRecipientNotFoundError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"u",
",",
"err",
")",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"m",
".",
"ActiveDevice",
"(",
")",
".",
"Valid",
"(",
")",
"{",
"return",
"libkb",
".",
"NewRecipientNotFoundError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"u",
")",
")",
"\n",
"}",
"\n",
"if",
"!",
"e",
".",
"Arg",
".",
"UseEntityKeys",
"{",
"return",
"libkb",
".",
"NewRecipientNotFoundError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"u",
")",
")",
"\n",
"}",
"\n",
"if",
"e",
".",
"Arg",
".",
"NoSelfEncrypt",
"{",
"return",
"libkb",
".",
"NewRecipientNotFoundError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"u",
")",
")",
"\n",
"}",
"\n\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"u",
")",
"\n",
"err",
"=",
"e",
".",
"lookupAndAddImplicitTeamKeys",
"(",
"m",
",",
"u",
")",
"\n",
"return",
"err",
"\n",
"case",
"libkb",
".",
"IsNoKeyError",
"(",
"err",
")",
":",
"// User exists but has no keys. Just try adding implicit team keys.",
"return",
"e",
".",
"lookupAndAddImplicitTeamKeys",
"(",
"m",
",",
"u",
")",
"\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"u",
",",
"err",
")",
"\n",
"}",
"\n\n",
"err",
"=",
"e",
".",
"AddDeviceAndPaperKeys",
"(",
"m",
",",
"upk",
")",
"\n",
"err2",
":=",
"e",
".",
"addPUKOrImplicitTeamKeys",
"(",
"m",
",",
"upk",
")",
"\n",
"// If we managed to add at least one key for upk, we are happy.",
"if",
"(",
"!",
"(",
"e",
".",
"Arg",
".",
"UseDeviceKeys",
"||",
"e",
".",
"Arg",
".",
"UsePaperKeys",
")",
"||",
"err",
"!=",
"nil",
")",
"&&",
"(",
"!",
"e",
".",
"Arg",
".",
"UseEntityKeys",
"||",
"err2",
"!=",
"nil",
")",
"{",
"return",
"libkb",
".",
"PickFirstError",
"(",
"err",
",",
"err2",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // identifyAndAddUserRecipient add the KID corresponding to a recipient to the recipientMap | [
"identifyAndAddUserRecipient",
"add",
"the",
"KID",
"corresponding",
"to",
"a",
"recipient",
"to",
"the",
"recipientMap"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/saltpackkeys/saltpack_recipient_keyfinder_engine.go#L151-L198 |
158,747 | keybase/client | go/auth/token.go | GenerateChallenge | func GenerateChallenge() (string, error) {
buf := make([]byte, ChallengeLengthBytes)
if _, err := rand.Read(buf); err != nil {
return "", err
}
return hex.EncodeToString(buf), nil
} | go | func GenerateChallenge() (string, error) {
buf := make([]byte, ChallengeLengthBytes)
if _, err := rand.Read(buf); err != nil {
return "", err
}
return hex.EncodeToString(buf), nil
} | [
"func",
"GenerateChallenge",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"ChallengeLengthBytes",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"rand",
".",
"Read",
"(",
"buf",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"hex",
".",
"EncodeToString",
"(",
"buf",
")",
",",
"nil",
"\n",
"}"
] | // GenerateChallenge returns a cryptographically secure random challenge string. | [
"GenerateChallenge",
"returns",
"a",
"cryptographically",
"secure",
"random",
"challenge",
"string",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/token.go#L205-L211 |
158,748 | keybase/client | go/auth/token.go | IsValidChallenge | func IsValidChallenge(challenge string) bool {
if len(challenge) != ChallengeLengthString {
return false
}
if _, err := hex.DecodeString(challenge); err != nil {
return false
}
return true
} | go | func IsValidChallenge(challenge string) bool {
if len(challenge) != ChallengeLengthString {
return false
}
if _, err := hex.DecodeString(challenge); err != nil {
return false
}
return true
} | [
"func",
"IsValidChallenge",
"(",
"challenge",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"challenge",
")",
"!=",
"ChallengeLengthString",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"hex",
".",
"DecodeString",
"(",
"challenge",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // IsValidChallenge returns true if the passed challenge is validly formed. | [
"IsValidChallenge",
"returns",
"true",
"if",
"the",
"passed",
"challenge",
"is",
"validly",
"formed",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/auth/token.go#L214-L222 |
158,749 | keybase/client | go/kbfs/libfuse/prefetch_file.go | Attr | func (f *PrefetchFile) Attr(ctx context.Context, a *fuse.Attr) error {
a.Size = 0
a.Mode = 0222
return nil
} | go | func (f *PrefetchFile) Attr(ctx context.Context, a *fuse.Attr) error {
a.Size = 0
a.Mode = 0222
return nil
} | [
"func",
"(",
"f",
"*",
"PrefetchFile",
")",
"Attr",
"(",
"ctx",
"context",
".",
"Context",
",",
"a",
"*",
"fuse",
".",
"Attr",
")",
"error",
"{",
"a",
".",
"Size",
"=",
"0",
"\n",
"a",
".",
"Mode",
"=",
"0222",
"\n",
"return",
"nil",
"\n",
"}"
] | // Attr implements the fs.Node interface for PrefetchFile. | [
"Attr",
"implements",
"the",
"fs",
".",
"Node",
"interface",
"for",
"PrefetchFile",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/prefetch_file.go#L27-L31 |
158,750 | keybase/client | go/kbfs/libfuse/prefetch_file.go | Write | func (f *PrefetchFile) Write(ctx context.Context, req *fuse.WriteRequest,
resp *fuse.WriteResponse) (err error) {
f.fs.log.CDebugf(ctx, "PrefetchFile (enable: %t) Write", f.enable)
defer func() { err = f.fs.processError(ctx, libkbfs.WriteMode, err) }()
if len(req.Data) == 0 {
return nil
}
f.fs.config.BlockOps().TogglePrefetcher(f.enable)
resp.Size = len(req.Data)
return nil
} | go | func (f *PrefetchFile) Write(ctx context.Context, req *fuse.WriteRequest,
resp *fuse.WriteResponse) (err error) {
f.fs.log.CDebugf(ctx, "PrefetchFile (enable: %t) Write", f.enable)
defer func() { err = f.fs.processError(ctx, libkbfs.WriteMode, err) }()
if len(req.Data) == 0 {
return nil
}
f.fs.config.BlockOps().TogglePrefetcher(f.enable)
resp.Size = len(req.Data)
return nil
} | [
"func",
"(",
"f",
"*",
"PrefetchFile",
")",
"Write",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"WriteRequest",
",",
"resp",
"*",
"fuse",
".",
"WriteResponse",
")",
"(",
"err",
"error",
")",
"{",
"f",
".",
"fs",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"f",
".",
"enable",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"f",
".",
"fs",
".",
"processError",
"(",
"ctx",
",",
"libkbfs",
".",
"WriteMode",
",",
"err",
")",
"}",
"(",
")",
"\n",
"if",
"len",
"(",
"req",
".",
"Data",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"f",
".",
"fs",
".",
"config",
".",
"BlockOps",
"(",
")",
".",
"TogglePrefetcher",
"(",
"f",
".",
"enable",
")",
"\n\n",
"resp",
".",
"Size",
"=",
"len",
"(",
"req",
".",
"Data",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Write implements the fs.HandleWriter interface for PrefetchFile. | [
"Write",
"implements",
"the",
"fs",
".",
"HandleWriter",
"interface",
"for",
"PrefetchFile",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/prefetch_file.go#L38-L50 |
158,751 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e NeedSelfRekeyError) Error() string {
return fmt.Sprintf("This device does not yet have read access to "+
"directory %s, log into Keybase from one of your other "+
"devices to grant access: %+v",
tlfhandle.BuildCanonicalPathForTlfName(tlf.Private, e.Tlf), e.Err)
} | go | func (e NeedSelfRekeyError) Error() string {
return fmt.Sprintf("This device does not yet have read access to "+
"directory %s, log into Keybase from one of your other "+
"devices to grant access: %+v",
tlfhandle.BuildCanonicalPathForTlfName(tlf.Private, e.Tlf), e.Err)
} | [
"func",
"(",
"e",
"NeedSelfRekeyError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"tlfhandle",
".",
"BuildCanonicalPathForTlfName",
"(",
"tlf",
".",
"Private",
",",
"e",
".",
"Tlf",
")",
",",
"e",
".",
"Err",
")",
"\n",
"}"
] | // Error implements the error interface for NeedSelfRekeyError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"NeedSelfRekeyError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L162-L167 |
158,752 | keybase/client | go/kbfs/libkbfs/errors.go | ToStatus | func (e NeedSelfRekeyError) ToStatus() keybase1.Status {
kv := keybase1.StringKVPair{
Key: "Tlf",
Value: string(e.Tlf),
}
return keybase1.Status{
Code: int(keybase1.StatusCode_SCNeedSelfRekey),
Name: "SC_NEED_SELF_REKEY",
Desc: e.Error(),
Fields: []keybase1.StringKVPair{kv},
}
} | go | func (e NeedSelfRekeyError) ToStatus() keybase1.Status {
kv := keybase1.StringKVPair{
Key: "Tlf",
Value: string(e.Tlf),
}
return keybase1.Status{
Code: int(keybase1.StatusCode_SCNeedSelfRekey),
Name: "SC_NEED_SELF_REKEY",
Desc: e.Error(),
Fields: []keybase1.StringKVPair{kv},
}
} | [
"func",
"(",
"e",
"NeedSelfRekeyError",
")",
"ToStatus",
"(",
")",
"keybase1",
".",
"Status",
"{",
"kv",
":=",
"keybase1",
".",
"StringKVPair",
"{",
"Key",
":",
"\"",
"\"",
",",
"Value",
":",
"string",
"(",
"e",
".",
"Tlf",
")",
",",
"}",
"\n",
"return",
"keybase1",
".",
"Status",
"{",
"Code",
":",
"int",
"(",
"keybase1",
".",
"StatusCode_SCNeedSelfRekey",
")",
",",
"Name",
":",
"\"",
"\"",
",",
"Desc",
":",
"e",
".",
"Error",
"(",
")",
",",
"Fields",
":",
"[",
"]",
"keybase1",
".",
"StringKVPair",
"{",
"kv",
"}",
",",
"}",
"\n",
"}"
] | // ToStatus exports error to status | [
"ToStatus",
"exports",
"error",
"to",
"status"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L170-L181 |
158,753 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e NotFileError) Error() string {
return fmt.Sprintf("%s is not a file (folder %s)", e.path, e.path.Tlf)
} | go | func (e NotFileError) Error() string {
return fmt.Sprintf("%s is not a file (folder %s)", e.path, e.path.Tlf)
} | [
"func",
"(",
"e",
"NotFileError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"path",
",",
"e",
".",
"path",
".",
"Tlf",
")",
"\n",
"}"
] | // Error implements the error interface for NotFileError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"NotFileError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L248-L250 |
158,754 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e NotDirError) Error() string {
return fmt.Sprintf("%s is not a directory (folder %s)", e.path, e.path.Tlf)
} | go | func (e NotDirError) Error() string {
return fmt.Sprintf("%s is not a directory (folder %s)", e.path, e.path.Tlf)
} | [
"func",
"(",
"e",
"NotDirError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"path",
",",
"e",
".",
"path",
".",
"Tlf",
")",
"\n",
"}"
] | // Error implements the error interface for NotDirError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"NotDirError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L259-L261 |
158,755 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e NoSuchMDError) Error() string {
return fmt.Sprintf("Couldn't get metadata for folder %v, revision %d, "+
"%s", e.Tlf, e.Rev, e.BID)
} | go | func (e NoSuchMDError) Error() string {
return fmt.Sprintf("Couldn't get metadata for folder %v, revision %d, "+
"%s", e.Tlf, e.Rev, e.BID)
} | [
"func",
"(",
"e",
"NoSuchMDError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"Tlf",
",",
"e",
".",
"Rev",
",",
"e",
".",
"BID",
")",
"\n",
"}"
] | // Error implements the error interface for NoSuchMDError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"NoSuchMDError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L330-L333 |
158,756 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e NewDataVersionError) Error() string {
return fmt.Sprintf(
"The data at path %s is of a version (%d) that we can't read "+
"(in folder %s)",
e.path, e.DataVer, e.path.Tlf)
} | go | func (e NewDataVersionError) Error() string {
return fmt.Sprintf(
"The data at path %s is of a version (%d) that we can't read "+
"(in folder %s)",
e.path, e.DataVer, e.path.Tlf)
} | [
"func",
"(",
"e",
"NewDataVersionError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"path",
",",
"e",
".",
"DataVer",
",",
"e",
".",
"path",
".",
"Tlf",
")",
"\n",
"}"
] | // Error implements the error interface for NewDataVersionError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"NewDataVersionError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L355-L360 |
158,757 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e TooLowByteCountError) Error() string {
return fmt.Sprintf("Expected at least %d bytes, got %d bytes",
e.ExpectedMinByteCount, e.ByteCount)
} | go | func (e TooLowByteCountError) Error() string {
return fmt.Sprintf("Expected at least %d bytes, got %d bytes",
e.ExpectedMinByteCount, e.ByteCount)
} | [
"func",
"(",
"e",
"TooLowByteCountError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"ExpectedMinByteCount",
",",
"e",
".",
"ByteCount",
")",
"\n",
"}"
] | // Error implements the error interface for TooLowByteCountError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"TooLowByteCountError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L396-L399 |
158,758 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e InconsistentEncodedSizeError) Error() string {
return fmt.Sprintf("Block pointer to dirty block %v with non-zero "+
"encoded size = %d bytes", e.info.ID, e.info.EncodedSize)
} | go | func (e InconsistentEncodedSizeError) Error() string {
return fmt.Sprintf("Block pointer to dirty block %v with non-zero "+
"encoded size = %d bytes", e.info.ID, e.info.EncodedSize)
} | [
"func",
"(",
"e",
"InconsistentEncodedSizeError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"info",
".",
"ID",
",",
"e",
".",
"info",
".",
"EncodedSize",
")",
"\n",
"}"
] | // Error implements the error interface for InconsistentEncodedSizeError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"InconsistentEncodedSizeError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L408-L411 |
158,759 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e UnverifiableTlfUpdateError) Error() string {
return fmt.Sprintf("%s was last written by an unknown device claiming "+
"to belong to user %s. The device has possibly been revoked by the "+
"user. Use `keybase log send` to file an issue with the Keybase "+
"admins.", e.Tlf, e.User)
} | go | func (e UnverifiableTlfUpdateError) Error() string {
return fmt.Sprintf("%s was last written by an unknown device claiming "+
"to belong to user %s. The device has possibly been revoked by the "+
"user. Use `keybase log send` to file an issue with the Keybase "+
"admins.", e.Tlf, e.User)
} | [
"func",
"(",
"e",
"UnverifiableTlfUpdateError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
"+",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"Tlf",
",",
"e",
".",
"User",
")",
"\n",
"}"
] | // Error implements the error interface for UnverifiableTlfUpdateError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"UnverifiableTlfUpdateError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L443-L448 |
158,760 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e KeyCacheMissError) Error() string {
return fmt.Sprintf("Could not find key with tlf=%s, keyGen=%d", e.tlf, e.keyGen)
} | go | func (e KeyCacheMissError) Error() string {
return fmt.Sprintf("Could not find key with tlf=%s, keyGen=%d", e.tlf, e.keyGen)
} | [
"func",
"(",
"e",
"KeyCacheMissError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"tlf",
",",
"e",
".",
"keyGen",
")",
"\n",
"}"
] | // Error implements the error interface for KeyCacheMissError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"KeyCacheMissError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L458-L460 |
158,761 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e KeyCacheHitError) Error() string {
return fmt.Sprintf("Invalid key with tlf=%s, keyGen=%d", e.tlf, e.keyGen)
} | go | func (e KeyCacheHitError) Error() string {
return fmt.Sprintf("Invalid key with tlf=%s, keyGen=%d", e.tlf, e.keyGen)
} | [
"func",
"(",
"e",
"KeyCacheHitError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"tlf",
",",
"e",
".",
"keyGen",
")",
"\n",
"}"
] | // Error implements the error interface for KeyCacheHitError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"KeyCacheHitError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L470-L472 |
158,762 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e WrongOpsError) Error() string {
return fmt.Sprintf("Ops for folder %v, branch %s, was given path %s, "+
"branch %s", e.opsFB.Tlf, e.opsFB.Branch, e.nodeFB.Tlf, e.nodeFB.Branch)
} | go | func (e WrongOpsError) Error() string {
return fmt.Sprintf("Ops for folder %v, branch %s, was given path %s, "+
"branch %s", e.opsFB.Tlf, e.opsFB.Branch, e.nodeFB.Tlf, e.nodeFB.Branch)
} | [
"func",
"(",
"e",
"WrongOpsError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"opsFB",
".",
"Tlf",
",",
"e",
".",
"opsFB",
".",
"Branch",
",",
"e",
".",
"nodeFB",
".",
"Tlf",
",",
"e",
".",
"nodeFB",
".",
"Branch",
")",
"\n",
"}"
] | // Error implements the error interface for WrongOpsError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"WrongOpsError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L490-L493 |
158,763 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e KeyHalfMismatchError) Error() string {
return fmt.Sprintf("Key mismatch, expected ID: %s, actual ID: %s",
e.Expected, e.Actual)
} | go | func (e KeyHalfMismatchError) Error() string {
return fmt.Sprintf("Key mismatch, expected ID: %s, actual ID: %s",
e.Expected, e.Actual)
} | [
"func",
"(",
"e",
"KeyHalfMismatchError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Expected",
",",
"e",
".",
"Actual",
")",
"\n",
"}"
] | // Error implements the error interface for KeyHalfMismatchError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"KeyHalfMismatchError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L535-L538 |
158,764 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e MDUpdateInvertError) Error() string {
return fmt.Sprintf("MD revision %d isn't next in line for our "+
"current revision %d while inverting", e.rev, e.curr)
} | go | func (e MDUpdateInvertError) Error() string {
return fmt.Sprintf("MD revision %d isn't next in line for our "+
"current revision %d while inverting", e.rev, e.curr)
} | [
"func",
"(",
"e",
"MDUpdateInvertError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"rev",
",",
"e",
".",
"curr",
")",
"\n",
"}"
] | // Error implements the error interface for MDUpdateInvertError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"MDUpdateInvertError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L558-L561 |
158,765 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e DisallowedPrefixError) Error() string {
return fmt.Sprintf("Cannot create %s because it has the prefix %s",
e.name, e.prefix)
} | go | func (e DisallowedPrefixError) Error() string {
return fmt.Sprintf("Cannot create %s because it has the prefix %s",
e.name, e.prefix)
} | [
"func",
"(",
"e",
"DisallowedPrefixError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"name",
",",
"e",
".",
"prefix",
")",
"\n",
"}"
] | // Error implements the error interface for NoChainFoundError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"NoChainFoundError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L592-L595 |
158,766 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e NameTooLongError) Error() string {
return fmt.Sprintf("New directory entry name %s has more than the maximum "+
"allowed number of bytes (%d)", e.name, e.maxAllowedBytes)
} | go | func (e NameTooLongError) Error() string {
return fmt.Sprintf("New directory entry name %s has more than the maximum "+
"allowed number of bytes (%d)", e.name, e.maxAllowedBytes)
} | [
"func",
"(",
"e",
"NameTooLongError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"name",
",",
"e",
".",
"maxAllowedBytes",
")",
"\n",
"}"
] | // Error implements the error interface for NameTooLongError. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"NameTooLongError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L605-L608 |
158,767 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e RekeyPermissionError) Error() string {
return fmt.Sprintf("%s is trying to rekey directory %s in a manner "+
"inconsistent with their role", e.User, e.Dir)
} | go | func (e RekeyPermissionError) Error() string {
return fmt.Sprintf("%s is trying to rekey directory %s in a manner "+
"inconsistent with their role", e.User, e.Dir)
} | [
"func",
"(",
"e",
"RekeyPermissionError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"User",
",",
"e",
".",
"Dir",
")",
"\n",
"}"
] | // Error implements the error interface for RekeyPermissionError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"RekeyPermissionError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L622-L625 |
158,768 | keybase/client | go/kbfs/libkbfs/errors.go | NewRekeyPermissionError | func NewRekeyPermissionError(
dir *tlfhandle.Handle, username kbname.NormalizedUsername) error {
dirname := dir.GetCanonicalPath()
return RekeyPermissionError{username, dirname}
} | go | func NewRekeyPermissionError(
dir *tlfhandle.Handle, username kbname.NormalizedUsername) error {
dirname := dir.GetCanonicalPath()
return RekeyPermissionError{username, dirname}
} | [
"func",
"NewRekeyPermissionError",
"(",
"dir",
"*",
"tlfhandle",
".",
"Handle",
",",
"username",
"kbname",
".",
"NormalizedUsername",
")",
"error",
"{",
"dirname",
":=",
"dir",
".",
"GetCanonicalPath",
"(",
")",
"\n",
"return",
"RekeyPermissionError",
"{",
"username",
",",
"dirname",
"}",
"\n",
"}"
] | // NewRekeyPermissionError constructs a RekeyPermissionError for the given
// directory and user. | [
"NewRekeyPermissionError",
"constructs",
"a",
"RekeyPermissionError",
"for",
"the",
"given",
"directory",
"and",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L629-L633 |
158,769 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e NoSuchFolderListError) Error() string {
return fmt.Sprintf("/keybase/%s is not a Keybase folder. "+
"All folders begin with /keybase/%s or /keybase/%s.",
e.Name, e.PrivName, e.PubName)
} | go | func (e NoSuchFolderListError) Error() string {
return fmt.Sprintf("/keybase/%s is not a Keybase folder. "+
"All folders begin with /keybase/%s or /keybase/%s.",
e.Name, e.PrivName, e.PubName)
} | [
"func",
"(",
"e",
"NoSuchFolderListError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"Name",
",",
"e",
".",
"PrivName",
",",
"e",
".",
"PubName",
")",
"\n",
"}"
] | // Error implements the error interface for NoSuchFolderListError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"NoSuchFolderListError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L671-L675 |
158,770 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (w OverQuotaWarning) Error() string {
return fmt.Sprintf("You are using %d bytes, and your plan limits you "+
"to %d bytes. Please delete some data.", w.UsageBytes, w.LimitBytes)
} | go | func (w OverQuotaWarning) Error() string {
return fmt.Sprintf("You are using %d bytes, and your plan limits you "+
"to %d bytes. Please delete some data.", w.UsageBytes, w.LimitBytes)
} | [
"func",
"(",
"w",
"OverQuotaWarning",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"w",
".",
"UsageBytes",
",",
"w",
".",
"LimitBytes",
")",
"\n",
"}"
] | // Error implements the error interface for OverQuotaWarning. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"OverQuotaWarning",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L751-L754 |
158,771 | keybase/client | go/kbfs/libkbfs/errors.go | ToStatus | func (e DiskBlockCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskBlockCacheError
s.Name = "DISK_BLOCK_CACHE_ERROR"
s.Desc = e.Msg
return
} | go | func (e DiskBlockCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskBlockCacheError
s.Name = "DISK_BLOCK_CACHE_ERROR"
s.Desc = e.Msg
return
} | [
"func",
"(",
"e",
"DiskBlockCacheError",
")",
"ToStatus",
"(",
")",
"(",
"s",
"keybase1",
".",
"Status",
")",
"{",
"s",
".",
"Code",
"=",
"StatusCodeDiskBlockCacheError",
"\n",
"s",
".",
"Name",
"=",
"\"",
"\"",
"\n",
"s",
".",
"Desc",
"=",
"e",
".",
"Msg",
"\n",
"return",
"\n",
"}"
] | // ToStatus implements the ExportableError interface for DiskBlockCacheError. | [
"ToStatus",
"implements",
"the",
"ExportableError",
"interface",
"for",
"DiskBlockCacheError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L872-L877 |
158,772 | keybase/client | go/kbfs/libkbfs/errors.go | ToStatus | func (e DiskMDCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskMDCacheError
s.Name = "DISK_MD_CACHE_ERROR"
s.Desc = e.Msg
return
} | go | func (e DiskMDCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskMDCacheError
s.Name = "DISK_MD_CACHE_ERROR"
s.Desc = e.Msg
return
} | [
"func",
"(",
"e",
"DiskMDCacheError",
")",
"ToStatus",
"(",
")",
"(",
"s",
"keybase1",
".",
"Status",
")",
"{",
"s",
".",
"Code",
"=",
"StatusCodeDiskMDCacheError",
"\n",
"s",
".",
"Name",
"=",
"\"",
"\"",
"\n",
"s",
".",
"Desc",
"=",
"e",
".",
"Msg",
"\n",
"return",
"\n",
"}"
] | // ToStatus implements the ExportableError interface for DiskMDCacheError. | [
"ToStatus",
"implements",
"the",
"ExportableError",
"interface",
"for",
"DiskMDCacheError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L894-L899 |
158,773 | keybase/client | go/kbfs/libkbfs/errors.go | ToStatus | func (e DiskQuotaCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskQuotaCacheError
s.Name = "DISK_QUOTA_CACHE_ERROR"
s.Desc = e.Msg
return
} | go | func (e DiskQuotaCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskQuotaCacheError
s.Name = "DISK_QUOTA_CACHE_ERROR"
s.Desc = e.Msg
return
} | [
"func",
"(",
"e",
"DiskQuotaCacheError",
")",
"ToStatus",
"(",
")",
"(",
"s",
"keybase1",
".",
"Status",
")",
"{",
"s",
".",
"Code",
"=",
"StatusCodeDiskQuotaCacheError",
"\n",
"s",
".",
"Name",
"=",
"\"",
"\"",
"\n",
"s",
".",
"Desc",
"=",
"e",
".",
"Msg",
"\n",
"return",
"\n",
"}"
] | // ToStatus implements the ExportableError interface for DiskQuotaCacheError. | [
"ToStatus",
"implements",
"the",
"ExportableError",
"interface",
"for",
"DiskQuotaCacheError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L916-L921 |
158,774 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e RevokedDeviceVerificationError) Error() string {
return fmt.Sprintf("Device was revoked at time %s, root seqno %d",
e.info.Time.Time().Format(time.RFC3339Nano), e.info.MerkleRoot.Seqno)
} | go | func (e RevokedDeviceVerificationError) Error() string {
return fmt.Sprintf("Device was revoked at time %s, root seqno %d",
e.info.Time.Time().Format(time.RFC3339Nano), e.info.MerkleRoot.Seqno)
} | [
"func",
"(",
"e",
"RevokedDeviceVerificationError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"info",
".",
"Time",
".",
"Time",
"(",
")",
".",
"Format",
"(",
"time",
".",
"RFC3339Nano",
")",
",",
"e",
".",
"info",
".",
"MerkleRoot",
".",
"Seqno",
")",
"\n",
"}"
] | // Error implements the Error interface for RevokedDeviceVerificationError. | [
"Error",
"implements",
"the",
"Error",
"interface",
"for",
"RevokedDeviceVerificationError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L937-L940 |
158,775 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e MDWrittenAfterRevokeError) Error() string {
return fmt.Sprintf("Failed to verify revision %d of folder %s by key %s; "+
"last valid revision would have been %d",
e.revBad, e.tlfID, e.verifyingKey, e.revLimit)
} | go | func (e MDWrittenAfterRevokeError) Error() string {
return fmt.Sprintf("Failed to verify revision %d of folder %s by key %s; "+
"last valid revision would have been %d",
e.revBad, e.tlfID, e.verifyingKey, e.revLimit)
} | [
"func",
"(",
"e",
"MDWrittenAfterRevokeError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"revBad",
",",
"e",
".",
"tlfID",
",",
"e",
".",
"verifyingKey",
",",
"e",
".",
"revLimit",
")",
"\n",
"}"
] | // Error implements the Error interface for MDWrittenAfterRevokeError. | [
"Error",
"implements",
"the",
"Error",
"interface",
"for",
"MDWrittenAfterRevokeError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L953-L957 |
158,776 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e RevGarbageCollectedError) Error() string {
return fmt.Sprintf("Requested revision %d has already been garbage "+
"collected (last GC'd rev=%d)", e.rev, e.lastGCRev)
} | go | func (e RevGarbageCollectedError) Error() string {
return fmt.Sprintf("Requested revision %d has already been garbage "+
"collected (last GC'd rev=%d)", e.rev, e.lastGCRev)
} | [
"func",
"(",
"e",
"RevGarbageCollectedError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"rev",
",",
"e",
".",
"lastGCRev",
")",
"\n",
"}"
] | // Error implements the Error interface for RevGarbageCollectedError. | [
"Error",
"implements",
"the",
"Error",
"interface",
"for",
"RevGarbageCollectedError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L967-L970 |
158,777 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e NextMDNotCachedError) Error() string {
return fmt.Sprintf("The MD following %d for folder %s is not cached",
e.RootSeqno, e.TlfID)
} | go | func (e NextMDNotCachedError) Error() string {
return fmt.Sprintf("The MD following %d for folder %s is not cached",
e.RootSeqno, e.TlfID)
} | [
"func",
"(",
"e",
"NextMDNotCachedError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"RootSeqno",
",",
"e",
".",
"TlfID",
")",
"\n",
"}"
] | // Error implements the Error interface for NextMDNotCachedError. | [
"Error",
"implements",
"the",
"Error",
"interface",
"for",
"NextMDNotCachedError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L1016-L1019 |
158,778 | keybase/client | go/kbfs/libkbfs/errors.go | Error | func (e DiskCacheTooFullForBlockError) Error() string {
return fmt.Sprintf(
"Disk cache too full for block %s requested with action %s",
e.Ptr, e.Action)
} | go | func (e DiskCacheTooFullForBlockError) Error() string {
return fmt.Sprintf(
"Disk cache too full for block %s requested with action %s",
e.Ptr, e.Action)
} | [
"func",
"(",
"e",
"DiskCacheTooFullForBlockError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Ptr",
",",
"e",
".",
"Action",
")",
"\n",
"}"
] | // Error implements the Error interface for DiskCacheTooFullForBlockError. | [
"Error",
"implements",
"the",
"Error",
"interface",
"for",
"DiskCacheTooFullForBlockError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/errors.go#L1029-L1033 |
158,779 | keybase/client | go/kbfs/dokan/winacl/winacl.go | NewSecurityDescriptorWithBuffer | func NewSecurityDescriptorWithBuffer(bs []byte) *SecurityDescriptor {
for i := range bs {
bs[i] = 0
}
var sd = SecurityDescriptor{bytes: bs,
curOffset: int(unsafe.Sizeof(selfRelativeSecurityDescriptor{}))}
if len(bs) >= sd.curOffset {
sd.ptr = (*selfRelativeSecurityDescriptor)(unsafe.Pointer(&bs[0]))
sd.ptr.Revision = 1
sd.ptr.Control = seSelfRelative | seOwnerDefaulted | seGroupDefaulted
}
return &sd
} | go | func NewSecurityDescriptorWithBuffer(bs []byte) *SecurityDescriptor {
for i := range bs {
bs[i] = 0
}
var sd = SecurityDescriptor{bytes: bs,
curOffset: int(unsafe.Sizeof(selfRelativeSecurityDescriptor{}))}
if len(bs) >= sd.curOffset {
sd.ptr = (*selfRelativeSecurityDescriptor)(unsafe.Pointer(&bs[0]))
sd.ptr.Revision = 1
sd.ptr.Control = seSelfRelative | seOwnerDefaulted | seGroupDefaulted
}
return &sd
} | [
"func",
"NewSecurityDescriptorWithBuffer",
"(",
"bs",
"[",
"]",
"byte",
")",
"*",
"SecurityDescriptor",
"{",
"for",
"i",
":=",
"range",
"bs",
"{",
"bs",
"[",
"i",
"]",
"=",
"0",
"\n",
"}",
"\n",
"var",
"sd",
"=",
"SecurityDescriptor",
"{",
"bytes",
":",
"bs",
",",
"curOffset",
":",
"int",
"(",
"unsafe",
".",
"Sizeof",
"(",
"selfRelativeSecurityDescriptor",
"{",
"}",
")",
")",
"}",
"\n",
"if",
"len",
"(",
"bs",
")",
">=",
"sd",
".",
"curOffset",
"{",
"sd",
".",
"ptr",
"=",
"(",
"*",
"selfRelativeSecurityDescriptor",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"bs",
"[",
"0",
"]",
")",
")",
"\n",
"sd",
".",
"ptr",
".",
"Revision",
"=",
"1",
"\n",
"sd",
".",
"ptr",
".",
"Control",
"=",
"seSelfRelative",
"|",
"seOwnerDefaulted",
"|",
"seGroupDefaulted",
"\n",
"}",
"\n",
"return",
"&",
"sd",
"\n",
"}"
] | // NewSecurityDescriptorWithBuffer creates a new self-referential
// security descriptor in the buffer provided. | [
"NewSecurityDescriptorWithBuffer",
"creates",
"a",
"new",
"self",
"-",
"referential",
"security",
"descriptor",
"in",
"the",
"buffer",
"provided",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/winacl/winacl.go#L27-L39 |
158,780 | keybase/client | go/kbfs/dokan/winacl/winacl.go | SetOwner | func (sd *SecurityDescriptor) SetOwner(sid *SID) {
if off := sd.setSid(sid); off != 0 {
sd.ptr.OwnerOffset = int32(off)
sd.ptr.Control &^= seOwnerDefaulted
}
} | go | func (sd *SecurityDescriptor) SetOwner(sid *SID) {
if off := sd.setSid(sid); off != 0 {
sd.ptr.OwnerOffset = int32(off)
sd.ptr.Control &^= seOwnerDefaulted
}
} | [
"func",
"(",
"sd",
"*",
"SecurityDescriptor",
")",
"SetOwner",
"(",
"sid",
"*",
"SID",
")",
"{",
"if",
"off",
":=",
"sd",
".",
"setSid",
"(",
"sid",
")",
";",
"off",
"!=",
"0",
"{",
"sd",
".",
"ptr",
".",
"OwnerOffset",
"=",
"int32",
"(",
"off",
")",
"\n",
"sd",
".",
"ptr",
".",
"Control",
"&^=",
"seOwnerDefaulted",
"\n",
"}",
"\n",
"}"
] | // SetOwner sets the owner field of a SecurityDescriptor. | [
"SetOwner",
"sets",
"the",
"owner",
"field",
"of",
"a",
"SecurityDescriptor",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/winacl/winacl.go#L78-L83 |
158,781 | keybase/client | go/kbfs/dokan/winacl/winacl.go | SetGroup | func (sd *SecurityDescriptor) SetGroup(sid *SID) {
if off := sd.setSid(sid); off != 0 {
sd.ptr.GroupOffset = int32(off)
sd.ptr.Control &^= seGroupDefaulted
}
} | go | func (sd *SecurityDescriptor) SetGroup(sid *SID) {
if off := sd.setSid(sid); off != 0 {
sd.ptr.GroupOffset = int32(off)
sd.ptr.Control &^= seGroupDefaulted
}
} | [
"func",
"(",
"sd",
"*",
"SecurityDescriptor",
")",
"SetGroup",
"(",
"sid",
"*",
"SID",
")",
"{",
"if",
"off",
":=",
"sd",
".",
"setSid",
"(",
"sid",
")",
";",
"off",
"!=",
"0",
"{",
"sd",
".",
"ptr",
".",
"GroupOffset",
"=",
"int32",
"(",
"off",
")",
"\n",
"sd",
".",
"ptr",
".",
"Control",
"&^=",
"seGroupDefaulted",
"\n",
"}",
"\n",
"}"
] | // SetGroup sets the owner field of a SecurityDescriptor. | [
"SetGroup",
"sets",
"the",
"owner",
"field",
"of",
"a",
"SecurityDescriptor",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/winacl/winacl.go#L86-L91 |
158,782 | keybase/client | go/kbfs/dokan/winacl/winacl.go | SetDacl | func (sd *SecurityDescriptor) SetDacl(acl *ACL) {
bs := acl.bytes()
off := sd.curOffset
sd.curOffset += len(bs)
if sd.HasOverflowed() {
return
}
copy(sd.bytes[off:], bs)
sd.ptr.Control |= seDaclPresent
sd.ptr.DaclOffset = int32(off)
} | go | func (sd *SecurityDescriptor) SetDacl(acl *ACL) {
bs := acl.bytes()
off := sd.curOffset
sd.curOffset += len(bs)
if sd.HasOverflowed() {
return
}
copy(sd.bytes[off:], bs)
sd.ptr.Control |= seDaclPresent
sd.ptr.DaclOffset = int32(off)
} | [
"func",
"(",
"sd",
"*",
"SecurityDescriptor",
")",
"SetDacl",
"(",
"acl",
"*",
"ACL",
")",
"{",
"bs",
":=",
"acl",
".",
"bytes",
"(",
")",
"\n",
"off",
":=",
"sd",
".",
"curOffset",
"\n",
"sd",
".",
"curOffset",
"+=",
"len",
"(",
"bs",
")",
"\n",
"if",
"sd",
".",
"HasOverflowed",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"copy",
"(",
"sd",
".",
"bytes",
"[",
"off",
":",
"]",
",",
"bs",
")",
"\n",
"sd",
".",
"ptr",
".",
"Control",
"|=",
"seDaclPresent",
"\n",
"sd",
".",
"ptr",
".",
"DaclOffset",
"=",
"int32",
"(",
"off",
")",
"\n",
"}"
] | // SetDacl sets a dacl in the security descriptor to the given ACL. | [
"SetDacl",
"sets",
"a",
"dacl",
"in",
"the",
"security",
"descriptor",
"to",
"the",
"given",
"ACL",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/winacl/winacl.go#L94-L104 |
158,783 | keybase/client | go/kbfs/dokan/winacl/winacl.go | bufToSlice | func bufToSlice(ptr unsafe.Pointer, nbytes int) []byte {
if ptr == nil || nbytes == 0 {
return nil
}
return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(ptr),
Len: int(nbytes),
Cap: int(nbytes)}))
} | go | func bufToSlice(ptr unsafe.Pointer, nbytes int) []byte {
if ptr == nil || nbytes == 0 {
return nil
}
return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(ptr),
Len: int(nbytes),
Cap: int(nbytes)}))
} | [
"func",
"bufToSlice",
"(",
"ptr",
"unsafe",
".",
"Pointer",
",",
"nbytes",
"int",
")",
"[",
"]",
"byte",
"{",
"if",
"ptr",
"==",
"nil",
"||",
"nbytes",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"*",
"(",
"*",
"[",
"]",
"byte",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"reflect",
".",
"SliceHeader",
"{",
"Data",
":",
"uintptr",
"(",
"ptr",
")",
",",
"Len",
":",
"int",
"(",
"nbytes",
")",
",",
"Cap",
":",
"int",
"(",
"nbytes",
")",
"}",
")",
")",
"\n",
"}"
] | // bufToSlice returns a byte slice aliasing the pointer and length given as arguments. | [
"bufToSlice",
"returns",
"a",
"byte",
"slice",
"aliasing",
"the",
"pointer",
"and",
"length",
"given",
"as",
"arguments",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/winacl/winacl.go#L127-L135 |
158,784 | keybase/client | go/chat/unfurl/cache.go | get | func (c *unfurlCache) get(key string) (res cacheItem, ok bool) {
c.Lock()
defer c.Unlock()
item, ok := c.cache.Get(key)
if !ok {
return res, false
}
cacheItem, ok := item.(cacheItem)
if !ok {
return res, false
}
valid := c.clock.Now().Sub(cacheItem.ctime.Time()) <= defaultCacheLifetime
if !valid {
c.cache.Remove(key)
}
return cacheItem, valid
} | go | func (c *unfurlCache) get(key string) (res cacheItem, ok bool) {
c.Lock()
defer c.Unlock()
item, ok := c.cache.Get(key)
if !ok {
return res, false
}
cacheItem, ok := item.(cacheItem)
if !ok {
return res, false
}
valid := c.clock.Now().Sub(cacheItem.ctime.Time()) <= defaultCacheLifetime
if !valid {
c.cache.Remove(key)
}
return cacheItem, valid
} | [
"func",
"(",
"c",
"*",
"unfurlCache",
")",
"get",
"(",
"key",
"string",
")",
"(",
"res",
"cacheItem",
",",
"ok",
"bool",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n\n",
"item",
",",
"ok",
":=",
"c",
".",
"cache",
".",
"Get",
"(",
"key",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"res",
",",
"false",
"\n",
"}",
"\n",
"cacheItem",
",",
"ok",
":=",
"item",
".",
"(",
"cacheItem",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"res",
",",
"false",
"\n",
"}",
"\n",
"valid",
":=",
"c",
".",
"clock",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"cacheItem",
".",
"ctime",
".",
"Time",
"(",
")",
")",
"<=",
"defaultCacheLifetime",
"\n",
"if",
"!",
"valid",
"{",
"c",
".",
"cache",
".",
"Remove",
"(",
"key",
")",
"\n",
"}",
"\n",
"return",
"cacheItem",
",",
"valid",
"\n",
"}"
] | // get determines if the item is in the cache and newer than 10
// minutes. We don't want to cache this value indefinitely in case the page
// content changes. | [
"get",
"determines",
"if",
"the",
"item",
"is",
"in",
"the",
"cache",
"and",
"newer",
"than",
"10",
"minutes",
".",
"We",
"don",
"t",
"want",
"to",
"cache",
"this",
"value",
"indefinitely",
"in",
"case",
"the",
"page",
"content",
"changes",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/unfurl/cache.go#L44-L61 |
158,785 | keybase/client | go/libkb/paperkey_phrase.go | MakePaperKeyPhrase | func MakePaperKeyPhrase(version uint8) (PaperKeyPhrase, error) {
nbits := PaperKeySecretEntropy + PaperKeyIDBits + PaperKeyVersionBits
for i := 0; i < 1000; i++ {
words, err := SecWordList(nbits)
if err != nil {
return "", err
}
if wordVersion(words[len(words)-1]) != version {
continue
}
return NewPaperKeyPhrase(strings.Join(words, " ")), nil
}
return "", KeyGenError{Msg: "exhausted attempts to generate valid paper key"}
} | go | func MakePaperKeyPhrase(version uint8) (PaperKeyPhrase, error) {
nbits := PaperKeySecretEntropy + PaperKeyIDBits + PaperKeyVersionBits
for i := 0; i < 1000; i++ {
words, err := SecWordList(nbits)
if err != nil {
return "", err
}
if wordVersion(words[len(words)-1]) != version {
continue
}
return NewPaperKeyPhrase(strings.Join(words, " ")), nil
}
return "", KeyGenError{Msg: "exhausted attempts to generate valid paper key"}
} | [
"func",
"MakePaperKeyPhrase",
"(",
"version",
"uint8",
")",
"(",
"PaperKeyPhrase",
",",
"error",
")",
"{",
"nbits",
":=",
"PaperKeySecretEntropy",
"+",
"PaperKeyIDBits",
"+",
"PaperKeyVersionBits",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"1000",
";",
"i",
"++",
"{",
"words",
",",
"err",
":=",
"SecWordList",
"(",
"nbits",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"if",
"wordVersion",
"(",
"words",
"[",
"len",
"(",
"words",
")",
"-",
"1",
"]",
")",
"!=",
"version",
"{",
"continue",
"\n",
"}",
"\n",
"return",
"NewPaperKeyPhrase",
"(",
"strings",
".",
"Join",
"(",
"words",
",",
"\"",
"\"",
")",
")",
",",
"nil",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
",",
"KeyGenError",
"{",
"Msg",
":",
"\"",
"\"",
"}",
"\n",
"}"
] | // MakePaperKeyPhrase creates a new, random paper key phrase for
// the given version. | [
"MakePaperKeyPhrase",
"creates",
"a",
"new",
"random",
"paper",
"key",
"phrase",
"for",
"the",
"given",
"version",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/paperkey_phrase.go#L20-L33 |
158,786 | keybase/client | go/libkb/paperkey_phrase.go | NewPaperKeyPhrase | func NewPaperKeyPhrase(phrase string) PaperKeyPhrase {
phrase = strings.TrimSpace(strings.ToLower(phrase))
return PaperKeyPhrase(strings.Join(strings.Fields(phrase), " "))
} | go | func NewPaperKeyPhrase(phrase string) PaperKeyPhrase {
phrase = strings.TrimSpace(strings.ToLower(phrase))
return PaperKeyPhrase(strings.Join(strings.Fields(phrase), " "))
} | [
"func",
"NewPaperKeyPhrase",
"(",
"phrase",
"string",
")",
"PaperKeyPhrase",
"{",
"phrase",
"=",
"strings",
".",
"TrimSpace",
"(",
"strings",
".",
"ToLower",
"(",
"phrase",
")",
")",
"\n",
"return",
"PaperKeyPhrase",
"(",
"strings",
".",
"Join",
"(",
"strings",
".",
"Fields",
"(",
"phrase",
")",
",",
"\"",
"\"",
")",
")",
"\n",
"}"
] | // NewPaperKeyPhrase converts a string into a PaperKeyPhrase. | [
"NewPaperKeyPhrase",
"converts",
"a",
"string",
"into",
"a",
"PaperKeyPhrase",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/paperkey_phrase.go#L36-L39 |
158,787 | keybase/client | go/libkb/paperkey_phrase.go | Version | func (p PaperKeyPhrase) Version() (uint8, error) {
words := p.words()
if len(words) == 0 {
return 0, errors.New("empty paper key phrase")
}
return wordVersion(words[len(words)-1]), nil
} | go | func (p PaperKeyPhrase) Version() (uint8, error) {
words := p.words()
if len(words) == 0 {
return 0, errors.New("empty paper key phrase")
}
return wordVersion(words[len(words)-1]), nil
} | [
"func",
"(",
"p",
"PaperKeyPhrase",
")",
"Version",
"(",
")",
"(",
"uint8",
",",
"error",
")",
"{",
"words",
":=",
"p",
".",
"words",
"(",
")",
"\n",
"if",
"len",
"(",
"words",
")",
"==",
"0",
"{",
"return",
"0",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"wordVersion",
"(",
"words",
"[",
"len",
"(",
"words",
")",
"-",
"1",
"]",
")",
",",
"nil",
"\n",
"}"
] | // Version calculates the phrase version. 0-15 are possible
// versions. | [
"Version",
"calculates",
"the",
"phrase",
"version",
".",
"0",
"-",
"15",
"are",
"possible",
"versions",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/paperkey_phrase.go#L53-L59 |
158,788 | keybase/client | go/libkb/paperkey_phrase.go | wordVersion | func wordVersion(word string) uint8 {
h := sha256.Sum256([]byte(word))
if PaperKeyVersionBits > 8 {
panic("PaperKeyVersionBits must be 8 bits or fewer")
}
return h[len(h)-1] & ((1 << PaperKeyVersionBits) - 1)
} | go | func wordVersion(word string) uint8 {
h := sha256.Sum256([]byte(word))
if PaperKeyVersionBits > 8 {
panic("PaperKeyVersionBits must be 8 bits or fewer")
}
return h[len(h)-1] & ((1 << PaperKeyVersionBits) - 1)
} | [
"func",
"wordVersion",
"(",
"word",
"string",
")",
"uint8",
"{",
"h",
":=",
"sha256",
".",
"Sum256",
"(",
"[",
"]",
"byte",
"(",
"word",
")",
")",
"\n",
"if",
"PaperKeyVersionBits",
">",
"8",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"h",
"[",
"len",
"(",
"h",
")",
"-",
"1",
"]",
"&",
"(",
"(",
"1",
"<<",
"PaperKeyVersionBits",
")",
"-",
"1",
")",
"\n",
"}"
] | // wordVersion calculates the paper key phrase version based on a
// word. | [
"wordVersion",
"calculates",
"the",
"paper",
"key",
"phrase",
"version",
"based",
"on",
"a",
"word",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/paperkey_phrase.go#L87-L93 |
158,789 | keybase/client | go/engine/passphrase_change.go | NewPassphraseChange | func NewPassphraseChange(g *libkb.GlobalContext, a *keybase1.PassphraseChangeArg) *PassphraseChange {
return &PassphraseChange{
arg: a,
Contextified: libkb.NewContextified(g),
}
} | go | func NewPassphraseChange(g *libkb.GlobalContext, a *keybase1.PassphraseChangeArg) *PassphraseChange {
return &PassphraseChange{
arg: a,
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewPassphraseChange",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"a",
"*",
"keybase1",
".",
"PassphraseChangeArg",
")",
"*",
"PassphraseChange",
"{",
"return",
"&",
"PassphraseChange",
"{",
"arg",
":",
"a",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"}"
] | // NewPassphraseChange creates a new engine for changing user passphrases,
// either if the current passphrase is known, or in "force" mode | [
"NewPassphraseChange",
"creates",
"a",
"new",
"engine",
"for",
"changing",
"user",
"passphrases",
"either",
"if",
"the",
"current",
"passphrase",
"is",
"known",
"or",
"in",
"force",
"mode"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/passphrase_change.go#L25-L30 |
158,790 | keybase/client | go/engine/passphrase_change.go | Prereqs | func (c *PassphraseChange) Prereqs() Prereqs {
if c.arg.Force {
return Prereqs{}
}
return Prereqs{Device: true}
} | go | func (c *PassphraseChange) Prereqs() Prereqs {
if c.arg.Force {
return Prereqs{}
}
return Prereqs{Device: true}
} | [
"func",
"(",
"c",
"*",
"PassphraseChange",
")",
"Prereqs",
"(",
")",
"Prereqs",
"{",
"if",
"c",
".",
"arg",
".",
"Force",
"{",
"return",
"Prereqs",
"{",
"}",
"\n",
"}",
"\n\n",
"return",
"Prereqs",
"{",
"Device",
":",
"true",
"}",
"\n",
"}"
] | // Prereqs returns engine prereqs | [
"Prereqs",
"returns",
"engine",
"prereqs"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/passphrase_change.go#L38-L44 |
158,791 | keybase/client | go/engine/passphrase_change.go | findUpdateDevice | func (c *PassphraseChange) findUpdateDevice(m libkb.MetaContext) (ad *libkb.ActiveDevice, err error) {
defer m.Trace("PassphraseChange#findUpdateDevice", func() error { return err })()
if ad = m.G().ActiveDevice; ad.Valid() {
m.Debug("| returning globally active device key")
return ad, nil
}
kp, err := c.findPaperKeys(m)
if err != nil {
m.Debug("| error fetching paper keys")
return nil, err
}
ad = libkb.NewActiveDeviceWithDeviceWithKeys(m, m.CurrentUserVersion(), kp)
m.Debug("| installing paper key as thread-local active device")
return ad, nil
} | go | func (c *PassphraseChange) findUpdateDevice(m libkb.MetaContext) (ad *libkb.ActiveDevice, err error) {
defer m.Trace("PassphraseChange#findUpdateDevice", func() error { return err })()
if ad = m.G().ActiveDevice; ad.Valid() {
m.Debug("| returning globally active device key")
return ad, nil
}
kp, err := c.findPaperKeys(m)
if err != nil {
m.Debug("| error fetching paper keys")
return nil, err
}
ad = libkb.NewActiveDeviceWithDeviceWithKeys(m, m.CurrentUserVersion(), kp)
m.Debug("| installing paper key as thread-local active device")
return ad, nil
} | [
"func",
"(",
"c",
"*",
"PassphraseChange",
")",
"findUpdateDevice",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"ad",
"*",
"libkb",
".",
"ActiveDevice",
",",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"if",
"ad",
"=",
"m",
".",
"G",
"(",
")",
".",
"ActiveDevice",
";",
"ad",
".",
"Valid",
"(",
")",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"ad",
",",
"nil",
"\n",
"}",
"\n",
"kp",
",",
"err",
":=",
"c",
".",
"findPaperKeys",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ad",
"=",
"libkb",
".",
"NewActiveDeviceWithDeviceWithKeys",
"(",
"m",
",",
"m",
".",
"CurrentUserVersion",
"(",
")",
",",
"kp",
")",
"\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"ad",
",",
"nil",
"\n",
"}"
] | // findUpdateKeys looks for keys to perform the passphrase update.
// The first choice is device keys. If that fails, it will look
// for backup keys. If backup keys are necessary, then it will
// also log the user in with the backup keys. | [
"findUpdateKeys",
"looks",
"for",
"keys",
"to",
"perform",
"the",
"passphrase",
"update",
".",
"The",
"first",
"choice",
"is",
"device",
"keys",
".",
"If",
"that",
"fails",
"it",
"will",
"look",
"for",
"backup",
"keys",
".",
"If",
"backup",
"keys",
"are",
"necessary",
"then",
"it",
"will",
"also",
"log",
"the",
"user",
"in",
"with",
"the",
"backup",
"keys",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/passphrase_change.go#L120-L134 |
158,792 | keybase/client | go/engine/passphrase_change.go | runForcedUpdate | func (c *PassphraseChange) runForcedUpdate(m libkb.MetaContext) (err error) {
defer m.Trace("PassphraseChange#runForcedUpdate", func() error { return err })()
ad, err := c.findUpdateDevice(m)
if err != nil {
return
}
if ad == nil {
return libkb.NoSecretKeyError{}
}
enc, err := ad.EncryptionKey()
if err != nil {
return err
}
sig, err := ad.SigningKey()
if err != nil {
return err
}
m = m.WithActiveDevice(ad)
ppGen, oldClientHalf, err := fetchLKS(m, enc)
if err != nil {
return
}
err = c.forceUpdatePassphrase(m, sig, ppGen, oldClientHalf)
if err != nil {
return err
}
_, err = m.SyncSecrets()
if err != nil {
return err
}
m = m.WithGlobalActiveDevice()
// Reset passphrase stream cache so that subsequent updates go through
// without a problem (see CORE-3933)
m.ActiveDevice().ClearCaches()
return nil
} | go | func (c *PassphraseChange) runForcedUpdate(m libkb.MetaContext) (err error) {
defer m.Trace("PassphraseChange#runForcedUpdate", func() error { return err })()
ad, err := c.findUpdateDevice(m)
if err != nil {
return
}
if ad == nil {
return libkb.NoSecretKeyError{}
}
enc, err := ad.EncryptionKey()
if err != nil {
return err
}
sig, err := ad.SigningKey()
if err != nil {
return err
}
m = m.WithActiveDevice(ad)
ppGen, oldClientHalf, err := fetchLKS(m, enc)
if err != nil {
return
}
err = c.forceUpdatePassphrase(m, sig, ppGen, oldClientHalf)
if err != nil {
return err
}
_, err = m.SyncSecrets()
if err != nil {
return err
}
m = m.WithGlobalActiveDevice()
// Reset passphrase stream cache so that subsequent updates go through
// without a problem (see CORE-3933)
m.ActiveDevice().ClearCaches()
return nil
} | [
"func",
"(",
"c",
"*",
"PassphraseChange",
")",
"runForcedUpdate",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"ad",
",",
"err",
":=",
"c",
".",
"findUpdateDevice",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"ad",
"==",
"nil",
"{",
"return",
"libkb",
".",
"NoSecretKeyError",
"{",
"}",
"\n",
"}",
"\n\n",
"enc",
",",
"err",
":=",
"ad",
".",
"EncryptionKey",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"sig",
",",
"err",
":=",
"ad",
".",
"SigningKey",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"m",
"=",
"m",
".",
"WithActiveDevice",
"(",
"ad",
")",
"\n",
"ppGen",
",",
"oldClientHalf",
",",
"err",
":=",
"fetchLKS",
"(",
"m",
",",
"enc",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"err",
"=",
"c",
".",
"forceUpdatePassphrase",
"(",
"m",
",",
"sig",
",",
"ppGen",
",",
"oldClientHalf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"m",
".",
"SyncSecrets",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"m",
"=",
"m",
".",
"WithGlobalActiveDevice",
"(",
")",
"\n",
"// Reset passphrase stream cache so that subsequent updates go through",
"// without a problem (see CORE-3933)",
"m",
".",
"ActiveDevice",
"(",
")",
".",
"ClearCaches",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // 1. Get keys for decryption and signing
// 2. If necessary, log in with backup keys
// 3. Get lks client half from server
// 4. Post an update passphrase proof | [
"1",
".",
"Get",
"keys",
"for",
"decryption",
"and",
"signing",
"2",
".",
"If",
"necessary",
"log",
"in",
"with",
"backup",
"keys",
"3",
".",
"Get",
"lks",
"client",
"half",
"from",
"server",
"4",
".",
"Post",
"an",
"update",
"passphrase",
"proof"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/passphrase_change.go#L202-L244 |
158,793 | keybase/client | go/engine/passphrase_change.go | runStandardUpdate | func (c *PassphraseChange) runStandardUpdate(m libkb.MetaContext) (err error) {
defer m.Trace("PassphraseChange.runStandardUpdate", func() error { return err })()
var ppStream *libkb.PassphraseStream
if len(c.arg.OldPassphrase) == 0 {
ppStream, err = libkb.GetPassphraseStreamViaPromptInLoginContext(m)
} else {
ppStream, err = libkb.VerifyPassphraseGetStreamInLoginContext(m, c.arg.OldPassphrase)
}
if err != nil {
return err
}
pgpKeys, err := c.findAndDecryptPrivatePGPKeys(m)
if err != nil {
return err
}
gen := m.PassphraseStream().Generation()
oldClientHalf := m.PassphraseStream().LksClientHalf()
payload, err := c.commonArgs(m, oldClientHalf, pgpKeys, gen)
if err != nil {
return err
}
lp, err := libkb.ComputeLoginPackage2(m, ppStream)
if err != nil {
return err
}
payload["ppgen"] = gen
payload["old_pdpka4"] = lp.PDPKA4()
payload["old_pdpka5"] = lp.PDPKA5()
postArg := libkb.APIArg{
Endpoint: "passphrase/replace",
SessionType: libkb.APISessionTypeREQUIRED,
JSONPayload: payload,
}
_, err = c.G().API.PostJSON(m, postArg)
if err != nil {
return err
}
_, err = m.SyncSecrets()
if err != nil {
return err
}
// Reset the passphrase stream cache on the global Active Device, since if it exists,
// it was for a previous version of the passphrase.
m = m.WithGlobalActiveDevice()
m.ActiveDevice().ClearCaches()
return nil
} | go | func (c *PassphraseChange) runStandardUpdate(m libkb.MetaContext) (err error) {
defer m.Trace("PassphraseChange.runStandardUpdate", func() error { return err })()
var ppStream *libkb.PassphraseStream
if len(c.arg.OldPassphrase) == 0 {
ppStream, err = libkb.GetPassphraseStreamViaPromptInLoginContext(m)
} else {
ppStream, err = libkb.VerifyPassphraseGetStreamInLoginContext(m, c.arg.OldPassphrase)
}
if err != nil {
return err
}
pgpKeys, err := c.findAndDecryptPrivatePGPKeys(m)
if err != nil {
return err
}
gen := m.PassphraseStream().Generation()
oldClientHalf := m.PassphraseStream().LksClientHalf()
payload, err := c.commonArgs(m, oldClientHalf, pgpKeys, gen)
if err != nil {
return err
}
lp, err := libkb.ComputeLoginPackage2(m, ppStream)
if err != nil {
return err
}
payload["ppgen"] = gen
payload["old_pdpka4"] = lp.PDPKA4()
payload["old_pdpka5"] = lp.PDPKA5()
postArg := libkb.APIArg{
Endpoint: "passphrase/replace",
SessionType: libkb.APISessionTypeREQUIRED,
JSONPayload: payload,
}
_, err = c.G().API.PostJSON(m, postArg)
if err != nil {
return err
}
_, err = m.SyncSecrets()
if err != nil {
return err
}
// Reset the passphrase stream cache on the global Active Device, since if it exists,
// it was for a previous version of the passphrase.
m = m.WithGlobalActiveDevice()
m.ActiveDevice().ClearCaches()
return nil
} | [
"func",
"(",
"c",
"*",
"PassphraseChange",
")",
"runStandardUpdate",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"var",
"ppStream",
"*",
"libkb",
".",
"PassphraseStream",
"\n",
"if",
"len",
"(",
"c",
".",
"arg",
".",
"OldPassphrase",
")",
"==",
"0",
"{",
"ppStream",
",",
"err",
"=",
"libkb",
".",
"GetPassphraseStreamViaPromptInLoginContext",
"(",
"m",
")",
"\n",
"}",
"else",
"{",
"ppStream",
",",
"err",
"=",
"libkb",
".",
"VerifyPassphraseGetStreamInLoginContext",
"(",
"m",
",",
"c",
".",
"arg",
".",
"OldPassphrase",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"pgpKeys",
",",
"err",
":=",
"c",
".",
"findAndDecryptPrivatePGPKeys",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"gen",
":=",
"m",
".",
"PassphraseStream",
"(",
")",
".",
"Generation",
"(",
")",
"\n",
"oldClientHalf",
":=",
"m",
".",
"PassphraseStream",
"(",
")",
".",
"LksClientHalf",
"(",
")",
"\n\n",
"payload",
",",
"err",
":=",
"c",
".",
"commonArgs",
"(",
"m",
",",
"oldClientHalf",
",",
"pgpKeys",
",",
"gen",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"lp",
",",
"err",
":=",
"libkb",
".",
"ComputeLoginPackage2",
"(",
"m",
",",
"ppStream",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"payload",
"[",
"\"",
"\"",
"]",
"=",
"gen",
"\n",
"payload",
"[",
"\"",
"\"",
"]",
"=",
"lp",
".",
"PDPKA4",
"(",
")",
"\n",
"payload",
"[",
"\"",
"\"",
"]",
"=",
"lp",
".",
"PDPKA5",
"(",
")",
"\n\n",
"postArg",
":=",
"libkb",
".",
"APIArg",
"{",
"Endpoint",
":",
"\"",
"\"",
",",
"SessionType",
":",
"libkb",
".",
"APISessionTypeREQUIRED",
",",
"JSONPayload",
":",
"payload",
",",
"}",
"\n\n",
"_",
",",
"err",
"=",
"c",
".",
"G",
"(",
")",
".",
"API",
".",
"PostJSON",
"(",
"m",
",",
"postArg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"m",
".",
"SyncSecrets",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Reset the passphrase stream cache on the global Active Device, since if it exists,",
"// it was for a previous version of the passphrase.",
"m",
"=",
"m",
".",
"WithGlobalActiveDevice",
"(",
")",
"\n",
"m",
".",
"ActiveDevice",
"(",
")",
".",
"ClearCaches",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // runStandardUpdate is for when the user knows the current password. | [
"runStandardUpdate",
"is",
"for",
"when",
"the",
"user",
"knows",
"the",
"current",
"password",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/passphrase_change.go#L247-L305 |
158,794 | keybase/client | go/engine/passphrase_change.go | findAndDecryptPrivatePGPKeys | func (c *PassphraseChange) findAndDecryptPrivatePGPKeys(m libkb.MetaContext) ([]libkb.GenericKey, error) {
var keyList []libkb.GenericKey
// Using a paper key makes TripleSec-synced keys unrecoverable
if c.usingPaper {
m.Debug("using a paper key, thus TripleSec-synced keys are unrecoverable")
return keyList, nil
}
// Only use the synced secret keys:
blocks, err := c.me.AllSyncedSecretKeys(m)
if err != nil {
return nil, err
}
secretRetriever := libkb.NewSecretStore(c.G(), c.me.GetNormalizedName())
for _, block := range blocks {
parg := m.SecretKeyPromptArg(libkb.SecretKeyArg{}, "passphrase change")
key, err := block.PromptAndUnlock(m, parg, secretRetriever, c.me)
if err != nil {
return nil, err
}
keyList = append(keyList, key)
}
return keyList, nil
} | go | func (c *PassphraseChange) findAndDecryptPrivatePGPKeys(m libkb.MetaContext) ([]libkb.GenericKey, error) {
var keyList []libkb.GenericKey
// Using a paper key makes TripleSec-synced keys unrecoverable
if c.usingPaper {
m.Debug("using a paper key, thus TripleSec-synced keys are unrecoverable")
return keyList, nil
}
// Only use the synced secret keys:
blocks, err := c.me.AllSyncedSecretKeys(m)
if err != nil {
return nil, err
}
secretRetriever := libkb.NewSecretStore(c.G(), c.me.GetNormalizedName())
for _, block := range blocks {
parg := m.SecretKeyPromptArg(libkb.SecretKeyArg{}, "passphrase change")
key, err := block.PromptAndUnlock(m, parg, secretRetriever, c.me)
if err != nil {
return nil, err
}
keyList = append(keyList, key)
}
return keyList, nil
} | [
"func",
"(",
"c",
"*",
"PassphraseChange",
")",
"findAndDecryptPrivatePGPKeys",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"[",
"]",
"libkb",
".",
"GenericKey",
",",
"error",
")",
"{",
"var",
"keyList",
"[",
"]",
"libkb",
".",
"GenericKey",
"\n\n",
"// Using a paper key makes TripleSec-synced keys unrecoverable",
"if",
"c",
".",
"usingPaper",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"keyList",
",",
"nil",
"\n",
"}",
"\n\n",
"// Only use the synced secret keys:",
"blocks",
",",
"err",
":=",
"c",
".",
"me",
".",
"AllSyncedSecretKeys",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"secretRetriever",
":=",
"libkb",
".",
"NewSecretStore",
"(",
"c",
".",
"G",
"(",
")",
",",
"c",
".",
"me",
".",
"GetNormalizedName",
"(",
")",
")",
"\n\n",
"for",
"_",
",",
"block",
":=",
"range",
"blocks",
"{",
"parg",
":=",
"m",
".",
"SecretKeyPromptArg",
"(",
"libkb",
".",
"SecretKeyArg",
"{",
"}",
",",
"\"",
"\"",
")",
"\n",
"key",
",",
"err",
":=",
"block",
".",
"PromptAndUnlock",
"(",
"m",
",",
"parg",
",",
"secretRetriever",
",",
"c",
".",
"me",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"keyList",
"=",
"append",
"(",
"keyList",
",",
"key",
")",
"\n",
"}",
"\n\n",
"return",
"keyList",
",",
"nil",
"\n",
"}"
] | // findAndDecryptPrivatePGPKeys gets the user's private pgp keys if any exist and decrypts them. | [
"findAndDecryptPrivatePGPKeys",
"gets",
"the",
"user",
"s",
"private",
"pgp",
"keys",
"if",
"any",
"exist",
"and",
"decrypts",
"them",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/passphrase_change.go#L370-L398 |
158,795 | keybase/client | go/engine/passphrase_change.go | findAndDecryptPrivatePGPKeysLossy | func (c *PassphraseChange) findAndDecryptPrivatePGPKeysLossy(m libkb.MetaContext) ([]libkb.GenericKey, int, error) {
var keyList []libkb.GenericKey
nLost := 0
// Only use the synced secret keys:
blocks, err := c.me.AllSyncedSecretKeys(m)
if err != nil {
return nil, 0, err
}
secretRetriever := libkb.NewSecretStore(c.G(), c.me.GetNormalizedName())
for _, block := range blocks {
key, err := block.UnlockNoPrompt(m, secretRetriever)
if err == nil {
keyList = append(keyList, key)
} else {
if err != libkb.ErrUnlockNotPossible {
return nil, 0, err
}
nLost++
m.Debug("findAndDecryptPrivatePGPKeysLossy: ignoring failure to decrypt key without prompt")
}
}
return keyList, nLost, nil
} | go | func (c *PassphraseChange) findAndDecryptPrivatePGPKeysLossy(m libkb.MetaContext) ([]libkb.GenericKey, int, error) {
var keyList []libkb.GenericKey
nLost := 0
// Only use the synced secret keys:
blocks, err := c.me.AllSyncedSecretKeys(m)
if err != nil {
return nil, 0, err
}
secretRetriever := libkb.NewSecretStore(c.G(), c.me.GetNormalizedName())
for _, block := range blocks {
key, err := block.UnlockNoPrompt(m, secretRetriever)
if err == nil {
keyList = append(keyList, key)
} else {
if err != libkb.ErrUnlockNotPossible {
return nil, 0, err
}
nLost++
m.Debug("findAndDecryptPrivatePGPKeysLossy: ignoring failure to decrypt key without prompt")
}
}
return keyList, nLost, nil
} | [
"func",
"(",
"c",
"*",
"PassphraseChange",
")",
"findAndDecryptPrivatePGPKeysLossy",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"[",
"]",
"libkb",
".",
"GenericKey",
",",
"int",
",",
"error",
")",
"{",
"var",
"keyList",
"[",
"]",
"libkb",
".",
"GenericKey",
"\n",
"nLost",
":=",
"0",
"\n\n",
"// Only use the synced secret keys:",
"blocks",
",",
"err",
":=",
"c",
".",
"me",
".",
"AllSyncedSecretKeys",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"secretRetriever",
":=",
"libkb",
".",
"NewSecretStore",
"(",
"c",
".",
"G",
"(",
")",
",",
"c",
".",
"me",
".",
"GetNormalizedName",
"(",
")",
")",
"\n\n",
"for",
"_",
",",
"block",
":=",
"range",
"blocks",
"{",
"key",
",",
"err",
":=",
"block",
".",
"UnlockNoPrompt",
"(",
"m",
",",
"secretRetriever",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"keyList",
"=",
"append",
"(",
"keyList",
",",
"key",
")",
"\n",
"}",
"else",
"{",
"if",
"err",
"!=",
"libkb",
".",
"ErrUnlockNotPossible",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"nLost",
"++",
"\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"keyList",
",",
"nLost",
",",
"nil",
"\n",
"}"
] | // findAndDecryptPrivatePGPKeysLossy gets the user's private pgp keys if any exist and attempts
// to decrypt them without prompting the user. If any fail to decrypt, they are silently not returned.
// The second return value is the number of keys which were not decrypted. | [
"findAndDecryptPrivatePGPKeysLossy",
"gets",
"the",
"user",
"s",
"private",
"pgp",
"keys",
"if",
"any",
"exist",
"and",
"attempts",
"to",
"decrypt",
"them",
"without",
"prompting",
"the",
"user",
".",
"If",
"any",
"fail",
"to",
"decrypt",
"they",
"are",
"silently",
"not",
"returned",
".",
"The",
"second",
"return",
"value",
"is",
"the",
"number",
"of",
"keys",
"which",
"were",
"not",
"decrypted",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/passphrase_change.go#L403-L430 |
158,796 | keybase/client | go/engine/passphrase_change.go | encodePrivatePGPKey | func (c *PassphraseChange) encodePrivatePGPKey(key libkb.GenericKey, tsec libkb.Triplesec, gen libkb.PassphraseGeneration) (string, error) {
skb, err := libkb.ToServerSKB(c.G(), key, tsec, gen)
if err != nil {
return "", err
}
return skb.ArmoredEncode()
} | go | func (c *PassphraseChange) encodePrivatePGPKey(key libkb.GenericKey, tsec libkb.Triplesec, gen libkb.PassphraseGeneration) (string, error) {
skb, err := libkb.ToServerSKB(c.G(), key, tsec, gen)
if err != nil {
return "", err
}
return skb.ArmoredEncode()
} | [
"func",
"(",
"c",
"*",
"PassphraseChange",
")",
"encodePrivatePGPKey",
"(",
"key",
"libkb",
".",
"GenericKey",
",",
"tsec",
"libkb",
".",
"Triplesec",
",",
"gen",
"libkb",
".",
"PassphraseGeneration",
")",
"(",
"string",
",",
"error",
")",
"{",
"skb",
",",
"err",
":=",
"libkb",
".",
"ToServerSKB",
"(",
"c",
".",
"G",
"(",
")",
",",
"key",
",",
"tsec",
",",
"gen",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"skb",
".",
"ArmoredEncode",
"(",
")",
"\n",
"}"
] | // encodePrivatePGPKey encrypts key with tsec and armor-encodes it.
// It includes the passphrase generation in the data. | [
"encodePrivatePGPKey",
"encrypts",
"key",
"with",
"tsec",
"and",
"armor",
"-",
"encodes",
"it",
".",
"It",
"includes",
"the",
"passphrase",
"generation",
"in",
"the",
"data",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/passphrase_change.go#L434-L441 |
158,797 | keybase/client | go/engine/devlist.go | NewDevList | func NewDevList(g *libkb.GlobalContext) *DevList {
return &DevList{
Contextified: libkb.NewContextified(g),
}
} | go | func NewDevList(g *libkb.GlobalContext) *DevList {
return &DevList{
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewDevList",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"*",
"DevList",
"{",
"return",
"&",
"DevList",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"}"
] | // NewDevList creates a DevList engine. | [
"NewDevList",
"creates",
"a",
"DevList",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/devlist.go#L21-L25 |
158,798 | keybase/client | go/client/chat_common.go | postRetentionPolicy | func postRetentionPolicy(ctx context.Context, lcli chat1.LocalClient, tui libkb.TerminalUI,
conv *chat1.ConversationLocal, policy chat1.RetentionPolicy, setChannel bool, doPrompt bool) (err error) {
teamInvolved := (conv.Info.MembersType == chat1.ConversationMembersType_TEAM)
teamWide := teamInvolved && !setChannel
if doPrompt {
promptText := fmt.Sprintf("Set the conversation retention policy?\nHit Enter to confirm, or Ctrl-C to cancel.")
if teamInvolved {
promptText = fmt.Sprintf("Set the channel retention policy?\nHit Enter to confirm, or Ctrl-C to cancel.")
}
if teamWide {
promptText = fmt.Sprintf("Set the team-wide retention policy?\nHit Enter to confirm, or Ctrl-C to cancel.")
}
if _, err = tui.Prompt(PromptDescriptorChatSetRetention, promptText); err != nil {
return err
}
}
if teamWide {
teamID, err := keybase1.TeamIDFromString(conv.Info.Triple.Tlfid.String())
if err != nil {
return err
}
return lcli.SetTeamRetentionLocal(ctx, chat1.SetTeamRetentionLocalArg{
TeamID: teamID,
Policy: policy,
})
}
return lcli.SetConvRetentionLocal(ctx, chat1.SetConvRetentionLocalArg{
ConvID: conv.Info.Id,
Policy: policy,
})
} | go | func postRetentionPolicy(ctx context.Context, lcli chat1.LocalClient, tui libkb.TerminalUI,
conv *chat1.ConversationLocal, policy chat1.RetentionPolicy, setChannel bool, doPrompt bool) (err error) {
teamInvolved := (conv.Info.MembersType == chat1.ConversationMembersType_TEAM)
teamWide := teamInvolved && !setChannel
if doPrompt {
promptText := fmt.Sprintf("Set the conversation retention policy?\nHit Enter to confirm, or Ctrl-C to cancel.")
if teamInvolved {
promptText = fmt.Sprintf("Set the channel retention policy?\nHit Enter to confirm, or Ctrl-C to cancel.")
}
if teamWide {
promptText = fmt.Sprintf("Set the team-wide retention policy?\nHit Enter to confirm, or Ctrl-C to cancel.")
}
if _, err = tui.Prompt(PromptDescriptorChatSetRetention, promptText); err != nil {
return err
}
}
if teamWide {
teamID, err := keybase1.TeamIDFromString(conv.Info.Triple.Tlfid.String())
if err != nil {
return err
}
return lcli.SetTeamRetentionLocal(ctx, chat1.SetTeamRetentionLocalArg{
TeamID: teamID,
Policy: policy,
})
}
return lcli.SetConvRetentionLocal(ctx, chat1.SetConvRetentionLocalArg{
ConvID: conv.Info.Id,
Policy: policy,
})
} | [
"func",
"postRetentionPolicy",
"(",
"ctx",
"context",
".",
"Context",
",",
"lcli",
"chat1",
".",
"LocalClient",
",",
"tui",
"libkb",
".",
"TerminalUI",
",",
"conv",
"*",
"chat1",
".",
"ConversationLocal",
",",
"policy",
"chat1",
".",
"RetentionPolicy",
",",
"setChannel",
"bool",
",",
"doPrompt",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"teamInvolved",
":=",
"(",
"conv",
".",
"Info",
".",
"MembersType",
"==",
"chat1",
".",
"ConversationMembersType_TEAM",
")",
"\n",
"teamWide",
":=",
"teamInvolved",
"&&",
"!",
"setChannel",
"\n\n",
"if",
"doPrompt",
"{",
"promptText",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"if",
"teamInvolved",
"{",
"promptText",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"if",
"teamWide",
"{",
"promptText",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
"=",
"tui",
".",
"Prompt",
"(",
"PromptDescriptorChatSetRetention",
",",
"promptText",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"teamWide",
"{",
"teamID",
",",
"err",
":=",
"keybase1",
".",
"TeamIDFromString",
"(",
"conv",
".",
"Info",
".",
"Triple",
".",
"Tlfid",
".",
"String",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"lcli",
".",
"SetTeamRetentionLocal",
"(",
"ctx",
",",
"chat1",
".",
"SetTeamRetentionLocalArg",
"{",
"TeamID",
":",
"teamID",
",",
"Policy",
":",
"policy",
",",
"}",
")",
"\n",
"}",
"\n",
"return",
"lcli",
".",
"SetConvRetentionLocal",
"(",
"ctx",
",",
"chat1",
".",
"SetConvRetentionLocalArg",
"{",
"ConvID",
":",
"conv",
".",
"Info",
".",
"Id",
",",
"Policy",
":",
"policy",
",",
"}",
")",
"\n",
"}"
] | // Post a retention policy
// Set's the channel policy if `setChannel`, otherwise sets the team-wide policy. `setChannel` is ignored if using a non-team.
// UI is optional if `doPrompt` is false. | [
"Post",
"a",
"retention",
"policy",
"Set",
"s",
"the",
"channel",
"policy",
"if",
"setChannel",
"otherwise",
"sets",
"the",
"team",
"-",
"wide",
"policy",
".",
"setChannel",
"is",
"ignored",
"if",
"using",
"a",
"non",
"-",
"team",
".",
"UI",
"is",
"optional",
"if",
"doPrompt",
"is",
"false",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/chat_common.go#L30-L62 |
158,799 | keybase/client | go/client/chat_common.go | postConvMinWriterRole | func postConvMinWriterRole(ctx context.Context, lcli chat1.LocalClient, tui libkb.TerminalUI,
conv *chat1.ConversationLocal, role keybase1.TeamRole, doPrompt bool) (err error) {
if doPrompt {
promptText := fmt.Sprintf("Set the minimium writer role of %v for this conversation?\nHit Enter to confirm, or Ctrl-C to cancel.", role)
if _, err = tui.Prompt(PromptDescriptorChatSetConvMinWriterRole, promptText); err != nil {
return err
}
}
return lcli.SetConvMinWriterRoleLocal(ctx, chat1.SetConvMinWriterRoleLocalArg{
ConvID: conv.Info.Id,
Role: role,
})
} | go | func postConvMinWriterRole(ctx context.Context, lcli chat1.LocalClient, tui libkb.TerminalUI,
conv *chat1.ConversationLocal, role keybase1.TeamRole, doPrompt bool) (err error) {
if doPrompt {
promptText := fmt.Sprintf("Set the minimium writer role of %v for this conversation?\nHit Enter to confirm, or Ctrl-C to cancel.", role)
if _, err = tui.Prompt(PromptDescriptorChatSetConvMinWriterRole, promptText); err != nil {
return err
}
}
return lcli.SetConvMinWriterRoleLocal(ctx, chat1.SetConvMinWriterRoleLocalArg{
ConvID: conv.Info.Id,
Role: role,
})
} | [
"func",
"postConvMinWriterRole",
"(",
"ctx",
"context",
".",
"Context",
",",
"lcli",
"chat1",
".",
"LocalClient",
",",
"tui",
"libkb",
".",
"TerminalUI",
",",
"conv",
"*",
"chat1",
".",
"ConversationLocal",
",",
"role",
"keybase1",
".",
"TeamRole",
",",
"doPrompt",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"if",
"doPrompt",
"{",
"promptText",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"role",
")",
"\n",
"if",
"_",
",",
"err",
"=",
"tui",
".",
"Prompt",
"(",
"PromptDescriptorChatSetConvMinWriterRole",
",",
"promptText",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"lcli",
".",
"SetConvMinWriterRoleLocal",
"(",
"ctx",
",",
"chat1",
".",
"SetConvMinWriterRoleLocalArg",
"{",
"ConvID",
":",
"conv",
".",
"Info",
".",
"Id",
",",
"Role",
":",
"role",
",",
"}",
")",
"\n",
"}"
] | // Post a min writer role for the given conversation | [
"Post",
"a",
"min",
"writer",
"role",
"for",
"the",
"given",
"conversation"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/chat_common.go#L65-L77 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.