id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
160,400 | keybase/client | go/engine/kex2_provisioner.go | GetHello2Arg | func (e *Kex2Provisioner) GetHello2Arg() (arg2 keybase1.Hello2Arg, err error) {
// Pull the metaContext out of the this object, since we can't pass it through the
// kex2/provisioner interface
m := e.mctx
defer m.Trace("Kex2Provisioner#GetHello2Arg", func() error { return err })()
var arg1 keybase1.HelloArg
arg1, err = e.GetHelloArg()
if err != nil {
return arg2, err
}
arg2 = keybase1.Hello2Arg{
Uid: arg1.Uid,
Token: arg1.Token,
Csrf: arg1.Csrf,
SigBody: arg1.SigBody,
}
return arg2, nil
} | go | func (e *Kex2Provisioner) GetHello2Arg() (arg2 keybase1.Hello2Arg, err error) {
// Pull the metaContext out of the this object, since we can't pass it through the
// kex2/provisioner interface
m := e.mctx
defer m.Trace("Kex2Provisioner#GetHello2Arg", func() error { return err })()
var arg1 keybase1.HelloArg
arg1, err = e.GetHelloArg()
if err != nil {
return arg2, err
}
arg2 = keybase1.Hello2Arg{
Uid: arg1.Uid,
Token: arg1.Token,
Csrf: arg1.Csrf,
SigBody: arg1.SigBody,
}
return arg2, nil
} | [
"func",
"(",
"e",
"*",
"Kex2Provisioner",
")",
"GetHello2Arg",
"(",
")",
"(",
"arg2",
"keybase1",
".",
"Hello2Arg",
",",
"err",
"error",
")",
"{",
"// Pull the metaContext out of the this object, since we can't pass it through the",
"// kex2/provisioner interface",
"m",
":=",
"e",
".",
"mctx",
"\n\n",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"var",
"arg1",
"keybase1",
".",
"HelloArg",
"\n",
"arg1",
",",
"err",
"=",
"e",
".",
"GetHelloArg",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"arg2",
",",
"err",
"\n",
"}",
"\n\n",
"arg2",
"=",
"keybase1",
".",
"Hello2Arg",
"{",
"Uid",
":",
"arg1",
".",
"Uid",
",",
"Token",
":",
"arg1",
".",
"Token",
",",
"Csrf",
":",
"arg1",
".",
"Csrf",
",",
"SigBody",
":",
"arg1",
".",
"SigBody",
",",
"}",
"\n",
"return",
"arg2",
",",
"nil",
"\n",
"}"
] | // GetHello2Arg implements GetHello2Arg in kex2.Provisioner. | [
"GetHello2Arg",
"implements",
"GetHello2Arg",
"in",
"kex2",
".",
"Provisioner",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/kex2_provisioner.go#L207-L227 |
160,401 | keybase/client | go/engine/kex2_provisioner.go | CounterSign | func (e *Kex2Provisioner) CounterSign(input keybase1.HelloRes) (sig []byte, err error) {
m := e.mctx
defer m.Trace("Kex2Provisioner#CounterSign", func() error { return err })()
jw, err := jsonw.Unmarshal([]byte(input))
if err != nil {
return nil, err
}
// check the reverse signature and put the values from the provisionee into
// e.proof
if err = e.checkReverseSig(jw); err != nil {
m.Debug("provisioner failed to verify reverse sig: %s", err)
return nil, err
}
m.Debug("provisioner verified reverse sig")
// remember some device information for ProvisionUI.ProvisionerSuccess()
if err = e.rememberDeviceInfo(e.proof); err != nil {
return nil, err
}
// sign the whole thing with provisioner's signing key
s, _, _, err := libkb.SignJSON(e.proof, e.signingKey)
if err != nil {
return nil, err
}
return []byte(s), nil
} | go | func (e *Kex2Provisioner) CounterSign(input keybase1.HelloRes) (sig []byte, err error) {
m := e.mctx
defer m.Trace("Kex2Provisioner#CounterSign", func() error { return err })()
jw, err := jsonw.Unmarshal([]byte(input))
if err != nil {
return nil, err
}
// check the reverse signature and put the values from the provisionee into
// e.proof
if err = e.checkReverseSig(jw); err != nil {
m.Debug("provisioner failed to verify reverse sig: %s", err)
return nil, err
}
m.Debug("provisioner verified reverse sig")
// remember some device information for ProvisionUI.ProvisionerSuccess()
if err = e.rememberDeviceInfo(e.proof); err != nil {
return nil, err
}
// sign the whole thing with provisioner's signing key
s, _, _, err := libkb.SignJSON(e.proof, e.signingKey)
if err != nil {
return nil, err
}
return []byte(s), nil
} | [
"func",
"(",
"e",
"*",
"Kex2Provisioner",
")",
"CounterSign",
"(",
"input",
"keybase1",
".",
"HelloRes",
")",
"(",
"sig",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"m",
":=",
"e",
".",
"mctx",
"\n",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"jw",
",",
"err",
":=",
"jsonw",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"input",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// check the reverse signature and put the values from the provisionee into",
"// e.proof",
"if",
"err",
"=",
"e",
".",
"checkReverseSig",
"(",
"jw",
")",
";",
"err",
"!=",
"nil",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"// remember some device information for ProvisionUI.ProvisionerSuccess()",
"if",
"err",
"=",
"e",
".",
"rememberDeviceInfo",
"(",
"e",
".",
"proof",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// sign the whole thing with provisioner's signing key",
"s",
",",
"_",
",",
"_",
",",
"err",
":=",
"libkb",
".",
"SignJSON",
"(",
"e",
".",
"proof",
",",
"e",
".",
"signingKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"[",
"]",
"byte",
"(",
"s",
")",
",",
"nil",
"\n",
"}"
] | // CounterSign implements CounterSign in kex2.Provisioner. | [
"CounterSign",
"implements",
"CounterSign",
"in",
"kex2",
".",
"Provisioner",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/kex2_provisioner.go#L230-L259 |
160,402 | keybase/client | go/engine/kex2_provisioner.go | CounterSign2 | func (e *Kex2Provisioner) CounterSign2(input keybase1.Hello2Res) (output keybase1.DidCounterSign2Arg, err error) {
m := e.mctx
defer m.Trace("Kex2Provisioner#CounterSign2", func() error { return err })()
var key libkb.GenericKey
key, err = libkb.ImportKeypairFromKID(input.EncryptionKey)
if err != nil {
return output, err
}
output.Sig, err = e.CounterSign(input.SigPayload)
if err != nil {
return output, err
}
var ppsPacked []byte
ppsPacked, err = libkb.MsgpackEncode(e.pps)
if err != nil {
return output, err
}
output.PpsEncrypted, err = key.EncryptToString(ppsPacked, nil)
// Sync the PUK, if the pukring is nil, we don't have a PUK and have
// nothing to box. We also can't make a userEKBox which is signed by the
// PUK.
pukring, err := e.syncPUK(m)
if err != nil || pukring == nil {
return output, err
}
output.PukBox, err = e.makePukBox(m, pukring, key)
if err != nil {
return output, err
}
userEKBoxStorage := m.G().GetUserEKBoxStorage()
if input.DeviceEkKID.Exists() && userEKBoxStorage != nil {
// If we error out here the provisionee will create it's own keys later
// but we shouldn't fail kex.
userEKBox, ekErr := makeUserEKBoxForProvisionee(m, input.DeviceEkKID)
if ekErr != nil {
userEKBox = nil
m.Debug("Unable to makeUserEKBox %v", ekErr)
}
output.UserEkBox = userEKBox
} else {
m.Debug("Skipping userEKBox generation empty KID or storage. KID: %v, storage: %v", input.DeviceEkKID, userEKBoxStorage)
}
return output, nil
} | go | func (e *Kex2Provisioner) CounterSign2(input keybase1.Hello2Res) (output keybase1.DidCounterSign2Arg, err error) {
m := e.mctx
defer m.Trace("Kex2Provisioner#CounterSign2", func() error { return err })()
var key libkb.GenericKey
key, err = libkb.ImportKeypairFromKID(input.EncryptionKey)
if err != nil {
return output, err
}
output.Sig, err = e.CounterSign(input.SigPayload)
if err != nil {
return output, err
}
var ppsPacked []byte
ppsPacked, err = libkb.MsgpackEncode(e.pps)
if err != nil {
return output, err
}
output.PpsEncrypted, err = key.EncryptToString(ppsPacked, nil)
// Sync the PUK, if the pukring is nil, we don't have a PUK and have
// nothing to box. We also can't make a userEKBox which is signed by the
// PUK.
pukring, err := e.syncPUK(m)
if err != nil || pukring == nil {
return output, err
}
output.PukBox, err = e.makePukBox(m, pukring, key)
if err != nil {
return output, err
}
userEKBoxStorage := m.G().GetUserEKBoxStorage()
if input.DeviceEkKID.Exists() && userEKBoxStorage != nil {
// If we error out here the provisionee will create it's own keys later
// but we shouldn't fail kex.
userEKBox, ekErr := makeUserEKBoxForProvisionee(m, input.DeviceEkKID)
if ekErr != nil {
userEKBox = nil
m.Debug("Unable to makeUserEKBox %v", ekErr)
}
output.UserEkBox = userEKBox
} else {
m.Debug("Skipping userEKBox generation empty KID or storage. KID: %v, storage: %v", input.DeviceEkKID, userEKBoxStorage)
}
return output, nil
} | [
"func",
"(",
"e",
"*",
"Kex2Provisioner",
")",
"CounterSign2",
"(",
"input",
"keybase1",
".",
"Hello2Res",
")",
"(",
"output",
"keybase1",
".",
"DidCounterSign2Arg",
",",
"err",
"error",
")",
"{",
"m",
":=",
"e",
".",
"mctx",
"\n\n",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"var",
"key",
"libkb",
".",
"GenericKey",
"\n",
"key",
",",
"err",
"=",
"libkb",
".",
"ImportKeypairFromKID",
"(",
"input",
".",
"EncryptionKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"output",
",",
"err",
"\n",
"}",
"\n\n",
"output",
".",
"Sig",
",",
"err",
"=",
"e",
".",
"CounterSign",
"(",
"input",
".",
"SigPayload",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"output",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ppsPacked",
"[",
"]",
"byte",
"\n",
"ppsPacked",
",",
"err",
"=",
"libkb",
".",
"MsgpackEncode",
"(",
"e",
".",
"pps",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"output",
",",
"err",
"\n",
"}",
"\n",
"output",
".",
"PpsEncrypted",
",",
"err",
"=",
"key",
".",
"EncryptToString",
"(",
"ppsPacked",
",",
"nil",
")",
"\n\n",
"// Sync the PUK, if the pukring is nil, we don't have a PUK and have",
"// nothing to box. We also can't make a userEKBox which is signed by the",
"// PUK.",
"pukring",
",",
"err",
":=",
"e",
".",
"syncPUK",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"pukring",
"==",
"nil",
"{",
"return",
"output",
",",
"err",
"\n",
"}",
"\n\n",
"output",
".",
"PukBox",
",",
"err",
"=",
"e",
".",
"makePukBox",
"(",
"m",
",",
"pukring",
",",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"output",
",",
"err",
"\n",
"}",
"\n\n",
"userEKBoxStorage",
":=",
"m",
".",
"G",
"(",
")",
".",
"GetUserEKBoxStorage",
"(",
")",
"\n",
"if",
"input",
".",
"DeviceEkKID",
".",
"Exists",
"(",
")",
"&&",
"userEKBoxStorage",
"!=",
"nil",
"{",
"// If we error out here the provisionee will create it's own keys later",
"// but we shouldn't fail kex.",
"userEKBox",
",",
"ekErr",
":=",
"makeUserEKBoxForProvisionee",
"(",
"m",
",",
"input",
".",
"DeviceEkKID",
")",
"\n",
"if",
"ekErr",
"!=",
"nil",
"{",
"userEKBox",
"=",
"nil",
"\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"ekErr",
")",
"\n",
"}",
"\n",
"output",
".",
"UserEkBox",
"=",
"userEKBox",
"\n",
"}",
"else",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"input",
".",
"DeviceEkKID",
",",
"userEKBoxStorage",
")",
"\n",
"}",
"\n\n",
"return",
"output",
",",
"nil",
"\n",
"}"
] | // CounterSign2 implements CounterSign in kex2.Provisioner. | [
"CounterSign2",
"implements",
"CounterSign",
"in",
"kex2",
".",
"Provisioner",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/kex2_provisioner.go#L262-L313 |
160,403 | keybase/client | go/engine/kex2_provisioner.go | skeletonProof | func (e *Kex2Provisioner) skeletonProof(m libkb.MetaContext) (sigBody string, err error) {
// Set the local sigchain guard to tell background tasks
// to stay off the sigchain while we do this.
// This is released at the end of Kex2Provisioner#Run
e.G().LocalSigchainGuard().Set(context.TODO(), "Kex2Provisioner")
// reload the self user to make sure it is fresh
// (this fixes TestProvisionWithRevoke [CORE-5631, CORE-5636])
if err := e.loadMe(); err != nil {
return "", err
}
delg := libkb.Delegator{
ExistingKey: e.signingKey,
Me: e.me,
DelegationType: libkb.DelegationTypeSibkey,
Expire: libkb.NaclEdDSAExpireIn,
Contextified: libkb.NewContextified(e.G()),
}
e.proof, err = libkb.KeyProof(m, delg)
if err != nil {
return "", err
}
body, err := e.proof.Marshal()
if err != nil {
return "", err
}
return string(body), nil
} | go | func (e *Kex2Provisioner) skeletonProof(m libkb.MetaContext) (sigBody string, err error) {
// Set the local sigchain guard to tell background tasks
// to stay off the sigchain while we do this.
// This is released at the end of Kex2Provisioner#Run
e.G().LocalSigchainGuard().Set(context.TODO(), "Kex2Provisioner")
// reload the self user to make sure it is fresh
// (this fixes TestProvisionWithRevoke [CORE-5631, CORE-5636])
if err := e.loadMe(); err != nil {
return "", err
}
delg := libkb.Delegator{
ExistingKey: e.signingKey,
Me: e.me,
DelegationType: libkb.DelegationTypeSibkey,
Expire: libkb.NaclEdDSAExpireIn,
Contextified: libkb.NewContextified(e.G()),
}
e.proof, err = libkb.KeyProof(m, delg)
if err != nil {
return "", err
}
body, err := e.proof.Marshal()
if err != nil {
return "", err
}
return string(body), nil
} | [
"func",
"(",
"e",
"*",
"Kex2Provisioner",
")",
"skeletonProof",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"sigBody",
"string",
",",
"err",
"error",
")",
"{",
"// Set the local sigchain guard to tell background tasks",
"// to stay off the sigchain while we do this.",
"// This is released at the end of Kex2Provisioner#Run",
"e",
".",
"G",
"(",
")",
".",
"LocalSigchainGuard",
"(",
")",
".",
"Set",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"\"",
"\"",
")",
"\n\n",
"// reload the self user to make sure it is fresh",
"// (this fixes TestProvisionWithRevoke [CORE-5631, CORE-5636])",
"if",
"err",
":=",
"e",
".",
"loadMe",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"delg",
":=",
"libkb",
".",
"Delegator",
"{",
"ExistingKey",
":",
"e",
".",
"signingKey",
",",
"Me",
":",
"e",
".",
"me",
",",
"DelegationType",
":",
"libkb",
".",
"DelegationTypeSibkey",
",",
"Expire",
":",
"libkb",
".",
"NaclEdDSAExpireIn",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"e",
".",
"G",
"(",
")",
")",
",",
"}",
"\n\n",
"e",
".",
"proof",
",",
"err",
"=",
"libkb",
".",
"KeyProof",
"(",
"m",
",",
"delg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"body",
",",
"err",
":=",
"e",
".",
"proof",
".",
"Marshal",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"string",
"(",
"body",
")",
",",
"nil",
"\n",
"}"
] | // skeletonProof generates a partial key proof structure that device Y can
// fill in. When verifying the reverse signature we fill in the values from Y
// to check the reverse signature | [
"skeletonProof",
"generates",
"a",
"partial",
"key",
"proof",
"structure",
"that",
"device",
"Y",
"can",
"fill",
"in",
".",
"When",
"verifying",
"the",
"reverse",
"signature",
"we",
"fill",
"in",
"the",
"values",
"from",
"Y",
"to",
"check",
"the",
"reverse",
"signature"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/kex2_provisioner.go#L318-L348 |
160,404 | keybase/client | go/engine/kex2_provisioner.go | rememberDeviceInfo | func (e *Kex2Provisioner) rememberDeviceInfo(jw *jsonw.Wrapper) error {
name, err := jw.AtPath("body.device.name").GetString()
if err != nil {
return err
}
e.provisioneeDeviceName = name
dtype, err := jw.AtPath("body.device.type").GetString()
if err != nil {
return err
}
e.provisioneeDeviceType = dtype
return nil
} | go | func (e *Kex2Provisioner) rememberDeviceInfo(jw *jsonw.Wrapper) error {
name, err := jw.AtPath("body.device.name").GetString()
if err != nil {
return err
}
e.provisioneeDeviceName = name
dtype, err := jw.AtPath("body.device.type").GetString()
if err != nil {
return err
}
e.provisioneeDeviceType = dtype
return nil
} | [
"func",
"(",
"e",
"*",
"Kex2Provisioner",
")",
"rememberDeviceInfo",
"(",
"jw",
"*",
"jsonw",
".",
"Wrapper",
")",
"error",
"{",
"name",
",",
"err",
":=",
"jw",
".",
"AtPath",
"(",
"\"",
"\"",
")",
".",
"GetString",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"e",
".",
"provisioneeDeviceName",
"=",
"name",
"\n\n",
"dtype",
",",
"err",
":=",
"jw",
".",
"AtPath",
"(",
"\"",
"\"",
")",
".",
"GetString",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"e",
".",
"provisioneeDeviceType",
"=",
"dtype",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // rememberDeviceInfo saves the device name and type in
// Kex2Provisioner for later use. | [
"rememberDeviceInfo",
"saves",
"the",
"device",
"name",
"and",
"type",
"in",
"Kex2Provisioner",
"for",
"later",
"use",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/kex2_provisioner.go#L408-L422 |
160,405 | keybase/client | go/engine/kex2_provisioner.go | syncPUK | func (e *Kex2Provisioner) syncPUK(m libkb.MetaContext) (*libkb.PerUserKeyring, error) {
pukring, err := e.G().GetPerUserKeyring(m.Ctx())
if err != nil {
return nil, err
}
if err = pukring.Sync(m); err != nil {
return nil, err
}
if !pukring.HasAnyKeys() {
return nil, nil
}
return pukring, nil
} | go | func (e *Kex2Provisioner) syncPUK(m libkb.MetaContext) (*libkb.PerUserKeyring, error) {
pukring, err := e.G().GetPerUserKeyring(m.Ctx())
if err != nil {
return nil, err
}
if err = pukring.Sync(m); err != nil {
return nil, err
}
if !pukring.HasAnyKeys() {
return nil, nil
}
return pukring, nil
} | [
"func",
"(",
"e",
"*",
"Kex2Provisioner",
")",
"syncPUK",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"*",
"libkb",
".",
"PerUserKeyring",
",",
"error",
")",
"{",
"pukring",
",",
"err",
":=",
"e",
".",
"G",
"(",
")",
".",
"GetPerUserKeyring",
"(",
"m",
".",
"Ctx",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"err",
"=",
"pukring",
".",
"Sync",
"(",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"pukring",
".",
"HasAnyKeys",
"(",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return",
"pukring",
",",
"nil",
"\n",
"}"
] | // Returns nil if there are no per-user-keys. | [
"Returns",
"nil",
"if",
"there",
"are",
"no",
"per",
"-",
"user",
"-",
"keys",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/kex2_provisioner.go#L425-L437 |
160,406 | keybase/client | go/kbfs/libkbfs/block_put_state_disk.go | AddNewBlock | func (bps *blockPutStateDisk) AddNewBlock(
ctx context.Context, blockPtr data.BlockPointer, block data.Block,
readyBlockData data.ReadyBlockData, syncedCb func() error) error {
// Add the pointer and the cb to the memory-based put state, and
// put the ready data directly into the disk cache.
err := bps.diskCache.Put(
ctx, bps.kmd.TlfID(), blockPtr.ID, readyBlockData.Buf,
readyBlockData.ServerHalf)
if err != nil {
return err
}
if _, isDir := block.(*data.DirBlock); isDir {
bps.isDir[blockPtr] = true
}
return bps.blockPutStateMemory.AddNewBlock(
ctx, blockPtr, nil, data.ReadyBlockData{}, syncedCb)
} | go | func (bps *blockPutStateDisk) AddNewBlock(
ctx context.Context, blockPtr data.BlockPointer, block data.Block,
readyBlockData data.ReadyBlockData, syncedCb func() error) error {
// Add the pointer and the cb to the memory-based put state, and
// put the ready data directly into the disk cache.
err := bps.diskCache.Put(
ctx, bps.kmd.TlfID(), blockPtr.ID, readyBlockData.Buf,
readyBlockData.ServerHalf)
if err != nil {
return err
}
if _, isDir := block.(*data.DirBlock); isDir {
bps.isDir[blockPtr] = true
}
return bps.blockPutStateMemory.AddNewBlock(
ctx, blockPtr, nil, data.ReadyBlockData{}, syncedCb)
} | [
"func",
"(",
"bps",
"*",
"blockPutStateDisk",
")",
"AddNewBlock",
"(",
"ctx",
"context",
".",
"Context",
",",
"blockPtr",
"data",
".",
"BlockPointer",
",",
"block",
"data",
".",
"Block",
",",
"readyBlockData",
"data",
".",
"ReadyBlockData",
",",
"syncedCb",
"func",
"(",
")",
"error",
")",
"error",
"{",
"// Add the pointer and the cb to the memory-based put state, and",
"// put the ready data directly into the disk cache.",
"err",
":=",
"bps",
".",
"diskCache",
".",
"Put",
"(",
"ctx",
",",
"bps",
".",
"kmd",
".",
"TlfID",
"(",
")",
",",
"blockPtr",
".",
"ID",
",",
"readyBlockData",
".",
"Buf",
",",
"readyBlockData",
".",
"ServerHalf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"isDir",
":=",
"block",
".",
"(",
"*",
"data",
".",
"DirBlock",
")",
";",
"isDir",
"{",
"bps",
".",
"isDir",
"[",
"blockPtr",
"]",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"bps",
".",
"blockPutStateMemory",
".",
"AddNewBlock",
"(",
"ctx",
",",
"blockPtr",
",",
"nil",
",",
"data",
".",
"ReadyBlockData",
"{",
"}",
",",
"syncedCb",
")",
"\n",
"}"
] | // AddNewBlock implements the blockPutState interface for blockPutStateDisk. | [
"AddNewBlock",
"implements",
"the",
"blockPutState",
"interface",
"for",
"blockPutStateDisk",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_put_state_disk.go#L46-L64 |
160,407 | keybase/client | go/libkb/context.go | SwitchUserNewConfigActiveDevice | func (m MetaContext) SwitchUserNewConfigActiveDevice(uv keybase1.UserVersion, n NormalizedUsername, salt []byte, d keybase1.DeviceID, sigKey GenericKey, encKey GenericKey, deviceName string) error {
ad := NewProvisionalActiveDevice(m, uv, d, sigKey, encKey, deviceName)
return m.switchUserNewConfig(uv.Uid, n, salt, d, ad)
} | go | func (m MetaContext) SwitchUserNewConfigActiveDevice(uv keybase1.UserVersion, n NormalizedUsername, salt []byte, d keybase1.DeviceID, sigKey GenericKey, encKey GenericKey, deviceName string) error {
ad := NewProvisionalActiveDevice(m, uv, d, sigKey, encKey, deviceName)
return m.switchUserNewConfig(uv.Uid, n, salt, d, ad)
} | [
"func",
"(",
"m",
"MetaContext",
")",
"SwitchUserNewConfigActiveDevice",
"(",
"uv",
"keybase1",
".",
"UserVersion",
",",
"n",
"NormalizedUsername",
",",
"salt",
"[",
"]",
"byte",
",",
"d",
"keybase1",
".",
"DeviceID",
",",
"sigKey",
"GenericKey",
",",
"encKey",
"GenericKey",
",",
"deviceName",
"string",
")",
"error",
"{",
"ad",
":=",
"NewProvisionalActiveDevice",
"(",
"m",
",",
"uv",
",",
"d",
",",
"sigKey",
",",
"encKey",
",",
"deviceName",
")",
"\n",
"return",
"m",
".",
"switchUserNewConfig",
"(",
"uv",
".",
"Uid",
",",
"n",
",",
"salt",
",",
"d",
",",
"ad",
")",
"\n",
"}"
] | // SwitchUserNewConfigActiveDevice creates a new config file stanza and an
// active device for the given user, all while holding the switchUserMu lock. | [
"SwitchUserNewConfigActiveDevice",
"creates",
"a",
"new",
"config",
"file",
"stanza",
"and",
"an",
"active",
"device",
"for",
"the",
"given",
"user",
"all",
"while",
"holding",
"the",
"switchUserMu",
"lock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/context.go#L368-L371 |
160,408 | keybase/client | go/libkb/context.go | SwitchUserLoggedOut | func (m MetaContext) SwitchUserLoggedOut() (err error) {
defer m.Trace("MetaContext#SwitchUserLoggedOut", func() error { return err })()
g := m.G()
defer g.switchUserMu.Acquire(m, "SwitchUserLoggedOut")()
cw := g.Env.GetConfigWriter()
if cw == nil {
return NoConfigWriterError{}
}
g.ActiveDevice.Clear()
err = cw.SetUserConfig(nil, false)
if err != nil {
return err
}
return nil
} | go | func (m MetaContext) SwitchUserLoggedOut() (err error) {
defer m.Trace("MetaContext#SwitchUserLoggedOut", func() error { return err })()
g := m.G()
defer g.switchUserMu.Acquire(m, "SwitchUserLoggedOut")()
cw := g.Env.GetConfigWriter()
if cw == nil {
return NoConfigWriterError{}
}
g.ActiveDevice.Clear()
err = cw.SetUserConfig(nil, false)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"m",
"MetaContext",
")",
"SwitchUserLoggedOut",
"(",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"g",
":=",
"m",
".",
"G",
"(",
")",
"\n",
"defer",
"g",
".",
"switchUserMu",
".",
"Acquire",
"(",
"m",
",",
"\"",
"\"",
")",
"(",
")",
"\n",
"cw",
":=",
"g",
".",
"Env",
".",
"GetConfigWriter",
"(",
")",
"\n",
"if",
"cw",
"==",
"nil",
"{",
"return",
"NoConfigWriterError",
"{",
"}",
"\n",
"}",
"\n",
"g",
".",
"ActiveDevice",
".",
"Clear",
"(",
")",
"\n",
"err",
"=",
"cw",
".",
"SetUserConfig",
"(",
"nil",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // SwitchUserLoggedOut clears the active device and the current_user stanza of
// the config file, all while holding the switchUserMu | [
"SwitchUserLoggedOut",
"clears",
"the",
"active",
"device",
"and",
"the",
"current_user",
"stanza",
"of",
"the",
"config",
"file",
"all",
"while",
"holding",
"the",
"switchUserMu"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/context.go#L479-L493 |
160,409 | keybase/client | go/libkb/context.go | SetActiveDevice | func (m MetaContext) SetActiveDevice(uv keybase1.UserVersion, deviceID keybase1.DeviceID,
sigKey, encKey GenericKey, deviceName string) error {
g := m.G()
defer g.switchUserMu.Acquire(m, "SetActiveDevice")()
if !g.Env.GetUID().Equal(uv.Uid) {
return NewUIDMismatchError("UID switched out from underneath provisioning process")
}
return g.ActiveDevice.Set(m, uv, deviceID, sigKey, encKey, deviceName, 0)
} | go | func (m MetaContext) SetActiveDevice(uv keybase1.UserVersion, deviceID keybase1.DeviceID,
sigKey, encKey GenericKey, deviceName string) error {
g := m.G()
defer g.switchUserMu.Acquire(m, "SetActiveDevice")()
if !g.Env.GetUID().Equal(uv.Uid) {
return NewUIDMismatchError("UID switched out from underneath provisioning process")
}
return g.ActiveDevice.Set(m, uv, deviceID, sigKey, encKey, deviceName, 0)
} | [
"func",
"(",
"m",
"MetaContext",
")",
"SetActiveDevice",
"(",
"uv",
"keybase1",
".",
"UserVersion",
",",
"deviceID",
"keybase1",
".",
"DeviceID",
",",
"sigKey",
",",
"encKey",
"GenericKey",
",",
"deviceName",
"string",
")",
"error",
"{",
"g",
":=",
"m",
".",
"G",
"(",
")",
"\n",
"defer",
"g",
".",
"switchUserMu",
".",
"Acquire",
"(",
"m",
",",
"\"",
"\"",
")",
"(",
")",
"\n",
"if",
"!",
"g",
".",
"Env",
".",
"GetUID",
"(",
")",
".",
"Equal",
"(",
"uv",
".",
"Uid",
")",
"{",
"return",
"NewUIDMismatchError",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"g",
".",
"ActiveDevice",
".",
"Set",
"(",
"m",
",",
"uv",
",",
"deviceID",
",",
"sigKey",
",",
"encKey",
",",
"deviceName",
",",
"0",
")",
"\n",
"}"
] | // SetActiveDevice sets the active device to have the UserVersion, deviceID,
// sigKey, encKey and deviceName as specified, and does so while grabbing the
// global switchUser lock, since it should be sycnhronized with attempts to
// switch the global logged in user. It does not, however, change the
// `current_user` in the config file, or edit the global config file in any
// way. | [
"SetActiveDevice",
"sets",
"the",
"active",
"device",
"to",
"have",
"the",
"UserVersion",
"deviceID",
"sigKey",
"encKey",
"and",
"deviceName",
"as",
"specified",
"and",
"does",
"so",
"while",
"grabbing",
"the",
"global",
"switchUser",
"lock",
"since",
"it",
"should",
"be",
"sycnhronized",
"with",
"attempts",
"to",
"switch",
"the",
"global",
"logged",
"in",
"user",
".",
"It",
"does",
"not",
"however",
"change",
"the",
"current_user",
"in",
"the",
"config",
"file",
"or",
"edit",
"the",
"global",
"config",
"file",
"in",
"any",
"way",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/context.go#L501-L509 |
160,410 | keybase/client | go/libkb/context.go | LogoutAndDeprovisionIfRevoked | func (m MetaContext) LogoutAndDeprovisionIfRevoked() (err error) {
m = m.WithLogTag("LOIR")
defer m.Trace("GlobalContext#LogoutAndDeprovisionIfRevoked", func() error { return err })()
if !m.ActiveDevice().Valid() {
m.Debug("LogoutAndDeprovisionIfRevoked: skipping check (not logged in)")
return nil
}
if m.G().Env.GetSkipLogoutIfRevokedCheck() {
m.Debug("LogoutAndDeprovisionIfRevoked: skipping check (SkipLogoutIfRevokedCheck)")
return nil
}
doLogout := false
err = CheckCurrentUIDDeviceID(m)
switch err.(type) {
case nil:
m.Debug("LogoutAndDeprovisionIfRevoked: current device ok")
case DeviceNotFoundError:
m.Debug("LogoutAndDeprovisionIfRevoked: device not found error; user was likely reset; calling logout (%s)", err)
doLogout = true
case KeyRevokedError:
m.Debug("LogoutAndDeprovisionIfRevoked: key revoked error error; device was revoked; calling logout (%s)", err)
doLogout = true
default:
m.Debug("LogoutAndDeprovisionIfRevoked: non-actionable error: %s", err)
}
if doLogout {
username := m.G().Env.GetUsername()
if err := m.G().Logout(m.Ctx()); err != nil {
return err
}
return ClearSecretsOnDeprovision(m, username)
}
return nil
} | go | func (m MetaContext) LogoutAndDeprovisionIfRevoked() (err error) {
m = m.WithLogTag("LOIR")
defer m.Trace("GlobalContext#LogoutAndDeprovisionIfRevoked", func() error { return err })()
if !m.ActiveDevice().Valid() {
m.Debug("LogoutAndDeprovisionIfRevoked: skipping check (not logged in)")
return nil
}
if m.G().Env.GetSkipLogoutIfRevokedCheck() {
m.Debug("LogoutAndDeprovisionIfRevoked: skipping check (SkipLogoutIfRevokedCheck)")
return nil
}
doLogout := false
err = CheckCurrentUIDDeviceID(m)
switch err.(type) {
case nil:
m.Debug("LogoutAndDeprovisionIfRevoked: current device ok")
case DeviceNotFoundError:
m.Debug("LogoutAndDeprovisionIfRevoked: device not found error; user was likely reset; calling logout (%s)", err)
doLogout = true
case KeyRevokedError:
m.Debug("LogoutAndDeprovisionIfRevoked: key revoked error error; device was revoked; calling logout (%s)", err)
doLogout = true
default:
m.Debug("LogoutAndDeprovisionIfRevoked: non-actionable error: %s", err)
}
if doLogout {
username := m.G().Env.GetUsername()
if err := m.G().Logout(m.Ctx()); err != nil {
return err
}
return ClearSecretsOnDeprovision(m, username)
}
return nil
} | [
"func",
"(",
"m",
"MetaContext",
")",
"LogoutAndDeprovisionIfRevoked",
"(",
")",
"(",
"err",
"error",
")",
"{",
"m",
"=",
"m",
".",
"WithLogTag",
"(",
"\"",
"\"",
")",
"\n\n",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"if",
"!",
"m",
".",
"ActiveDevice",
"(",
")",
".",
"Valid",
"(",
")",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"G",
"(",
")",
".",
"Env",
".",
"GetSkipLogoutIfRevokedCheck",
"(",
")",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"doLogout",
":=",
"false",
"\n",
"err",
"=",
"CheckCurrentUIDDeviceID",
"(",
"m",
")",
"\n",
"switch",
"err",
".",
"(",
"type",
")",
"{",
"case",
"nil",
":",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"case",
"DeviceNotFoundError",
":",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"doLogout",
"=",
"true",
"\n",
"case",
"KeyRevokedError",
":",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"doLogout",
"=",
"true",
"\n",
"default",
":",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"doLogout",
"{",
"username",
":=",
"m",
".",
"G",
"(",
")",
".",
"Env",
".",
"GetUsername",
"(",
")",
"\n",
"if",
"err",
":=",
"m",
".",
"G",
"(",
")",
".",
"Logout",
"(",
"m",
".",
"Ctx",
"(",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"ClearSecretsOnDeprovision",
"(",
"m",
",",
"username",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // LogoutAndDeprovisionIfRevoked loads the user and checks if the current
// device keys have been revoked. If so, it calls Logout and then runs the
// ClearSecretsOnDeprovision | [
"LogoutAndDeprovisionIfRevoked",
"loads",
"the",
"user",
"and",
"checks",
"if",
"the",
"current",
"device",
"keys",
"have",
"been",
"revoked",
".",
"If",
"so",
"it",
"calls",
"Logout",
"and",
"then",
"runs",
"the",
"ClearSecretsOnDeprovision"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/context.go#L526-L565 |
160,411 | keybase/client | go/libcmdline/fork_nix.go | SpawnDetachedProcess | func SpawnDetachedProcess(
cmd string, args []string, _ logger.Logger) (pid int, err error) {
var files []uintptr
var devnull *os.File
defer func() {
if err != nil && devnull != nil {
devnull.Close()
}
}()
if devnull, err = os.OpenFile("/dev/null", os.O_RDONLY, 0); err != nil {
return
}
nullfd := devnull.Fd()
files = append(files, nullfd, nullfd, nullfd)
attr := syscall.ProcAttr{
Env: os.Environ(),
Sys: &syscall.SysProcAttr{Setsid: true},
Files: files,
}
pid, err = syscall.ForkExec(cmd, args, &attr)
return pid, err
} | go | func SpawnDetachedProcess(
cmd string, args []string, _ logger.Logger) (pid int, err error) {
var files []uintptr
var devnull *os.File
defer func() {
if err != nil && devnull != nil {
devnull.Close()
}
}()
if devnull, err = os.OpenFile("/dev/null", os.O_RDONLY, 0); err != nil {
return
}
nullfd := devnull.Fd()
files = append(files, nullfd, nullfd, nullfd)
attr := syscall.ProcAttr{
Env: os.Environ(),
Sys: &syscall.SysProcAttr{Setsid: true},
Files: files,
}
pid, err = syscall.ForkExec(cmd, args, &attr)
return pid, err
} | [
"func",
"SpawnDetachedProcess",
"(",
"cmd",
"string",
",",
"args",
"[",
"]",
"string",
",",
"_",
"logger",
".",
"Logger",
")",
"(",
"pid",
"int",
",",
"err",
"error",
")",
"{",
"var",
"files",
"[",
"]",
"uintptr",
"\n",
"var",
"devnull",
"*",
"os",
".",
"File",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"!=",
"nil",
"&&",
"devnull",
"!=",
"nil",
"{",
"devnull",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"if",
"devnull",
",",
"err",
"=",
"os",
".",
"OpenFile",
"(",
"\"",
"\"",
",",
"os",
".",
"O_RDONLY",
",",
"0",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"nullfd",
":=",
"devnull",
".",
"Fd",
"(",
")",
"\n",
"files",
"=",
"append",
"(",
"files",
",",
"nullfd",
",",
"nullfd",
",",
"nullfd",
")",
"\n\n",
"attr",
":=",
"syscall",
".",
"ProcAttr",
"{",
"Env",
":",
"os",
".",
"Environ",
"(",
")",
",",
"Sys",
":",
"&",
"syscall",
".",
"SysProcAttr",
"{",
"Setsid",
":",
"true",
"}",
",",
"Files",
":",
"files",
",",
"}",
"\n\n",
"pid",
",",
"err",
"=",
"syscall",
".",
"ForkExec",
"(",
"cmd",
",",
"args",
",",
"&",
"attr",
")",
"\n",
"return",
"pid",
",",
"err",
"\n",
"}"
] | // SpawnDetachedProcess spawns a background process and detech from the calling
// process. | [
"SpawnDetachedProcess",
"spawns",
"a",
"background",
"process",
"and",
"detech",
"from",
"the",
"calling",
"process",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libcmdline/fork_nix.go#L17-L42 |
160,412 | keybase/client | go/kbfs/libfuse/special_read_file.go | Attr | func (f *SpecialReadFile) Attr(ctx context.Context, a *fuse.Attr) error {
data, t, err := f.read(ctx)
if err != nil {
return err
}
// Have a low non-zero value for Valid to avoid being swamped
// with requests, while still keeping the size up to date.
a.Valid = 1 * time.Second
// Some apps (e.g., Chrome) get confused if we use a 0 size
// here, as is usual for pseudofiles. So return the actual
// size, even though it may be racy.
a.Size = uint64(len(data))
a.Mtime = t
a.Ctime = t
a.Mode = 0444
return nil
} | go | func (f *SpecialReadFile) Attr(ctx context.Context, a *fuse.Attr) error {
data, t, err := f.read(ctx)
if err != nil {
return err
}
// Have a low non-zero value for Valid to avoid being swamped
// with requests, while still keeping the size up to date.
a.Valid = 1 * time.Second
// Some apps (e.g., Chrome) get confused if we use a 0 size
// here, as is usual for pseudofiles. So return the actual
// size, even though it may be racy.
a.Size = uint64(len(data))
a.Mtime = t
a.Ctime = t
a.Mode = 0444
return nil
} | [
"func",
"(",
"f",
"*",
"SpecialReadFile",
")",
"Attr",
"(",
"ctx",
"context",
".",
"Context",
",",
"a",
"*",
"fuse",
".",
"Attr",
")",
"error",
"{",
"data",
",",
"t",
",",
"err",
":=",
"f",
".",
"read",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Have a low non-zero value for Valid to avoid being swamped",
"// with requests, while still keeping the size up to date.",
"a",
".",
"Valid",
"=",
"1",
"*",
"time",
".",
"Second",
"\n",
"// Some apps (e.g., Chrome) get confused if we use a 0 size",
"// here, as is usual for pseudofiles. So return the actual",
"// size, even though it may be racy.",
"a",
".",
"Size",
"=",
"uint64",
"(",
"len",
"(",
"data",
")",
")",
"\n",
"a",
".",
"Mtime",
"=",
"t",
"\n",
"a",
".",
"Ctime",
"=",
"t",
"\n",
"a",
".",
"Mode",
"=",
"0444",
"\n",
"return",
"nil",
"\n",
"}"
] | // Attr implements the fs.Node interface for SpecialReadFile. | [
"Attr",
"implements",
"the",
"fs",
".",
"Node",
"interface",
"for",
"SpecialReadFile",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/special_read_file.go#L26-L43 |
160,413 | keybase/client | go/kbfs/libfuse/special_read_file.go | Open | func (f *SpecialReadFile) Open(ctx context.Context, req *fuse.OpenRequest,
resp *fuse.OpenResponse) (fs.Handle, error) {
data, _, err := f.read(ctx)
if err != nil {
return nil, err
}
resp.Flags |= fuse.OpenDirectIO
return fs.DataHandle(data), nil
} | go | func (f *SpecialReadFile) Open(ctx context.Context, req *fuse.OpenRequest,
resp *fuse.OpenResponse) (fs.Handle, error) {
data, _, err := f.read(ctx)
if err != nil {
return nil, err
}
resp.Flags |= fuse.OpenDirectIO
return fs.DataHandle(data), nil
} | [
"func",
"(",
"f",
"*",
"SpecialReadFile",
")",
"Open",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"OpenRequest",
",",
"resp",
"*",
"fuse",
".",
"OpenResponse",
")",
"(",
"fs",
".",
"Handle",
",",
"error",
")",
"{",
"data",
",",
"_",
",",
"err",
":=",
"f",
".",
"read",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"resp",
".",
"Flags",
"|=",
"fuse",
".",
"OpenDirectIO",
"\n",
"return",
"fs",
".",
"DataHandle",
"(",
"data",
")",
",",
"nil",
"\n",
"}"
] | // Open implements the fs.NodeOpener interface for SpecialReadFile. | [
"Open",
"implements",
"the",
"fs",
".",
"NodeOpener",
"interface",
"for",
"SpecialReadFile",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/special_read_file.go#L48-L57 |
160,414 | keybase/client | go/client/cmd_simplefs_stat.go | NewCmdSimpleFSStat | func NewCmdSimpleFSStat(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "stat",
ArgumentHelp: "<path>",
Usage: "stat directory element",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdSimpleFSStat{Contextified: libkb.NewContextified(g)}, "stat", c)
cl.SetNoStandalone()
},
Flags: []cli.Flag{
cli.IntFlag{
Name: "rev",
Usage: "a revision number for the KBFS folder",
},
cli.StringFlag{
Name: "time",
Usage: "a time for the KBFS folder (eg \"2018-07-27 22:05\")",
},
cli.StringFlag{
Name: "reltime, relative-time",
Usage: "a relative time for the KBFS folder (eg \"5m\")",
},
cli.BoolFlag{
Name: "show-archived",
Usage: "shows stats for several previous revisions",
},
cli.BoolFlag{
Name: "show-last-archived",
Usage: "shows stats for sequential previous revisions",
},
},
}
} | go | func NewCmdSimpleFSStat(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "stat",
ArgumentHelp: "<path>",
Usage: "stat directory element",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdSimpleFSStat{Contextified: libkb.NewContextified(g)}, "stat", c)
cl.SetNoStandalone()
},
Flags: []cli.Flag{
cli.IntFlag{
Name: "rev",
Usage: "a revision number for the KBFS folder",
},
cli.StringFlag{
Name: "time",
Usage: "a time for the KBFS folder (eg \"2018-07-27 22:05\")",
},
cli.StringFlag{
Name: "reltime, relative-time",
Usage: "a relative time for the KBFS folder (eg \"5m\")",
},
cli.BoolFlag{
Name: "show-archived",
Usage: "shows stats for several previous revisions",
},
cli.BoolFlag{
Name: "show-last-archived",
Usage: "shows stats for sequential previous revisions",
},
},
}
} | [
"func",
"NewCmdSimpleFSStat",
"(",
"cl",
"*",
"libcmdline",
".",
"CommandLine",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"ArgumentHelp",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"Action",
":",
"func",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"cl",
".",
"ChooseCommand",
"(",
"&",
"CmdSimpleFSStat",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
"}",
",",
"\"",
"\"",
",",
"c",
")",
"\n",
"cl",
".",
"SetNoStandalone",
"(",
")",
"\n",
"}",
",",
"Flags",
":",
"[",
"]",
"cli",
".",
"Flag",
"{",
"cli",
".",
"IntFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"}",
",",
"cli",
".",
"StringFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"}",
",",
"cli",
".",
"StringFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"}",
",",
"cli",
".",
"BoolFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"}",
",",
"cli",
".",
"BoolFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"}",
",",
"}",
",",
"}",
"\n",
"}"
] | // NewCmdSimpleFSStat creates a new cli.Command. | [
"NewCmdSimpleFSStat",
"creates",
"a",
"new",
"cli",
".",
"Command",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_simplefs_stat.go#L26-L58 |
160,415 | keybase/client | go/kbfs/tlfhandle/errors.go | Error | func (e HandleMismatchError) Error() string {
return fmt.Sprintf("Could not verify metadata (revision=%d) for directory %s (id=%s): %s",
e.Revision, e.Dir, e.TlfID, e.Err)
} | go | func (e HandleMismatchError) Error() string {
return fmt.Sprintf("Could not verify metadata (revision=%d) for directory %s (id=%s): %s",
e.Revision, e.Dir, e.TlfID, e.Err)
} | [
"func",
"(",
"e",
"HandleMismatchError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Revision",
",",
"e",
".",
"Dir",
",",
"e",
".",
"TlfID",
",",
"e",
".",
"Err",
")",
"\n",
"}"
] | // Error implements the error interface for HandleMismatchError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"HandleMismatchError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/errors.go#L46-L49 |
160,416 | keybase/client | go/kbfs/tlfhandle/errors.go | Error | func (e ReadAccessError) Error() string {
return fmt.Sprintf("%s does not have read access to directory %s",
e.User, BuildCanonicalPathForTlfName(e.Type, e.Tlf))
} | go | func (e ReadAccessError) Error() string {
return fmt.Sprintf("%s does not have read access to directory %s",
e.User, BuildCanonicalPathForTlfName(e.Type, e.Tlf))
} | [
"func",
"(",
"e",
"ReadAccessError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"User",
",",
"BuildCanonicalPathForTlfName",
"(",
"e",
".",
"Type",
",",
"e",
".",
"Tlf",
")",
")",
"\n",
"}"
] | // Error implements the error interface for ReadAccessError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"ReadAccessError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/errors.go#L61-L64 |
160,417 | keybase/client | go/kbfs/tlfhandle/errors.go | NewReadAccessError | func NewReadAccessError(h *Handle, username kbname.NormalizedUsername, filename string) error {
tlfname := h.GetCanonicalName()
return ReadAccessError{
User: username,
Filename: filename,
Tlf: tlfname,
Type: h.Type(),
}
} | go | func NewReadAccessError(h *Handle, username kbname.NormalizedUsername, filename string) error {
tlfname := h.GetCanonicalName()
return ReadAccessError{
User: username,
Filename: filename,
Tlf: tlfname,
Type: h.Type(),
}
} | [
"func",
"NewReadAccessError",
"(",
"h",
"*",
"Handle",
",",
"username",
"kbname",
".",
"NormalizedUsername",
",",
"filename",
"string",
")",
"error",
"{",
"tlfname",
":=",
"h",
".",
"GetCanonicalName",
"(",
")",
"\n",
"return",
"ReadAccessError",
"{",
"User",
":",
"username",
",",
"Filename",
":",
"filename",
",",
"Tlf",
":",
"tlfname",
",",
"Type",
":",
"h",
".",
"Type",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewReadAccessError constructs a ReadAccessError for the given
// directory and user. | [
"NewReadAccessError",
"constructs",
"a",
"ReadAccessError",
"for",
"the",
"given",
"directory",
"and",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/errors.go#L68-L76 |
160,418 | keybase/client | go/kbfs/tlfhandle/errors.go | Error | func (e WriteAccessError) Error() string {
if e.Tlf != "" {
return fmt.Sprintf("%s does not have write access to directory %s",
e.User, BuildCanonicalPathForTlfName(e.Type, e.Tlf))
}
return fmt.Sprintf("%s does not have write access to %s", e.User, e.Filename)
} | go | func (e WriteAccessError) Error() string {
if e.Tlf != "" {
return fmt.Sprintf("%s does not have write access to directory %s",
e.User, BuildCanonicalPathForTlfName(e.Type, e.Tlf))
}
return fmt.Sprintf("%s does not have write access to %s", e.User, e.Filename)
} | [
"func",
"(",
"e",
"WriteAccessError",
")",
"Error",
"(",
")",
"string",
"{",
"if",
"e",
".",
"Tlf",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"User",
",",
"BuildCanonicalPathForTlfName",
"(",
"e",
".",
"Type",
",",
"e",
".",
"Tlf",
")",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"User",
",",
"e",
".",
"Filename",
")",
"\n",
"}"
] | // Error implements the error interface for WriteAccessError | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"WriteAccessError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/errors.go#L87-L93 |
160,419 | keybase/client | go/kbfs/tlfhandle/errors.go | NewWriteAccessError | func NewWriteAccessError(h *Handle, username kbname.NormalizedUsername, filename string) error {
tlfName := tlf.CanonicalName("")
t := tlf.Private
if h != nil {
tlfName = h.GetCanonicalName()
t = h.Type()
}
return WriteAccessError{
User: username,
Filename: filename,
Tlf: tlfName,
Type: t,
}
} | go | func NewWriteAccessError(h *Handle, username kbname.NormalizedUsername, filename string) error {
tlfName := tlf.CanonicalName("")
t := tlf.Private
if h != nil {
tlfName = h.GetCanonicalName()
t = h.Type()
}
return WriteAccessError{
User: username,
Filename: filename,
Tlf: tlfName,
Type: t,
}
} | [
"func",
"NewWriteAccessError",
"(",
"h",
"*",
"Handle",
",",
"username",
"kbname",
".",
"NormalizedUsername",
",",
"filename",
"string",
")",
"error",
"{",
"tlfName",
":=",
"tlf",
".",
"CanonicalName",
"(",
"\"",
"\"",
")",
"\n",
"t",
":=",
"tlf",
".",
"Private",
"\n",
"if",
"h",
"!=",
"nil",
"{",
"tlfName",
"=",
"h",
".",
"GetCanonicalName",
"(",
")",
"\n",
"t",
"=",
"h",
".",
"Type",
"(",
")",
"\n",
"}",
"\n",
"return",
"WriteAccessError",
"{",
"User",
":",
"username",
",",
"Filename",
":",
"filename",
",",
"Tlf",
":",
"tlfName",
",",
"Type",
":",
"t",
",",
"}",
"\n",
"}"
] | // NewWriteAccessError is an access error trying to write a file | [
"NewWriteAccessError",
"is",
"an",
"access",
"error",
"trying",
"to",
"write",
"a",
"file"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/errors.go#L96-L109 |
160,420 | keybase/client | go/kbfs/libkbfs/data_types.go | Equals | func (bc BlockChanges) Equals(other BlockChanges) bool {
if bc.Info != other.Info || len(bc.Ops) != len(other.Ops) ||
(bc.sizeEstimate != 0 && other.sizeEstimate != 0 &&
bc.sizeEstimate != other.sizeEstimate) {
return false
}
// TODO: check for op equality?
return true
} | go | func (bc BlockChanges) Equals(other BlockChanges) bool {
if bc.Info != other.Info || len(bc.Ops) != len(other.Ops) ||
(bc.sizeEstimate != 0 && other.sizeEstimate != 0 &&
bc.sizeEstimate != other.sizeEstimate) {
return false
}
// TODO: check for op equality?
return true
} | [
"func",
"(",
"bc",
"BlockChanges",
")",
"Equals",
"(",
"other",
"BlockChanges",
")",
"bool",
"{",
"if",
"bc",
".",
"Info",
"!=",
"other",
".",
"Info",
"||",
"len",
"(",
"bc",
".",
"Ops",
")",
"!=",
"len",
"(",
"other",
".",
"Ops",
")",
"||",
"(",
"bc",
".",
"sizeEstimate",
"!=",
"0",
"&&",
"other",
".",
"sizeEstimate",
"!=",
"0",
"&&",
"bc",
".",
"sizeEstimate",
"!=",
"other",
".",
"sizeEstimate",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"// TODO: check for op equality?",
"return",
"true",
"\n",
"}"
] | // Equals returns true if the given BlockChanges is equal to this
// BlockChanges. Currently does not check for equality at the
// operation level. | [
"Equals",
"returns",
"true",
"if",
"the",
"given",
"BlockChanges",
"is",
"equal",
"to",
"this",
"BlockChanges",
".",
"Currently",
"does",
"not",
"check",
"for",
"equality",
"at",
"the",
"operation",
"level",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L77-L85 |
160,421 | keybase/client | go/kbfs/libkbfs/data_types.go | AddRefBlock | func (bc *BlockChanges) AddRefBlock(ptr data.BlockPointer) {
if bc.sizeEstimate != 0 {
panic("Can't alter block changes after the size is estimated")
}
bc.Ops[len(bc.Ops)-1].AddRefBlock(ptr)
} | go | func (bc *BlockChanges) AddRefBlock(ptr data.BlockPointer) {
if bc.sizeEstimate != 0 {
panic("Can't alter block changes after the size is estimated")
}
bc.Ops[len(bc.Ops)-1].AddRefBlock(ptr)
} | [
"func",
"(",
"bc",
"*",
"BlockChanges",
")",
"AddRefBlock",
"(",
"ptr",
"data",
".",
"BlockPointer",
")",
"{",
"if",
"bc",
".",
"sizeEstimate",
"!=",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"bc",
".",
"Ops",
"[",
"len",
"(",
"bc",
".",
"Ops",
")",
"-",
"1",
"]",
".",
"AddRefBlock",
"(",
"ptr",
")",
"\n",
"}"
] | // AddRefBlock adds the newly-referenced block to this BlockChanges
// and updates the size estimate. | [
"AddRefBlock",
"adds",
"the",
"newly",
"-",
"referenced",
"block",
"to",
"this",
"BlockChanges",
"and",
"updates",
"the",
"size",
"estimate",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L89-L94 |
160,422 | keybase/client | go/kbfs/libkbfs/data_types.go | AddUpdate | func (bc *BlockChanges) AddUpdate(oldPtr data.BlockPointer, newPtr data.BlockPointer) {
if bc.sizeEstimate != 0 {
panic("Can't alter block changes after the size is estimated")
}
bc.Ops[len(bc.Ops)-1].AddUpdate(oldPtr, newPtr)
} | go | func (bc *BlockChanges) AddUpdate(oldPtr data.BlockPointer, newPtr data.BlockPointer) {
if bc.sizeEstimate != 0 {
panic("Can't alter block changes after the size is estimated")
}
bc.Ops[len(bc.Ops)-1].AddUpdate(oldPtr, newPtr)
} | [
"func",
"(",
"bc",
"*",
"BlockChanges",
")",
"AddUpdate",
"(",
"oldPtr",
"data",
".",
"BlockPointer",
",",
"newPtr",
"data",
".",
"BlockPointer",
")",
"{",
"if",
"bc",
".",
"sizeEstimate",
"!=",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"bc",
".",
"Ops",
"[",
"len",
"(",
"bc",
".",
"Ops",
")",
"-",
"1",
"]",
".",
"AddUpdate",
"(",
"oldPtr",
",",
"newPtr",
")",
"\n",
"}"
] | // AddUpdate adds the newly updated block to this BlockChanges
// and updates the size estimate. | [
"AddUpdate",
"adds",
"the",
"newly",
"updated",
"block",
"to",
"this",
"BlockChanges",
"and",
"updates",
"the",
"size",
"estimate",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L107-L112 |
160,423 | keybase/client | go/kbfs/libkbfs/data_types.go | SizeEstimate | func (bc *BlockChanges) SizeEstimate() uint64 {
if bc.sizeEstimate == 0 {
for _, op := range bc.Ops {
numPtrs := len(op.Refs()) + len(op.Unrefs()) +
2*len(op.allUpdates())
bc.sizeEstimate +=
uint64(numPtrs)*data.BPSize + op.SizeExceptUpdates()
}
}
return bc.sizeEstimate
} | go | func (bc *BlockChanges) SizeEstimate() uint64 {
if bc.sizeEstimate == 0 {
for _, op := range bc.Ops {
numPtrs := len(op.Refs()) + len(op.Unrefs()) +
2*len(op.allUpdates())
bc.sizeEstimate +=
uint64(numPtrs)*data.BPSize + op.SizeExceptUpdates()
}
}
return bc.sizeEstimate
} | [
"func",
"(",
"bc",
"*",
"BlockChanges",
")",
"SizeEstimate",
"(",
")",
"uint64",
"{",
"if",
"bc",
".",
"sizeEstimate",
"==",
"0",
"{",
"for",
"_",
",",
"op",
":=",
"range",
"bc",
".",
"Ops",
"{",
"numPtrs",
":=",
"len",
"(",
"op",
".",
"Refs",
"(",
")",
")",
"+",
"len",
"(",
"op",
".",
"Unrefs",
"(",
")",
")",
"+",
"2",
"*",
"len",
"(",
"op",
".",
"allUpdates",
"(",
")",
")",
"\n",
"bc",
".",
"sizeEstimate",
"+=",
"uint64",
"(",
"numPtrs",
")",
"*",
"data",
".",
"BPSize",
"+",
"op",
".",
"SizeExceptUpdates",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"bc",
".",
"sizeEstimate",
"\n",
"}"
] | // SizeEstimate calculates the estimated size of the encoded version
// of this BlockChanges. | [
"SizeEstimate",
"calculates",
"the",
"estimated",
"size",
"of",
"the",
"encoded",
"version",
"of",
"this",
"BlockChanges",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L125-L135 |
160,424 | keybase/client | go/kbfs/libkbfs/data_types.go | ToProtocolStatus | func (s PrefetchStatus) ToProtocolStatus() keybase1.PrefetchStatus {
switch s {
case NoPrefetch:
return keybase1.PrefetchStatus_NOT_STARTED
case TriggeredPrefetch:
return keybase1.PrefetchStatus_IN_PROGRESS
case FinishedPrefetch:
return keybase1.PrefetchStatus_COMPLETE
default:
panic(fmt.Sprintf("Unknown prefetch status: %s", s))
}
} | go | func (s PrefetchStatus) ToProtocolStatus() keybase1.PrefetchStatus {
switch s {
case NoPrefetch:
return keybase1.PrefetchStatus_NOT_STARTED
case TriggeredPrefetch:
return keybase1.PrefetchStatus_IN_PROGRESS
case FinishedPrefetch:
return keybase1.PrefetchStatus_COMPLETE
default:
panic(fmt.Sprintf("Unknown prefetch status: %s", s))
}
} | [
"func",
"(",
"s",
"PrefetchStatus",
")",
"ToProtocolStatus",
"(",
")",
"keybase1",
".",
"PrefetchStatus",
"{",
"switch",
"s",
"{",
"case",
"NoPrefetch",
":",
"return",
"keybase1",
".",
"PrefetchStatus_NOT_STARTED",
"\n",
"case",
"TriggeredPrefetch",
":",
"return",
"keybase1",
".",
"PrefetchStatus_IN_PROGRESS",
"\n",
"case",
"FinishedPrefetch",
":",
"return",
"keybase1",
".",
"PrefetchStatus_COMPLETE",
"\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
")",
")",
"\n",
"}",
"\n",
"}"
] | // ToProtocolStatus returns a prefetch status that can be send over
// the keybase1 protocol. | [
"ToProtocolStatus",
"returns",
"a",
"prefetch",
"status",
"that",
"can",
"be",
"send",
"over",
"the",
"keybase1",
"protocol",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L317-L328 |
160,425 | keybase/client | go/kbfs/libkbfs/data_types.go | UnmarshalJSON | func (s *PrefetchStatus) UnmarshalJSON(b []byte) error {
var st string
if err := json.Unmarshal(b, &st); err != nil {
return err
}
switch st {
default:
return ErrUnrecognizedPrefetchStatus
case "NoPrefetch":
*s = NoPrefetch
case "TriggeredPrefetch":
*s = TriggeredPrefetch
case "FinishedPrefetch":
*s = FinishedPrefetch
}
return nil
} | go | func (s *PrefetchStatus) UnmarshalJSON(b []byte) error {
var st string
if err := json.Unmarshal(b, &st); err != nil {
return err
}
switch st {
default:
return ErrUnrecognizedPrefetchStatus
case "NoPrefetch":
*s = NoPrefetch
case "TriggeredPrefetch":
*s = TriggeredPrefetch
case "FinishedPrefetch":
*s = FinishedPrefetch
}
return nil
} | [
"func",
"(",
"s",
"*",
"PrefetchStatus",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"st",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"st",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"switch",
"st",
"{",
"default",
":",
"return",
"ErrUnrecognizedPrefetchStatus",
"\n",
"case",
"\"",
"\"",
":",
"*",
"s",
"=",
"NoPrefetch",
"\n",
"case",
"\"",
"\"",
":",
"*",
"s",
"=",
"TriggeredPrefetch",
"\n",
"case",
"\"",
"\"",
":",
"*",
"s",
"=",
"FinishedPrefetch",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON converts a PrefetchStatus from JSON | [
"UnmarshalJSON",
"converts",
"a",
"PrefetchStatus",
"from",
"JSON"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L336-L352 |
160,426 | keybase/client | go/kbfs/libkbfs/data_types.go | ToProtocol | func (s PrefetchStatus) ToProtocol() kbgitkbfs.PrefetchStatus {
protocolPrefetchStatus := kbgitkbfs.PrefetchStatus(s)
_, ok := kbgitkbfs.PrefetchStatusRevMap[protocolPrefetchStatus]
if !ok {
panic("Invalid prefetch status for protocol")
}
return protocolPrefetchStatus
} | go | func (s PrefetchStatus) ToProtocol() kbgitkbfs.PrefetchStatus {
protocolPrefetchStatus := kbgitkbfs.PrefetchStatus(s)
_, ok := kbgitkbfs.PrefetchStatusRevMap[protocolPrefetchStatus]
if !ok {
panic("Invalid prefetch status for protocol")
}
return protocolPrefetchStatus
} | [
"func",
"(",
"s",
"PrefetchStatus",
")",
"ToProtocol",
"(",
")",
"kbgitkbfs",
".",
"PrefetchStatus",
"{",
"protocolPrefetchStatus",
":=",
"kbgitkbfs",
".",
"PrefetchStatus",
"(",
"s",
")",
"\n",
"_",
",",
"ok",
":=",
"kbgitkbfs",
".",
"PrefetchStatusRevMap",
"[",
"protocolPrefetchStatus",
"]",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"protocolPrefetchStatus",
"\n",
"}"
] | // ToProtocol transforms a PrefetchStatus to a kbgitkbfs.PrefetchStatus, while
// validating its value. | [
"ToProtocol",
"transforms",
"a",
"PrefetchStatus",
"to",
"a",
"kbgitkbfs",
".",
"PrefetchStatus",
"while",
"validating",
"its",
"value",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L356-L363 |
160,427 | keybase/client | go/kbfs/libkbfs/data_types.go | PrefetchStatusFromProtocol | func PrefetchStatusFromProtocol(
protocolPrefetchStatus kbgitkbfs.PrefetchStatus) PrefetchStatus {
s := PrefetchStatus(protocolPrefetchStatus)
switch s {
case NoPrefetch:
case TriggeredPrefetch:
case FinishedPrefetch:
default:
panic("Invalid prefetch status from protocol")
}
return s
} | go | func PrefetchStatusFromProtocol(
protocolPrefetchStatus kbgitkbfs.PrefetchStatus) PrefetchStatus {
s := PrefetchStatus(protocolPrefetchStatus)
switch s {
case NoPrefetch:
case TriggeredPrefetch:
case FinishedPrefetch:
default:
panic("Invalid prefetch status from protocol")
}
return s
} | [
"func",
"PrefetchStatusFromProtocol",
"(",
"protocolPrefetchStatus",
"kbgitkbfs",
".",
"PrefetchStatus",
")",
"PrefetchStatus",
"{",
"s",
":=",
"PrefetchStatus",
"(",
"protocolPrefetchStatus",
")",
"\n",
"switch",
"s",
"{",
"case",
"NoPrefetch",
":",
"case",
"TriggeredPrefetch",
":",
"case",
"FinishedPrefetch",
":",
"default",
":",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"s",
"\n",
"}"
] | // PrefetchStatusFromProtocol transforms a kbgitkbfs.PrefetchStatus to a
// PrefetchStatus, while validating its value. | [
"PrefetchStatusFromProtocol",
"transforms",
"a",
"kbgitkbfs",
".",
"PrefetchStatus",
"to",
"a",
"PrefetchStatus",
"while",
"validating",
"its",
"value",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L367-L378 |
160,428 | keybase/client | go/kbfs/libkbfs/data_types.go | Combine | func (bra BlockRequestAction) Combine(
other BlockRequestAction) BlockRequestAction {
combined := bra | other
// If the actions don't agree on stop-if-full, we should remove it
// from the combined result.
if bra.StopIfFull() != other.StopIfFull() {
combined = combined &^ blockRequestStopIfFull
}
return combined
} | go | func (bra BlockRequestAction) Combine(
other BlockRequestAction) BlockRequestAction {
combined := bra | other
// If the actions don't agree on stop-if-full, we should remove it
// from the combined result.
if bra.StopIfFull() != other.StopIfFull() {
combined = combined &^ blockRequestStopIfFull
}
return combined
} | [
"func",
"(",
"bra",
"BlockRequestAction",
")",
"Combine",
"(",
"other",
"BlockRequestAction",
")",
"BlockRequestAction",
"{",
"combined",
":=",
"bra",
"|",
"other",
"\n",
"// If the actions don't agree on stop-if-full, we should remove it",
"// from the combined result.",
"if",
"bra",
".",
"StopIfFull",
"(",
")",
"!=",
"other",
".",
"StopIfFull",
"(",
")",
"{",
"combined",
"=",
"combined",
"&^",
"blockRequestStopIfFull",
"\n",
"}",
"\n",
"return",
"combined",
"\n",
"}"
] | // Combine returns a new action by taking `other` into account. | [
"Combine",
"returns",
"a",
"new",
"action",
"by",
"taking",
"other",
"into",
"account",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L517-L526 |
160,429 | keybase/client | go/kbfs/libkbfs/data_types.go | Prefetch | func (bra BlockRequestAction) Prefetch(block data.Block) bool {
// When syncing, always prefetch child blocks of an indirect
// block, since it makes no sense to sync just part of a
// multi-block object.
if block.IsIndirect() && bra.Sync() {
return true
}
return bra.prefetch()
} | go | func (bra BlockRequestAction) Prefetch(block data.Block) bool {
// When syncing, always prefetch child blocks of an indirect
// block, since it makes no sense to sync just part of a
// multi-block object.
if block.IsIndirect() && bra.Sync() {
return true
}
return bra.prefetch()
} | [
"func",
"(",
"bra",
"BlockRequestAction",
")",
"Prefetch",
"(",
"block",
"data",
".",
"Block",
")",
"bool",
"{",
"// When syncing, always prefetch child blocks of an indirect",
"// block, since it makes no sense to sync just part of a",
"// multi-block object.",
"if",
"block",
".",
"IsIndirect",
"(",
")",
"&&",
"bra",
".",
"Sync",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"bra",
".",
"prefetch",
"(",
")",
"\n",
"}"
] | // Prefetch returns true if the action indicates the block should
// trigger a prefetch. | [
"Prefetch",
"returns",
"true",
"if",
"the",
"action",
"indicates",
"the",
"block",
"should",
"trigger",
"a",
"prefetch",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L534-L542 |
160,430 | keybase/client | go/kbfs/libkbfs/data_types.go | ChildAction | func (bra BlockRequestAction) ChildAction(block data.Block) BlockRequestAction {
// When syncing, always prefetch child blocks of an indirect
// block, since it makes no sense to sync just part of a
// multi-block object.
if bra.DeepPrefetch() || (block.IsIndirect() && bra.Sync()) {
return bra
}
return bra &^ (blockRequestPrefetch | blockRequestSync)
} | go | func (bra BlockRequestAction) ChildAction(block data.Block) BlockRequestAction {
// When syncing, always prefetch child blocks of an indirect
// block, since it makes no sense to sync just part of a
// multi-block object.
if bra.DeepPrefetch() || (block.IsIndirect() && bra.Sync()) {
return bra
}
return bra &^ (blockRequestPrefetch | blockRequestSync)
} | [
"func",
"(",
"bra",
"BlockRequestAction",
")",
"ChildAction",
"(",
"block",
"data",
".",
"Block",
")",
"BlockRequestAction",
"{",
"// When syncing, always prefetch child blocks of an indirect",
"// block, since it makes no sense to sync just part of a",
"// multi-block object.",
"if",
"bra",
".",
"DeepPrefetch",
"(",
")",
"||",
"(",
"block",
".",
"IsIndirect",
"(",
")",
"&&",
"bra",
".",
"Sync",
"(",
")",
")",
"{",
"return",
"bra",
"\n",
"}",
"\n",
"return",
"bra",
"&^",
"(",
"blockRequestPrefetch",
"|",
"blockRequestSync",
")",
"\n",
"}"
] | // ChildAction returns the action that should propagate down to any
// children of this block. | [
"ChildAction",
"returns",
"the",
"action",
"that",
"should",
"propagate",
"down",
"to",
"any",
"children",
"of",
"this",
"block",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L572-L580 |
160,431 | keybase/client | go/kbfs/libkbfs/data_types.go | ToProtocolProgress | func (p PrefetchProgress) ToProtocolProgress(clock Clock) (
out keybase1.PrefetchProgress) {
out.BytesFetched = int64(p.SubtreeBytesFetched)
out.BytesTotal = int64(p.SubtreeBytesTotal)
out.Start = keybase1.ToTime(p.Start)
if out.BytesTotal == 0 || out.Start == 0 {
return out
}
timeRunning := clock.Now().Sub(p.Start)
fracDone := float64(out.BytesFetched) / float64(out.BytesTotal)
totalTimeEstimate := time.Duration(float64(timeRunning) / fracDone)
endEstimate := p.Start.Add(totalTimeEstimate)
out.EndEstimate = keybase1.ToTime(endEstimate)
return out
} | go | func (p PrefetchProgress) ToProtocolProgress(clock Clock) (
out keybase1.PrefetchProgress) {
out.BytesFetched = int64(p.SubtreeBytesFetched)
out.BytesTotal = int64(p.SubtreeBytesTotal)
out.Start = keybase1.ToTime(p.Start)
if out.BytesTotal == 0 || out.Start == 0 {
return out
}
timeRunning := clock.Now().Sub(p.Start)
fracDone := float64(out.BytesFetched) / float64(out.BytesTotal)
totalTimeEstimate := time.Duration(float64(timeRunning) / fracDone)
endEstimate := p.Start.Add(totalTimeEstimate)
out.EndEstimate = keybase1.ToTime(endEstimate)
return out
} | [
"func",
"(",
"p",
"PrefetchProgress",
")",
"ToProtocolProgress",
"(",
"clock",
"Clock",
")",
"(",
"out",
"keybase1",
".",
"PrefetchProgress",
")",
"{",
"out",
".",
"BytesFetched",
"=",
"int64",
"(",
"p",
".",
"SubtreeBytesFetched",
")",
"\n",
"out",
".",
"BytesTotal",
"=",
"int64",
"(",
"p",
".",
"SubtreeBytesTotal",
")",
"\n",
"out",
".",
"Start",
"=",
"keybase1",
".",
"ToTime",
"(",
"p",
".",
"Start",
")",
"\n\n",
"if",
"out",
".",
"BytesTotal",
"==",
"0",
"||",
"out",
".",
"Start",
"==",
"0",
"{",
"return",
"out",
"\n",
"}",
"\n\n",
"timeRunning",
":=",
"clock",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"p",
".",
"Start",
")",
"\n",
"fracDone",
":=",
"float64",
"(",
"out",
".",
"BytesFetched",
")",
"/",
"float64",
"(",
"out",
".",
"BytesTotal",
")",
"\n",
"totalTimeEstimate",
":=",
"time",
".",
"Duration",
"(",
"float64",
"(",
"timeRunning",
")",
"/",
"fracDone",
")",
"\n",
"endEstimate",
":=",
"p",
".",
"Start",
".",
"Add",
"(",
"totalTimeEstimate",
")",
"\n",
"out",
".",
"EndEstimate",
"=",
"keybase1",
".",
"ToTime",
"(",
"endEstimate",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // ToProtocolProgress creates a progress suitable of being sent over
// the keybase1 protocol to the service. | [
"ToProtocolProgress",
"creates",
"a",
"progress",
"suitable",
"of",
"being",
"sent",
"over",
"the",
"keybase1",
"protocol",
"to",
"the",
"service",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L649-L665 |
160,432 | keybase/client | go/kbfs/libkbfs/data_types.go | ToProtocolStatus | func (p PrefetchProgress) ToProtocolStatus() keybase1.PrefetchStatus {
if p.SubtreeBytesTotal == p.SubtreeBytesFetched ||
p.SubtreeBytesTotal == 0 {
return keybase1.PrefetchStatus_COMPLETE
}
return keybase1.PrefetchStatus_IN_PROGRESS
} | go | func (p PrefetchProgress) ToProtocolStatus() keybase1.PrefetchStatus {
if p.SubtreeBytesTotal == p.SubtreeBytesFetched ||
p.SubtreeBytesTotal == 0 {
return keybase1.PrefetchStatus_COMPLETE
}
return keybase1.PrefetchStatus_IN_PROGRESS
} | [
"func",
"(",
"p",
"PrefetchProgress",
")",
"ToProtocolStatus",
"(",
")",
"keybase1",
".",
"PrefetchStatus",
"{",
"if",
"p",
".",
"SubtreeBytesTotal",
"==",
"p",
".",
"SubtreeBytesFetched",
"||",
"p",
".",
"SubtreeBytesTotal",
"==",
"0",
"{",
"return",
"keybase1",
".",
"PrefetchStatus_COMPLETE",
"\n",
"}",
"\n",
"return",
"keybase1",
".",
"PrefetchStatus_IN_PROGRESS",
"\n",
"}"
] | // ToProtocolStatus creates a status suitable of being sent over the
// keybase1 protocol to the service. It never generates NOT_STARTED
// since that doesn't make sense once you already have a prefetch
// progress created. | [
"ToProtocolStatus",
"creates",
"a",
"status",
"suitable",
"of",
"being",
"sent",
"over",
"the",
"keybase1",
"protocol",
"to",
"the",
"service",
".",
"It",
"never",
"generates",
"NOT_STARTED",
"since",
"that",
"doesn",
"t",
"make",
"sense",
"once",
"you",
"already",
"have",
"a",
"prefetch",
"progress",
"created",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/data_types.go#L671-L677 |
160,433 | keybase/client | go/kbfs/libkbfs/util.go | MakeRandomRequestID | func MakeRandomRequestID() (string, error) {
// Use a random ID to tag each request. We want this to be really
// universally unique, as these request IDs might need to be
// propagated all the way to the server. Use a base64-encoded
// random 128-bit number.
buf := make([]byte, 128/8)
err := kbfscrypto.RandRead(buf)
if err != nil {
return "", err
}
return base64.RawURLEncoding.EncodeToString(buf), nil
} | go | func MakeRandomRequestID() (string, error) {
// Use a random ID to tag each request. We want this to be really
// universally unique, as these request IDs might need to be
// propagated all the way to the server. Use a base64-encoded
// random 128-bit number.
buf := make([]byte, 128/8)
err := kbfscrypto.RandRead(buf)
if err != nil {
return "", err
}
return base64.RawURLEncoding.EncodeToString(buf), nil
} | [
"func",
"MakeRandomRequestID",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Use a random ID to tag each request. We want this to be really",
"// universally unique, as these request IDs might need to be",
"// propagated all the way to the server. Use a base64-encoded",
"// random 128-bit number.",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"128",
"/",
"8",
")",
"\n",
"err",
":=",
"kbfscrypto",
".",
"RandRead",
"(",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"base64",
".",
"RawURLEncoding",
".",
"EncodeToString",
"(",
"buf",
")",
",",
"nil",
"\n",
"}"
] | // MakeRandomRequestID generates a random ID suitable for tagging a
// request in KBFS, and very likely to be universally unique. | [
"MakeRandomRequestID",
"generates",
"a",
"random",
"ID",
"suitable",
"for",
"tagging",
"a",
"request",
"in",
"KBFS",
"and",
"very",
"likely",
"to",
"be",
"universally",
"unique",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/util.go#L49-L60 |
160,434 | keybase/client | go/kbfs/libkbfs/util.go | VersionString | func VersionString() string {
if PrereleaseBuild != "" {
return fmt.Sprintf("%s-%s", libkb.Version, PrereleaseBuild)
}
return libkb.Version
} | go | func VersionString() string {
if PrereleaseBuild != "" {
return fmt.Sprintf("%s-%s", libkb.Version, PrereleaseBuild)
}
return libkb.Version
} | [
"func",
"VersionString",
"(",
")",
"string",
"{",
"if",
"PrereleaseBuild",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"libkb",
".",
"Version",
",",
"PrereleaseBuild",
")",
"\n",
"}",
"\n",
"return",
"libkb",
".",
"Version",
"\n",
"}"
] | // VersionString returns semantic version string | [
"VersionString",
"returns",
"semantic",
"version",
"string"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/util.go#L75-L80 |
160,435 | keybase/client | go/kbfs/libkbfs/util.go | CtxWithRandomIDReplayable | func CtxWithRandomIDReplayable(ctx context.Context, tagKey interface{},
tagName string, log Warninger) context.Context {
ctx = logger.ConvertRPCTagsToLogTags(ctx)
id, err := MakeRandomRequestID()
if err != nil && log != nil {
log.Warning("Couldn't generate a random request ID: %v", err)
}
return libcontext.NewContextReplayable(ctx, func(ctx context.Context) context.Context {
logTags := make(logger.CtxLogTags)
logTags[tagKey] = tagName
newCtx := logger.NewContextWithLogTags(ctx, logTags)
if err == nil {
newCtx = context.WithValue(newCtx, tagKey, id)
}
return newCtx
})
} | go | func CtxWithRandomIDReplayable(ctx context.Context, tagKey interface{},
tagName string, log Warninger) context.Context {
ctx = logger.ConvertRPCTagsToLogTags(ctx)
id, err := MakeRandomRequestID()
if err != nil && log != nil {
log.Warning("Couldn't generate a random request ID: %v", err)
}
return libcontext.NewContextReplayable(ctx, func(ctx context.Context) context.Context {
logTags := make(logger.CtxLogTags)
logTags[tagKey] = tagName
newCtx := logger.NewContextWithLogTags(ctx, logTags)
if err == nil {
newCtx = context.WithValue(newCtx, tagKey, id)
}
return newCtx
})
} | [
"func",
"CtxWithRandomIDReplayable",
"(",
"ctx",
"context",
".",
"Context",
",",
"tagKey",
"interface",
"{",
"}",
",",
"tagName",
"string",
",",
"log",
"Warninger",
")",
"context",
".",
"Context",
"{",
"ctx",
"=",
"logger",
".",
"ConvertRPCTagsToLogTags",
"(",
"ctx",
")",
"\n\n",
"id",
",",
"err",
":=",
"MakeRandomRequestID",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"log",
"!=",
"nil",
"{",
"log",
".",
"Warning",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"libcontext",
".",
"NewContextReplayable",
"(",
"ctx",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"logTags",
":=",
"make",
"(",
"logger",
".",
"CtxLogTags",
")",
"\n",
"logTags",
"[",
"tagKey",
"]",
"=",
"tagName",
"\n",
"newCtx",
":=",
"logger",
".",
"NewContextWithLogTags",
"(",
"ctx",
",",
"logTags",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"newCtx",
"=",
"context",
".",
"WithValue",
"(",
"newCtx",
",",
"tagKey",
",",
"id",
")",
"\n",
"}",
"\n",
"return",
"newCtx",
"\n",
"}",
")",
"\n",
"}"
] | // CtxWithRandomIDReplayable returns a replayable context with a
// random id associated with the given log key. | [
"CtxWithRandomIDReplayable",
"returns",
"a",
"replayable",
"context",
"with",
"a",
"random",
"id",
"associated",
"with",
"the",
"given",
"log",
"key",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/util.go#L100-L117 |
160,436 | keybase/client | go/kbfs/libkbfs/util.go | checkDataVersion | func checkDataVersion(
versioner data.Versioner, p data.Path, ptr data.BlockPointer) error {
if ptr.DataVer < data.FirstValidVer {
return errors.WithStack(InvalidDataVersionError{ptr.DataVer})
}
if versioner != nil && ptr.DataVer > versioner.DataVersion() {
return errors.WithStack(NewDataVersionError{p, ptr.DataVer})
}
return nil
} | go | func checkDataVersion(
versioner data.Versioner, p data.Path, ptr data.BlockPointer) error {
if ptr.DataVer < data.FirstValidVer {
return errors.WithStack(InvalidDataVersionError{ptr.DataVer})
}
if versioner != nil && ptr.DataVer > versioner.DataVersion() {
return errors.WithStack(NewDataVersionError{p, ptr.DataVer})
}
return nil
} | [
"func",
"checkDataVersion",
"(",
"versioner",
"data",
".",
"Versioner",
",",
"p",
"data",
".",
"Path",
",",
"ptr",
"data",
".",
"BlockPointer",
")",
"error",
"{",
"if",
"ptr",
".",
"DataVer",
"<",
"data",
".",
"FirstValidVer",
"{",
"return",
"errors",
".",
"WithStack",
"(",
"InvalidDataVersionError",
"{",
"ptr",
".",
"DataVer",
"}",
")",
"\n",
"}",
"\n",
"if",
"versioner",
"!=",
"nil",
"&&",
"ptr",
".",
"DataVer",
">",
"versioner",
".",
"DataVersion",
"(",
")",
"{",
"return",
"errors",
".",
"WithStack",
"(",
"NewDataVersionError",
"{",
"p",
",",
"ptr",
".",
"DataVer",
"}",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // checkDataVersion validates that the data version for a
// block pointer is valid for the given version validator | [
"checkDataVersion",
"validates",
"that",
"the",
"data",
"version",
"for",
"a",
"block",
"pointer",
"is",
"valid",
"for",
"the",
"given",
"version",
"validator"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/util.go#L121-L130 |
160,437 | keybase/client | go/kbfs/libkbfs/util.go | IsWriterFromHandle | func IsWriterFromHandle(
ctx context.Context, h *tlfhandle.Handle, checker kbfsmd.TeamMembershipChecker,
osg idutil.OfflineStatusGetter, uid keybase1.UID,
verifyingKey kbfscrypto.VerifyingKey) (bool, error) {
if h.TypeForKeying() != tlf.TeamKeying {
return h.IsWriter(uid), nil
}
// Team membership needs to be checked with the service. For a
// SingleTeam TLF, there is always only a single writer in the
// handle.
tid, err := h.FirstResolvedWriter().AsTeam()
if err != nil {
return false, err
}
offline := keybase1.OfflineAvailability_NONE
if osg != nil {
offline = osg.OfflineAvailabilityForID(h.TlfID())
}
return checker.IsTeamWriter(ctx, tid, uid, verifyingKey, offline)
} | go | func IsWriterFromHandle(
ctx context.Context, h *tlfhandle.Handle, checker kbfsmd.TeamMembershipChecker,
osg idutil.OfflineStatusGetter, uid keybase1.UID,
verifyingKey kbfscrypto.VerifyingKey) (bool, error) {
if h.TypeForKeying() != tlf.TeamKeying {
return h.IsWriter(uid), nil
}
// Team membership needs to be checked with the service. For a
// SingleTeam TLF, there is always only a single writer in the
// handle.
tid, err := h.FirstResolvedWriter().AsTeam()
if err != nil {
return false, err
}
offline := keybase1.OfflineAvailability_NONE
if osg != nil {
offline = osg.OfflineAvailabilityForID(h.TlfID())
}
return checker.IsTeamWriter(ctx, tid, uid, verifyingKey, offline)
} | [
"func",
"IsWriterFromHandle",
"(",
"ctx",
"context",
".",
"Context",
",",
"h",
"*",
"tlfhandle",
".",
"Handle",
",",
"checker",
"kbfsmd",
".",
"TeamMembershipChecker",
",",
"osg",
"idutil",
".",
"OfflineStatusGetter",
",",
"uid",
"keybase1",
".",
"UID",
",",
"verifyingKey",
"kbfscrypto",
".",
"VerifyingKey",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"h",
".",
"TypeForKeying",
"(",
")",
"!=",
"tlf",
".",
"TeamKeying",
"{",
"return",
"h",
".",
"IsWriter",
"(",
"uid",
")",
",",
"nil",
"\n",
"}",
"\n\n",
"// Team membership needs to be checked with the service. For a",
"// SingleTeam TLF, there is always only a single writer in the",
"// handle.",
"tid",
",",
"err",
":=",
"h",
".",
"FirstResolvedWriter",
"(",
")",
".",
"AsTeam",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"offline",
":=",
"keybase1",
".",
"OfflineAvailability_NONE",
"\n",
"if",
"osg",
"!=",
"nil",
"{",
"offline",
"=",
"osg",
".",
"OfflineAvailabilityForID",
"(",
"h",
".",
"TlfID",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"checker",
".",
"IsTeamWriter",
"(",
"ctx",
",",
"tid",
",",
"uid",
",",
"verifyingKey",
",",
"offline",
")",
"\n",
"}"
] | // IsWriterFromHandle checks whether the given UID is a writer for the
// given handle. It understands team-keyed handles as well as
// classically-keyed handles. | [
"IsWriterFromHandle",
"checks",
"whether",
"the",
"given",
"UID",
"is",
"a",
"writer",
"for",
"the",
"given",
"handle",
".",
"It",
"understands",
"team",
"-",
"keyed",
"handles",
"as",
"well",
"as",
"classically",
"-",
"keyed",
"handles",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/util.go#L210-L230 |
160,438 | keybase/client | go/kbfs/libkbfs/util.go | IsOnlyWriterInNonTeamTlf | func IsOnlyWriterInNonTeamTlf(ctx context.Context, kbpki KBPKI,
h *tlfhandle.Handle) bool {
session, err := idutil.GetCurrentSessionIfPossible(
ctx, kbpki, h.Type() == tlf.Public)
if err != nil {
return false
}
if h.TypeForKeying() == tlf.TeamKeying {
return false
}
return tlf.UserIsOnlyWriter(session.Name, h.GetCanonicalName())
} | go | func IsOnlyWriterInNonTeamTlf(ctx context.Context, kbpki KBPKI,
h *tlfhandle.Handle) bool {
session, err := idutil.GetCurrentSessionIfPossible(
ctx, kbpki, h.Type() == tlf.Public)
if err != nil {
return false
}
if h.TypeForKeying() == tlf.TeamKeying {
return false
}
return tlf.UserIsOnlyWriter(session.Name, h.GetCanonicalName())
} | [
"func",
"IsOnlyWriterInNonTeamTlf",
"(",
"ctx",
"context",
".",
"Context",
",",
"kbpki",
"KBPKI",
",",
"h",
"*",
"tlfhandle",
".",
"Handle",
")",
"bool",
"{",
"session",
",",
"err",
":=",
"idutil",
".",
"GetCurrentSessionIfPossible",
"(",
"ctx",
",",
"kbpki",
",",
"h",
".",
"Type",
"(",
")",
"==",
"tlf",
".",
"Public",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"h",
".",
"TypeForKeying",
"(",
")",
"==",
"tlf",
".",
"TeamKeying",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"tlf",
".",
"UserIsOnlyWriter",
"(",
"session",
".",
"Name",
",",
"h",
".",
"GetCanonicalName",
"(",
")",
")",
"\n",
"}"
] | // IsOnlyWriterInNonTeamTlf returns true if and only if the TLF described by h
// is a non-team TLF, and the currently logged-in user is the only writer for
// the TLF. In case of any error false is returned. | [
"IsOnlyWriterInNonTeamTlf",
"returns",
"true",
"if",
"and",
"only",
"if",
"the",
"TLF",
"described",
"by",
"h",
"is",
"a",
"non",
"-",
"team",
"TLF",
"and",
"the",
"currently",
"logged",
"-",
"in",
"user",
"is",
"the",
"only",
"writer",
"for",
"the",
"TLF",
".",
"In",
"case",
"of",
"any",
"error",
"false",
"is",
"returned",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/util.go#L269-L280 |
160,439 | keybase/client | go/service/simplefs.go | SimpleFSListRecursiveToDepth | func (s *SimpleFSHandler) SimpleFSListRecursiveToDepth(ctx context.Context, arg keybase1.SimpleFSListRecursiveToDepthArg) error {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return err
}
return cli.SimpleFSListRecursiveToDepth(ctx, arg)
} | go | func (s *SimpleFSHandler) SimpleFSListRecursiveToDepth(ctx context.Context, arg keybase1.SimpleFSListRecursiveToDepthArg) error {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return err
}
return cli.SimpleFSListRecursiveToDepth(ctx, arg)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSListRecursiveToDepth",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"SimpleFSListRecursiveToDepthArg",
")",
"error",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSListRecursiveToDepth",
"(",
"ctx",
",",
"arg",
")",
"\n",
"}"
] | // SimpleFSListRecursiveToDepth - Begin recursive list of items in directory at
// path to a given depth. | [
"SimpleFSListRecursiveToDepth",
"-",
"Begin",
"recursive",
"list",
"of",
"items",
"in",
"directory",
"at",
"path",
"to",
"a",
"given",
"depth",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L90-L98 |
160,440 | keybase/client | go/service/simplefs.go | SimpleFSSymlink | func (s *SimpleFSHandler) SimpleFSSymlink(ctx context.Context, arg keybase1.SimpleFSSymlinkArg) error {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return err
}
return cli.SimpleFSSymlink(ctx, arg)
} | go | func (s *SimpleFSHandler) SimpleFSSymlink(ctx context.Context, arg keybase1.SimpleFSSymlinkArg) error {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return err
}
return cli.SimpleFSSymlink(ctx, arg)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSSymlink",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"SimpleFSSymlinkArg",
")",
"error",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSSymlink",
"(",
"ctx",
",",
"arg",
")",
"\n",
"}"
] | // SimpleFSSymlink - Make a symlink from KBFS to either elsewhere in KBFS or in the regular filesystem | [
"SimpleFSSymlink",
"-",
"Make",
"a",
"symlink",
"from",
"KBFS",
"to",
"either",
"elsewhere",
"in",
"KBFS",
"or",
"in",
"the",
"regular",
"filesystem"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L157-L165 |
160,441 | keybase/client | go/service/simplefs.go | SimpleFSGetRevisions | func (s *SimpleFSHandler) SimpleFSGetRevisions(
ctx context.Context, arg keybase1.SimpleFSGetRevisionsArg) error {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return err
}
return cli.SimpleFSGetRevisions(ctx, arg)
} | go | func (s *SimpleFSHandler) SimpleFSGetRevisions(
ctx context.Context, arg keybase1.SimpleFSGetRevisionsArg) error {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return err
}
return cli.SimpleFSGetRevisions(ctx, arg)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSGetRevisions",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"SimpleFSGetRevisionsArg",
")",
"error",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSGetRevisions",
"(",
"ctx",
",",
"arg",
")",
"\n",
"}"
] | // SimpleFSGetRevisions - Get revision info for a directory entry | [
"SimpleFSGetRevisions",
"-",
"Get",
"revision",
"info",
"for",
"a",
"directory",
"entry"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L240-L249 |
160,442 | keybase/client | go/service/simplefs.go | SimpleFSReadRevisions | func (s *SimpleFSHandler) SimpleFSReadRevisions(
ctx context.Context, opID keybase1.OpID) (
keybase1.GetRevisionsResult, error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.GetRevisionsResult{}, err
}
return cli.SimpleFSReadRevisions(ctx, opID)
} | go | func (s *SimpleFSHandler) SimpleFSReadRevisions(
ctx context.Context, opID keybase1.OpID) (
keybase1.GetRevisionsResult, error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.GetRevisionsResult{}, err
}
return cli.SimpleFSReadRevisions(ctx, opID)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSReadRevisions",
"(",
"ctx",
"context",
".",
"Context",
",",
"opID",
"keybase1",
".",
"OpID",
")",
"(",
"keybase1",
".",
"GetRevisionsResult",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"GetRevisionsResult",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSReadRevisions",
"(",
"ctx",
",",
"opID",
")",
"\n",
"}"
] | // SimpleFSReadRevisions - Get list of revisions in progress. Can
// indicate status of pending to get more entries. | [
"SimpleFSReadRevisions",
"-",
"Get",
"list",
"of",
"revisions",
"in",
"progress",
".",
"Can",
"indicate",
"status",
"of",
"pending",
"to",
"get",
"more",
"entries",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L253-L263 |
160,443 | keybase/client | go/service/simplefs.go | SimpleFSGetHTTPAddressAndToken | func (s *SimpleFSHandler) SimpleFSGetHTTPAddressAndToken(ctx context.Context) (keybase1.SimpleFSGetHTTPAddressAndTokenResponse, error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.SimpleFSGetHTTPAddressAndTokenResponse{}, err
}
return cli.SimpleFSGetHTTPAddressAndToken(ctx)
} | go | func (s *SimpleFSHandler) SimpleFSGetHTTPAddressAndToken(ctx context.Context) (keybase1.SimpleFSGetHTTPAddressAndTokenResponse, error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.SimpleFSGetHTTPAddressAndTokenResponse{}, err
}
return cli.SimpleFSGetHTTPAddressAndToken(ctx)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSGetHTTPAddressAndToken",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"keybase1",
".",
"SimpleFSGetHTTPAddressAndTokenResponse",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"SimpleFSGetHTTPAddressAndTokenResponse",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSGetHTTPAddressAndToken",
"(",
"ctx",
")",
"\n",
"}"
] | // SimpleFSGetHTTPAddressAndToken implements the SimpleFSInterface. | [
"SimpleFSGetHTTPAddressAndToken",
"implements",
"the",
"SimpleFSInterface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L354-L362 |
160,444 | keybase/client | go/service/simplefs.go | SimpleFSUserEditHistory | func (s *SimpleFSHandler) SimpleFSUserEditHistory(ctx context.Context) (
res []keybase1.FSFolderEditHistory, err error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return nil, err
}
return cli.SimpleFSUserEditHistory(ctx)
} | go | func (s *SimpleFSHandler) SimpleFSUserEditHistory(ctx context.Context) (
res []keybase1.FSFolderEditHistory, err error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return nil, err
}
return cli.SimpleFSUserEditHistory(ctx)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSUserEditHistory",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"res",
"[",
"]",
"keybase1",
".",
"FSFolderEditHistory",
",",
"err",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSUserEditHistory",
"(",
"ctx",
")",
"\n",
"}"
] | // SimpleFSUserEditHistory implements the SimpleFSInterface. | [
"SimpleFSUserEditHistory",
"implements",
"the",
"SimpleFSInterface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L365-L374 |
160,445 | keybase/client | go/service/simplefs.go | SimpleFSFolderEditHistory | func (s *SimpleFSHandler) SimpleFSFolderEditHistory(
ctx context.Context, path keybase1.Path) (
res keybase1.FSFolderEditHistory, err error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.FSFolderEditHistory{}, err
}
return cli.SimpleFSFolderEditHistory(ctx, path)
} | go | func (s *SimpleFSHandler) SimpleFSFolderEditHistory(
ctx context.Context, path keybase1.Path) (
res keybase1.FSFolderEditHistory, err error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.FSFolderEditHistory{}, err
}
return cli.SimpleFSFolderEditHistory(ctx, path)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSFolderEditHistory",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"keybase1",
".",
"Path",
")",
"(",
"res",
"keybase1",
".",
"FSFolderEditHistory",
",",
"err",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"FSFolderEditHistory",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSFolderEditHistory",
"(",
"ctx",
",",
"path",
")",
"\n",
"}"
] | // SimpleFSFolderEditHistory implements the SimpleFSInterface. | [
"SimpleFSFolderEditHistory",
"implements",
"the",
"SimpleFSInterface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L377-L387 |
160,446 | keybase/client | go/service/simplefs.go | SimpleFSReset | func (s *SimpleFSHandler) SimpleFSReset(
ctx context.Context, path keybase1.Path) (err error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return err
}
return cli.SimpleFSReset(ctx, path)
} | go | func (s *SimpleFSHandler) SimpleFSReset(
ctx context.Context, path keybase1.Path) (err error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return err
}
return cli.SimpleFSReset(ctx, path)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSReset",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"keybase1",
".",
"Path",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSReset",
"(",
"ctx",
",",
"path",
")",
"\n",
"}"
] | // SimpleFSReset implements the SimpleFSInterface. | [
"SimpleFSReset",
"implements",
"the",
"SimpleFSInterface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L390-L399 |
160,447 | keybase/client | go/service/simplefs.go | SimpleFSGetUserQuotaUsage | func (s *SimpleFSHandler) SimpleFSGetUserQuotaUsage(ctx context.Context) (
keybase1.SimpleFSQuotaUsage, error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
return cli.SimpleFSGetUserQuotaUsage(ctx)
} | go | func (s *SimpleFSHandler) SimpleFSGetUserQuotaUsage(ctx context.Context) (
keybase1.SimpleFSQuotaUsage, error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
return cli.SimpleFSGetUserQuotaUsage(ctx)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSGetUserQuotaUsage",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"keybase1",
".",
"SimpleFSQuotaUsage",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"SimpleFSQuotaUsage",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSGetUserQuotaUsage",
"(",
"ctx",
")",
"\n",
"}"
] | // SimpleFSGetUserQuotaUsage implements the SimpleFSInterface. | [
"SimpleFSGetUserQuotaUsage",
"implements",
"the",
"SimpleFSInterface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L402-L411 |
160,448 | keybase/client | go/service/simplefs.go | SimpleFSGetTeamQuotaUsage | func (s *SimpleFSHandler) SimpleFSGetTeamQuotaUsage(
ctx context.Context, teamName keybase1.TeamName) (
keybase1.SimpleFSQuotaUsage, error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
return cli.SimpleFSGetTeamQuotaUsage(ctx, teamName)
} | go | func (s *SimpleFSHandler) SimpleFSGetTeamQuotaUsage(
ctx context.Context, teamName keybase1.TeamName) (
keybase1.SimpleFSQuotaUsage, error) {
ctx, cancel := s.wrapContextWithTimeout(ctx)
defer cancel()
cli, err := s.client()
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
return cli.SimpleFSGetTeamQuotaUsage(ctx, teamName)
} | [
"func",
"(",
"s",
"*",
"SimpleFSHandler",
")",
"SimpleFSGetTeamQuotaUsage",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamName",
"keybase1",
".",
"TeamName",
")",
"(",
"keybase1",
".",
"SimpleFSQuotaUsage",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"s",
".",
"wrapContextWithTimeout",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"cli",
",",
"err",
":=",
"s",
".",
"client",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"SimpleFSQuotaUsage",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"cli",
".",
"SimpleFSGetTeamQuotaUsage",
"(",
"ctx",
",",
"teamName",
")",
"\n",
"}"
] | // SimpleFSGetTeamQuotaUsage implements the SimpleFSInterface. | [
"SimpleFSGetTeamQuotaUsage",
"implements",
"the",
"SimpleFSInterface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/simplefs.go#L414-L424 |
160,449 | keybase/client | go/install/install_darwinwindows.go | GetNeedUpdate | func GetNeedUpdate() (bool, error) {
updaterPath, err := UpdaterBinPath()
if err != nil {
return false, err
}
cmd := exec.Command(updaterPath, "need-update")
out, err := cmd.Output()
if err != nil {
return false, err
}
needUpdate, err := strconv.ParseBool(strings.TrimSpace(string(out)))
if err != nil {
return false, err
}
return needUpdate, nil
} | go | func GetNeedUpdate() (bool, error) {
updaterPath, err := UpdaterBinPath()
if err != nil {
return false, err
}
cmd := exec.Command(updaterPath, "need-update")
out, err := cmd.Output()
if err != nil {
return false, err
}
needUpdate, err := strconv.ParseBool(strings.TrimSpace(string(out)))
if err != nil {
return false, err
}
return needUpdate, nil
} | [
"func",
"GetNeedUpdate",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"updaterPath",
",",
"err",
":=",
"UpdaterBinPath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"updaterPath",
",",
"\"",
"\"",
")",
"\n",
"out",
",",
"err",
":=",
"cmd",
".",
"Output",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"needUpdate",
",",
"err",
":=",
"strconv",
".",
"ParseBool",
"(",
"strings",
".",
"TrimSpace",
"(",
"string",
"(",
"out",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"needUpdate",
",",
"nil",
"\n",
"}"
] | // GetNeedUpdate returns true if updater says we have a new update available.
// This runs `updater need-update`, which ignores the snooze. | [
"GetNeedUpdate",
"returns",
"true",
"if",
"updater",
"says",
"we",
"have",
"a",
"new",
"update",
"available",
".",
"This",
"runs",
"updater",
"need",
"-",
"update",
"which",
"ignores",
"the",
"snooze",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/install/install_darwinwindows.go#L16-L31 |
160,450 | keybase/client | go/chat/flip/simple.go | Flip | func Flip(cp CommitmentPayload, players []PlayerState) (*PRNG, error) {
err := checkPlayers(cp, players)
if err != nil {
return nil, err
}
res := computeSecret(players)
return NewPRNG(res), nil
} | go | func Flip(cp CommitmentPayload, players []PlayerState) (*PRNG, error) {
err := checkPlayers(cp, players)
if err != nil {
return nil, err
}
res := computeSecret(players)
return NewPRNG(res), nil
} | [
"func",
"Flip",
"(",
"cp",
"CommitmentPayload",
",",
"players",
"[",
"]",
"PlayerState",
")",
"(",
"*",
"PRNG",
",",
"error",
")",
"{",
"err",
":=",
"checkPlayers",
"(",
"cp",
",",
"players",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"res",
":=",
"computeSecret",
"(",
"players",
")",
"\n",
"return",
"NewPRNG",
"(",
"res",
")",
",",
"nil",
"\n",
"}"
] | // Flip takes all the completed PlayerStates from the game, makes sure they don't have
// an error, and if not, outputs a PRNG from which arbirarily many ints, or bools,
// can be deterministically plucked. If there's an error, PRNG will be nil. | [
"Flip",
"takes",
"all",
"the",
"completed",
"PlayerStates",
"from",
"the",
"game",
"makes",
"sure",
"they",
"don",
"t",
"have",
"an",
"error",
"and",
"if",
"not",
"outputs",
"a",
"PRNG",
"from",
"which",
"arbirarily",
"many",
"ints",
"or",
"bools",
"can",
"be",
"deterministically",
"plucked",
".",
"If",
"there",
"s",
"an",
"error",
"PRNG",
"will",
"be",
"nil",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/simple.go#L81-L88 |
160,451 | keybase/client | go/chat/flip/simple.go | FlipOneBig | func FlipOneBig(cp CommitmentPayload, players []PlayerState, modulus *big.Int) (*big.Int, error) {
prng, err := Flip(cp, players)
if err != nil {
return nil, err
}
return prng.Big(modulus), nil
} | go | func FlipOneBig(cp CommitmentPayload, players []PlayerState, modulus *big.Int) (*big.Int, error) {
prng, err := Flip(cp, players)
if err != nil {
return nil, err
}
return prng.Big(modulus), nil
} | [
"func",
"FlipOneBig",
"(",
"cp",
"CommitmentPayload",
",",
"players",
"[",
"]",
"PlayerState",
",",
"modulus",
"*",
"big",
".",
"Int",
")",
"(",
"*",
"big",
".",
"Int",
",",
"error",
")",
"{",
"prng",
",",
"err",
":=",
"Flip",
"(",
"cp",
",",
"players",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"prng",
".",
"Big",
"(",
"modulus",
")",
",",
"nil",
"\n",
"}"
] | // FlipOneBig takes all the completed PlayerStates, and checks them. If no error,
// then outputs one random number between 0 and the given modulus, which is an arbitrarily
// big number. If there was an error in the game setup, then it will return nil and the error. | [
"FlipOneBig",
"takes",
"all",
"the",
"completed",
"PlayerStates",
"and",
"checks",
"them",
".",
"If",
"no",
"error",
"then",
"outputs",
"one",
"random",
"number",
"between",
"0",
"and",
"the",
"given",
"modulus",
"which",
"is",
"an",
"arbitrarily",
"big",
"number",
".",
"If",
"there",
"was",
"an",
"error",
"in",
"the",
"game",
"setup",
"then",
"it",
"will",
"return",
"nil",
"and",
"the",
"error",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/simple.go#L93-L99 |
160,452 | keybase/client | go/chat/flip/simple.go | FlipInt | func FlipInt(cp CommitmentPayload, players []PlayerState, modulus int64) (int64, error) {
prng, err := Flip(cp, players)
if err != nil {
return 0, err
}
return prng.Int(modulus), nil
} | go | func FlipInt(cp CommitmentPayload, players []PlayerState, modulus int64) (int64, error) {
prng, err := Flip(cp, players)
if err != nil {
return 0, err
}
return prng.Int(modulus), nil
} | [
"func",
"FlipInt",
"(",
"cp",
"CommitmentPayload",
",",
"players",
"[",
"]",
"PlayerState",
",",
"modulus",
"int64",
")",
"(",
"int64",
",",
"error",
")",
"{",
"prng",
",",
"err",
":=",
"Flip",
"(",
"cp",
",",
"players",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
"prng",
".",
"Int",
"(",
"modulus",
")",
",",
"nil",
"\n",
"}"
] | // FlipOneInt takes all the completed PlayerStates, and checks them. If no error,
// then outputs one random number between 0 and the given modulus, a signed 64-bit int.
// If there was an error in the game setup, then it will return 0 and the error. | [
"FlipOneInt",
"takes",
"all",
"the",
"completed",
"PlayerStates",
"and",
"checks",
"them",
".",
"If",
"no",
"error",
"then",
"outputs",
"one",
"random",
"number",
"between",
"0",
"and",
"the",
"given",
"modulus",
"a",
"signed",
"64",
"-",
"bit",
"int",
".",
"If",
"there",
"was",
"an",
"error",
"in",
"the",
"game",
"setup",
"then",
"it",
"will",
"return",
"0",
"and",
"the",
"error",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/simple.go#L104-L110 |
160,453 | keybase/client | go/chat/flip/simple.go | FlipBool | func FlipBool(cp CommitmentPayload, players []PlayerState) (bool, error) {
prng, err := Flip(cp, players)
if err != nil {
return false, err
}
return prng.Bool(), nil
} | go | func FlipBool(cp CommitmentPayload, players []PlayerState) (bool, error) {
prng, err := Flip(cp, players)
if err != nil {
return false, err
}
return prng.Bool(), nil
} | [
"func",
"FlipBool",
"(",
"cp",
"CommitmentPayload",
",",
"players",
"[",
"]",
"PlayerState",
")",
"(",
"bool",
",",
"error",
")",
"{",
"prng",
",",
"err",
":=",
"Flip",
"(",
"cp",
",",
"players",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"prng",
".",
"Bool",
"(",
")",
",",
"nil",
"\n",
"}"
] | // FlipOneBool takes all the completed PlayerStates, and checks them. If no error,
// then outputs one random bool. If there was an error in the game setup, then it will
// return false and the error. | [
"FlipOneBool",
"takes",
"all",
"the",
"completed",
"PlayerStates",
"and",
"checks",
"them",
".",
"If",
"no",
"error",
"then",
"outputs",
"one",
"random",
"bool",
".",
"If",
"there",
"was",
"an",
"error",
"in",
"the",
"game",
"setup",
"then",
"it",
"will",
"return",
"false",
"and",
"the",
"error",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/flip/simple.go#L115-L121 |
160,454 | keybase/client | go/engine/saltpack_decrypt.go | NewSaltpackDecrypt | func NewSaltpackDecrypt(arg *SaltpackDecryptArg, pnymResolver saltpack.SymmetricKeyResolver) *SaltpackDecrypt {
return &SaltpackDecrypt{
arg: arg,
pnymResolver: pnymResolver,
}
} | go | func NewSaltpackDecrypt(arg *SaltpackDecryptArg, pnymResolver saltpack.SymmetricKeyResolver) *SaltpackDecrypt {
return &SaltpackDecrypt{
arg: arg,
pnymResolver: pnymResolver,
}
} | [
"func",
"NewSaltpackDecrypt",
"(",
"arg",
"*",
"SaltpackDecryptArg",
",",
"pnymResolver",
"saltpack",
".",
"SymmetricKeyResolver",
")",
"*",
"SaltpackDecrypt",
"{",
"return",
"&",
"SaltpackDecrypt",
"{",
"arg",
":",
"arg",
",",
"pnymResolver",
":",
"pnymResolver",
",",
"}",
"\n",
"}"
] | // NewSaltpackDecrypt creates a SaltpackDecrypt engine. | [
"NewSaltpackDecrypt",
"creates",
"a",
"SaltpackDecrypt",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/saltpack_decrypt.go#L31-L36 |
160,455 | keybase/client | go/chat/storage/reacjis.go | UserReacjis | func (s *ReacjiStore) UserReacjis(ctx context.Context, uid gregor1.UID) keybase1.UserReacjis {
s.Lock()
defer s.Unlock()
cache := s.populateCacheLocked(ctx, uid)
pairs := []reacjiPair{}
for name, freq := range cache.FrequencyMap {
pairs = append(pairs, reacjiPair{name: name, freq: freq})
}
// sort by frequency and then alphabetically
sort.Slice(pairs, func(i, j int) bool {
if pairs[i].freq == pairs[j].freq {
return pairs[i].name < pairs[j].name
}
return pairs[i].freq > pairs[j].freq
})
reacjis := []string{}
for _, p := range pairs {
reacjis = append(reacjis, p.name)
}
if len(reacjis) < len(DefaultTopReacjis) {
reacjis = append(reacjis, DefaultTopReacjis[:len(DefaultTopReacjis)-len(reacjis)]...)
}
return keybase1.UserReacjis{
TopReacjis: reacjis,
SkinTone: cache.SkinTone,
}
} | go | func (s *ReacjiStore) UserReacjis(ctx context.Context, uid gregor1.UID) keybase1.UserReacjis {
s.Lock()
defer s.Unlock()
cache := s.populateCacheLocked(ctx, uid)
pairs := []reacjiPair{}
for name, freq := range cache.FrequencyMap {
pairs = append(pairs, reacjiPair{name: name, freq: freq})
}
// sort by frequency and then alphabetically
sort.Slice(pairs, func(i, j int) bool {
if pairs[i].freq == pairs[j].freq {
return pairs[i].name < pairs[j].name
}
return pairs[i].freq > pairs[j].freq
})
reacjis := []string{}
for _, p := range pairs {
reacjis = append(reacjis, p.name)
}
if len(reacjis) < len(DefaultTopReacjis) {
reacjis = append(reacjis, DefaultTopReacjis[:len(DefaultTopReacjis)-len(reacjis)]...)
}
return keybase1.UserReacjis{
TopReacjis: reacjis,
SkinTone: cache.SkinTone,
}
} | [
"func",
"(",
"s",
"*",
"ReacjiStore",
")",
"UserReacjis",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"gregor1",
".",
"UID",
")",
"keybase1",
".",
"UserReacjis",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"cache",
":=",
"s",
".",
"populateCacheLocked",
"(",
"ctx",
",",
"uid",
")",
"\n",
"pairs",
":=",
"[",
"]",
"reacjiPair",
"{",
"}",
"\n",
"for",
"name",
",",
"freq",
":=",
"range",
"cache",
".",
"FrequencyMap",
"{",
"pairs",
"=",
"append",
"(",
"pairs",
",",
"reacjiPair",
"{",
"name",
":",
"name",
",",
"freq",
":",
"freq",
"}",
")",
"\n",
"}",
"\n",
"// sort by frequency and then alphabetically",
"sort",
".",
"Slice",
"(",
"pairs",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"if",
"pairs",
"[",
"i",
"]",
".",
"freq",
"==",
"pairs",
"[",
"j",
"]",
".",
"freq",
"{",
"return",
"pairs",
"[",
"i",
"]",
".",
"name",
"<",
"pairs",
"[",
"j",
"]",
".",
"name",
"\n",
"}",
"\n",
"return",
"pairs",
"[",
"i",
"]",
".",
"freq",
">",
"pairs",
"[",
"j",
"]",
".",
"freq",
"\n",
"}",
")",
"\n\n",
"reacjis",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"pairs",
"{",
"reacjis",
"=",
"append",
"(",
"reacjis",
",",
"p",
".",
"name",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"reacjis",
")",
"<",
"len",
"(",
"DefaultTopReacjis",
")",
"{",
"reacjis",
"=",
"append",
"(",
"reacjis",
",",
"DefaultTopReacjis",
"[",
":",
"len",
"(",
"DefaultTopReacjis",
")",
"-",
"len",
"(",
"reacjis",
")",
"]",
"...",
")",
"\n",
"}",
"\n",
"return",
"keybase1",
".",
"UserReacjis",
"{",
"TopReacjis",
":",
"reacjis",
",",
"SkinTone",
":",
"cache",
".",
"SkinTone",
",",
"}",
"\n",
"}"
] | // UserReacjis returns the user's most frequently used reacjis falling back to
// `DefaultTopReacjis` if there is not enough history. Results are ordered by
// frequency and then alphabetically. | [
"UserReacjis",
"returns",
"the",
"user",
"s",
"most",
"frequently",
"used",
"reacjis",
"falling",
"back",
"to",
"DefaultTopReacjis",
"if",
"there",
"is",
"not",
"enough",
"history",
".",
"Results",
"are",
"ordered",
"by",
"frequency",
"and",
"then",
"alphabetically",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/reacjis.go#L198-L226 |
160,456 | keybase/client | go/kbfs/libfuse/symlink.go | Attr | func (s *Symlink) Attr(ctx context.Context, a *fuse.Attr) (err error) {
s.parent.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Symlink Attr")
defer func() { err = s.parent.folder.processError(ctx, libkbfs.ReadMode, err) }()
_, de, err := s.parent.folder.fs.config.KBFSOps().Lookup(ctx, s.parent.node, s.name)
if err != nil {
if _, ok := err.(idutil.NoSuchNameError); ok {
return fuse.ESTALE
}
return err
}
s.parent.folder.fillAttrWithUIDAndWritePerm(ctx, s.parent.node, &de, a)
a.Mode = os.ModeSymlink | a.Mode | 0500
a.Inode = s.inode
return nil
} | go | func (s *Symlink) Attr(ctx context.Context, a *fuse.Attr) (err error) {
s.parent.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Symlink Attr")
defer func() { err = s.parent.folder.processError(ctx, libkbfs.ReadMode, err) }()
_, de, err := s.parent.folder.fs.config.KBFSOps().Lookup(ctx, s.parent.node, s.name)
if err != nil {
if _, ok := err.(idutil.NoSuchNameError); ok {
return fuse.ESTALE
}
return err
}
s.parent.folder.fillAttrWithUIDAndWritePerm(ctx, s.parent.node, &de, a)
a.Mode = os.ModeSymlink | a.Mode | 0500
a.Inode = s.inode
return nil
} | [
"func",
"(",
"s",
"*",
"Symlink",
")",
"Attr",
"(",
"ctx",
"context",
".",
"Context",
",",
"a",
"*",
"fuse",
".",
"Attr",
")",
"(",
"err",
"error",
")",
"{",
"s",
".",
"parent",
".",
"folder",
".",
"fs",
".",
"vlog",
".",
"CLogf",
"(",
"ctx",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"s",
".",
"parent",
".",
"folder",
".",
"processError",
"(",
"ctx",
",",
"libkbfs",
".",
"ReadMode",
",",
"err",
")",
"}",
"(",
")",
"\n\n",
"_",
",",
"de",
",",
"err",
":=",
"s",
".",
"parent",
".",
"folder",
".",
"fs",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"Lookup",
"(",
"ctx",
",",
"s",
".",
"parent",
".",
"node",
",",
"s",
".",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"idutil",
".",
"NoSuchNameError",
")",
";",
"ok",
"{",
"return",
"fuse",
".",
"ESTALE",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"s",
".",
"parent",
".",
"folder",
".",
"fillAttrWithUIDAndWritePerm",
"(",
"ctx",
",",
"s",
".",
"parent",
".",
"node",
",",
"&",
"de",
",",
"a",
")",
"\n",
"a",
".",
"Mode",
"=",
"os",
".",
"ModeSymlink",
"|",
"a",
".",
"Mode",
"|",
"0500",
"\n",
"a",
".",
"Inode",
"=",
"s",
".",
"inode",
"\n",
"return",
"nil",
"\n",
"}"
] | // Attr implements the fs.Node interface for Symlink | [
"Attr",
"implements",
"the",
"fs",
".",
"Node",
"interface",
"for",
"Symlink"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/symlink.go#L38-L54 |
160,457 | keybase/client | go/kbfs/libfuse/symlink.go | Readlink | func (s *Symlink) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (link string, err error) {
s.parent.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Symlink Readlink")
defer func() { err = s.parent.folder.processError(ctx, libkbfs.ReadMode, err) }()
_, de, err := s.parent.folder.fs.config.KBFSOps().Lookup(ctx, s.parent.node, s.name)
if err != nil {
return "", err
}
if de.Type != data.Sym {
return "", fuse.Errno(syscall.EINVAL)
}
return de.SymPath, nil
} | go | func (s *Symlink) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (link string, err error) {
s.parent.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Symlink Readlink")
defer func() { err = s.parent.folder.processError(ctx, libkbfs.ReadMode, err) }()
_, de, err := s.parent.folder.fs.config.KBFSOps().Lookup(ctx, s.parent.node, s.name)
if err != nil {
return "", err
}
if de.Type != data.Sym {
return "", fuse.Errno(syscall.EINVAL)
}
return de.SymPath, nil
} | [
"func",
"(",
"s",
"*",
"Symlink",
")",
"Readlink",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"ReadlinkRequest",
")",
"(",
"link",
"string",
",",
"err",
"error",
")",
"{",
"s",
".",
"parent",
".",
"folder",
".",
"fs",
".",
"vlog",
".",
"CLogf",
"(",
"ctx",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"s",
".",
"parent",
".",
"folder",
".",
"processError",
"(",
"ctx",
",",
"libkbfs",
".",
"ReadMode",
",",
"err",
")",
"}",
"(",
")",
"\n\n",
"_",
",",
"de",
",",
"err",
":=",
"s",
".",
"parent",
".",
"folder",
".",
"fs",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"Lookup",
"(",
"ctx",
",",
"s",
".",
"parent",
".",
"node",
",",
"s",
".",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"de",
".",
"Type",
"!=",
"data",
".",
"Sym",
"{",
"return",
"\"",
"\"",
",",
"fuse",
".",
"Errno",
"(",
"syscall",
".",
"EINVAL",
")",
"\n",
"}",
"\n",
"return",
"de",
".",
"SymPath",
",",
"nil",
"\n",
"}"
] | // Readlink implements the fs.NodeReadlinker interface for Symlink | [
"Readlink",
"implements",
"the",
"fs",
".",
"NodeReadlinker",
"interface",
"for",
"Symlink"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/symlink.go#L59-L72 |
160,458 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | DeserializeTLFWriterKeyBundleV3 | func DeserializeTLFWriterKeyBundleV3(codec kbfscodec.Codec, path string) (
TLFWriterKeyBundleV3, error) {
var wkb TLFWriterKeyBundleV3
err := kbfscodec.DeserializeFromFile(codec, path, &wkb)
if err != nil {
return TLFWriterKeyBundleV3{}, err
}
if len(wkb.Keys) == 0 {
return TLFWriterKeyBundleV3{}, errors.New(
"Writer key bundle with no keys (DeserializeTLFWriterKeyBundleV3)")
}
return wkb, nil
} | go | func DeserializeTLFWriterKeyBundleV3(codec kbfscodec.Codec, path string) (
TLFWriterKeyBundleV3, error) {
var wkb TLFWriterKeyBundleV3
err := kbfscodec.DeserializeFromFile(codec, path, &wkb)
if err != nil {
return TLFWriterKeyBundleV3{}, err
}
if len(wkb.Keys) == 0 {
return TLFWriterKeyBundleV3{}, errors.New(
"Writer key bundle with no keys (DeserializeTLFWriterKeyBundleV3)")
}
return wkb, nil
} | [
"func",
"DeserializeTLFWriterKeyBundleV3",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"path",
"string",
")",
"(",
"TLFWriterKeyBundleV3",
",",
"error",
")",
"{",
"var",
"wkb",
"TLFWriterKeyBundleV3",
"\n",
"err",
":=",
"kbfscodec",
".",
"DeserializeFromFile",
"(",
"codec",
",",
"path",
",",
"&",
"wkb",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFWriterKeyBundleV3",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"wkb",
".",
"Keys",
")",
"==",
"0",
"{",
"return",
"TLFWriterKeyBundleV3",
"{",
"}",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"wkb",
",",
"nil",
"\n",
"}"
] | // DeserializeTLFWriterKeyBundleV3 deserializes a TLFWriterKeyBundleV3
// from the given path and returns it. | [
"DeserializeTLFWriterKeyBundleV3",
"deserializes",
"a",
"TLFWriterKeyBundleV3",
"from",
"the",
"given",
"path",
"and",
"returns",
"it",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L254-L266 |
160,459 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | IsWriter | func (wkb TLFWriterKeyBundleV3) IsWriter(user keybase1.UID, deviceKey kbfscrypto.CryptPublicKey) bool {
_, ok := wkb.Keys[user][deviceKey]
return ok
} | go | func (wkb TLFWriterKeyBundleV3) IsWriter(user keybase1.UID, deviceKey kbfscrypto.CryptPublicKey) bool {
_, ok := wkb.Keys[user][deviceKey]
return ok
} | [
"func",
"(",
"wkb",
"TLFWriterKeyBundleV3",
")",
"IsWriter",
"(",
"user",
"keybase1",
".",
"UID",
",",
"deviceKey",
"kbfscrypto",
".",
"CryptPublicKey",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"wkb",
".",
"Keys",
"[",
"user",
"]",
"[",
"deviceKey",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsWriter returns true if the given user device is in the device set. | [
"IsWriter",
"returns",
"true",
"if",
"the",
"given",
"user",
"device",
"is",
"in",
"the",
"device",
"set",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L292-L295 |
160,460 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | TLFWriterKeyBundleIDFromBytes | func TLFWriterKeyBundleIDFromBytes(data []byte) (TLFWriterKeyBundleID, error) {
h, err := kbfshash.HashFromBytes(data)
if err != nil {
return TLFWriterKeyBundleID{}, err
}
return TLFWriterKeyBundleID{h}, nil
} | go | func TLFWriterKeyBundleIDFromBytes(data []byte) (TLFWriterKeyBundleID, error) {
h, err := kbfshash.HashFromBytes(data)
if err != nil {
return TLFWriterKeyBundleID{}, err
}
return TLFWriterKeyBundleID{h}, nil
} | [
"func",
"TLFWriterKeyBundleIDFromBytes",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"TLFWriterKeyBundleID",
",",
"error",
")",
"{",
"h",
",",
"err",
":=",
"kbfshash",
".",
"HashFromBytes",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFWriterKeyBundleID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"TLFWriterKeyBundleID",
"{",
"h",
"}",
",",
"nil",
"\n",
"}"
] | // TLFWriterKeyBundleIDFromBytes creates a new TLFWriterKeyBundleID from the given bytes.
// If the returned error is nil, the returned TLFWriterKeyBundleID is valid. | [
"TLFWriterKeyBundleIDFromBytes",
"creates",
"a",
"new",
"TLFWriterKeyBundleID",
"from",
"the",
"given",
"bytes",
".",
"If",
"the",
"returned",
"error",
"is",
"nil",
"the",
"returned",
"TLFWriterKeyBundleID",
"is",
"valid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L321-L327 |
160,461 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | TLFWriterKeyBundleIDFromString | func TLFWriterKeyBundleIDFromString(id string) (TLFWriterKeyBundleID, error) {
if len(id) == 0 {
return TLFWriterKeyBundleID{}, nil
}
h, err := kbfshash.HashFromString(id)
if err != nil {
return TLFWriterKeyBundleID{}, err
}
return TLFWriterKeyBundleID{h}, nil
} | go | func TLFWriterKeyBundleIDFromString(id string) (TLFWriterKeyBundleID, error) {
if len(id) == 0 {
return TLFWriterKeyBundleID{}, nil
}
h, err := kbfshash.HashFromString(id)
if err != nil {
return TLFWriterKeyBundleID{}, err
}
return TLFWriterKeyBundleID{h}, nil
} | [
"func",
"TLFWriterKeyBundleIDFromString",
"(",
"id",
"string",
")",
"(",
"TLFWriterKeyBundleID",
",",
"error",
")",
"{",
"if",
"len",
"(",
"id",
")",
"==",
"0",
"{",
"return",
"TLFWriterKeyBundleID",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"h",
",",
"err",
":=",
"kbfshash",
".",
"HashFromString",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFWriterKeyBundleID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"TLFWriterKeyBundleID",
"{",
"h",
"}",
",",
"nil",
"\n",
"}"
] | // TLFWriterKeyBundleIDFromString creates a new TLFWriterKeyBundleID from the given string.
// If the returned error is nil, the returned TLFWriterKeyBundleID is valid. | [
"TLFWriterKeyBundleIDFromString",
"creates",
"a",
"new",
"TLFWriterKeyBundleID",
"from",
"the",
"given",
"string",
".",
"If",
"the",
"returned",
"error",
"is",
"nil",
"the",
"returned",
"TLFWriterKeyBundleID",
"is",
"valid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L331-L340 |
160,462 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | MarshalBinary | func (h TLFWriterKeyBundleID) MarshalBinary() (data []byte, err error) {
return h.h.MarshalBinary()
} | go | func (h TLFWriterKeyBundleID) MarshalBinary() (data []byte, err error) {
return h.h.MarshalBinary()
} | [
"func",
"(",
"h",
"TLFWriterKeyBundleID",
")",
"MarshalBinary",
"(",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"h",
".",
"h",
".",
"MarshalBinary",
"(",
")",
"\n",
"}"
] | // MarshalBinary implements the encoding.BinaryMarshaler interface for
// TLFWriterKeyBundleID. Returns an error if the TLFWriterKeyBundleID is invalid and not the
// zero TLFWriterKeyBundleID. | [
"MarshalBinary",
"implements",
"the",
"encoding",
".",
"BinaryMarshaler",
"interface",
"for",
"TLFWriterKeyBundleID",
".",
"Returns",
"an",
"error",
"if",
"the",
"TLFWriterKeyBundleID",
"is",
"invalid",
"and",
"not",
"the",
"zero",
"TLFWriterKeyBundleID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L362-L364 |
160,463 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | UnmarshalBinary | func (h *TLFWriterKeyBundleID) UnmarshalBinary(data []byte) error {
return h.h.UnmarshalBinary(data)
} | go | func (h *TLFWriterKeyBundleID) UnmarshalBinary(data []byte) error {
return h.h.UnmarshalBinary(data)
} | [
"func",
"(",
"h",
"*",
"TLFWriterKeyBundleID",
")",
"UnmarshalBinary",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"h",
".",
"h",
".",
"UnmarshalBinary",
"(",
"data",
")",
"\n",
"}"
] | // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
// for TLFWriterKeyBundleID. Returns an error if the given byte array is non-empty and
// the TLFWriterKeyBundleID is invalid. | [
"UnmarshalBinary",
"implements",
"the",
"encoding",
".",
"BinaryUnmarshaler",
"interface",
"for",
"TLFWriterKeyBundleID",
".",
"Returns",
"an",
"error",
"if",
"the",
"given",
"byte",
"array",
"is",
"non",
"-",
"empty",
"and",
"the",
"TLFWriterKeyBundleID",
"is",
"invalid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L369-L371 |
160,464 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | MakeTLFWriterKeyBundleID | func MakeTLFWriterKeyBundleID(codec kbfscodec.Codec, wkb TLFWriterKeyBundleV3) (
TLFWriterKeyBundleID, error) {
if len(wkb.Keys) == 0 {
return TLFWriterKeyBundleID{}, errors.New(
"Writer key bundle with no keys (MakeTLFWriterKeyBundleID)")
}
buf, err := codec.Encode(wkb)
if err != nil {
return TLFWriterKeyBundleID{}, err
}
h, err := kbfshash.DefaultHash(buf)
if err != nil {
return TLFWriterKeyBundleID{}, err
}
return TLFWriterKeyBundleID{h}, nil
} | go | func MakeTLFWriterKeyBundleID(codec kbfscodec.Codec, wkb TLFWriterKeyBundleV3) (
TLFWriterKeyBundleID, error) {
if len(wkb.Keys) == 0 {
return TLFWriterKeyBundleID{}, errors.New(
"Writer key bundle with no keys (MakeTLFWriterKeyBundleID)")
}
buf, err := codec.Encode(wkb)
if err != nil {
return TLFWriterKeyBundleID{}, err
}
h, err := kbfshash.DefaultHash(buf)
if err != nil {
return TLFWriterKeyBundleID{}, err
}
return TLFWriterKeyBundleID{h}, nil
} | [
"func",
"MakeTLFWriterKeyBundleID",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"wkb",
"TLFWriterKeyBundleV3",
")",
"(",
"TLFWriterKeyBundleID",
",",
"error",
")",
"{",
"if",
"len",
"(",
"wkb",
".",
"Keys",
")",
"==",
"0",
"{",
"return",
"TLFWriterKeyBundleID",
"{",
"}",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"buf",
",",
"err",
":=",
"codec",
".",
"Encode",
"(",
"wkb",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFWriterKeyBundleID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"h",
",",
"err",
":=",
"kbfshash",
".",
"DefaultHash",
"(",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFWriterKeyBundleID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"TLFWriterKeyBundleID",
"{",
"h",
"}",
",",
"nil",
"\n",
"}"
] | // MakeTLFWriterKeyBundleID hashes a TLFWriterKeyBundleV3 to create an ID. | [
"MakeTLFWriterKeyBundleID",
"hashes",
"a",
"TLFWriterKeyBundleV3",
"to",
"create",
"an",
"ID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L379-L394 |
160,465 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | DeserializeTLFReaderKeyBundleV3 | func DeserializeTLFReaderKeyBundleV3(codec kbfscodec.Codec, path string) (
TLFReaderKeyBundleV3, error) {
var rkb TLFReaderKeyBundleV3
err := kbfscodec.DeserializeFromFile(codec, path, &rkb)
if err != nil {
return TLFReaderKeyBundleV3{}, err
}
if len(rkb.Keys) == 0 {
rkb.Keys = make(UserDeviceKeyInfoMapV3)
}
return rkb, nil
} | go | func DeserializeTLFReaderKeyBundleV3(codec kbfscodec.Codec, path string) (
TLFReaderKeyBundleV3, error) {
var rkb TLFReaderKeyBundleV3
err := kbfscodec.DeserializeFromFile(codec, path, &rkb)
if err != nil {
return TLFReaderKeyBundleV3{}, err
}
if len(rkb.Keys) == 0 {
rkb.Keys = make(UserDeviceKeyInfoMapV3)
}
return rkb, nil
} | [
"func",
"DeserializeTLFReaderKeyBundleV3",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"path",
"string",
")",
"(",
"TLFReaderKeyBundleV3",
",",
"error",
")",
"{",
"var",
"rkb",
"TLFReaderKeyBundleV3",
"\n",
"err",
":=",
"kbfscodec",
".",
"DeserializeFromFile",
"(",
"codec",
",",
"path",
",",
"&",
"rkb",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFReaderKeyBundleV3",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"rkb",
".",
"Keys",
")",
"==",
"0",
"{",
"rkb",
".",
"Keys",
"=",
"make",
"(",
"UserDeviceKeyInfoMapV3",
")",
"\n",
"}",
"\n",
"return",
"rkb",
",",
"nil",
"\n",
"}"
] | // DeserializeTLFReaderKeyBundleV3 deserializes a TLFReaderKeyBundleV3
// from the given path and returns it. | [
"DeserializeTLFReaderKeyBundleV3",
"deserializes",
"a",
"TLFReaderKeyBundleV3",
"from",
"the",
"given",
"path",
"and",
"returns",
"it",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L415-L426 |
160,466 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | TLFReaderKeyBundleIDFromBytes | func TLFReaderKeyBundleIDFromBytes(data []byte) (TLFReaderKeyBundleID, error) {
h, err := kbfshash.HashFromBytes(data)
if err != nil {
return TLFReaderKeyBundleID{}, err
}
return TLFReaderKeyBundleID{h}, nil
} | go | func TLFReaderKeyBundleIDFromBytes(data []byte) (TLFReaderKeyBundleID, error) {
h, err := kbfshash.HashFromBytes(data)
if err != nil {
return TLFReaderKeyBundleID{}, err
}
return TLFReaderKeyBundleID{h}, nil
} | [
"func",
"TLFReaderKeyBundleIDFromBytes",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"TLFReaderKeyBundleID",
",",
"error",
")",
"{",
"h",
",",
"err",
":=",
"kbfshash",
".",
"HashFromBytes",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFReaderKeyBundleID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"TLFReaderKeyBundleID",
"{",
"h",
"}",
",",
"nil",
"\n",
"}"
] | // TLFReaderKeyBundleIDFromBytes creates a new TLFReaderKeyBundleID from the given bytes.
// If the returned error is nil, the returned TLFReaderKeyBundleID is valid. | [
"TLFReaderKeyBundleIDFromBytes",
"creates",
"a",
"new",
"TLFReaderKeyBundleID",
"from",
"the",
"given",
"bytes",
".",
"If",
"the",
"returned",
"error",
"is",
"nil",
"the",
"returned",
"TLFReaderKeyBundleID",
"is",
"valid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L474-L480 |
160,467 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | TLFReaderKeyBundleIDFromString | func TLFReaderKeyBundleIDFromString(id string) (TLFReaderKeyBundleID, error) {
if len(id) == 0 {
return TLFReaderKeyBundleID{}, nil
}
h, err := kbfshash.HashFromString(id)
if err != nil {
return TLFReaderKeyBundleID{}, err
}
return TLFReaderKeyBundleID{h}, nil
} | go | func TLFReaderKeyBundleIDFromString(id string) (TLFReaderKeyBundleID, error) {
if len(id) == 0 {
return TLFReaderKeyBundleID{}, nil
}
h, err := kbfshash.HashFromString(id)
if err != nil {
return TLFReaderKeyBundleID{}, err
}
return TLFReaderKeyBundleID{h}, nil
} | [
"func",
"TLFReaderKeyBundleIDFromString",
"(",
"id",
"string",
")",
"(",
"TLFReaderKeyBundleID",
",",
"error",
")",
"{",
"if",
"len",
"(",
"id",
")",
"==",
"0",
"{",
"return",
"TLFReaderKeyBundleID",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"h",
",",
"err",
":=",
"kbfshash",
".",
"HashFromString",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFReaderKeyBundleID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"TLFReaderKeyBundleID",
"{",
"h",
"}",
",",
"nil",
"\n",
"}"
] | // TLFReaderKeyBundleIDFromString creates a new TLFReaderKeyBundleID from the given string.
// If the returned error is nil, the returned TLFReaderKeyBundleID is valid. | [
"TLFReaderKeyBundleIDFromString",
"creates",
"a",
"new",
"TLFReaderKeyBundleID",
"from",
"the",
"given",
"string",
".",
"If",
"the",
"returned",
"error",
"is",
"nil",
"the",
"returned",
"TLFReaderKeyBundleID",
"is",
"valid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L484-L493 |
160,468 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | MarshalBinary | func (h TLFReaderKeyBundleID) MarshalBinary() (data []byte, err error) {
return h.h.MarshalBinary()
} | go | func (h TLFReaderKeyBundleID) MarshalBinary() (data []byte, err error) {
return h.h.MarshalBinary()
} | [
"func",
"(",
"h",
"TLFReaderKeyBundleID",
")",
"MarshalBinary",
"(",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"h",
".",
"h",
".",
"MarshalBinary",
"(",
")",
"\n",
"}"
] | // MarshalBinary implements the encoding.BinaryMarshaler interface for
// TLFReaderKeyBundleID. Returns an error if the TLFReaderKeyBundleID is invalid and not the
// zero TLFReaderKeyBundleID. | [
"MarshalBinary",
"implements",
"the",
"encoding",
".",
"BinaryMarshaler",
"interface",
"for",
"TLFReaderKeyBundleID",
".",
"Returns",
"an",
"error",
"if",
"the",
"TLFReaderKeyBundleID",
"is",
"invalid",
"and",
"not",
"the",
"zero",
"TLFReaderKeyBundleID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L508-L510 |
160,469 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | UnmarshalBinary | func (h *TLFReaderKeyBundleID) UnmarshalBinary(data []byte) error {
return h.h.UnmarshalBinary(data)
} | go | func (h *TLFReaderKeyBundleID) UnmarshalBinary(data []byte) error {
return h.h.UnmarshalBinary(data)
} | [
"func",
"(",
"h",
"*",
"TLFReaderKeyBundleID",
")",
"UnmarshalBinary",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"h",
".",
"h",
".",
"UnmarshalBinary",
"(",
"data",
")",
"\n",
"}"
] | // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
// for TLFReaderKeyBundleID. Returns an error if the given byte array is non-empty and
// the TLFReaderKeyBundleID is invalid. | [
"UnmarshalBinary",
"implements",
"the",
"encoding",
".",
"BinaryUnmarshaler",
"interface",
"for",
"TLFReaderKeyBundleID",
".",
"Returns",
"an",
"error",
"if",
"the",
"given",
"byte",
"array",
"is",
"non",
"-",
"empty",
"and",
"the",
"TLFReaderKeyBundleID",
"is",
"invalid",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L515-L517 |
160,470 | keybase/client | go/kbfs/kbfsmd/key_bundle_v3.go | MakeTLFReaderKeyBundleID | func MakeTLFReaderKeyBundleID(codec kbfscodec.Codec, rkb TLFReaderKeyBundleV3) (
TLFReaderKeyBundleID, error) {
buf, err := codec.Encode(rkb)
if err != nil {
return TLFReaderKeyBundleID{}, err
}
h, err := kbfshash.DefaultHash(buf)
if err != nil {
return TLFReaderKeyBundleID{}, err
}
return TLFReaderKeyBundleID{h}, nil
} | go | func MakeTLFReaderKeyBundleID(codec kbfscodec.Codec, rkb TLFReaderKeyBundleV3) (
TLFReaderKeyBundleID, error) {
buf, err := codec.Encode(rkb)
if err != nil {
return TLFReaderKeyBundleID{}, err
}
h, err := kbfshash.DefaultHash(buf)
if err != nil {
return TLFReaderKeyBundleID{}, err
}
return TLFReaderKeyBundleID{h}, nil
} | [
"func",
"MakeTLFReaderKeyBundleID",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"rkb",
"TLFReaderKeyBundleV3",
")",
"(",
"TLFReaderKeyBundleID",
",",
"error",
")",
"{",
"buf",
",",
"err",
":=",
"codec",
".",
"Encode",
"(",
"rkb",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFReaderKeyBundleID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"h",
",",
"err",
":=",
"kbfshash",
".",
"DefaultHash",
"(",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"TLFReaderKeyBundleID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"TLFReaderKeyBundleID",
"{",
"h",
"}",
",",
"nil",
"\n",
"}"
] | // MakeTLFReaderKeyBundleID hashes a TLFReaderKeyBundleV3 to create an ID. | [
"MakeTLFReaderKeyBundleID",
"hashes",
"a",
"TLFReaderKeyBundleV3",
"to",
"create",
"an",
"ID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle_v3.go#L525-L536 |
160,471 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | NewMDServerMemory | func NewMDServerMemory(config mdServerLocalConfig) (*MDServerMemory, error) {
handleDb := make(map[mdHandleKey]tlf.ID)
latestHandleDb := make(map[tlf.ID]tlf.Handle)
mdDb := make(map[mdBlockKey]mdBlockMemList)
branchDb := make(map[mdBranchKey]kbfsmd.BranchID)
writerKeyBundleDb := make(map[mdExtraWriterKey]kbfsmd.TLFWriterKeyBundleV3)
readerKeyBundleDb := make(map[mdExtraReaderKey]kbfsmd.TLFReaderKeyBundleV3)
log := config.MakeLogger("MDSM")
truncateLockManager := newMDServerLocalTruncatedLockManager()
shared := mdServerMemShared{
handleDb: handleDb,
latestHandleDb: latestHandleDb,
mdDb: mdDb,
branchDb: branchDb,
writerKeyBundleDb: writerKeyBundleDb,
readerKeyBundleDb: readerKeyBundleDb,
truncateLockManager: &truncateLockManager,
lockIDs: make(map[mdLockMemKey]mdLockMemVal),
iTeamMigrationLocks: make(map[tlf.ID]bool),
updateManager: newMDServerLocalUpdateManager(),
merkleRoots: make(map[keybase1.MerkleTreeID]*kbfsmd.MerkleRoot),
}
mdserv := &MDServerMemory{config, log, &shared}
return mdserv, nil
} | go | func NewMDServerMemory(config mdServerLocalConfig) (*MDServerMemory, error) {
handleDb := make(map[mdHandleKey]tlf.ID)
latestHandleDb := make(map[tlf.ID]tlf.Handle)
mdDb := make(map[mdBlockKey]mdBlockMemList)
branchDb := make(map[mdBranchKey]kbfsmd.BranchID)
writerKeyBundleDb := make(map[mdExtraWriterKey]kbfsmd.TLFWriterKeyBundleV3)
readerKeyBundleDb := make(map[mdExtraReaderKey]kbfsmd.TLFReaderKeyBundleV3)
log := config.MakeLogger("MDSM")
truncateLockManager := newMDServerLocalTruncatedLockManager()
shared := mdServerMemShared{
handleDb: handleDb,
latestHandleDb: latestHandleDb,
mdDb: mdDb,
branchDb: branchDb,
writerKeyBundleDb: writerKeyBundleDb,
readerKeyBundleDb: readerKeyBundleDb,
truncateLockManager: &truncateLockManager,
lockIDs: make(map[mdLockMemKey]mdLockMemVal),
iTeamMigrationLocks: make(map[tlf.ID]bool),
updateManager: newMDServerLocalUpdateManager(),
merkleRoots: make(map[keybase1.MerkleTreeID]*kbfsmd.MerkleRoot),
}
mdserv := &MDServerMemory{config, log, &shared}
return mdserv, nil
} | [
"func",
"NewMDServerMemory",
"(",
"config",
"mdServerLocalConfig",
")",
"(",
"*",
"MDServerMemory",
",",
"error",
")",
"{",
"handleDb",
":=",
"make",
"(",
"map",
"[",
"mdHandleKey",
"]",
"tlf",
".",
"ID",
")",
"\n",
"latestHandleDb",
":=",
"make",
"(",
"map",
"[",
"tlf",
".",
"ID",
"]",
"tlf",
".",
"Handle",
")",
"\n",
"mdDb",
":=",
"make",
"(",
"map",
"[",
"mdBlockKey",
"]",
"mdBlockMemList",
")",
"\n",
"branchDb",
":=",
"make",
"(",
"map",
"[",
"mdBranchKey",
"]",
"kbfsmd",
".",
"BranchID",
")",
"\n",
"writerKeyBundleDb",
":=",
"make",
"(",
"map",
"[",
"mdExtraWriterKey",
"]",
"kbfsmd",
".",
"TLFWriterKeyBundleV3",
")",
"\n",
"readerKeyBundleDb",
":=",
"make",
"(",
"map",
"[",
"mdExtraReaderKey",
"]",
"kbfsmd",
".",
"TLFReaderKeyBundleV3",
")",
"\n",
"log",
":=",
"config",
".",
"MakeLogger",
"(",
"\"",
"\"",
")",
"\n",
"truncateLockManager",
":=",
"newMDServerLocalTruncatedLockManager",
"(",
")",
"\n",
"shared",
":=",
"mdServerMemShared",
"{",
"handleDb",
":",
"handleDb",
",",
"latestHandleDb",
":",
"latestHandleDb",
",",
"mdDb",
":",
"mdDb",
",",
"branchDb",
":",
"branchDb",
",",
"writerKeyBundleDb",
":",
"writerKeyBundleDb",
",",
"readerKeyBundleDb",
":",
"readerKeyBundleDb",
",",
"truncateLockManager",
":",
"&",
"truncateLockManager",
",",
"lockIDs",
":",
"make",
"(",
"map",
"[",
"mdLockMemKey",
"]",
"mdLockMemVal",
")",
",",
"iTeamMigrationLocks",
":",
"make",
"(",
"map",
"[",
"tlf",
".",
"ID",
"]",
"bool",
")",
",",
"updateManager",
":",
"newMDServerLocalUpdateManager",
"(",
")",
",",
"merkleRoots",
":",
"make",
"(",
"map",
"[",
"keybase1",
".",
"MerkleTreeID",
"]",
"*",
"kbfsmd",
".",
"MerkleRoot",
")",
",",
"}",
"\n",
"mdserv",
":=",
"&",
"MDServerMemory",
"{",
"config",
",",
"log",
",",
"&",
"shared",
"}",
"\n",
"return",
"mdserv",
",",
"nil",
"\n",
"}"
] | // NewMDServerMemory constructs a new MDServerMemory object that stores
// all data in-memory. | [
"NewMDServerMemory",
"constructs",
"a",
"new",
"MDServerMemory",
"object",
"that",
"stores",
"all",
"data",
"in",
"-",
"memory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L109-L133 |
160,472 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | GetForHandle | func (md *MDServerMemory) GetForHandle(ctx context.Context, handle tlf.Handle,
mStatus kbfsmd.MergeStatus, _ *keybase1.LockID) (
tlf.ID, *RootMetadataSigned, error) {
if err := checkContext(ctx); err != nil {
return tlf.NullID, nil, err
}
id, created, err := md.getHandleID(ctx, handle, mStatus)
if err != nil {
return tlf.NullID, nil, err
}
if created {
return id, nil, nil
}
rmds, err := md.GetForTLF(ctx, id, kbfsmd.NullBranchID, mStatus, nil)
if err != nil {
return tlf.NullID, nil, err
}
return id, rmds, nil
} | go | func (md *MDServerMemory) GetForHandle(ctx context.Context, handle tlf.Handle,
mStatus kbfsmd.MergeStatus, _ *keybase1.LockID) (
tlf.ID, *RootMetadataSigned, error) {
if err := checkContext(ctx); err != nil {
return tlf.NullID, nil, err
}
id, created, err := md.getHandleID(ctx, handle, mStatus)
if err != nil {
return tlf.NullID, nil, err
}
if created {
return id, nil, nil
}
rmds, err := md.GetForTLF(ctx, id, kbfsmd.NullBranchID, mStatus, nil)
if err != nil {
return tlf.NullID, nil, err
}
return id, rmds, nil
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"GetForHandle",
"(",
"ctx",
"context",
".",
"Context",
",",
"handle",
"tlf",
".",
"Handle",
",",
"mStatus",
"kbfsmd",
".",
"MergeStatus",
",",
"_",
"*",
"keybase1",
".",
"LockID",
")",
"(",
"tlf",
".",
"ID",
",",
"*",
"RootMetadataSigned",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"tlf",
".",
"NullID",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"id",
",",
"created",
",",
"err",
":=",
"md",
".",
"getHandleID",
"(",
"ctx",
",",
"handle",
",",
"mStatus",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"tlf",
".",
"NullID",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"created",
"{",
"return",
"id",
",",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"rmds",
",",
"err",
":=",
"md",
".",
"GetForTLF",
"(",
"ctx",
",",
"id",
",",
"kbfsmd",
".",
"NullBranchID",
",",
"mStatus",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"tlf",
".",
"NullID",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"id",
",",
"rmds",
",",
"nil",
"\n",
"}"
] | // GetForHandle implements the MDServer interface for MDServerMemory. | [
"GetForHandle",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L217-L238 |
160,473 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | GetForTLF | func (md *MDServerMemory) GetForTLF(ctx context.Context, id tlf.ID,
bid kbfsmd.BranchID, mStatus kbfsmd.MergeStatus, _ *keybase1.LockID) (
*RootMetadataSigned, error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
md.lock.RLock()
defer md.lock.RUnlock()
bid, err := md.checkGetParamsRLocked(ctx, id, bid, mStatus)
if err != nil {
return nil, err
}
if mStatus == kbfsmd.Unmerged && bid == kbfsmd.NullBranchID {
return nil, nil
}
rmds, err := md.getHeadForTLFRLocked(ctx, id, bid, mStatus)
if err != nil {
return nil, kbfsmd.ServerError{Err: err}
}
return rmds, nil
} | go | func (md *MDServerMemory) GetForTLF(ctx context.Context, id tlf.ID,
bid kbfsmd.BranchID, mStatus kbfsmd.MergeStatus, _ *keybase1.LockID) (
*RootMetadataSigned, error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
md.lock.RLock()
defer md.lock.RUnlock()
bid, err := md.checkGetParamsRLocked(ctx, id, bid, mStatus)
if err != nil {
return nil, err
}
if mStatus == kbfsmd.Unmerged && bid == kbfsmd.NullBranchID {
return nil, nil
}
rmds, err := md.getHeadForTLFRLocked(ctx, id, bid, mStatus)
if err != nil {
return nil, kbfsmd.ServerError{Err: err}
}
return rmds, nil
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"GetForTLF",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
",",
"bid",
"kbfsmd",
".",
"BranchID",
",",
"mStatus",
"kbfsmd",
".",
"MergeStatus",
",",
"_",
"*",
"keybase1",
".",
"LockID",
")",
"(",
"*",
"RootMetadataSigned",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"md",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"md",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"bid",
",",
"err",
":=",
"md",
".",
"checkGetParamsRLocked",
"(",
"ctx",
",",
"id",
",",
"bid",
",",
"mStatus",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"mStatus",
"==",
"kbfsmd",
".",
"Unmerged",
"&&",
"bid",
"==",
"kbfsmd",
".",
"NullBranchID",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"rmds",
",",
"err",
":=",
"md",
".",
"getHeadForTLFRLocked",
"(",
"ctx",
",",
"id",
",",
"bid",
",",
"mStatus",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"kbfsmd",
".",
"ServerError",
"{",
"Err",
":",
"err",
"}",
"\n",
"}",
"\n",
"return",
"rmds",
",",
"nil",
"\n",
"}"
] | // GetForTLF implements the MDServer interface for MDServerMemory. | [
"GetForTLF",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L287-L310 |
160,474 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | GetForTLFByTime | func (md *MDServerMemory) GetForTLFByTime(
ctx context.Context, id tlf.ID, serverTime time.Time) (
*RootMetadataSigned, error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
md.lock.RLock()
defer md.lock.RUnlock()
key, err := md.getMDKey(id, kbfsmd.NullBranchID, kbfsmd.Merged)
if err != nil {
return nil, err
}
err = md.checkShutdownRLocked()
if err != nil {
return nil, err
}
blockList, ok := md.mdDb[key]
if !ok {
return nil, nil
}
blocks := blockList.blocks
// Iterate backward until we find a timestamp less than `serverTime`.
for i := len(blocks) - 1; i >= 0; i-- {
t := blocks[i].timestamp
if t.After(serverTime) {
continue
}
max := md.config.MetadataVersion()
ver := blocks[i].version
buf := blocks[i].encodedMd
rmds, err := DecodeRootMetadataSigned(
md.config.Codec(), id, ver, max, buf, t)
if err != nil {
return nil, err
}
return rmds, nil
}
return nil, errors.Errorf(
"No MD found for TLF %s and serverTime %s", id, serverTime)
} | go | func (md *MDServerMemory) GetForTLFByTime(
ctx context.Context, id tlf.ID, serverTime time.Time) (
*RootMetadataSigned, error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
md.lock.RLock()
defer md.lock.RUnlock()
key, err := md.getMDKey(id, kbfsmd.NullBranchID, kbfsmd.Merged)
if err != nil {
return nil, err
}
err = md.checkShutdownRLocked()
if err != nil {
return nil, err
}
blockList, ok := md.mdDb[key]
if !ok {
return nil, nil
}
blocks := blockList.blocks
// Iterate backward until we find a timestamp less than `serverTime`.
for i := len(blocks) - 1; i >= 0; i-- {
t := blocks[i].timestamp
if t.After(serverTime) {
continue
}
max := md.config.MetadataVersion()
ver := blocks[i].version
buf := blocks[i].encodedMd
rmds, err := DecodeRootMetadataSigned(
md.config.Codec(), id, ver, max, buf, t)
if err != nil {
return nil, err
}
return rmds, nil
}
return nil, errors.Errorf(
"No MD found for TLF %s and serverTime %s", id, serverTime)
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"GetForTLFByTime",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
",",
"serverTime",
"time",
".",
"Time",
")",
"(",
"*",
"RootMetadataSigned",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"md",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"md",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"key",
",",
"err",
":=",
"md",
".",
"getMDKey",
"(",
"id",
",",
"kbfsmd",
".",
"NullBranchID",
",",
"kbfsmd",
".",
"Merged",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"err",
"=",
"md",
".",
"checkShutdownRLocked",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"blockList",
",",
"ok",
":=",
"md",
".",
"mdDb",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"blocks",
":=",
"blockList",
".",
"blocks",
"\n\n",
"// Iterate backward until we find a timestamp less than `serverTime`.",
"for",
"i",
":=",
"len",
"(",
"blocks",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"t",
":=",
"blocks",
"[",
"i",
"]",
".",
"timestamp",
"\n",
"if",
"t",
".",
"After",
"(",
"serverTime",
")",
"{",
"continue",
"\n",
"}",
"\n\n",
"max",
":=",
"md",
".",
"config",
".",
"MetadataVersion",
"(",
")",
"\n",
"ver",
":=",
"blocks",
"[",
"i",
"]",
".",
"version",
"\n",
"buf",
":=",
"blocks",
"[",
"i",
"]",
".",
"encodedMd",
"\n",
"rmds",
",",
"err",
":=",
"DecodeRootMetadataSigned",
"(",
"md",
".",
"config",
".",
"Codec",
"(",
")",
",",
"id",
",",
"ver",
",",
"max",
",",
"buf",
",",
"t",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"rmds",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"id",
",",
"serverTime",
")",
"\n",
"}"
] | // GetForTLFByTime implements the MDServer interface for MDServerMemory. | [
"GetForTLFByTime",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L313-L358 |
160,475 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | Lock | func (md *MDServerMemory) Lock(ctx context.Context,
tlfID tlf.ID, lockID keybase1.LockID) error {
// An RPC-based client would receive a throttle message from the
// server and retry with backoff, but here we need to implement
// the retry logic explicitly.
for {
ch := md.doLock(ctx, tlfID, lockID)
if ch == nil {
return nil
}
select {
// TODO: wait for the clock to pass the expired time. We'd
// need a new method in the `Clock` interface to support this.
case <-ch:
continue
case <-ctx.Done():
return ctx.Err()
}
}
} | go | func (md *MDServerMemory) Lock(ctx context.Context,
tlfID tlf.ID, lockID keybase1.LockID) error {
// An RPC-based client would receive a throttle message from the
// server and retry with backoff, but here we need to implement
// the retry logic explicitly.
for {
ch := md.doLock(ctx, tlfID, lockID)
if ch == nil {
return nil
}
select {
// TODO: wait for the clock to pass the expired time. We'd
// need a new method in the `Clock` interface to support this.
case <-ch:
continue
case <-ctx.Done():
return ctx.Err()
}
}
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"Lock",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"lockID",
"keybase1",
".",
"LockID",
")",
"error",
"{",
"// An RPC-based client would receive a throttle message from the",
"// server and retry with backoff, but here we need to implement",
"// the retry logic explicitly.",
"for",
"{",
"ch",
":=",
"md",
".",
"doLock",
"(",
"ctx",
",",
"tlfID",
",",
"lockID",
")",
"\n",
"if",
"ch",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"select",
"{",
"// TODO: wait for the clock to pass the expired time. We'd",
"// need a new method in the `Clock` interface to support this.",
"case",
"<-",
"ch",
":",
"continue",
"\n",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // Lock implements the MDServer interface for MDServerMemory. | [
"Lock",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L769-L788 |
160,476 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | ReleaseLock | func (md *MDServerMemory) ReleaseLock(ctx context.Context,
tlfID tlf.ID, lockID keybase1.LockID) error {
md.lock.Lock()
defer md.lock.Unlock()
md.releaseLockLocked(ctx, tlfID, lockID)
return nil
} | go | func (md *MDServerMemory) ReleaseLock(ctx context.Context,
tlfID tlf.ID, lockID keybase1.LockID) error {
md.lock.Lock()
defer md.lock.Unlock()
md.releaseLockLocked(ctx, tlfID, lockID)
return nil
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"ReleaseLock",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"lockID",
"keybase1",
".",
"LockID",
")",
"error",
"{",
"md",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"md",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"md",
".",
"releaseLockLocked",
"(",
"ctx",
",",
"tlfID",
",",
"lockID",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // ReleaseLock implements the MDServer interface for MDServerMemory. | [
"ReleaseLock",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L791-L797 |
160,477 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | PruneBranch | func (md *MDServerMemory) PruneBranch(ctx context.Context, id tlf.ID, bid kbfsmd.BranchID) error {
if err := checkContext(ctx); err != nil {
return err
}
if bid == kbfsmd.NullBranchID {
return kbfsmd.ServerErrorBadRequest{Reason: "Invalid branch ID"}
}
md.lock.Lock()
defer md.lock.Unlock()
currBID, err := md.getBranchIDRLocked(ctx, id)
if err != nil {
return err
}
if currBID == kbfsmd.NullBranchID || bid != currBID {
return kbfsmd.ServerErrorBadRequest{Reason: "Invalid branch ID"}
}
// Don't actually delete unmerged history. This is intentional to be consistent
// with the mdserver behavior-- it garbage collects discarded branches in the
// background.
branchKey, err := md.getBranchKey(ctx, id)
if err != nil {
return kbfsmd.ServerError{Err: err}
}
err = md.checkShutdownRLocked()
if err != nil {
return err
}
delete(md.branchDb, branchKey)
return nil
} | go | func (md *MDServerMemory) PruneBranch(ctx context.Context, id tlf.ID, bid kbfsmd.BranchID) error {
if err := checkContext(ctx); err != nil {
return err
}
if bid == kbfsmd.NullBranchID {
return kbfsmd.ServerErrorBadRequest{Reason: "Invalid branch ID"}
}
md.lock.Lock()
defer md.lock.Unlock()
currBID, err := md.getBranchIDRLocked(ctx, id)
if err != nil {
return err
}
if currBID == kbfsmd.NullBranchID || bid != currBID {
return kbfsmd.ServerErrorBadRequest{Reason: "Invalid branch ID"}
}
// Don't actually delete unmerged history. This is intentional to be consistent
// with the mdserver behavior-- it garbage collects discarded branches in the
// background.
branchKey, err := md.getBranchKey(ctx, id)
if err != nil {
return kbfsmd.ServerError{Err: err}
}
err = md.checkShutdownRLocked()
if err != nil {
return err
}
delete(md.branchDb, branchKey)
return nil
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"PruneBranch",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
",",
"bid",
"kbfsmd",
".",
"BranchID",
")",
"error",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"bid",
"==",
"kbfsmd",
".",
"NullBranchID",
"{",
"return",
"kbfsmd",
".",
"ServerErrorBadRequest",
"{",
"Reason",
":",
"\"",
"\"",
"}",
"\n",
"}",
"\n\n",
"md",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"md",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"currBID",
",",
"err",
":=",
"md",
".",
"getBranchIDRLocked",
"(",
"ctx",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"currBID",
"==",
"kbfsmd",
".",
"NullBranchID",
"||",
"bid",
"!=",
"currBID",
"{",
"return",
"kbfsmd",
".",
"ServerErrorBadRequest",
"{",
"Reason",
":",
"\"",
"\"",
"}",
"\n",
"}",
"\n\n",
"// Don't actually delete unmerged history. This is intentional to be consistent",
"// with the mdserver behavior-- it garbage collects discarded branches in the",
"// background.",
"branchKey",
",",
"err",
":=",
"md",
".",
"getBranchKey",
"(",
"ctx",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"kbfsmd",
".",
"ServerError",
"{",
"Err",
":",
"err",
"}",
"\n",
"}",
"\n",
"err",
"=",
"md",
".",
"checkShutdownRLocked",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"delete",
"(",
"md",
".",
"branchDb",
",",
"branchKey",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // PruneBranch implements the MDServer interface for MDServerMemory. | [
"PruneBranch",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L809-L843 |
160,478 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | RegisterForUpdate | func (md *MDServerMemory) RegisterForUpdate(ctx context.Context, id tlf.ID,
currHead kbfsmd.Revision) (<-chan error, error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
// are we already past this revision? If so, fire observer
// immediately
currMergedHeadRev, err := md.getCurrentMergedHeadRevision(ctx, id)
if err != nil {
return nil, err
}
c := md.updateManager.registerForUpdate(id, currHead, currMergedHeadRev, md)
return c, nil
} | go | func (md *MDServerMemory) RegisterForUpdate(ctx context.Context, id tlf.ID,
currHead kbfsmd.Revision) (<-chan error, error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
// are we already past this revision? If so, fire observer
// immediately
currMergedHeadRev, err := md.getCurrentMergedHeadRevision(ctx, id)
if err != nil {
return nil, err
}
c := md.updateManager.registerForUpdate(id, currHead, currMergedHeadRev, md)
return c, nil
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"RegisterForUpdate",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
",",
"currHead",
"kbfsmd",
".",
"Revision",
")",
"(",
"<-",
"chan",
"error",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// are we already past this revision? If so, fire observer",
"// immediately",
"currMergedHeadRev",
",",
"err",
":=",
"md",
".",
"getCurrentMergedHeadRevision",
"(",
"ctx",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"c",
":=",
"md",
".",
"updateManager",
".",
"registerForUpdate",
"(",
"id",
",",
"currHead",
",",
"currMergedHeadRev",
",",
"md",
")",
"\n",
"return",
"c",
",",
"nil",
"\n",
"}"
] | // RegisterForUpdate implements the MDServer interface for MDServerMemory. | [
"RegisterForUpdate",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L863-L878 |
160,479 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | CancelRegistration | func (md *MDServerMemory) CancelRegistration(_ context.Context, id tlf.ID) {
md.updateManager.cancel(id, md)
} | go | func (md *MDServerMemory) CancelRegistration(_ context.Context, id tlf.ID) {
md.updateManager.cancel(id, md)
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"CancelRegistration",
"(",
"_",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
")",
"{",
"md",
".",
"updateManager",
".",
"cancel",
"(",
"id",
",",
"md",
")",
"\n",
"}"
] | // CancelRegistration implements the MDServer interface for MDServerMemory. | [
"CancelRegistration",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L881-L883 |
160,480 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | TruncateLock | func (md *MDServerMemory) TruncateLock(ctx context.Context, id tlf.ID) (
bool, error) {
if err := checkContext(ctx); err != nil {
return false, err
}
md.lock.Lock()
defer md.lock.Unlock()
err := md.checkShutdownRLocked()
if err != nil {
return false, err
}
myKey, err := md.getCurrentDeviceKey(ctx)
if err != nil {
return false, err
}
return md.truncateLockManager.truncateLock(myKey, id)
} | go | func (md *MDServerMemory) TruncateLock(ctx context.Context, id tlf.ID) (
bool, error) {
if err := checkContext(ctx); err != nil {
return false, err
}
md.lock.Lock()
defer md.lock.Unlock()
err := md.checkShutdownRLocked()
if err != nil {
return false, err
}
myKey, err := md.getCurrentDeviceKey(ctx)
if err != nil {
return false, err
}
return md.truncateLockManager.truncateLock(myKey, id)
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"TruncateLock",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"md",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"md",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"err",
":=",
"md",
".",
"checkShutdownRLocked",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"myKey",
",",
"err",
":=",
"md",
".",
"getCurrentDeviceKey",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"md",
".",
"truncateLockManager",
".",
"truncateLock",
"(",
"myKey",
",",
"id",
")",
"\n",
"}"
] | // TruncateLock implements the MDServer interface for MDServerMemory. | [
"TruncateLock",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L900-L919 |
160,481 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | Shutdown | func (md *MDServerMemory) Shutdown() {
md.lock.Lock()
defer md.lock.Unlock()
md.handleDb = nil
md.latestHandleDb = nil
md.branchDb = nil
md.truncateLockManager = nil
} | go | func (md *MDServerMemory) Shutdown() {
md.lock.Lock()
defer md.lock.Unlock()
md.handleDb = nil
md.latestHandleDb = nil
md.branchDb = nil
md.truncateLockManager = nil
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"Shutdown",
"(",
")",
"{",
"md",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"md",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"md",
".",
"handleDb",
"=",
"nil",
"\n",
"md",
".",
"latestHandleDb",
"=",
"nil",
"\n",
"md",
".",
"branchDb",
"=",
"nil",
"\n",
"md",
".",
"truncateLockManager",
"=",
"nil",
"\n",
"}"
] | // Shutdown implements the MDServer interface for MDServerMemory. | [
"Shutdown",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L944-L951 |
160,482 | keybase/client | go/kbfs/libkbfs/mdserver_memory.go | GetKeyBundles | func (md *MDServerMemory) GetKeyBundles(ctx context.Context,
tlfID tlf.ID, wkbID kbfsmd.TLFWriterKeyBundleID, rkbID kbfsmd.TLFReaderKeyBundleID) (
*kbfsmd.TLFWriterKeyBundleV3, *kbfsmd.TLFReaderKeyBundleV3, error) {
if err := checkContext(ctx); err != nil {
return nil, nil, err
}
md.lock.RLock()
defer md.lock.RUnlock()
wkb, rkb, err := md.getKeyBundlesRLocked(tlfID, wkbID, rkbID)
if err != nil {
return nil, nil, kbfsmd.ServerError{Err: err}
}
return wkb, rkb, nil
} | go | func (md *MDServerMemory) GetKeyBundles(ctx context.Context,
tlfID tlf.ID, wkbID kbfsmd.TLFWriterKeyBundleID, rkbID kbfsmd.TLFReaderKeyBundleID) (
*kbfsmd.TLFWriterKeyBundleV3, *kbfsmd.TLFReaderKeyBundleV3, error) {
if err := checkContext(ctx); err != nil {
return nil, nil, err
}
md.lock.RLock()
defer md.lock.RUnlock()
wkb, rkb, err := md.getKeyBundlesRLocked(tlfID, wkbID, rkbID)
if err != nil {
return nil, nil, kbfsmd.ServerError{Err: err}
}
return wkb, rkb, nil
} | [
"func",
"(",
"md",
"*",
"MDServerMemory",
")",
"GetKeyBundles",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"wkbID",
"kbfsmd",
".",
"TLFWriterKeyBundleID",
",",
"rkbID",
"kbfsmd",
".",
"TLFReaderKeyBundleID",
")",
"(",
"*",
"kbfsmd",
".",
"TLFWriterKeyBundleV3",
",",
"*",
"kbfsmd",
".",
"TLFReaderKeyBundleV3",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"md",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"md",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"wkb",
",",
"rkb",
",",
"err",
":=",
"md",
".",
"getKeyBundlesRLocked",
"(",
"tlfID",
",",
"wkbID",
",",
"rkbID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"kbfsmd",
".",
"ServerError",
"{",
"Err",
":",
"err",
"}",
"\n",
"}",
"\n",
"return",
"wkb",
",",
"rkb",
",",
"nil",
"\n",
"}"
] | // GetKeyBundles implements the MDServer interface for MDServerMemory. | [
"GetKeyBundles",
"implements",
"the",
"MDServer",
"interface",
"for",
"MDServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_memory.go#L1136-L1151 |
160,483 | keybase/client | go/kbfs/kbfsblock/quota.go | NewUsageStat | func NewUsageStat() *UsageStat {
return &UsageStat{
Bytes: make(map[UsageType]int64),
Blocks: make(map[UsageType]int64),
}
} | go | func NewUsageStat() *UsageStat {
return &UsageStat{
Bytes: make(map[UsageType]int64),
Blocks: make(map[UsageType]int64),
}
} | [
"func",
"NewUsageStat",
"(",
")",
"*",
"UsageStat",
"{",
"return",
"&",
"UsageStat",
"{",
"Bytes",
":",
"make",
"(",
"map",
"[",
"UsageType",
"]",
"int64",
")",
",",
"Blocks",
":",
"make",
"(",
"map",
"[",
"UsageType",
"]",
"int64",
")",
",",
"}",
"\n",
"}"
] | // NewUsageStat creates a new UsageStat | [
"NewUsageStat",
"creates",
"a",
"new",
"UsageStat"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/quota.go#L38-L43 |
160,484 | keybase/client | go/kbfs/kbfsblock/quota.go | NonZero | func (u *UsageStat) NonZero() bool {
for i := UsageType(0); i < NumUsage; i++ {
if u.Bytes[i] != 0 {
return true
}
}
return false
} | go | func (u *UsageStat) NonZero() bool {
for i := UsageType(0); i < NumUsage; i++ {
if u.Bytes[i] != 0 {
return true
}
}
return false
} | [
"func",
"(",
"u",
"*",
"UsageStat",
")",
"NonZero",
"(",
")",
"bool",
"{",
"for",
"i",
":=",
"UsageType",
"(",
"0",
")",
";",
"i",
"<",
"NumUsage",
";",
"i",
"++",
"{",
"if",
"u",
".",
"Bytes",
"[",
"i",
"]",
"!=",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // NonZero checks whether UsageStat has accumulated any usage info | [
"NonZero",
"checks",
"whether",
"UsageStat",
"has",
"accumulated",
"any",
"usage",
"info"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/quota.go#L46-L53 |
160,485 | keybase/client | go/kbfs/kbfsblock/quota.go | AccumOne | func (u *UsageStat) AccumOne(change int, usage UsageType) {
if change == 0 {
return
}
if usage == UsageMDWrite || usage >= NumUsage {
return
}
u.Bytes[usage] += int64(change)
if change > 0 {
u.Blocks[usage]++
} else {
u.Blocks[usage]--
}
} | go | func (u *UsageStat) AccumOne(change int, usage UsageType) {
if change == 0 {
return
}
if usage == UsageMDWrite || usage >= NumUsage {
return
}
u.Bytes[usage] += int64(change)
if change > 0 {
u.Blocks[usage]++
} else {
u.Blocks[usage]--
}
} | [
"func",
"(",
"u",
"*",
"UsageStat",
")",
"AccumOne",
"(",
"change",
"int",
",",
"usage",
"UsageType",
")",
"{",
"if",
"change",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"if",
"usage",
"==",
"UsageMDWrite",
"||",
"usage",
">=",
"NumUsage",
"{",
"return",
"\n",
"}",
"\n",
"u",
".",
"Bytes",
"[",
"usage",
"]",
"+=",
"int64",
"(",
"change",
")",
"\n",
"if",
"change",
">",
"0",
"{",
"u",
".",
"Blocks",
"[",
"usage",
"]",
"++",
"\n",
"}",
"else",
"{",
"u",
".",
"Blocks",
"[",
"usage",
"]",
"--",
"\n",
"}",
"\n",
"}"
] | //AccumOne records the usage of one block, whose size is denoted by change
//A positive change means the block is newly added, negative means the block
//is deleted. If archive is true, it means the block is archived. | [
"AccumOne",
"records",
"the",
"usage",
"of",
"one",
"block",
"whose",
"size",
"is",
"denoted",
"by",
"change",
"A",
"positive",
"change",
"means",
"the",
"block",
"is",
"newly",
"added",
"negative",
"means",
"the",
"block",
"is",
"deleted",
".",
"If",
"archive",
"is",
"true",
"it",
"means",
"the",
"block",
"is",
"archived",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/quota.go#L58-L71 |
160,486 | keybase/client | go/kbfs/kbfsblock/quota.go | AccumOne | func (u *QuotaInfo) AccumOne(change int, folder string, usage UsageType) {
if _, ok := u.Folders[folder]; !ok {
u.Folders[folder] = NewUsageStat()
}
u.Folders[folder].AccumOne(change, usage)
u.Total.AccumOne(change, usage)
} | go | func (u *QuotaInfo) AccumOne(change int, folder string, usage UsageType) {
if _, ok := u.Folders[folder]; !ok {
u.Folders[folder] = NewUsageStat()
}
u.Folders[folder].AccumOne(change, usage)
u.Total.AccumOne(change, usage)
} | [
"func",
"(",
"u",
"*",
"QuotaInfo",
")",
"AccumOne",
"(",
"change",
"int",
",",
"folder",
"string",
",",
"usage",
"UsageType",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"u",
".",
"Folders",
"[",
"folder",
"]",
";",
"!",
"ok",
"{",
"u",
".",
"Folders",
"[",
"folder",
"]",
"=",
"NewUsageStat",
"(",
")",
"\n",
"}",
"\n",
"u",
".",
"Folders",
"[",
"folder",
"]",
".",
"AccumOne",
"(",
"change",
",",
"usage",
")",
"\n",
"u",
".",
"Total",
".",
"AccumOne",
"(",
"change",
",",
"usage",
")",
"\n",
"}"
] | // AccumOne combines one quota charge to the existing QuotaInfo | [
"AccumOne",
"combines",
"one",
"quota",
"charge",
"to",
"the",
"existing",
"QuotaInfo"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/quota.go#L103-L109 |
160,487 | keybase/client | go/kbfs/kbfsblock/quota.go | ToBytes | func (u *QuotaInfo) ToBytes(codec kbfscodec.Codec) ([]byte, error) {
return codec.Encode(u)
} | go | func (u *QuotaInfo) ToBytes(codec kbfscodec.Codec) ([]byte, error) {
return codec.Encode(u)
} | [
"func",
"(",
"u",
"*",
"QuotaInfo",
")",
"ToBytes",
"(",
"codec",
"kbfscodec",
".",
"Codec",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"codec",
".",
"Encode",
"(",
"u",
")",
"\n",
"}"
] | // ToBytes marshals this QuotaInfo | [
"ToBytes",
"marshals",
"this",
"QuotaInfo"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/quota.go#L129-L131 |
160,488 | keybase/client | go/kbfs/kbfsblock/quota.go | QuotaInfoDecode | func QuotaInfoDecode(b []byte, codec kbfscodec.Codec) (
*QuotaInfo, error) {
var info QuotaInfo
err := codec.Decode(b, &info)
if err != nil {
return nil, err
}
return &info, nil
} | go | func QuotaInfoDecode(b []byte, codec kbfscodec.Codec) (
*QuotaInfo, error) {
var info QuotaInfo
err := codec.Decode(b, &info)
if err != nil {
return nil, err
}
return &info, nil
} | [
"func",
"QuotaInfoDecode",
"(",
"b",
"[",
"]",
"byte",
",",
"codec",
"kbfscodec",
".",
"Codec",
")",
"(",
"*",
"QuotaInfo",
",",
"error",
")",
"{",
"var",
"info",
"QuotaInfo",
"\n",
"err",
":=",
"codec",
".",
"Decode",
"(",
"b",
",",
"&",
"info",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"info",
",",
"nil",
"\n",
"}"
] | // QuotaInfoDecode decodes b into a QuotaInfo | [
"QuotaInfoDecode",
"decodes",
"b",
"into",
"a",
"QuotaInfo"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/quota.go#L134-L143 |
160,489 | keybase/client | go/kbfs/data/dirty_bcache.go | NewDirtyBlockCacheStandard | func NewDirtyBlockCacheStandard(
clock idutil.Clock, log logger.Logger, vlog *libkb.VDebugLog,
minSyncBufCap int64, maxSyncBufCap int64,
startSyncBufCap int64) *DirtyBlockCacheStandard {
d := &DirtyBlockCacheStandard{
clock: clock,
log: log,
vlog: vlog,
requestsChan: make(chan dirtyReq, 1000),
bytesDecreasedChan: make(chan struct{}, 1),
shutdownChan: make(chan struct{}),
cache: make(map[dirtyBlockID]Block),
minSyncBufCap: minSyncBufCap,
maxSyncBufCap: maxSyncBufCap,
syncBufferCap: startSyncBufCap,
resetBufferCapTime: resetBufferCapTimeDefault,
}
d.reqWg.Add(1)
go d.processPermission()
return d
} | go | func NewDirtyBlockCacheStandard(
clock idutil.Clock, log logger.Logger, vlog *libkb.VDebugLog,
minSyncBufCap int64, maxSyncBufCap int64,
startSyncBufCap int64) *DirtyBlockCacheStandard {
d := &DirtyBlockCacheStandard{
clock: clock,
log: log,
vlog: vlog,
requestsChan: make(chan dirtyReq, 1000),
bytesDecreasedChan: make(chan struct{}, 1),
shutdownChan: make(chan struct{}),
cache: make(map[dirtyBlockID]Block),
minSyncBufCap: minSyncBufCap,
maxSyncBufCap: maxSyncBufCap,
syncBufferCap: startSyncBufCap,
resetBufferCapTime: resetBufferCapTimeDefault,
}
d.reqWg.Add(1)
go d.processPermission()
return d
} | [
"func",
"NewDirtyBlockCacheStandard",
"(",
"clock",
"idutil",
".",
"Clock",
",",
"log",
"logger",
".",
"Logger",
",",
"vlog",
"*",
"libkb",
".",
"VDebugLog",
",",
"minSyncBufCap",
"int64",
",",
"maxSyncBufCap",
"int64",
",",
"startSyncBufCap",
"int64",
")",
"*",
"DirtyBlockCacheStandard",
"{",
"d",
":=",
"&",
"DirtyBlockCacheStandard",
"{",
"clock",
":",
"clock",
",",
"log",
":",
"log",
",",
"vlog",
":",
"vlog",
",",
"requestsChan",
":",
"make",
"(",
"chan",
"dirtyReq",
",",
"1000",
")",
",",
"bytesDecreasedChan",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
",",
"shutdownChan",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"cache",
":",
"make",
"(",
"map",
"[",
"dirtyBlockID",
"]",
"Block",
")",
",",
"minSyncBufCap",
":",
"minSyncBufCap",
",",
"maxSyncBufCap",
":",
"maxSyncBufCap",
",",
"syncBufferCap",
":",
"startSyncBufCap",
",",
"resetBufferCapTime",
":",
"resetBufferCapTimeDefault",
",",
"}",
"\n",
"d",
".",
"reqWg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"d",
".",
"processPermission",
"(",
")",
"\n",
"return",
"d",
"\n",
"}"
] | // NewDirtyBlockCacheStandard constructs a new BlockCacheStandard
// instance. The min and max buffer capacities define the possible
// range of how many bytes we'll try to sync in any one sync, and the
// start size defines the initial buffer size. | [
"NewDirtyBlockCacheStandard",
"constructs",
"a",
"new",
"BlockCacheStandard",
"instance",
".",
"The",
"min",
"and",
"max",
"buffer",
"capacities",
"define",
"the",
"possible",
"range",
"of",
"how",
"many",
"bytes",
"we",
"ll",
"try",
"to",
"sync",
"in",
"any",
"one",
"sync",
"and",
"the",
"start",
"size",
"defines",
"the",
"initial",
"buffer",
"size",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L163-L183 |
160,490 | keybase/client | go/kbfs/data/dirty_bcache.go | Get | func (d *DirtyBlockCacheStandard) Get(
_ context.Context, _ tlf.ID, ptr BlockPointer, branch BranchName) (
Block, error) {
block := func() Block {
dirtyID := dirtyBlockID{
id: ptr.ID,
refNonce: ptr.RefNonce,
branch: branch,
}
d.lock.RLock()
defer d.lock.RUnlock()
return d.cache[dirtyID]
}()
if block != nil {
return block, nil
}
return nil, NoSuchBlockError{ptr.ID}
} | go | func (d *DirtyBlockCacheStandard) Get(
_ context.Context, _ tlf.ID, ptr BlockPointer, branch BranchName) (
Block, error) {
block := func() Block {
dirtyID := dirtyBlockID{
id: ptr.ID,
refNonce: ptr.RefNonce,
branch: branch,
}
d.lock.RLock()
defer d.lock.RUnlock()
return d.cache[dirtyID]
}()
if block != nil {
return block, nil
}
return nil, NoSuchBlockError{ptr.ID}
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"Get",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"tlf",
".",
"ID",
",",
"ptr",
"BlockPointer",
",",
"branch",
"BranchName",
")",
"(",
"Block",
",",
"error",
")",
"{",
"block",
":=",
"func",
"(",
")",
"Block",
"{",
"dirtyID",
":=",
"dirtyBlockID",
"{",
"id",
":",
"ptr",
".",
"ID",
",",
"refNonce",
":",
"ptr",
".",
"RefNonce",
",",
"branch",
":",
"branch",
",",
"}",
"\n",
"d",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"d",
".",
"cache",
"[",
"dirtyID",
"]",
"\n",
"}",
"(",
")",
"\n",
"if",
"block",
"!=",
"nil",
"{",
"return",
"block",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"NoSuchBlockError",
"{",
"ptr",
".",
"ID",
"}",
"\n",
"}"
] | // Get implements the DirtyBlockCache interface for
// DirtyBlockCacheStandard. | [
"Get",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L195-L213 |
160,491 | keybase/client | go/kbfs/data/dirty_bcache.go | Put | func (d *DirtyBlockCacheStandard) Put(
_ context.Context, _ tlf.ID, ptr BlockPointer, branch BranchName,
block Block) error {
dirtyID := dirtyBlockID{
id: ptr.ID,
refNonce: ptr.RefNonce,
branch: branch,
}
d.lock.Lock()
defer d.lock.Unlock()
d.cache[dirtyID] = block
return nil
} | go | func (d *DirtyBlockCacheStandard) Put(
_ context.Context, _ tlf.ID, ptr BlockPointer, branch BranchName,
block Block) error {
dirtyID := dirtyBlockID{
id: ptr.ID,
refNonce: ptr.RefNonce,
branch: branch,
}
d.lock.Lock()
defer d.lock.Unlock()
d.cache[dirtyID] = block
return nil
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"Put",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"tlf",
".",
"ID",
",",
"ptr",
"BlockPointer",
",",
"branch",
"BranchName",
",",
"block",
"Block",
")",
"error",
"{",
"dirtyID",
":=",
"dirtyBlockID",
"{",
"id",
":",
"ptr",
".",
"ID",
",",
"refNonce",
":",
"ptr",
".",
"RefNonce",
",",
"branch",
":",
"branch",
",",
"}",
"\n\n",
"d",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"d",
".",
"cache",
"[",
"dirtyID",
"]",
"=",
"block",
"\n",
"return",
"nil",
"\n",
"}"
] | // Put implements the DirtyBlockCache interface for
// DirtyBlockCacheStandard. | [
"Put",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L217-L230 |
160,492 | keybase/client | go/kbfs/data/dirty_bcache.go | Delete | func (d *DirtyBlockCacheStandard) Delete(_ tlf.ID, ptr BlockPointer,
branch BranchName) error {
dirtyID := dirtyBlockID{
id: ptr.ID,
refNonce: ptr.RefNonce,
branch: branch,
}
d.lock.Lock()
defer d.lock.Unlock()
delete(d.cache, dirtyID)
return nil
} | go | func (d *DirtyBlockCacheStandard) Delete(_ tlf.ID, ptr BlockPointer,
branch BranchName) error {
dirtyID := dirtyBlockID{
id: ptr.ID,
refNonce: ptr.RefNonce,
branch: branch,
}
d.lock.Lock()
defer d.lock.Unlock()
delete(d.cache, dirtyID)
return nil
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"Delete",
"(",
"_",
"tlf",
".",
"ID",
",",
"ptr",
"BlockPointer",
",",
"branch",
"BranchName",
")",
"error",
"{",
"dirtyID",
":=",
"dirtyBlockID",
"{",
"id",
":",
"ptr",
".",
"ID",
",",
"refNonce",
":",
"ptr",
".",
"RefNonce",
",",
"branch",
":",
"branch",
",",
"}",
"\n\n",
"d",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"d",
".",
"cache",
",",
"dirtyID",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Delete implements the DirtyBlockCache interface for
// DirtyBlockCacheStandard. | [
"Delete",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L234-L246 |
160,493 | keybase/client | go/kbfs/data/dirty_bcache.go | IsDirty | func (d *DirtyBlockCacheStandard) IsDirty(_ tlf.ID, ptr BlockPointer,
branch BranchName) (isDirty bool) {
dirtyID := dirtyBlockID{
id: ptr.ID,
refNonce: ptr.RefNonce,
branch: branch,
}
d.lock.RLock()
defer d.lock.RUnlock()
_, isDirty = d.cache[dirtyID]
return
} | go | func (d *DirtyBlockCacheStandard) IsDirty(_ tlf.ID, ptr BlockPointer,
branch BranchName) (isDirty bool) {
dirtyID := dirtyBlockID{
id: ptr.ID,
refNonce: ptr.RefNonce,
branch: branch,
}
d.lock.RLock()
defer d.lock.RUnlock()
_, isDirty = d.cache[dirtyID]
return
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"IsDirty",
"(",
"_",
"tlf",
".",
"ID",
",",
"ptr",
"BlockPointer",
",",
"branch",
"BranchName",
")",
"(",
"isDirty",
"bool",
")",
"{",
"dirtyID",
":=",
"dirtyBlockID",
"{",
"id",
":",
"ptr",
".",
"ID",
",",
"refNonce",
":",
"ptr",
".",
"RefNonce",
",",
"branch",
":",
"branch",
",",
"}",
"\n\n",
"d",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"_",
",",
"isDirty",
"=",
"d",
".",
"cache",
"[",
"dirtyID",
"]",
"\n",
"return",
"\n",
"}"
] | // IsDirty implements the DirtyBlockCache interface for
// DirtyBlockCacheStandard. | [
"IsDirty",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L250-L262 |
160,494 | keybase/client | go/kbfs/data/dirty_bcache.go | IsAnyDirty | func (d *DirtyBlockCacheStandard) IsAnyDirty(_ tlf.ID) bool {
d.lock.RLock()
defer d.lock.RUnlock()
return len(d.cache) > 0 || d.syncBufBytes > 0 || d.waitBufBytes > 0
} | go | func (d *DirtyBlockCacheStandard) IsAnyDirty(_ tlf.ID) bool {
d.lock.RLock()
defer d.lock.RUnlock()
return len(d.cache) > 0 || d.syncBufBytes > 0 || d.waitBufBytes > 0
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"IsAnyDirty",
"(",
"_",
"tlf",
".",
"ID",
")",
"bool",
"{",
"d",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"d",
".",
"cache",
")",
">",
"0",
"||",
"d",
".",
"syncBufBytes",
">",
"0",
"||",
"d",
".",
"waitBufBytes",
">",
"0",
"\n",
"}"
] | // IsAnyDirty implements the DirtyBlockCache interface for
// DirtyBlockCacheStandard. | [
"IsAnyDirty",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L266-L270 |
160,495 | keybase/client | go/kbfs/data/dirty_bcache.go | calcBackpressure | func (d *DirtyBlockCacheStandard) calcBackpressure(start time.Time,
deadline time.Time) time.Duration {
d.lock.RLock()
defer d.lock.RUnlock()
// We don't want to use the whole deadline, so cut it some slack.
totalReqTime := deadline.Sub(start) - backpressureSlack
if totalReqTime <= 0 {
return 0
}
// Keep the window full in preparation for the next sync, after
// it's full start applying backpressure.
if d.waitBufBytes < d.syncBufferCap {
return 0
}
// The backpressure is proportional to how far our overage is
// toward filling up our next sync buffer.
backpressureFrac := float64(d.waitBufBytes-d.syncBufferCap) /
float64(d.syncBufferCap)
if backpressureFrac > 1.0 {
backpressureFrac = 1.0
}
totalBackpressure := time.Duration(
float64(totalReqTime) * backpressureFrac)
timeSpentSoFar := d.clock.Now().Sub(start)
if totalBackpressure <= timeSpentSoFar {
return 0
}
// How much time do we have left, given how much time this request
// has waited so far?
return totalBackpressure - timeSpentSoFar
} | go | func (d *DirtyBlockCacheStandard) calcBackpressure(start time.Time,
deadline time.Time) time.Duration {
d.lock.RLock()
defer d.lock.RUnlock()
// We don't want to use the whole deadline, so cut it some slack.
totalReqTime := deadline.Sub(start) - backpressureSlack
if totalReqTime <= 0 {
return 0
}
// Keep the window full in preparation for the next sync, after
// it's full start applying backpressure.
if d.waitBufBytes < d.syncBufferCap {
return 0
}
// The backpressure is proportional to how far our overage is
// toward filling up our next sync buffer.
backpressureFrac := float64(d.waitBufBytes-d.syncBufferCap) /
float64(d.syncBufferCap)
if backpressureFrac > 1.0 {
backpressureFrac = 1.0
}
totalBackpressure := time.Duration(
float64(totalReqTime) * backpressureFrac)
timeSpentSoFar := d.clock.Now().Sub(start)
if totalBackpressure <= timeSpentSoFar {
return 0
}
// How much time do we have left, given how much time this request
// has waited so far?
return totalBackpressure - timeSpentSoFar
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"calcBackpressure",
"(",
"start",
"time",
".",
"Time",
",",
"deadline",
"time",
".",
"Time",
")",
"time",
".",
"Duration",
"{",
"d",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"// We don't want to use the whole deadline, so cut it some slack.",
"totalReqTime",
":=",
"deadline",
".",
"Sub",
"(",
"start",
")",
"-",
"backpressureSlack",
"\n",
"if",
"totalReqTime",
"<=",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"// Keep the window full in preparation for the next sync, after",
"// it's full start applying backpressure.",
"if",
"d",
".",
"waitBufBytes",
"<",
"d",
".",
"syncBufferCap",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"// The backpressure is proportional to how far our overage is",
"// toward filling up our next sync buffer.",
"backpressureFrac",
":=",
"float64",
"(",
"d",
".",
"waitBufBytes",
"-",
"d",
".",
"syncBufferCap",
")",
"/",
"float64",
"(",
"d",
".",
"syncBufferCap",
")",
"\n",
"if",
"backpressureFrac",
">",
"1.0",
"{",
"backpressureFrac",
"=",
"1.0",
"\n",
"}",
"\n",
"totalBackpressure",
":=",
"time",
".",
"Duration",
"(",
"float64",
"(",
"totalReqTime",
")",
"*",
"backpressureFrac",
")",
"\n",
"timeSpentSoFar",
":=",
"d",
".",
"clock",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"start",
")",
"\n",
"if",
"totalBackpressure",
"<=",
"timeSpentSoFar",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"// How much time do we have left, given how much time this request",
"// has waited so far?",
"return",
"totalBackpressure",
"-",
"timeSpentSoFar",
"\n",
"}"
] | // calcBackpressure returns how much longer a given request should be
// blocked, as a function of its deadline and how past full the
// syncing buffer is. In its lifetime, the request should be blocked
// by roughly the same fraction of its total deadline as how past full
// the buffer is. This will let KBFS slow down writes according to
// how slow the background Syncs are, so we don't accumulate more
// bytes to Sync than we can handle. See KBFS-731. | [
"calcBackpressure",
"returns",
"how",
"much",
"longer",
"a",
"given",
"request",
"should",
"be",
"blocked",
"as",
"a",
"function",
"of",
"its",
"deadline",
"and",
"how",
"past",
"full",
"the",
"syncing",
"buffer",
"is",
".",
"In",
"its",
"lifetime",
"the",
"request",
"should",
"be",
"blocked",
"by",
"roughly",
"the",
"same",
"fraction",
"of",
"its",
"total",
"deadline",
"as",
"how",
"past",
"full",
"the",
"buffer",
"is",
".",
"This",
"will",
"let",
"KBFS",
"slow",
"down",
"writes",
"according",
"to",
"how",
"slow",
"the",
"background",
"Syncs",
"are",
"so",
"we",
"don",
"t",
"accumulate",
"more",
"bytes",
"to",
"Sync",
"than",
"we",
"can",
"handle",
".",
"See",
"KBFS",
"-",
"731",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L281-L314 |
160,496 | keybase/client | go/kbfs/data/dirty_bcache.go | RequestPermissionToDirty | func (d *DirtyBlockCacheStandard) RequestPermissionToDirty(
ctx context.Context, _ tlf.ID, estimatedDirtyBytes int64) (
DirtyPermChan, error) {
d.shutdownLock.RLock()
defer d.shutdownLock.RUnlock()
if d.isShutdown {
return nil, ShutdownHappenedError{}
}
if estimatedDirtyBytes < 0 {
panic("Must request permission for a non-negative number of bytes.")
}
c := make(chan struct{})
// No need to wait to write 0 bytes.
if estimatedDirtyBytes == 0 {
close(c)
return c, nil
}
now := d.clock.Now()
deadline, ok := ctx.Deadline()
defaultDeadline := now.Add(BackgroundTaskTimeout / 2)
if !ok || deadline.After(defaultDeadline) {
// Use half of the background task timeout, to make sure we
// never get close to a timeout in a background task.
deadline = defaultDeadline
}
req := dirtyReq{c, estimatedDirtyBytes, now, deadline}
select {
case d.requestsChan <- req:
return c, nil
case <-ctx.Done():
return nil, ctx.Err()
}
} | go | func (d *DirtyBlockCacheStandard) RequestPermissionToDirty(
ctx context.Context, _ tlf.ID, estimatedDirtyBytes int64) (
DirtyPermChan, error) {
d.shutdownLock.RLock()
defer d.shutdownLock.RUnlock()
if d.isShutdown {
return nil, ShutdownHappenedError{}
}
if estimatedDirtyBytes < 0 {
panic("Must request permission for a non-negative number of bytes.")
}
c := make(chan struct{})
// No need to wait to write 0 bytes.
if estimatedDirtyBytes == 0 {
close(c)
return c, nil
}
now := d.clock.Now()
deadline, ok := ctx.Deadline()
defaultDeadline := now.Add(BackgroundTaskTimeout / 2)
if !ok || deadline.After(defaultDeadline) {
// Use half of the background task timeout, to make sure we
// never get close to a timeout in a background task.
deadline = defaultDeadline
}
req := dirtyReq{c, estimatedDirtyBytes, now, deadline}
select {
case d.requestsChan <- req:
return c, nil
case <-ctx.Done():
return nil, ctx.Err()
}
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"RequestPermissionToDirty",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"tlf",
".",
"ID",
",",
"estimatedDirtyBytes",
"int64",
")",
"(",
"DirtyPermChan",
",",
"error",
")",
"{",
"d",
".",
"shutdownLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"shutdownLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"d",
".",
"isShutdown",
"{",
"return",
"nil",
",",
"ShutdownHappenedError",
"{",
"}",
"\n",
"}",
"\n\n",
"if",
"estimatedDirtyBytes",
"<",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"c",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n\n",
"// No need to wait to write 0 bytes.",
"if",
"estimatedDirtyBytes",
"==",
"0",
"{",
"close",
"(",
"c",
")",
"\n",
"return",
"c",
",",
"nil",
"\n",
"}",
"\n\n",
"now",
":=",
"d",
".",
"clock",
".",
"Now",
"(",
")",
"\n",
"deadline",
",",
"ok",
":=",
"ctx",
".",
"Deadline",
"(",
")",
"\n",
"defaultDeadline",
":=",
"now",
".",
"Add",
"(",
"BackgroundTaskTimeout",
"/",
"2",
")",
"\n",
"if",
"!",
"ok",
"||",
"deadline",
".",
"After",
"(",
"defaultDeadline",
")",
"{",
"// Use half of the background task timeout, to make sure we",
"// never get close to a timeout in a background task.",
"deadline",
"=",
"defaultDeadline",
"\n",
"}",
"\n",
"req",
":=",
"dirtyReq",
"{",
"c",
",",
"estimatedDirtyBytes",
",",
"now",
",",
"deadline",
"}",
"\n",
"select",
"{",
"case",
"d",
".",
"requestsChan",
"<-",
"req",
":",
"return",
"c",
",",
"nil",
"\n",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"nil",
",",
"ctx",
".",
"Err",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // RequestPermissionToDirty implements the DirtyBlockCache interface
// for DirtyBlockCacheStandard. | [
"RequestPermissionToDirty",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L487-L522 |
160,497 | keybase/client | go/kbfs/data/dirty_bcache.go | UpdateUnsyncedBytes | func (d *DirtyBlockCacheStandard) UpdateUnsyncedBytes(_ tlf.ID,
newUnsyncedBytes int64, wasSyncing bool) {
d.lock.Lock()
defer d.lock.Unlock()
if wasSyncing {
d.syncBufBytes += newUnsyncedBytes
} else {
d.updateWaitBufLocked(newUnsyncedBytes)
}
if newUnsyncedBytes < 0 {
d.signalDecreasedBytes()
}
} | go | func (d *DirtyBlockCacheStandard) UpdateUnsyncedBytes(_ tlf.ID,
newUnsyncedBytes int64, wasSyncing bool) {
d.lock.Lock()
defer d.lock.Unlock()
if wasSyncing {
d.syncBufBytes += newUnsyncedBytes
} else {
d.updateWaitBufLocked(newUnsyncedBytes)
}
if newUnsyncedBytes < 0 {
d.signalDecreasedBytes()
}
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"UpdateUnsyncedBytes",
"(",
"_",
"tlf",
".",
"ID",
",",
"newUnsyncedBytes",
"int64",
",",
"wasSyncing",
"bool",
")",
"{",
"d",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"wasSyncing",
"{",
"d",
".",
"syncBufBytes",
"+=",
"newUnsyncedBytes",
"\n",
"}",
"else",
"{",
"d",
".",
"updateWaitBufLocked",
"(",
"newUnsyncedBytes",
")",
"\n",
"}",
"\n",
"if",
"newUnsyncedBytes",
"<",
"0",
"{",
"d",
".",
"signalDecreasedBytes",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // UpdateUnsyncedBytes implements the DirtyBlockCache interface for
// DirtyBlockCacheStandard. | [
"UpdateUnsyncedBytes",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L545-L557 |
160,498 | keybase/client | go/kbfs/data/dirty_bcache.go | UpdateSyncingBytes | func (d *DirtyBlockCacheStandard) UpdateSyncingBytes(_ tlf.ID, size int64) {
d.lock.Lock()
defer d.lock.Unlock()
d.syncBufBytes += size
d.updateWaitBufLocked(-size)
d.signalDecreasedBytes()
} | go | func (d *DirtyBlockCacheStandard) UpdateSyncingBytes(_ tlf.ID, size int64) {
d.lock.Lock()
defer d.lock.Unlock()
d.syncBufBytes += size
d.updateWaitBufLocked(-size)
d.signalDecreasedBytes()
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"UpdateSyncingBytes",
"(",
"_",
"tlf",
".",
"ID",
",",
"size",
"int64",
")",
"{",
"d",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"d",
".",
"syncBufBytes",
"+=",
"size",
"\n",
"d",
".",
"updateWaitBufLocked",
"(",
"-",
"size",
")",
"\n",
"d",
".",
"signalDecreasedBytes",
"(",
")",
"\n",
"}"
] | // UpdateSyncingBytes implements the DirtyBlockCache interface for
// DirtyBlockCacheStandard. | [
"UpdateSyncingBytes",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L561-L567 |
160,499 | keybase/client | go/kbfs/data/dirty_bcache.go | SyncFinished | func (d *DirtyBlockCacheStandard) SyncFinished(_ tlf.ID, size int64) {
d.lock.Lock()
defer d.lock.Unlock()
if size <= 0 {
return
}
d.syncStarted = time.Time{}
// If the outstanding bytes have timed out, don't count them
// towards the buffer increase.
ignore := d.ignoreSyncBytes
if ignore > size {
ignore = size
}
bufferIncrease := size - ignore
d.ignoreSyncBytes -= ignore
// If the sync was a reasonably large fraction of the current
// buffer capacity, restart the reset timer.
if size >= d.syncBufferCap/2 {
if d.resetter != nil {
d.resetter.Stop()
}
d.resetter = time.AfterFunc(d.resetBufferCapTime, d.resetBufferCap)
}
// Only increase the buffer size if we sent over a lot of bytes.
// We don't want a series of small writes to increase the buffer
// size, since that doesn't give us any real information about the
// throughput of the connection.
if bufferIncrease >= d.syncBufferCap {
d.syncBufferCap += bufferIncrease
if d.syncBufferCap > d.maxSyncBufCap {
d.syncBufferCap = d.maxSyncBufCap
}
}
d.signalDecreasedBytes()
d.vlog.CLogf(
context.TODO(), libkb.VLog1,
"Finished syncing %d bytes, syncBufferCap=%d, waitBuf=%d, ignored=%d",
size, d.syncBufferCap, d.waitBufBytes, ignore)
} | go | func (d *DirtyBlockCacheStandard) SyncFinished(_ tlf.ID, size int64) {
d.lock.Lock()
defer d.lock.Unlock()
if size <= 0 {
return
}
d.syncStarted = time.Time{}
// If the outstanding bytes have timed out, don't count them
// towards the buffer increase.
ignore := d.ignoreSyncBytes
if ignore > size {
ignore = size
}
bufferIncrease := size - ignore
d.ignoreSyncBytes -= ignore
// If the sync was a reasonably large fraction of the current
// buffer capacity, restart the reset timer.
if size >= d.syncBufferCap/2 {
if d.resetter != nil {
d.resetter.Stop()
}
d.resetter = time.AfterFunc(d.resetBufferCapTime, d.resetBufferCap)
}
// Only increase the buffer size if we sent over a lot of bytes.
// We don't want a series of small writes to increase the buffer
// size, since that doesn't give us any real information about the
// throughput of the connection.
if bufferIncrease >= d.syncBufferCap {
d.syncBufferCap += bufferIncrease
if d.syncBufferCap > d.maxSyncBufCap {
d.syncBufferCap = d.maxSyncBufCap
}
}
d.signalDecreasedBytes()
d.vlog.CLogf(
context.TODO(), libkb.VLog1,
"Finished syncing %d bytes, syncBufferCap=%d, waitBuf=%d, ignored=%d",
size, d.syncBufferCap, d.waitBufBytes, ignore)
} | [
"func",
"(",
"d",
"*",
"DirtyBlockCacheStandard",
")",
"SyncFinished",
"(",
"_",
"tlf",
".",
"ID",
",",
"size",
"int64",
")",
"{",
"d",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"size",
"<=",
"0",
"{",
"return",
"\n",
"}",
"\n",
"d",
".",
"syncStarted",
"=",
"time",
".",
"Time",
"{",
"}",
"\n\n",
"// If the outstanding bytes have timed out, don't count them",
"// towards the buffer increase.",
"ignore",
":=",
"d",
".",
"ignoreSyncBytes",
"\n",
"if",
"ignore",
">",
"size",
"{",
"ignore",
"=",
"size",
"\n",
"}",
"\n",
"bufferIncrease",
":=",
"size",
"-",
"ignore",
"\n",
"d",
".",
"ignoreSyncBytes",
"-=",
"ignore",
"\n\n",
"// If the sync was a reasonably large fraction of the current",
"// buffer capacity, restart the reset timer.",
"if",
"size",
">=",
"d",
".",
"syncBufferCap",
"/",
"2",
"{",
"if",
"d",
".",
"resetter",
"!=",
"nil",
"{",
"d",
".",
"resetter",
".",
"Stop",
"(",
")",
"\n",
"}",
"\n",
"d",
".",
"resetter",
"=",
"time",
".",
"AfterFunc",
"(",
"d",
".",
"resetBufferCapTime",
",",
"d",
".",
"resetBufferCap",
")",
"\n",
"}",
"\n\n",
"// Only increase the buffer size if we sent over a lot of bytes.",
"// We don't want a series of small writes to increase the buffer",
"// size, since that doesn't give us any real information about the",
"// throughput of the connection.",
"if",
"bufferIncrease",
">=",
"d",
".",
"syncBufferCap",
"{",
"d",
".",
"syncBufferCap",
"+=",
"bufferIncrease",
"\n",
"if",
"d",
".",
"syncBufferCap",
">",
"d",
".",
"maxSyncBufCap",
"{",
"d",
".",
"syncBufferCap",
"=",
"d",
".",
"maxSyncBufCap",
"\n",
"}",
"\n",
"}",
"\n",
"d",
".",
"signalDecreasedBytes",
"(",
")",
"\n",
"d",
".",
"vlog",
".",
"CLogf",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
",",
"size",
",",
"d",
".",
"syncBufferCap",
",",
"d",
".",
"waitBufBytes",
",",
"ignore",
")",
"\n",
"}"
] | // SyncFinished implements the DirtyBlockCache interface for
// DirtyBlockCacheStandard. | [
"SyncFinished",
"implements",
"the",
"DirtyBlockCache",
"interface",
"for",
"DirtyBlockCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_bcache.go#L599-L640 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.