id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
158,600 | keybase/client | go/stellar/stellar.go | CreateWalletSoft | func CreateWalletSoft(mctx libkb.MetaContext) {
var err error
defer mctx.TraceTimed("CreateWalletSoft", func() error { return err })()
if !mctx.G().LocalSigchainGuard().IsAvailable(mctx.Ctx(), "CreateWalletSoft") {
err = fmt.Errorf("yielding to guard")
return
}
_, err = CreateWalletGated(mctx)
} | go | func CreateWalletSoft(mctx libkb.MetaContext) {
var err error
defer mctx.TraceTimed("CreateWalletSoft", func() error { return err })()
if !mctx.G().LocalSigchainGuard().IsAvailable(mctx.Ctx(), "CreateWalletSoft") {
err = fmt.Errorf("yielding to guard")
return
}
_, err = CreateWalletGated(mctx)
} | [
"func",
"CreateWalletSoft",
"(",
"mctx",
"libkb",
".",
"MetaContext",
")",
"{",
"var",
"err",
"error",
"\n",
"defer",
"mctx",
".",
"TraceTimed",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"if",
"!",
"mctx",
".",
"G",
"(",
")",
".",
"LocalSigchainGuard",
"(",
")",
".",
"IsAvailable",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"\"",
"\"",
")",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"CreateWalletGated",
"(",
"mctx",
")",
"\n",
"}"
] | // CreateWalletSoft creates a user's initial wallet if they don't already have one.
// Does not get in the way of intentional user actions. | [
"CreateWalletSoft",
"creates",
"a",
"user",
"s",
"initial",
"wallet",
"if",
"they",
"don",
"t",
"already",
"have",
"one",
".",
"Does",
"not",
"get",
"in",
"the",
"way",
"of",
"intentional",
"user",
"actions",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L143-L151 |
158,601 | keybase/client | go/stellar/stellar.go | Upkeep | func Upkeep(mctx libkb.MetaContext) (err error) {
defer mctx.TraceTimed("Stellar.Upkeep", func() error { return err })()
_, _, prevAccountPukGens, err := remote.FetchBundleWithGens(mctx)
if err != nil {
return err
}
pukring, err := mctx.G().GetPerUserKeyring(mctx.Ctx())
if err != nil {
return err
}
err = pukring.Sync(mctx)
if err != nil {
return err
}
currentPukGen := pukring.CurrentGeneration()
var madeAnyChanges bool
for accountID, accountPukGen := range prevAccountPukGens {
if accountPukGen < currentPukGen {
madeAnyChanges = true
mctx.Debug("Stellar.Upkeep: reencrypting %s... for gen %v from gen %v", accountID[:5], currentPukGen, accountPukGen)
if err = pushSimpleUpdateForAccount(mctx, accountID); err != nil {
mctx.Debug("Stellar.Upkeep: error reencrypting %v: %v", accountID[:5], err)
return err
}
}
}
if !madeAnyChanges {
mctx.Debug("Stellar.Upkeep: no need to reencrypt. Everything is at gen %v", currentPukGen)
}
return nil
} | go | func Upkeep(mctx libkb.MetaContext) (err error) {
defer mctx.TraceTimed("Stellar.Upkeep", func() error { return err })()
_, _, prevAccountPukGens, err := remote.FetchBundleWithGens(mctx)
if err != nil {
return err
}
pukring, err := mctx.G().GetPerUserKeyring(mctx.Ctx())
if err != nil {
return err
}
err = pukring.Sync(mctx)
if err != nil {
return err
}
currentPukGen := pukring.CurrentGeneration()
var madeAnyChanges bool
for accountID, accountPukGen := range prevAccountPukGens {
if accountPukGen < currentPukGen {
madeAnyChanges = true
mctx.Debug("Stellar.Upkeep: reencrypting %s... for gen %v from gen %v", accountID[:5], currentPukGen, accountPukGen)
if err = pushSimpleUpdateForAccount(mctx, accountID); err != nil {
mctx.Debug("Stellar.Upkeep: error reencrypting %v: %v", accountID[:5], err)
return err
}
}
}
if !madeAnyChanges {
mctx.Debug("Stellar.Upkeep: no need to reencrypt. Everything is at gen %v", currentPukGen)
}
return nil
} | [
"func",
"Upkeep",
"(",
"mctx",
"libkb",
".",
"MetaContext",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"mctx",
".",
"TraceTimed",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"_",
",",
"_",
",",
"prevAccountPukGens",
",",
"err",
":=",
"remote",
".",
"FetchBundleWithGens",
"(",
"mctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"pukring",
",",
"err",
":=",
"mctx",
".",
"G",
"(",
")",
".",
"GetPerUserKeyring",
"(",
"mctx",
".",
"Ctx",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"pukring",
".",
"Sync",
"(",
"mctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"currentPukGen",
":=",
"pukring",
".",
"CurrentGeneration",
"(",
")",
"\n",
"var",
"madeAnyChanges",
"bool",
"\n",
"for",
"accountID",
",",
"accountPukGen",
":=",
"range",
"prevAccountPukGens",
"{",
"if",
"accountPukGen",
"<",
"currentPukGen",
"{",
"madeAnyChanges",
"=",
"true",
"\n",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"accountID",
"[",
":",
"5",
"]",
",",
"currentPukGen",
",",
"accountPukGen",
")",
"\n",
"if",
"err",
"=",
"pushSimpleUpdateForAccount",
"(",
"mctx",
",",
"accountID",
")",
";",
"err",
"!=",
"nil",
"{",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"accountID",
"[",
":",
"5",
"]",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"madeAnyChanges",
"{",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"currentPukGen",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Upkeep makes sure the bundle is encrypted for the user's latest PUK. | [
"Upkeep",
"makes",
"sure",
"the",
"bundle",
"is",
"encrypted",
"for",
"the",
"user",
"s",
"latest",
"PUK",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L164-L194 |
158,602 | keybase/client | go/stellar/stellar.go | SendPaymentCLI | func SendPaymentCLI(m libkb.MetaContext, walletState *WalletState, sendArg SendPaymentArg) (res SendPaymentResult, err error) {
return sendPayment(m, walletState, sendArg, true)
} | go | func SendPaymentCLI(m libkb.MetaContext, walletState *WalletState, sendArg SendPaymentArg) (res SendPaymentResult, err error) {
return sendPayment(m, walletState, sendArg, true)
} | [
"func",
"SendPaymentCLI",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"walletState",
"*",
"WalletState",
",",
"sendArg",
"SendPaymentArg",
")",
"(",
"res",
"SendPaymentResult",
",",
"err",
"error",
")",
"{",
"return",
"sendPayment",
"(",
"m",
",",
"walletState",
",",
"sendArg",
",",
"true",
")",
"\n",
"}"
] | // SendPaymentCLI sends XLM from CLI. | [
"SendPaymentCLI",
"sends",
"XLM",
"from",
"CLI",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L519-L521 |
158,603 | keybase/client | go/stellar/stellar.go | SendPaymentGUI | func SendPaymentGUI(m libkb.MetaContext, walletState *WalletState, sendArg SendPaymentArg) (res SendPaymentResult, err error) {
return sendPayment(m, walletState, sendArg, false)
} | go | func SendPaymentGUI(m libkb.MetaContext, walletState *WalletState, sendArg SendPaymentArg) (res SendPaymentResult, err error) {
return sendPayment(m, walletState, sendArg, false)
} | [
"func",
"SendPaymentGUI",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"walletState",
"*",
"WalletState",
",",
"sendArg",
"SendPaymentArg",
")",
"(",
"res",
"SendPaymentResult",
",",
"err",
"error",
")",
"{",
"return",
"sendPayment",
"(",
"m",
",",
"walletState",
",",
"sendArg",
",",
"false",
")",
"\n",
"}"
] | // SendPaymentGUI sends XLM from GUI. | [
"SendPaymentGUI",
"sends",
"XLM",
"from",
"GUI",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L524-L526 |
158,604 | keybase/client | go/stellar/stellar.go | SendPathPaymentCLI | func SendPathPaymentCLI(mctx libkb.MetaContext, walletState *WalletState, sendArg SendPathPaymentArg) (res SendPaymentResult, err error) {
return sendPathPayment(mctx, walletState, sendArg)
} | go | func SendPathPaymentCLI(mctx libkb.MetaContext, walletState *WalletState, sendArg SendPathPaymentArg) (res SendPaymentResult, err error) {
return sendPathPayment(mctx, walletState, sendArg)
} | [
"func",
"SendPathPaymentCLI",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"walletState",
"*",
"WalletState",
",",
"sendArg",
"SendPathPaymentArg",
")",
"(",
"res",
"SendPaymentResult",
",",
"err",
"error",
")",
"{",
"return",
"sendPathPayment",
"(",
"mctx",
",",
"walletState",
",",
"sendArg",
")",
"\n",
"}"
] | // SendPathPaymentCLI sends a path payment from CLI. | [
"SendPathPaymentCLI",
"sends",
"a",
"path",
"payment",
"from",
"CLI",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L709-L711 |
158,605 | keybase/client | go/stellar/stellar.go | SpecMiniChatPayments | func SpecMiniChatPayments(mctx libkb.MetaContext, walletState *WalletState, payments []libkb.MiniChatPayment) (*libkb.MiniChatPaymentSummary, error) {
// look up sender account
_, senderAccountBundle, err := LookupSenderPrimary(mctx)
if err != nil {
return nil, err
}
senderAccountID := senderAccountBundle.AccountID
senderCurrency, err := GetCurrencySetting(mctx, senderAccountID)
if err != nil {
return nil, err
}
senderRate, err := walletState.ExchangeRate(mctx.Ctx(), string(senderCurrency.Code))
if err != nil {
return nil, err
}
var summary libkb.MiniChatPaymentSummary
var xlmTotal int64
if len(payments) > 0 {
ch := make(chan indexedSpec)
for i, payment := range payments {
go func(payment libkb.MiniChatPayment, index int) {
spec, xlmAmountNumeric := specMiniChatPayment(mctx, walletState, payment)
ch <- indexedSpec{spec: spec, index: index, xlmAmountNumeric: xlmAmountNumeric}
}(payment, i)
}
summary.Specs = make([]libkb.MiniChatPaymentSpec, len(payments))
for i := 0; i < len(payments); i++ {
ispec := <-ch
summary.Specs[ispec.index] = ispec.spec
xlmTotal += ispec.xlmAmountNumeric
}
}
summary.XLMTotal = stellarnet.StringFromStellarAmount(xlmTotal)
if senderRate.Currency != "" && senderRate.Currency != "XLM" {
outsideAmount, err := stellarnet.ConvertXLMToOutside(summary.XLMTotal, senderRate.Rate)
if err != nil {
return nil, err
}
summary.DisplayTotal, err = FormatCurrencyWithCodeSuffix(mctx, outsideAmount, senderRate.Currency, stellarnet.Round)
if err != nil {
return nil, err
}
}
summary.XLMTotal, err = FormatAmountDescriptionXLM(mctx, summary.XLMTotal)
if err != nil {
return nil, err
}
return &summary, nil
} | go | func SpecMiniChatPayments(mctx libkb.MetaContext, walletState *WalletState, payments []libkb.MiniChatPayment) (*libkb.MiniChatPaymentSummary, error) {
// look up sender account
_, senderAccountBundle, err := LookupSenderPrimary(mctx)
if err != nil {
return nil, err
}
senderAccountID := senderAccountBundle.AccountID
senderCurrency, err := GetCurrencySetting(mctx, senderAccountID)
if err != nil {
return nil, err
}
senderRate, err := walletState.ExchangeRate(mctx.Ctx(), string(senderCurrency.Code))
if err != nil {
return nil, err
}
var summary libkb.MiniChatPaymentSummary
var xlmTotal int64
if len(payments) > 0 {
ch := make(chan indexedSpec)
for i, payment := range payments {
go func(payment libkb.MiniChatPayment, index int) {
spec, xlmAmountNumeric := specMiniChatPayment(mctx, walletState, payment)
ch <- indexedSpec{spec: spec, index: index, xlmAmountNumeric: xlmAmountNumeric}
}(payment, i)
}
summary.Specs = make([]libkb.MiniChatPaymentSpec, len(payments))
for i := 0; i < len(payments); i++ {
ispec := <-ch
summary.Specs[ispec.index] = ispec.spec
xlmTotal += ispec.xlmAmountNumeric
}
}
summary.XLMTotal = stellarnet.StringFromStellarAmount(xlmTotal)
if senderRate.Currency != "" && senderRate.Currency != "XLM" {
outsideAmount, err := stellarnet.ConvertXLMToOutside(summary.XLMTotal, senderRate.Rate)
if err != nil {
return nil, err
}
summary.DisplayTotal, err = FormatCurrencyWithCodeSuffix(mctx, outsideAmount, senderRate.Currency, stellarnet.Round)
if err != nil {
return nil, err
}
}
summary.XLMTotal, err = FormatAmountDescriptionXLM(mctx, summary.XLMTotal)
if err != nil {
return nil, err
}
return &summary, nil
} | [
"func",
"SpecMiniChatPayments",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"walletState",
"*",
"WalletState",
",",
"payments",
"[",
"]",
"libkb",
".",
"MiniChatPayment",
")",
"(",
"*",
"libkb",
".",
"MiniChatPaymentSummary",
",",
"error",
")",
"{",
"// look up sender account",
"_",
",",
"senderAccountBundle",
",",
"err",
":=",
"LookupSenderPrimary",
"(",
"mctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"senderAccountID",
":=",
"senderAccountBundle",
".",
"AccountID",
"\n",
"senderCurrency",
",",
"err",
":=",
"GetCurrencySetting",
"(",
"mctx",
",",
"senderAccountID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"senderRate",
",",
"err",
":=",
"walletState",
".",
"ExchangeRate",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"string",
"(",
"senderCurrency",
".",
"Code",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"summary",
"libkb",
".",
"MiniChatPaymentSummary",
"\n\n",
"var",
"xlmTotal",
"int64",
"\n",
"if",
"len",
"(",
"payments",
")",
">",
"0",
"{",
"ch",
":=",
"make",
"(",
"chan",
"indexedSpec",
")",
"\n",
"for",
"i",
",",
"payment",
":=",
"range",
"payments",
"{",
"go",
"func",
"(",
"payment",
"libkb",
".",
"MiniChatPayment",
",",
"index",
"int",
")",
"{",
"spec",
",",
"xlmAmountNumeric",
":=",
"specMiniChatPayment",
"(",
"mctx",
",",
"walletState",
",",
"payment",
")",
"\n",
"ch",
"<-",
"indexedSpec",
"{",
"spec",
":",
"spec",
",",
"index",
":",
"index",
",",
"xlmAmountNumeric",
":",
"xlmAmountNumeric",
"}",
"\n",
"}",
"(",
"payment",
",",
"i",
")",
"\n",
"}",
"\n\n",
"summary",
".",
"Specs",
"=",
"make",
"(",
"[",
"]",
"libkb",
".",
"MiniChatPaymentSpec",
",",
"len",
"(",
"payments",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"payments",
")",
";",
"i",
"++",
"{",
"ispec",
":=",
"<-",
"ch",
"\n",
"summary",
".",
"Specs",
"[",
"ispec",
".",
"index",
"]",
"=",
"ispec",
".",
"spec",
"\n",
"xlmTotal",
"+=",
"ispec",
".",
"xlmAmountNumeric",
"\n",
"}",
"\n",
"}",
"\n\n",
"summary",
".",
"XLMTotal",
"=",
"stellarnet",
".",
"StringFromStellarAmount",
"(",
"xlmTotal",
")",
"\n",
"if",
"senderRate",
".",
"Currency",
"!=",
"\"",
"\"",
"&&",
"senderRate",
".",
"Currency",
"!=",
"\"",
"\"",
"{",
"outsideAmount",
",",
"err",
":=",
"stellarnet",
".",
"ConvertXLMToOutside",
"(",
"summary",
".",
"XLMTotal",
",",
"senderRate",
".",
"Rate",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"summary",
".",
"DisplayTotal",
",",
"err",
"=",
"FormatCurrencyWithCodeSuffix",
"(",
"mctx",
",",
"outsideAmount",
",",
"senderRate",
".",
"Currency",
",",
"stellarnet",
".",
"Round",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"summary",
".",
"XLMTotal",
",",
"err",
"=",
"FormatAmountDescriptionXLM",
"(",
"mctx",
",",
"summary",
".",
"XLMTotal",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"summary",
",",
"nil",
"\n",
"}"
] | // SpecMiniChatPayments returns a summary of the payment amounts for each recipient
// and a total. | [
"SpecMiniChatPayments",
"returns",
"a",
"summary",
"of",
"the",
"payment",
"amounts",
"for",
"each",
"recipient",
"and",
"a",
"total",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L831-L886 |
158,606 | keybase/client | go/stellar/stellar.go | Claim | func Claim(mctx libkb.MetaContext, walletState *WalletState,
txID string, into stellar1.AccountID, dir *stellar1.RelayDirection,
autoClaimToken *string) (res stellar1.RelayClaimResult, err error) {
defer mctx.TraceTimed("Stellar.Claim", func() error { return err })()
mctx.Debug("Stellar.Claim(txID:%v, into:%v, dir:%v, autoClaimToken:%v)", txID, into, dir, autoClaimToken)
details, err := walletState.PaymentDetailsGeneric(mctx.Ctx(), txID)
if err != nil {
return res, err
}
p := details.Summary
typ, err := p.Typ()
if err != nil {
return res, fmt.Errorf("error getting payment details: %v", err)
}
switch typ {
case stellar1.PaymentSummaryType_STELLAR:
return res, fmt.Errorf("Payment cannot be claimed. It was found on the Stellar network but not in Keybase.")
case stellar1.PaymentSummaryType_DIRECT:
p := p.Direct()
switch p.TxStatus {
case stellar1.TransactionStatus_SUCCESS:
return res, fmt.Errorf("Payment cannot be claimed. The direct transfer already happened.")
case stellar1.TransactionStatus_PENDING:
return res, fmt.Errorf("Payment cannot be claimed. It is currently pending.")
default:
return res, fmt.Errorf("Payment cannot be claimed. The payment failed anyway.")
}
case stellar1.PaymentSummaryType_RELAY:
return claimPaymentWithDetail(mctx, walletState, p.Relay(), into, dir)
default:
return res, fmt.Errorf("unrecognized payment type: %v", typ)
}
} | go | func Claim(mctx libkb.MetaContext, walletState *WalletState,
txID string, into stellar1.AccountID, dir *stellar1.RelayDirection,
autoClaimToken *string) (res stellar1.RelayClaimResult, err error) {
defer mctx.TraceTimed("Stellar.Claim", func() error { return err })()
mctx.Debug("Stellar.Claim(txID:%v, into:%v, dir:%v, autoClaimToken:%v)", txID, into, dir, autoClaimToken)
details, err := walletState.PaymentDetailsGeneric(mctx.Ctx(), txID)
if err != nil {
return res, err
}
p := details.Summary
typ, err := p.Typ()
if err != nil {
return res, fmt.Errorf("error getting payment details: %v", err)
}
switch typ {
case stellar1.PaymentSummaryType_STELLAR:
return res, fmt.Errorf("Payment cannot be claimed. It was found on the Stellar network but not in Keybase.")
case stellar1.PaymentSummaryType_DIRECT:
p := p.Direct()
switch p.TxStatus {
case stellar1.TransactionStatus_SUCCESS:
return res, fmt.Errorf("Payment cannot be claimed. The direct transfer already happened.")
case stellar1.TransactionStatus_PENDING:
return res, fmt.Errorf("Payment cannot be claimed. It is currently pending.")
default:
return res, fmt.Errorf("Payment cannot be claimed. The payment failed anyway.")
}
case stellar1.PaymentSummaryType_RELAY:
return claimPaymentWithDetail(mctx, walletState, p.Relay(), into, dir)
default:
return res, fmt.Errorf("unrecognized payment type: %v", typ)
}
} | [
"func",
"Claim",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"walletState",
"*",
"WalletState",
",",
"txID",
"string",
",",
"into",
"stellar1",
".",
"AccountID",
",",
"dir",
"*",
"stellar1",
".",
"RelayDirection",
",",
"autoClaimToken",
"*",
"string",
")",
"(",
"res",
"stellar1",
".",
"RelayClaimResult",
",",
"err",
"error",
")",
"{",
"defer",
"mctx",
".",
"TraceTimed",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"txID",
",",
"into",
",",
"dir",
",",
"autoClaimToken",
")",
"\n",
"details",
",",
"err",
":=",
"walletState",
".",
"PaymentDetailsGeneric",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"txID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n",
"p",
":=",
"details",
".",
"Summary",
"\n",
"typ",
",",
"err",
":=",
"p",
".",
"Typ",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"switch",
"typ",
"{",
"case",
"stellar1",
".",
"PaymentSummaryType_STELLAR",
":",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"case",
"stellar1",
".",
"PaymentSummaryType_DIRECT",
":",
"p",
":=",
"p",
".",
"Direct",
"(",
")",
"\n",
"switch",
"p",
".",
"TxStatus",
"{",
"case",
"stellar1",
".",
"TransactionStatus_SUCCESS",
":",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"case",
"stellar1",
".",
"TransactionStatus_PENDING",
":",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"default",
":",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"case",
"stellar1",
".",
"PaymentSummaryType_RELAY",
":",
"return",
"claimPaymentWithDetail",
"(",
"mctx",
",",
"walletState",
",",
"p",
".",
"Relay",
"(",
")",
",",
"into",
",",
"dir",
")",
"\n",
"default",
":",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"typ",
")",
"\n",
"}",
"\n",
"}"
] | // Claim claims a waiting relay.
// If `dir` is nil the direction is inferred. | [
"Claim",
"claims",
"a",
"waiting",
"relay",
".",
"If",
"dir",
"is",
"nil",
"the",
"direction",
"is",
"inferred",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L1260-L1292 |
158,607 | keybase/client | go/stellar/stellar.go | claimPaymentWithDetail | func claimPaymentWithDetail(mctx libkb.MetaContext, walletState *WalletState,
p stellar1.PaymentSummaryRelay, into stellar1.AccountID, dir *stellar1.RelayDirection) (res stellar1.RelayClaimResult, err error) {
if p.Claim != nil && p.Claim.TxStatus == stellar1.TransactionStatus_SUCCESS {
recipient, _, err := mctx.G().GetUPAKLoader().Load(libkb.NewLoadUserByUIDArg(mctx.Ctx(), mctx.G(), p.Claim.To.Uid))
if err != nil || recipient == nil {
return res, fmt.Errorf("Payment already claimed")
}
return res, fmt.Errorf("Payment already claimed by %v", recipient.GetName())
}
rsec, err := relays.DecryptB64(mctx, p.TeamID, p.BoxB64)
if err != nil {
return res, fmt.Errorf("error opening secret to claim: %v", err)
}
skey, _, _, err := libkb.ParseStellarSecretKey(rsec.Sk.SecureNoLogString())
if err != nil {
return res, fmt.Errorf("error using shared secret key: %v", err)
}
destinationFunded, err := isAccountFunded(mctx.Ctx(), walletState, into)
if err != nil {
return res, err
}
useDir := stellar1.RelayDirection_CLAIM
if dir == nil {
// Infer direction
if p.From.Uid.Equal(mctx.ActiveDevice().UID()) {
useDir = stellar1.RelayDirection_YANK
}
} else {
// Direction from caller
useDir = *dir
}
baseFee := walletState.BaseFee(mctx)
sp, unlock := NewClaimSeqnoProvider(mctx, walletState)
defer unlock()
tb, err := getTimeboundsForSending(mctx, walletState)
if err != nil {
return res, err
}
sig, err := stellarnet.RelocateTransaction(stellarnet.SeedStr(skey.SecureNoLogString()),
stellarnet.AddressStr(into.String()), destinationFunded, nil, sp, tb, baseFee)
if err != nil {
return res, fmt.Errorf("error building claim transaction: %v", err)
}
return walletState.SubmitRelayClaim(mctx.Ctx(), stellar1.RelayClaimPost{
KeybaseID: p.KbTxID,
Dir: useDir,
SignedTransaction: sig.Signed,
})
} | go | func claimPaymentWithDetail(mctx libkb.MetaContext, walletState *WalletState,
p stellar1.PaymentSummaryRelay, into stellar1.AccountID, dir *stellar1.RelayDirection) (res stellar1.RelayClaimResult, err error) {
if p.Claim != nil && p.Claim.TxStatus == stellar1.TransactionStatus_SUCCESS {
recipient, _, err := mctx.G().GetUPAKLoader().Load(libkb.NewLoadUserByUIDArg(mctx.Ctx(), mctx.G(), p.Claim.To.Uid))
if err != nil || recipient == nil {
return res, fmt.Errorf("Payment already claimed")
}
return res, fmt.Errorf("Payment already claimed by %v", recipient.GetName())
}
rsec, err := relays.DecryptB64(mctx, p.TeamID, p.BoxB64)
if err != nil {
return res, fmt.Errorf("error opening secret to claim: %v", err)
}
skey, _, _, err := libkb.ParseStellarSecretKey(rsec.Sk.SecureNoLogString())
if err != nil {
return res, fmt.Errorf("error using shared secret key: %v", err)
}
destinationFunded, err := isAccountFunded(mctx.Ctx(), walletState, into)
if err != nil {
return res, err
}
useDir := stellar1.RelayDirection_CLAIM
if dir == nil {
// Infer direction
if p.From.Uid.Equal(mctx.ActiveDevice().UID()) {
useDir = stellar1.RelayDirection_YANK
}
} else {
// Direction from caller
useDir = *dir
}
baseFee := walletState.BaseFee(mctx)
sp, unlock := NewClaimSeqnoProvider(mctx, walletState)
defer unlock()
tb, err := getTimeboundsForSending(mctx, walletState)
if err != nil {
return res, err
}
sig, err := stellarnet.RelocateTransaction(stellarnet.SeedStr(skey.SecureNoLogString()),
stellarnet.AddressStr(into.String()), destinationFunded, nil, sp, tb, baseFee)
if err != nil {
return res, fmt.Errorf("error building claim transaction: %v", err)
}
return walletState.SubmitRelayClaim(mctx.Ctx(), stellar1.RelayClaimPost{
KeybaseID: p.KbTxID,
Dir: useDir,
SignedTransaction: sig.Signed,
})
} | [
"func",
"claimPaymentWithDetail",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"walletState",
"*",
"WalletState",
",",
"p",
"stellar1",
".",
"PaymentSummaryRelay",
",",
"into",
"stellar1",
".",
"AccountID",
",",
"dir",
"*",
"stellar1",
".",
"RelayDirection",
")",
"(",
"res",
"stellar1",
".",
"RelayClaimResult",
",",
"err",
"error",
")",
"{",
"if",
"p",
".",
"Claim",
"!=",
"nil",
"&&",
"p",
".",
"Claim",
".",
"TxStatus",
"==",
"stellar1",
".",
"TransactionStatus_SUCCESS",
"{",
"recipient",
",",
"_",
",",
"err",
":=",
"mctx",
".",
"G",
"(",
")",
".",
"GetUPAKLoader",
"(",
")",
".",
"Load",
"(",
"libkb",
".",
"NewLoadUserByUIDArg",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"mctx",
".",
"G",
"(",
")",
",",
"p",
".",
"Claim",
".",
"To",
".",
"Uid",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"recipient",
"==",
"nil",
"{",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"recipient",
".",
"GetName",
"(",
")",
")",
"\n",
"}",
"\n",
"rsec",
",",
"err",
":=",
"relays",
".",
"DecryptB64",
"(",
"mctx",
",",
"p",
".",
"TeamID",
",",
"p",
".",
"BoxB64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"skey",
",",
"_",
",",
"_",
",",
"err",
":=",
"libkb",
".",
"ParseStellarSecretKey",
"(",
"rsec",
".",
"Sk",
".",
"SecureNoLogString",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"destinationFunded",
",",
"err",
":=",
"isAccountFunded",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"walletState",
",",
"into",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n",
"useDir",
":=",
"stellar1",
".",
"RelayDirection_CLAIM",
"\n",
"if",
"dir",
"==",
"nil",
"{",
"// Infer direction",
"if",
"p",
".",
"From",
".",
"Uid",
".",
"Equal",
"(",
"mctx",
".",
"ActiveDevice",
"(",
")",
".",
"UID",
"(",
")",
")",
"{",
"useDir",
"=",
"stellar1",
".",
"RelayDirection_YANK",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// Direction from caller",
"useDir",
"=",
"*",
"dir",
"\n",
"}",
"\n\n",
"baseFee",
":=",
"walletState",
".",
"BaseFee",
"(",
"mctx",
")",
"\n",
"sp",
",",
"unlock",
":=",
"NewClaimSeqnoProvider",
"(",
"mctx",
",",
"walletState",
")",
"\n",
"defer",
"unlock",
"(",
")",
"\n",
"tb",
",",
"err",
":=",
"getTimeboundsForSending",
"(",
"mctx",
",",
"walletState",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n",
"sig",
",",
"err",
":=",
"stellarnet",
".",
"RelocateTransaction",
"(",
"stellarnet",
".",
"SeedStr",
"(",
"skey",
".",
"SecureNoLogString",
"(",
")",
")",
",",
"stellarnet",
".",
"AddressStr",
"(",
"into",
".",
"String",
"(",
")",
")",
",",
"destinationFunded",
",",
"nil",
",",
"sp",
",",
"tb",
",",
"baseFee",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"walletState",
".",
"SubmitRelayClaim",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"stellar1",
".",
"RelayClaimPost",
"{",
"KeybaseID",
":",
"p",
".",
"KbTxID",
",",
"Dir",
":",
"useDir",
",",
"SignedTransaction",
":",
"sig",
".",
"Signed",
",",
"}",
")",
"\n",
"}"
] | // If `dir` is nil the direction is inferred. | [
"If",
"dir",
"is",
"nil",
"the",
"direction",
"is",
"inferred",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L1295-L1344 |
158,608 | keybase/client | go/stellar/stellar.go | assertAssetIsSane | func assertAssetIsSane(asset stellar1.Asset) error {
switch asset.Type {
case "credit_alphanum4", "credit_alphanum12":
case "alphanum4", "alphanum12": // These prefixes that are missing "credit_" shouldn't show up, but just to be on the safe side.
default:
return fmt.Errorf("unrecognized asset type: %v", asset.Type)
}
// Sanity check asset code very loosely. We know tighter bounds but there's no need to fail here.
if len(asset.Code) == 0 || len(asset.Code) >= 20 {
return fmt.Errorf("invalid asset code: %v", asset.Code)
}
return nil
} | go | func assertAssetIsSane(asset stellar1.Asset) error {
switch asset.Type {
case "credit_alphanum4", "credit_alphanum12":
case "alphanum4", "alphanum12": // These prefixes that are missing "credit_" shouldn't show up, but just to be on the safe side.
default:
return fmt.Errorf("unrecognized asset type: %v", asset.Type)
}
// Sanity check asset code very loosely. We know tighter bounds but there's no need to fail here.
if len(asset.Code) == 0 || len(asset.Code) >= 20 {
return fmt.Errorf("invalid asset code: %v", asset.Code)
}
return nil
} | [
"func",
"assertAssetIsSane",
"(",
"asset",
"stellar1",
".",
"Asset",
")",
"error",
"{",
"switch",
"asset",
".",
"Type",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"// These prefixes that are missing \"credit_\" shouldn't show up, but just to be on the safe side.",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"asset",
".",
"Type",
")",
"\n",
"}",
"\n",
"// Sanity check asset code very loosely. We know tighter bounds but there's no need to fail here.",
"if",
"len",
"(",
"asset",
".",
"Code",
")",
"==",
"0",
"||",
"len",
"(",
"asset",
".",
"Code",
")",
">=",
"20",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"asset",
".",
"Code",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Return an error if asset is completely outside of what we understand, like
// asset unknown types or unexpected length. | [
"Return",
"an",
"error",
"if",
"asset",
"is",
"completely",
"outside",
"of",
"what",
"we",
"understand",
"like",
"asset",
"unknown",
"types",
"or",
"unexpected",
"length",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L1638-L1650 |
158,609 | keybase/client | go/stellar/stellar.go | ChangeAccountName | func ChangeAccountName(m libkb.MetaContext, walletState *WalletState, accountID stellar1.AccountID, newName string) (err error) {
if newName == "" {
return fmt.Errorf("name required")
}
runes := utf8.RuneCountInString(newName)
if runes > AccountNameMaxRunes {
return fmt.Errorf("account name can be %v characters at the longest but was %v", AccountNameMaxRunes, runes)
}
b, err := remote.FetchSecretlessBundle(m)
if err != nil {
return err
}
var found bool
for i, acc := range b.Accounts {
if acc.AccountID.Eq(accountID) {
// Change Name in place to modify Account struct.
b.Accounts[i].Name = newName
found = true
} else if acc.Name == newName {
return fmt.Errorf("you already have an account with that name")
}
}
if !found {
return fmt.Errorf("account not found: %v", accountID)
}
nextBundle := bundle.AdvanceBundle(*b)
if err := remote.Post(m, nextBundle); err != nil {
return err
}
return walletState.UpdateAccountEntriesWithBundle(m, "change account name", &nextBundle)
} | go | func ChangeAccountName(m libkb.MetaContext, walletState *WalletState, accountID stellar1.AccountID, newName string) (err error) {
if newName == "" {
return fmt.Errorf("name required")
}
runes := utf8.RuneCountInString(newName)
if runes > AccountNameMaxRunes {
return fmt.Errorf("account name can be %v characters at the longest but was %v", AccountNameMaxRunes, runes)
}
b, err := remote.FetchSecretlessBundle(m)
if err != nil {
return err
}
var found bool
for i, acc := range b.Accounts {
if acc.AccountID.Eq(accountID) {
// Change Name in place to modify Account struct.
b.Accounts[i].Name = newName
found = true
} else if acc.Name == newName {
return fmt.Errorf("you already have an account with that name")
}
}
if !found {
return fmt.Errorf("account not found: %v", accountID)
}
nextBundle := bundle.AdvanceBundle(*b)
if err := remote.Post(m, nextBundle); err != nil {
return err
}
return walletState.UpdateAccountEntriesWithBundle(m, "change account name", &nextBundle)
} | [
"func",
"ChangeAccountName",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"walletState",
"*",
"WalletState",
",",
"accountID",
"stellar1",
".",
"AccountID",
",",
"newName",
"string",
")",
"(",
"err",
"error",
")",
"{",
"if",
"newName",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"runes",
":=",
"utf8",
".",
"RuneCountInString",
"(",
"newName",
")",
"\n",
"if",
"runes",
">",
"AccountNameMaxRunes",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"AccountNameMaxRunes",
",",
"runes",
")",
"\n",
"}",
"\n",
"b",
",",
"err",
":=",
"remote",
".",
"FetchSecretlessBundle",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"var",
"found",
"bool",
"\n",
"for",
"i",
",",
"acc",
":=",
"range",
"b",
".",
"Accounts",
"{",
"if",
"acc",
".",
"AccountID",
".",
"Eq",
"(",
"accountID",
")",
"{",
"// Change Name in place to modify Account struct.",
"b",
".",
"Accounts",
"[",
"i",
"]",
".",
"Name",
"=",
"newName",
"\n",
"found",
"=",
"true",
"\n",
"}",
"else",
"if",
"acc",
".",
"Name",
"==",
"newName",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"found",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"accountID",
")",
"\n",
"}",
"\n",
"nextBundle",
":=",
"bundle",
".",
"AdvanceBundle",
"(",
"*",
"b",
")",
"\n",
"if",
"err",
":=",
"remote",
".",
"Post",
"(",
"m",
",",
"nextBundle",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"walletState",
".",
"UpdateAccountEntriesWithBundle",
"(",
"m",
",",
"\"",
"\"",
",",
"&",
"nextBundle",
")",
"\n",
"}"
] | // ChangeAccountName changes the name of an account.
// Make sure to keep this in sync with ValidateAccountNameLocal.
// An empty name is not allowed.
// Renaming an account to an already used name is blocked.
// Maximum length of AccountNameMaxRunes runes. | [
"ChangeAccountName",
"changes",
"the",
"name",
"of",
"an",
"account",
".",
"Make",
"sure",
"to",
"keep",
"this",
"in",
"sync",
"with",
"ValidateAccountNameLocal",
".",
"An",
"empty",
"name",
"is",
"not",
"allowed",
".",
"Renaming",
"an",
"account",
"to",
"an",
"already",
"used",
"name",
"is",
"blocked",
".",
"Maximum",
"length",
"of",
"AccountNameMaxRunes",
"runes",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L1746-L1777 |
158,610 | keybase/client | go/stellar/stellar.go | AccountExchangeRate | func AccountExchangeRate(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.OutsideExchangeRate, error) {
currency, err := GetCurrencySetting(mctx, accountID)
if err != nil {
return stellar1.OutsideExchangeRate{}, err
}
return remoter.ExchangeRate(mctx.Ctx(), string(currency.Code))
} | go | func AccountExchangeRate(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.OutsideExchangeRate, error) {
currency, err := GetCurrencySetting(mctx, accountID)
if err != nil {
return stellar1.OutsideExchangeRate{}, err
}
return remoter.ExchangeRate(mctx.Ctx(), string(currency.Code))
} | [
"func",
"AccountExchangeRate",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"remoter",
"remote",
".",
"Remoter",
",",
"accountID",
"stellar1",
".",
"AccountID",
")",
"(",
"stellar1",
".",
"OutsideExchangeRate",
",",
"error",
")",
"{",
"currency",
",",
"err",
":=",
"GetCurrencySetting",
"(",
"mctx",
",",
"accountID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"stellar1",
".",
"OutsideExchangeRate",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"remoter",
".",
"ExchangeRate",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"string",
"(",
"currency",
".",
"Code",
")",
")",
"\n",
"}"
] | // AccountExchangeRate returns the exchange rate for an account for the logged in user.
// Note that it is possible that multiple users can own the same account and have
// different display currency preferences. | [
"AccountExchangeRate",
"returns",
"the",
"exchange",
"rate",
"for",
"an",
"account",
"for",
"the",
"logged",
"in",
"user",
".",
"Note",
"that",
"it",
"is",
"possible",
"that",
"multiple",
"users",
"can",
"own",
"the",
"same",
"account",
"and",
"have",
"different",
"display",
"currency",
"preferences",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L2096-L2103 |
158,611 | keybase/client | go/stellar/stellar.go | WalletAccount | func WalletAccount(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.WalletAccountLocal, error) {
bundle, err := remote.FetchSecretlessBundle(mctx)
if err != nil {
return stellar1.WalletAccountLocal{}, err
}
entry, err := bundle.Lookup(accountID)
if err != nil {
return stellar1.WalletAccountLocal{}, err
}
return accountLocal(mctx, remoter, entry)
} | go | func WalletAccount(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.WalletAccountLocal, error) {
bundle, err := remote.FetchSecretlessBundle(mctx)
if err != nil {
return stellar1.WalletAccountLocal{}, err
}
entry, err := bundle.Lookup(accountID)
if err != nil {
return stellar1.WalletAccountLocal{}, err
}
return accountLocal(mctx, remoter, entry)
} | [
"func",
"WalletAccount",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"remoter",
"remote",
".",
"Remoter",
",",
"accountID",
"stellar1",
".",
"AccountID",
")",
"(",
"stellar1",
".",
"WalletAccountLocal",
",",
"error",
")",
"{",
"bundle",
",",
"err",
":=",
"remote",
".",
"FetchSecretlessBundle",
"(",
"mctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"stellar1",
".",
"WalletAccountLocal",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"entry",
",",
"err",
":=",
"bundle",
".",
"Lookup",
"(",
"accountID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"stellar1",
".",
"WalletAccountLocal",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"accountLocal",
"(",
"mctx",
",",
"remoter",
",",
"entry",
")",
"\n",
"}"
] | // WalletAccount returns stellar1.WalletAccountLocal for accountID. | [
"WalletAccount",
"returns",
"stellar1",
".",
"WalletAccountLocal",
"for",
"accountID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L2209-L2220 |
158,612 | keybase/client | go/stellar/stellar.go | AccountDetails | func AccountDetails(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.AccountDetails, error) {
details, err := remoter.Details(mctx.Ctx(), accountID)
details.SetDefaultDisplayCurrency()
if err != nil {
return details, err
}
err = mctx.G().GetStellar().UpdateUnreadCount(mctx.Ctx(), accountID, details.UnreadPayments)
if err != nil {
mctx.Debug("AccountDetails UpdateUnreadCount error: %s", err)
}
return details, nil
} | go | func AccountDetails(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.AccountDetails, error) {
details, err := remoter.Details(mctx.Ctx(), accountID)
details.SetDefaultDisplayCurrency()
if err != nil {
return details, err
}
err = mctx.G().GetStellar().UpdateUnreadCount(mctx.Ctx(), accountID, details.UnreadPayments)
if err != nil {
mctx.Debug("AccountDetails UpdateUnreadCount error: %s", err)
}
return details, nil
} | [
"func",
"AccountDetails",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"remoter",
"remote",
".",
"Remoter",
",",
"accountID",
"stellar1",
".",
"AccountID",
")",
"(",
"stellar1",
".",
"AccountDetails",
",",
"error",
")",
"{",
"details",
",",
"err",
":=",
"remoter",
".",
"Details",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"accountID",
")",
"\n",
"details",
".",
"SetDefaultDisplayCurrency",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"details",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"mctx",
".",
"G",
"(",
")",
".",
"GetStellar",
"(",
")",
".",
"UpdateUnreadCount",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"accountID",
",",
"details",
".",
"UnreadPayments",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"details",
",",
"nil",
"\n",
"}"
] | // AccountDetails gets stellar1.AccountDetails for accountID.
//
// It has the side effect of updating the badge state with the
// stellar payment unread count for accountID. | [
"AccountDetails",
"gets",
"stellar1",
".",
"AccountDetails",
"for",
"accountID",
".",
"It",
"has",
"the",
"side",
"effect",
"of",
"updating",
"the",
"badge",
"state",
"with",
"the",
"stellar",
"payment",
"unread",
"count",
"for",
"accountID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L2241-L2254 |
158,613 | keybase/client | go/client/terminal.go | GetSize | func (t *Terminal) GetSize() (int, int) {
if err := t.open(); err != nil {
return 80, 24
}
return t.engine.Size()
} | go | func (t *Terminal) GetSize() (int, int) {
if err := t.open(); err != nil {
return 80, 24
}
return t.engine.Size()
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"GetSize",
"(",
")",
"(",
"int",
",",
"int",
")",
"{",
"if",
"err",
":=",
"t",
".",
"open",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"80",
",",
"24",
"\n",
"}",
"\n",
"return",
"t",
".",
"engine",
".",
"Size",
"(",
")",
"\n",
"}"
] | // GetSize tries to get the size for the current terminal.
// It if fails it returns 80x24 | [
"GetSize",
"tries",
"to",
"get",
"the",
"size",
"for",
"the",
"current",
"terminal",
".",
"It",
"if",
"fails",
"it",
"returns",
"80x24"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/terminal.go#L113-L118 |
158,614 | keybase/client | go/kbfs/libfuse/quarantine_darwin.go | NewQuarantineXattrHandler | func NewQuarantineXattrHandler(node libkbfs.Node, folder *Folder,
) XattrHandler {
return &QuarantineXattrHandler{
node: node,
folder: folder,
}
} | go | func NewQuarantineXattrHandler(node libkbfs.Node, folder *Folder,
) XattrHandler {
return &QuarantineXattrHandler{
node: node,
folder: folder,
}
} | [
"func",
"NewQuarantineXattrHandler",
"(",
"node",
"libkbfs",
".",
"Node",
",",
"folder",
"*",
"Folder",
",",
")",
"XattrHandler",
"{",
"return",
"&",
"QuarantineXattrHandler",
"{",
"node",
":",
"node",
",",
"folder",
":",
"folder",
",",
"}",
"\n",
"}"
] | // NewQuarantineXattrHandler returns a handler that handles
// com.apple.quarantine, but returns fuse.ENOTSUP for all other xattrs. | [
"NewQuarantineXattrHandler",
"returns",
"a",
"handler",
"that",
"handles",
"com",
".",
"apple",
".",
"quarantine",
"but",
"returns",
"fuse",
".",
"ENOTSUP",
"for",
"all",
"other",
"xattrs",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/quarantine_darwin.go#L52-L58 |
158,615 | keybase/client | go/kbfs/libkbfs/disk_journal.go | makeDiskJournal | func makeDiskJournal(
codec kbfscodec.Codec, dir string, entryType reflect.Type) (
*diskJournal, error) {
j := &diskJournal{
codec: codec,
dir: dir,
entryType: entryType,
}
earliest, err := j.readEarliestOrdinalFromDisk()
if ioutil.IsNotExist(err) {
// Continue with j.earliestValid = false.
} else if err != nil {
return nil, err
} else {
j.earliestValid = true
j.earliest = earliest
}
latest, err := j.readLatestOrdinalFromDisk()
if ioutil.IsNotExist(err) {
// Continue with j.latestValid = false.
} else if err != nil {
return nil, err
} else {
j.latestValid = true
j.latest = latest
}
return j, nil
} | go | func makeDiskJournal(
codec kbfscodec.Codec, dir string, entryType reflect.Type) (
*diskJournal, error) {
j := &diskJournal{
codec: codec,
dir: dir,
entryType: entryType,
}
earliest, err := j.readEarliestOrdinalFromDisk()
if ioutil.IsNotExist(err) {
// Continue with j.earliestValid = false.
} else if err != nil {
return nil, err
} else {
j.earliestValid = true
j.earliest = earliest
}
latest, err := j.readLatestOrdinalFromDisk()
if ioutil.IsNotExist(err) {
// Continue with j.latestValid = false.
} else if err != nil {
return nil, err
} else {
j.latestValid = true
j.latest = latest
}
return j, nil
} | [
"func",
"makeDiskJournal",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"dir",
"string",
",",
"entryType",
"reflect",
".",
"Type",
")",
"(",
"*",
"diskJournal",
",",
"error",
")",
"{",
"j",
":=",
"&",
"diskJournal",
"{",
"codec",
":",
"codec",
",",
"dir",
":",
"dir",
",",
"entryType",
":",
"entryType",
",",
"}",
"\n\n",
"earliest",
",",
"err",
":=",
"j",
".",
"readEarliestOrdinalFromDisk",
"(",
")",
"\n",
"if",
"ioutil",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"// Continue with j.earliestValid = false.",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"else",
"{",
"j",
".",
"earliestValid",
"=",
"true",
"\n",
"j",
".",
"earliest",
"=",
"earliest",
"\n",
"}",
"\n\n",
"latest",
",",
"err",
":=",
"j",
".",
"readLatestOrdinalFromDisk",
"(",
")",
"\n",
"if",
"ioutil",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"// Continue with j.latestValid = false.",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"else",
"{",
"j",
".",
"latestValid",
"=",
"true",
"\n",
"j",
".",
"latest",
"=",
"latest",
"\n",
"}",
"\n\n",
"return",
"j",
",",
"nil",
"\n",
"}"
] | // makeDiskJournal returns a new diskJournal for the given directory. | [
"makeDiskJournal",
"returns",
"a",
"new",
"diskJournal",
"for",
"the",
"given",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_journal.go#L80-L110 |
158,616 | keybase/client | go/kbfs/libkbfs/disk_journal.go | clear | func (j *diskJournal) clear() error {
// Clear ordinals first to not leave the journal in a weird
// state if we crash in the middle of removing the files,
// assuming that file removal is atomic.
err := ioutil.Remove(j.earliestPath())
if err != nil {
return err
}
// If we crash here, on the next startup the journal will
// still be considered empty.
j.earliestValid = false
j.earliest = journalOrdinal(0)
err = ioutil.Remove(j.latestPath())
if err != nil {
return err
}
j.latestValid = false
j.latest = journalOrdinal(0)
// j.dir will be recreated on the next call to
// writeJournalEntry (via kbfscodec.SerializeToFile), which
// must always come before any ordinal write.
return ioutil.RemoveAll(j.dir)
} | go | func (j *diskJournal) clear() error {
// Clear ordinals first to not leave the journal in a weird
// state if we crash in the middle of removing the files,
// assuming that file removal is atomic.
err := ioutil.Remove(j.earliestPath())
if err != nil {
return err
}
// If we crash here, on the next startup the journal will
// still be considered empty.
j.earliestValid = false
j.earliest = journalOrdinal(0)
err = ioutil.Remove(j.latestPath())
if err != nil {
return err
}
j.latestValid = false
j.latest = journalOrdinal(0)
// j.dir will be recreated on the next call to
// writeJournalEntry (via kbfscodec.SerializeToFile), which
// must always come before any ordinal write.
return ioutil.RemoveAll(j.dir)
} | [
"func",
"(",
"j",
"*",
"diskJournal",
")",
"clear",
"(",
")",
"error",
"{",
"// Clear ordinals first to not leave the journal in a weird",
"// state if we crash in the middle of removing the files,",
"// assuming that file removal is atomic.",
"err",
":=",
"ioutil",
".",
"Remove",
"(",
"j",
".",
"earliestPath",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// If we crash here, on the next startup the journal will",
"// still be considered empty.",
"j",
".",
"earliestValid",
"=",
"false",
"\n",
"j",
".",
"earliest",
"=",
"journalOrdinal",
"(",
"0",
")",
"\n\n",
"err",
"=",
"ioutil",
".",
"Remove",
"(",
"j",
".",
"latestPath",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"j",
".",
"latestValid",
"=",
"false",
"\n",
"j",
".",
"latest",
"=",
"journalOrdinal",
"(",
"0",
")",
"\n\n",
"// j.dir will be recreated on the next call to",
"// writeJournalEntry (via kbfscodec.SerializeToFile), which",
"// must always come before any ordinal write.",
"return",
"ioutil",
".",
"RemoveAll",
"(",
"j",
".",
"dir",
")",
"\n",
"}"
] | // clear completely removes the journal directory. | [
"clear",
"completely",
"removes",
"the",
"journal",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_journal.go#L193-L220 |
158,617 | keybase/client | go/kbfs/libkbfs/disk_journal.go | move | func (j *diskJournal) move(newDir string) (oldDir string, err error) {
err = ioutil.Rename(j.dir, newDir)
if err != nil && !ioutil.IsNotExist(err) {
return "", err
}
oldDir = j.dir
j.dir = newDir
return oldDir, nil
} | go | func (j *diskJournal) move(newDir string) (oldDir string, err error) {
err = ioutil.Rename(j.dir, newDir)
if err != nil && !ioutil.IsNotExist(err) {
return "", err
}
oldDir = j.dir
j.dir = newDir
return oldDir, nil
} | [
"func",
"(",
"j",
"*",
"diskJournal",
")",
"move",
"(",
"newDir",
"string",
")",
"(",
"oldDir",
"string",
",",
"err",
"error",
")",
"{",
"err",
"=",
"ioutil",
".",
"Rename",
"(",
"j",
".",
"dir",
",",
"newDir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"!",
"ioutil",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"oldDir",
"=",
"j",
".",
"dir",
"\n",
"j",
".",
"dir",
"=",
"newDir",
"\n",
"return",
"oldDir",
",",
"nil",
"\n",
"}"
] | // move moves the journal to the given directory, which should share
// the same parent directory as the current journal directory. | [
"move",
"moves",
"the",
"journal",
"to",
"the",
"given",
"directory",
"which",
"should",
"share",
"the",
"same",
"parent",
"directory",
"as",
"the",
"current",
"journal",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_journal.go#L333-L341 |
158,618 | keybase/client | go/protocol/keybase1/pgp.go | PGPPull | func (c PGPClient) PGPPull(ctx context.Context, __arg PGPPullArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpPull", []interface{}{__arg}, nil)
return
} | go | func (c PGPClient) PGPPull(ctx context.Context, __arg PGPPullArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpPull", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"PGPClient",
")",
"PGPPull",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"PGPPullArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Download PGP keys for tracked users and update the local GPG keyring.
// If usernames is nonempty, update only those users. | [
"Download",
"PGP",
"keys",
"for",
"tracked",
"users",
"and",
"update",
"the",
"local",
"GPG",
"keyring",
".",
"If",
"usernames",
"is",
"nonempty",
"update",
"only",
"those",
"users",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/pgp.go#L632-L635 |
158,619 | keybase/client | go/protocol/keybase1/pgp.go | PGPExport | func (c PGPClient) PGPExport(ctx context.Context, __arg PGPExportArg) (res []KeyInfo, err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpExport", []interface{}{__arg}, &res)
return
} | go | func (c PGPClient) PGPExport(ctx context.Context, __arg PGPExportArg) (res []KeyInfo, err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpExport", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"PGPClient",
")",
"PGPExport",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"PGPExportArg",
")",
"(",
"res",
"[",
"]",
"KeyInfo",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // Exports active PGP keys. Only allows armored export. | [
"Exports",
"active",
"PGP",
"keys",
".",
"Only",
"allows",
"armored",
"export",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/pgp.go#L658-L661 |
158,620 | keybase/client | go/protocol/keybase1/pgp.go | PGPSelect | func (c PGPClient) PGPSelect(ctx context.Context, __arg PGPSelectArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpSelect", []interface{}{__arg}, nil)
return
} | go | func (c PGPClient) PGPSelect(ctx context.Context, __arg PGPSelectArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpSelect", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"PGPClient",
")",
"PGPSelect",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"PGPSelectArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Select an existing key and add to Keybase. | [
"Select",
"an",
"existing",
"key",
"and",
"add",
"to",
"Keybase",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/pgp.go#L690-L693 |
158,621 | keybase/client | go/protocol/keybase1/pgp.go | PGPStorageDismiss | func (c PGPClient) PGPStorageDismiss(ctx context.Context, sessionID int) (err error) {
__arg := PGPStorageDismissArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpStorageDismiss", []interface{}{__arg}, nil)
return
} | go | func (c PGPClient) PGPStorageDismiss(ctx context.Context, sessionID int) (err error) {
__arg := PGPStorageDismissArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpStorageDismiss", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"PGPClient",
")",
"PGPStorageDismiss",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"err",
"error",
")",
"{",
"__arg",
":=",
"PGPStorageDismissArg",
"{",
"SessionID",
":",
"sessionID",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Dismiss the PGP unlock via secret_store_file notification. | [
"Dismiss",
"the",
"PGP",
"unlock",
"via",
"secret_store_file",
"notification",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/pgp.go#L707-L711 |
158,622 | keybase/client | go/protocol/keybase1/pgp.go | PGPPushPrivate | func (c PGPClient) PGPPushPrivate(ctx context.Context, __arg PGPPushPrivateArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpPushPrivate", []interface{}{__arg}, nil)
return
} | go | func (c PGPClient) PGPPushPrivate(ctx context.Context, __arg PGPPushPrivateArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpPushPrivate", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"PGPClient",
")",
"PGPPushPrivate",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"PGPPushPrivateArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // push the PGP key that matches the given fingerprints from GnuPG to KBFS. If it is empty, then
// push all matching PGP keys in the user's sigchain. | [
"push",
"the",
"PGP",
"key",
"that",
"matches",
"the",
"given",
"fingerprints",
"from",
"GnuPG",
"to",
"KBFS",
".",
"If",
"it",
"is",
"empty",
"then",
"push",
"all",
"matching",
"PGP",
"keys",
"in",
"the",
"user",
"s",
"sigchain",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/pgp.go#L715-L718 |
158,623 | keybase/client | go/protocol/keybase1/pgp.go | PGPPullPrivate | func (c PGPClient) PGPPullPrivate(ctx context.Context, __arg PGPPullPrivateArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpPullPrivate", []interface{}{__arg}, nil)
return
} | go | func (c PGPClient) PGPPullPrivate(ctx context.Context, __arg PGPPullPrivateArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.pgp.pgpPullPrivate", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"PGPClient",
")",
"PGPPullPrivate",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"PGPPullPrivateArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // pull the given PGP keys from KBFS to the local GnuPG keychain. If it is empty, then
// attempt to pull all matching PGP keys in the user's sigchain. | [
"pull",
"the",
"given",
"PGP",
"keys",
"from",
"KBFS",
"to",
"the",
"local",
"GnuPG",
"keychain",
".",
"If",
"it",
"is",
"empty",
"then",
"attempt",
"to",
"pull",
"all",
"matching",
"PGP",
"keys",
"in",
"the",
"user",
"s",
"sigchain",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/pgp.go#L722-L725 |
158,624 | keybase/client | go/service/pgp.go | PGPStorageDismiss | func (h *PGPHandler) PGPStorageDismiss(ctx context.Context, sessionID int) error {
username := h.G().Env.GetUsername()
if username.IsNil() {
return libkb.NewNoUsernameError()
}
key := libkb.DbKeyNotificationDismiss(libkb.NotificationDismissPGPPrefix, username)
return h.G().LocalDb.PutRaw(key, []byte(libkb.NotificationDismissPGPValue))
} | go | func (h *PGPHandler) PGPStorageDismiss(ctx context.Context, sessionID int) error {
username := h.G().Env.GetUsername()
if username.IsNil() {
return libkb.NewNoUsernameError()
}
key := libkb.DbKeyNotificationDismiss(libkb.NotificationDismissPGPPrefix, username)
return h.G().LocalDb.PutRaw(key, []byte(libkb.NotificationDismissPGPValue))
} | [
"func",
"(",
"h",
"*",
"PGPHandler",
")",
"PGPStorageDismiss",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"error",
"{",
"username",
":=",
"h",
".",
"G",
"(",
")",
".",
"Env",
".",
"GetUsername",
"(",
")",
"\n",
"if",
"username",
".",
"IsNil",
"(",
")",
"{",
"return",
"libkb",
".",
"NewNoUsernameError",
"(",
")",
"\n",
"}",
"\n\n",
"key",
":=",
"libkb",
".",
"DbKeyNotificationDismiss",
"(",
"libkb",
".",
"NotificationDismissPGPPrefix",
",",
"username",
")",
"\n",
"return",
"h",
".",
"G",
"(",
")",
".",
"LocalDb",
".",
"PutRaw",
"(",
"key",
",",
"[",
"]",
"byte",
"(",
"libkb",
".",
"NotificationDismissPGPValue",
")",
")",
"\n",
"}"
] | // Set the PGP storage notification dismiss flag in the local DB. | [
"Set",
"the",
"PGP",
"storage",
"notification",
"dismiss",
"flag",
"in",
"the",
"local",
"DB",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/pgp.go#L313-L321 |
158,625 | keybase/client | go/kbfs/libfs/mount_interrupter.go | NewMountInterrupter | func NewMountInterrupter(log logger.Logger) *MountInterrupter {
return &MountInterrupter{done: make(chan struct{}), log: log}
} | go | func NewMountInterrupter(log logger.Logger) *MountInterrupter {
return &MountInterrupter{done: make(chan struct{}), log: log}
} | [
"func",
"NewMountInterrupter",
"(",
"log",
"logger",
".",
"Logger",
")",
"*",
"MountInterrupter",
"{",
"return",
"&",
"MountInterrupter",
"{",
"done",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"log",
":",
"log",
"}",
"\n",
"}"
] | // NewMountInterrupter creates a new MountInterrupter. | [
"NewMountInterrupter",
"creates",
"a",
"new",
"MountInterrupter",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/mount_interrupter.go#L33-L35 |
158,626 | keybase/client | go/kbfs/libfs/mount_interrupter.go | MountAndSetUnmount | func (mi *MountInterrupter) MountAndSetUnmount(mounter Mounter) error {
mi.log.Debug("Starting to mount the filesystem")
mi.Lock()
defer mi.Unlock()
select {
case <-mi.done:
return errors.New("MountInterrupter already done")
default:
}
err := mounter.Mount()
if err != nil {
mi.log.Errorf("Mounting the filesystem failed: %v", err)
return err
}
mi.fun = mounter.Unmount
mi.log.Info("Mounting the filesystem was a success")
return nil
} | go | func (mi *MountInterrupter) MountAndSetUnmount(mounter Mounter) error {
mi.log.Debug("Starting to mount the filesystem")
mi.Lock()
defer mi.Unlock()
select {
case <-mi.done:
return errors.New("MountInterrupter already done")
default:
}
err := mounter.Mount()
if err != nil {
mi.log.Errorf("Mounting the filesystem failed: %v", err)
return err
}
mi.fun = mounter.Unmount
mi.log.Info("Mounting the filesystem was a success")
return nil
} | [
"func",
"(",
"mi",
"*",
"MountInterrupter",
")",
"MountAndSetUnmount",
"(",
"mounter",
"Mounter",
")",
"error",
"{",
"mi",
".",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"mi",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mi",
".",
"Unlock",
"(",
")",
"\n",
"select",
"{",
"case",
"<-",
"mi",
".",
"done",
":",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"default",
":",
"}",
"\n",
"err",
":=",
"mounter",
".",
"Mount",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"mi",
".",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"mi",
".",
"fun",
"=",
"mounter",
".",
"Unmount",
"\n",
"mi",
".",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // MountAndSetUnmount calls Mount and sets the unmount function
// to be called once if mount succeeds.
// If Done has already been called MountAndSetUnmount returns
// an error. | [
"MountAndSetUnmount",
"calls",
"Mount",
"and",
"sets",
"the",
"unmount",
"function",
"to",
"be",
"called",
"once",
"if",
"mount",
"succeeds",
".",
"If",
"Done",
"has",
"already",
"been",
"called",
"MountAndSetUnmount",
"returns",
"an",
"error",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/mount_interrupter.go#L41-L58 |
158,627 | keybase/client | go/kbfs/libfs/mount_interrupter.go | Done | func (mi *MountInterrupter) Done() error {
mi.Lock()
defer mi.Unlock()
if mi.fun != nil {
err := mi.fun()
if err != nil {
mi.log.Errorf("Mount interrupter callback failed: %v", err)
return err
}
}
mi.once.Do(func() {
close(mi.done)
})
return nil
} | go | func (mi *MountInterrupter) Done() error {
mi.Lock()
defer mi.Unlock()
if mi.fun != nil {
err := mi.fun()
if err != nil {
mi.log.Errorf("Mount interrupter callback failed: %v", err)
return err
}
}
mi.once.Do(func() {
close(mi.done)
})
return nil
} | [
"func",
"(",
"mi",
"*",
"MountInterrupter",
")",
"Done",
"(",
")",
"error",
"{",
"mi",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mi",
".",
"Unlock",
"(",
")",
"\n",
"if",
"mi",
".",
"fun",
"!=",
"nil",
"{",
"err",
":=",
"mi",
".",
"fun",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"mi",
".",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"mi",
".",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"mi",
".",
"done",
")",
"\n",
"}",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Done signals Wait and runs the unmounter if set by MountAndSetUnmount.
// It can be called multiple times with no harm. Each call triggers a call to
// the unmounter. | [
"Done",
"signals",
"Wait",
"and",
"runs",
"the",
"unmounter",
"if",
"set",
"by",
"MountAndSetUnmount",
".",
"It",
"can",
"be",
"called",
"multiple",
"times",
"with",
"no",
"harm",
".",
"Each",
"call",
"triggers",
"a",
"call",
"to",
"the",
"unmounter",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/mount_interrupter.go#L63-L77 |
158,628 | keybase/client | go/kbfs/simplefs/simplefs.go | ToStatus | func (e simpleFSError) ToStatus() keybase1.Status {
return keybase1.Status{
Name: e.reason,
Code: int(keybase1.StatusCode_SCGeneric),
Desc: e.Error(),
}
} | go | func (e simpleFSError) ToStatus() keybase1.Status {
return keybase1.Status{
Name: e.reason,
Code: int(keybase1.StatusCode_SCGeneric),
Desc: e.Error(),
}
} | [
"func",
"(",
"e",
"simpleFSError",
")",
"ToStatus",
"(",
")",
"keybase1",
".",
"Status",
"{",
"return",
"keybase1",
".",
"Status",
"{",
"Name",
":",
"e",
".",
"reason",
",",
"Code",
":",
"int",
"(",
"keybase1",
".",
"StatusCode_SCGeneric",
")",
",",
"Desc",
":",
"e",
".",
"Error",
"(",
")",
",",
"}",
"\n",
"}"
] | // ToStatus implements the keybase1.ToStatusAble interface for simpleFSError | [
"ToStatus",
"implements",
"the",
"keybase1",
".",
"ToStatusAble",
"interface",
"for",
"simpleFSError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L60-L66 |
158,629 | keybase/client | go/kbfs/simplefs/simplefs.go | NewSimpleFS | func NewSimpleFS(appStateUpdater env.AppStateUpdater, config libkbfs.Config) keybase1.SimpleFSInterface {
return newSimpleFS(appStateUpdater, config)
} | go | func NewSimpleFS(appStateUpdater env.AppStateUpdater, config libkbfs.Config) keybase1.SimpleFSInterface {
return newSimpleFS(appStateUpdater, config)
} | [
"func",
"NewSimpleFS",
"(",
"appStateUpdater",
"env",
".",
"AppStateUpdater",
",",
"config",
"libkbfs",
".",
"Config",
")",
"keybase1",
".",
"SimpleFSInterface",
"{",
"return",
"newSimpleFS",
"(",
"appStateUpdater",
",",
"config",
")",
"\n",
"}"
] | // NewSimpleFS creates a new SimpleFS instance. | [
"NewSimpleFS",
"creates",
"a",
"new",
"SimpleFS",
"instance",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L157-L159 |
158,630 | keybase/client | go/kbfs/simplefs/simplefs.go | remoteTlfAndPath | func remoteTlfAndPath(path keybase1.Path) (
t tlf.Type, tlfName, middlePath, finalElem string, err error) {
ps, err := splitPathFromKbfsPath(path)
if err != nil {
return tlf.Private, "", "", "", err
}
switch {
case len(ps) < 2:
return tlf.Private, "", "", "", errInvalidRemotePath
case ps[0] == `private`:
t = tlf.Private
case ps[0] == `public`:
t = tlf.Public
case ps[0] == `team`:
t = tlf.SingleTeam
default:
return tlf.Private, "", "", "", errInvalidRemotePath
}
if len(ps) >= 3 {
finalElem = ps[len(ps)-1]
middlePath = stdpath.Join(ps[2 : len(ps)-1]...)
}
return t, ps[1], middlePath, finalElem, nil
} | go | func remoteTlfAndPath(path keybase1.Path) (
t tlf.Type, tlfName, middlePath, finalElem string, err error) {
ps, err := splitPathFromKbfsPath(path)
if err != nil {
return tlf.Private, "", "", "", err
}
switch {
case len(ps) < 2:
return tlf.Private, "", "", "", errInvalidRemotePath
case ps[0] == `private`:
t = tlf.Private
case ps[0] == `public`:
t = tlf.Public
case ps[0] == `team`:
t = tlf.SingleTeam
default:
return tlf.Private, "", "", "", errInvalidRemotePath
}
if len(ps) >= 3 {
finalElem = ps[len(ps)-1]
middlePath = stdpath.Join(ps[2 : len(ps)-1]...)
}
return t, ps[1], middlePath, finalElem, nil
} | [
"func",
"remoteTlfAndPath",
"(",
"path",
"keybase1",
".",
"Path",
")",
"(",
"t",
"tlf",
".",
"Type",
",",
"tlfName",
",",
"middlePath",
",",
"finalElem",
"string",
",",
"err",
"error",
")",
"{",
"ps",
",",
"err",
":=",
"splitPathFromKbfsPath",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"tlf",
".",
"Private",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"switch",
"{",
"case",
"len",
"(",
"ps",
")",
"<",
"2",
":",
"return",
"tlf",
".",
"Private",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"errInvalidRemotePath",
"\n",
"case",
"ps",
"[",
"0",
"]",
"==",
"`private`",
":",
"t",
"=",
"tlf",
".",
"Private",
"\n",
"case",
"ps",
"[",
"0",
"]",
"==",
"`public`",
":",
"t",
"=",
"tlf",
".",
"Public",
"\n",
"case",
"ps",
"[",
"0",
"]",
"==",
"`team`",
":",
"t",
"=",
"tlf",
".",
"SingleTeam",
"\n",
"default",
":",
"return",
"tlf",
".",
"Private",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"errInvalidRemotePath",
"\n",
"}",
"\n",
"if",
"len",
"(",
"ps",
")",
">=",
"3",
"{",
"finalElem",
"=",
"ps",
"[",
"len",
"(",
"ps",
")",
"-",
"1",
"]",
"\n",
"middlePath",
"=",
"stdpath",
".",
"Join",
"(",
"ps",
"[",
"2",
":",
"len",
"(",
"ps",
")",
"-",
"1",
"]",
"...",
")",
"\n",
"}",
"\n",
"return",
"t",
",",
"ps",
"[",
"1",
"]",
",",
"middlePath",
",",
"finalElem",
",",
"nil",
"\n",
"}"
] | // remoteTlfAndPath decodes a remote path for us. | [
"remoteTlfAndPath",
"decodes",
"a",
"remote",
"path",
"for",
"us",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L193-L216 |
158,631 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSListRecursiveToDepth | func (k *SimpleFS) SimpleFSListRecursiveToDepth(ctx context.Context, arg keybase1.SimpleFSListRecursiveToDepthArg) error {
return k.startAsync(ctx, arg.OpID, keybase1.AsyncOps_LIST_RECURSIVE_TO_DEPTH,
keybase1.NewOpDescriptionWithListRecursiveToDepth(
keybase1.ListToDepthArgs{
OpID: arg.OpID, Path: arg.Path, Filter: arg.Filter, Depth: arg.Depth,
}),
k.listRecursiveToDepth(arg.OpID, arg.Path, arg.Filter, arg.Depth, arg.RefreshSubscription),
)
} | go | func (k *SimpleFS) SimpleFSListRecursiveToDepth(ctx context.Context, arg keybase1.SimpleFSListRecursiveToDepthArg) error {
return k.startAsync(ctx, arg.OpID, keybase1.AsyncOps_LIST_RECURSIVE_TO_DEPTH,
keybase1.NewOpDescriptionWithListRecursiveToDepth(
keybase1.ListToDepthArgs{
OpID: arg.OpID, Path: arg.Path, Filter: arg.Filter, Depth: arg.Depth,
}),
k.listRecursiveToDepth(arg.OpID, arg.Path, arg.Filter, arg.Depth, arg.RefreshSubscription),
)
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSListRecursiveToDepth",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"SimpleFSListRecursiveToDepthArg",
")",
"error",
"{",
"return",
"k",
".",
"startAsync",
"(",
"ctx",
",",
"arg",
".",
"OpID",
",",
"keybase1",
".",
"AsyncOps_LIST_RECURSIVE_TO_DEPTH",
",",
"keybase1",
".",
"NewOpDescriptionWithListRecursiveToDepth",
"(",
"keybase1",
".",
"ListToDepthArgs",
"{",
"OpID",
":",
"arg",
".",
"OpID",
",",
"Path",
":",
"arg",
".",
"Path",
",",
"Filter",
":",
"arg",
".",
"Filter",
",",
"Depth",
":",
"arg",
".",
"Depth",
",",
"}",
")",
",",
"k",
".",
"listRecursiveToDepth",
"(",
"arg",
".",
"OpID",
",",
"arg",
".",
"Path",
",",
"arg",
".",
"Filter",
",",
"arg",
".",
"Depth",
",",
"arg",
".",
"RefreshSubscription",
")",
",",
")",
"\n",
"}"
] | // SimpleFSListRecursiveToDepth - Begin recursive list of items in directory at path up to a given depth. | [
"SimpleFSListRecursiveToDepth",
"-",
"Begin",
"recursive",
"list",
"of",
"items",
"in",
"directory",
"at",
"path",
"up",
"to",
"a",
"given",
"depth",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L838-L846 |
158,632 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSReadList | func (k *SimpleFS) SimpleFSReadList(_ context.Context, opid keybase1.OpID) (keybase1.SimpleFSListResult, error) {
k.lock.Lock()
res, _ := k.handles[opid]
var x interface{}
if res != nil {
x = res.async
res.async = nil
}
k.lock.Unlock()
lr, ok := x.(keybase1.SimpleFSListResult)
if !ok {
return keybase1.SimpleFSListResult{}, errNoResult
}
return lr, nil
} | go | func (k *SimpleFS) SimpleFSReadList(_ context.Context, opid keybase1.OpID) (keybase1.SimpleFSListResult, error) {
k.lock.Lock()
res, _ := k.handles[opid]
var x interface{}
if res != nil {
x = res.async
res.async = nil
}
k.lock.Unlock()
lr, ok := x.(keybase1.SimpleFSListResult)
if !ok {
return keybase1.SimpleFSListResult{}, errNoResult
}
return lr, nil
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSReadList",
"(",
"_",
"context",
".",
"Context",
",",
"opid",
"keybase1",
".",
"OpID",
")",
"(",
"keybase1",
".",
"SimpleFSListResult",
",",
"error",
")",
"{",
"k",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"res",
",",
"_",
":=",
"k",
".",
"handles",
"[",
"opid",
"]",
"\n",
"var",
"x",
"interface",
"{",
"}",
"\n",
"if",
"res",
"!=",
"nil",
"{",
"x",
"=",
"res",
".",
"async",
"\n",
"res",
".",
"async",
"=",
"nil",
"\n",
"}",
"\n",
"k",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"lr",
",",
"ok",
":=",
"x",
".",
"(",
"keybase1",
".",
"SimpleFSListResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"keybase1",
".",
"SimpleFSListResult",
"{",
"}",
",",
"errNoResult",
"\n",
"}",
"\n\n",
"return",
"lr",
",",
"nil",
"\n",
"}"
] | // SimpleFSReadList - Get list of Paths in progress. Can indicate status of pending
// to get more entries. | [
"SimpleFSReadList",
"-",
"Get",
"list",
"of",
"Paths",
"in",
"progress",
".",
"Can",
"indicate",
"status",
"of",
"pending",
"to",
"get",
"more",
"entries",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L861-L877 |
158,633 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSListFavorites | func (k *SimpleFS) SimpleFSListFavorites(ctx context.Context) (
keybase1.FavoritesResult, error) {
return k.config.KBFSOps().GetFavoritesAll(ctx)
} | go | func (k *SimpleFS) SimpleFSListFavorites(ctx context.Context) (
keybase1.FavoritesResult, error) {
return k.config.KBFSOps().GetFavoritesAll(ctx)
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSListFavorites",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"keybase1",
".",
"FavoritesResult",
",",
"error",
")",
"{",
"return",
"k",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"GetFavoritesAll",
"(",
"ctx",
")",
"\n",
"}"
] | // SimpleFSListFavorites lists the favorite, new,
// and ignored folders of the logged in user,
// getting its data from the KBFS Favorites cache. If the cache is stale,
// this will trigger a network request. | [
"SimpleFSListFavorites",
"lists",
"the",
"favorite",
"new",
"and",
"ignored",
"folders",
"of",
"the",
"logged",
"in",
"user",
"getting",
"its",
"data",
"from",
"the",
"KBFS",
"Favorites",
"cache",
".",
"If",
"the",
"cache",
"is",
"stale",
"this",
"will",
"trigger",
"a",
"network",
"request",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L883-L886 |
158,634 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSSymlink | func (k *SimpleFS) SimpleFSSymlink(ctx context.Context, arg keybase1.SimpleFSSymlinkArg) (err error) {
// This is not async.
ctx, err = k.startSyncOp(ctx, "Symlink", arg)
if err != nil {
return err
}
defer func() { k.doneSyncOp(ctx, err) }()
destFS, finalDestElem, err := k.getFS(ctx, arg.Link)
if err != nil {
return err
}
err = destFS.Symlink(arg.Target, finalDestElem)
return err
} | go | func (k *SimpleFS) SimpleFSSymlink(ctx context.Context, arg keybase1.SimpleFSSymlinkArg) (err error) {
// This is not async.
ctx, err = k.startSyncOp(ctx, "Symlink", arg)
if err != nil {
return err
}
defer func() { k.doneSyncOp(ctx, err) }()
destFS, finalDestElem, err := k.getFS(ctx, arg.Link)
if err != nil {
return err
}
err = destFS.Symlink(arg.Target, finalDestElem)
return err
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSSymlink",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"SimpleFSSymlinkArg",
")",
"(",
"err",
"error",
")",
"{",
"// This is not async.",
"ctx",
",",
"err",
"=",
"k",
".",
"startSyncOp",
"(",
"ctx",
",",
"\"",
"\"",
",",
"arg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"k",
".",
"doneSyncOp",
"(",
"ctx",
",",
"err",
")",
"}",
"(",
")",
"\n\n",
"destFS",
",",
"finalDestElem",
",",
"err",
":=",
"k",
".",
"getFS",
"(",
"ctx",
",",
"arg",
".",
"Link",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"destFS",
".",
"Symlink",
"(",
"arg",
".",
"Target",
",",
"finalDestElem",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // SimpleFSSymlink starts making a symlink of a file or directory | [
"SimpleFSSymlink",
"starts",
"making",
"a",
"symlink",
"of",
"a",
"file",
"or",
"directory"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L1054-L1069 |
158,635 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSGetRevisions | func (k *SimpleFS) SimpleFSGetRevisions(
ctx context.Context, arg keybase1.SimpleFSGetRevisionsArg) (err error) {
return k.startAsync(ctx, arg.OpID, keybase1.AsyncOps_GET_REVISIONS,
keybase1.NewOpDescriptionWithGetRevisions(
keybase1.GetRevisionsArgs{
OpID: arg.OpID,
Path: arg.Path,
SpanType: arg.SpanType,
}),
func(ctx context.Context) (err error) {
revs, err := k.doGetRevisions(ctx, arg.OpID, arg.Path, arg.SpanType)
if err != nil {
return err
}
k.setResult(arg.OpID, keybase1.GetRevisionsResult{
Revisions: revs,
// For don't set any progress indicators. If we decide we want
// to display partial results, we can fix this later.
})
return nil
})
} | go | func (k *SimpleFS) SimpleFSGetRevisions(
ctx context.Context, arg keybase1.SimpleFSGetRevisionsArg) (err error) {
return k.startAsync(ctx, arg.OpID, keybase1.AsyncOps_GET_REVISIONS,
keybase1.NewOpDescriptionWithGetRevisions(
keybase1.GetRevisionsArgs{
OpID: arg.OpID,
Path: arg.Path,
SpanType: arg.SpanType,
}),
func(ctx context.Context) (err error) {
revs, err := k.doGetRevisions(ctx, arg.OpID, arg.Path, arg.SpanType)
if err != nil {
return err
}
k.setResult(arg.OpID, keybase1.GetRevisionsResult{
Revisions: revs,
// For don't set any progress indicators. If we decide we want
// to display partial results, we can fix this later.
})
return nil
})
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSGetRevisions",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"SimpleFSGetRevisionsArg",
")",
"(",
"err",
"error",
")",
"{",
"return",
"k",
".",
"startAsync",
"(",
"ctx",
",",
"arg",
".",
"OpID",
",",
"keybase1",
".",
"AsyncOps_GET_REVISIONS",
",",
"keybase1",
".",
"NewOpDescriptionWithGetRevisions",
"(",
"keybase1",
".",
"GetRevisionsArgs",
"{",
"OpID",
":",
"arg",
".",
"OpID",
",",
"Path",
":",
"arg",
".",
"Path",
",",
"SpanType",
":",
"arg",
".",
"SpanType",
",",
"}",
")",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"revs",
",",
"err",
":=",
"k",
".",
"doGetRevisions",
"(",
"ctx",
",",
"arg",
".",
"OpID",
",",
"arg",
".",
"Path",
",",
"arg",
".",
"SpanType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"k",
".",
"setResult",
"(",
"arg",
".",
"OpID",
",",
"keybase1",
".",
"GetRevisionsResult",
"{",
"Revisions",
":",
"revs",
",",
"// For don't set any progress indicators. If we decide we want",
"// to display partial results, we can fix this later.",
"}",
")",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
] | // SimpleFSGetRevisions - Get revisions for a file | [
"SimpleFSGetRevisions",
"-",
"Get",
"revisions",
"for",
"a",
"file"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L1843-L1864 |
158,636 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSCancel | func (k *SimpleFS) SimpleFSCancel(_ context.Context, opid keybase1.OpID) error {
k.lock.Lock()
defer k.lock.Unlock()
delete(k.handles, opid)
w, ok := k.inProgress[opid]
if !ok {
return nil
}
delete(k.inProgress, opid)
w.cancel()
return nil
} | go | func (k *SimpleFS) SimpleFSCancel(_ context.Context, opid keybase1.OpID) error {
k.lock.Lock()
defer k.lock.Unlock()
delete(k.handles, opid)
w, ok := k.inProgress[opid]
if !ok {
return nil
}
delete(k.inProgress, opid)
w.cancel()
return nil
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSCancel",
"(",
"_",
"context",
".",
"Context",
",",
"opid",
"keybase1",
".",
"OpID",
")",
"error",
"{",
"k",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"k",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"k",
".",
"handles",
",",
"opid",
")",
"\n",
"w",
",",
"ok",
":=",
"k",
".",
"inProgress",
"[",
"opid",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"delete",
"(",
"k",
".",
"inProgress",
",",
"opid",
")",
"\n",
"w",
".",
"cancel",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // SimpleFSCancel starts to cancel op with the given opid.
// Also remove any pending references of opid everywhere.
// Returns before cancellation is guaranteeded to be done - that
// may take some time. Currently always returns nil. | [
"SimpleFSCancel",
"starts",
"to",
"cancel",
"op",
"with",
"the",
"given",
"opid",
".",
"Also",
"remove",
"any",
"pending",
"references",
"of",
"opid",
"everywhere",
".",
"Returns",
"before",
"cancellation",
"is",
"guaranteeded",
"to",
"be",
"done",
"-",
"that",
"may",
"take",
"some",
"time",
".",
"Currently",
"always",
"returns",
"nil",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L1924-L1935 |
158,637 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSCheck | func (k *SimpleFS) SimpleFSCheck(_ context.Context, opid keybase1.OpID) (keybase1.OpProgress, error) {
k.lock.RLock()
defer k.lock.RUnlock()
if p, ok := k.inProgress[opid]; ok {
// For now, estimate the ending time purely on the read progress.
var n, d int64
progress := p.progress
if progress.BytesTotal > 0 {
n = progress.BytesRead
d = progress.BytesTotal
} else if p.progress.FilesTotal > 0 {
n = progress.FilesRead
d = progress.FilesTotal
}
if n > 0 && d > 0 && !progress.Start.IsZero() &&
progress.EndEstimate.IsZero() {
// Crudely estimate that the total time for the op is the
// time spent so far, divided by the fraction of the
// reading that's been done.
start := keybase1.FromTime(progress.Start)
timeRunning := k.config.Clock().Now().Sub(start)
fracDone := float64(n) / float64(d)
totalTimeEstimate := time.Duration(float64(timeRunning) / fracDone)
progress.EndEstimate =
keybase1.ToTime(start.Add(totalTimeEstimate))
k.log.CDebugf(nil, "Start=%s, n=%d, d=%d, fracDone=%f, End=%s",
start, n, d, fracDone, start.Add(totalTimeEstimate))
}
return progress, nil
} else if _, ok := k.handles[opid]; ok {
// Return an empty progress and nil error if there's no async
// operation pending, but there is still an open handle.
return keybase1.OpProgress{}, nil
}
return keybase1.OpProgress{}, errNoResult
} | go | func (k *SimpleFS) SimpleFSCheck(_ context.Context, opid keybase1.OpID) (keybase1.OpProgress, error) {
k.lock.RLock()
defer k.lock.RUnlock()
if p, ok := k.inProgress[opid]; ok {
// For now, estimate the ending time purely on the read progress.
var n, d int64
progress := p.progress
if progress.BytesTotal > 0 {
n = progress.BytesRead
d = progress.BytesTotal
} else if p.progress.FilesTotal > 0 {
n = progress.FilesRead
d = progress.FilesTotal
}
if n > 0 && d > 0 && !progress.Start.IsZero() &&
progress.EndEstimate.IsZero() {
// Crudely estimate that the total time for the op is the
// time spent so far, divided by the fraction of the
// reading that's been done.
start := keybase1.FromTime(progress.Start)
timeRunning := k.config.Clock().Now().Sub(start)
fracDone := float64(n) / float64(d)
totalTimeEstimate := time.Duration(float64(timeRunning) / fracDone)
progress.EndEstimate =
keybase1.ToTime(start.Add(totalTimeEstimate))
k.log.CDebugf(nil, "Start=%s, n=%d, d=%d, fracDone=%f, End=%s",
start, n, d, fracDone, start.Add(totalTimeEstimate))
}
return progress, nil
} else if _, ok := k.handles[opid]; ok {
// Return an empty progress and nil error if there's no async
// operation pending, but there is still an open handle.
return keybase1.OpProgress{}, nil
}
return keybase1.OpProgress{}, errNoResult
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSCheck",
"(",
"_",
"context",
".",
"Context",
",",
"opid",
"keybase1",
".",
"OpID",
")",
"(",
"keybase1",
".",
"OpProgress",
",",
"error",
")",
"{",
"k",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"k",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"p",
",",
"ok",
":=",
"k",
".",
"inProgress",
"[",
"opid",
"]",
";",
"ok",
"{",
"// For now, estimate the ending time purely on the read progress.",
"var",
"n",
",",
"d",
"int64",
"\n",
"progress",
":=",
"p",
".",
"progress",
"\n",
"if",
"progress",
".",
"BytesTotal",
">",
"0",
"{",
"n",
"=",
"progress",
".",
"BytesRead",
"\n",
"d",
"=",
"progress",
".",
"BytesTotal",
"\n",
"}",
"else",
"if",
"p",
".",
"progress",
".",
"FilesTotal",
">",
"0",
"{",
"n",
"=",
"progress",
".",
"FilesRead",
"\n",
"d",
"=",
"progress",
".",
"FilesTotal",
"\n",
"}",
"\n",
"if",
"n",
">",
"0",
"&&",
"d",
">",
"0",
"&&",
"!",
"progress",
".",
"Start",
".",
"IsZero",
"(",
")",
"&&",
"progress",
".",
"EndEstimate",
".",
"IsZero",
"(",
")",
"{",
"// Crudely estimate that the total time for the op is the",
"// time spent so far, divided by the fraction of the",
"// reading that's been done.",
"start",
":=",
"keybase1",
".",
"FromTime",
"(",
"progress",
".",
"Start",
")",
"\n",
"timeRunning",
":=",
"k",
".",
"config",
".",
"Clock",
"(",
")",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"start",
")",
"\n",
"fracDone",
":=",
"float64",
"(",
"n",
")",
"/",
"float64",
"(",
"d",
")",
"\n",
"totalTimeEstimate",
":=",
"time",
".",
"Duration",
"(",
"float64",
"(",
"timeRunning",
")",
"/",
"fracDone",
")",
"\n",
"progress",
".",
"EndEstimate",
"=",
"keybase1",
".",
"ToTime",
"(",
"start",
".",
"Add",
"(",
"totalTimeEstimate",
")",
")",
"\n",
"k",
".",
"log",
".",
"CDebugf",
"(",
"nil",
",",
"\"",
"\"",
",",
"start",
",",
"n",
",",
"d",
",",
"fracDone",
",",
"start",
".",
"Add",
"(",
"totalTimeEstimate",
")",
")",
"\n",
"}",
"\n\n",
"return",
"progress",
",",
"nil",
"\n",
"}",
"else",
"if",
"_",
",",
"ok",
":=",
"k",
".",
"handles",
"[",
"opid",
"]",
";",
"ok",
"{",
"// Return an empty progress and nil error if there's no async",
"// operation pending, but there is still an open handle.",
"return",
"keybase1",
".",
"OpProgress",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"return",
"keybase1",
".",
"OpProgress",
"{",
"}",
",",
"errNoResult",
"\n",
"}"
] | // SimpleFSCheck - Check progress of pending operation
// Progress variable is still TBD.
// Return errNoResult if no operation found. | [
"SimpleFSCheck",
"-",
"Check",
"progress",
"of",
"pending",
"operation",
"Progress",
"variable",
"is",
"still",
"TBD",
".",
"Return",
"errNoResult",
"if",
"no",
"operation",
"found",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L1940-L1976 |
158,638 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSGetHTTPAddressAndToken | func (k *SimpleFS) SimpleFSGetHTTPAddressAndToken(ctx context.Context) (
resp keybase1.SimpleFSGetHTTPAddressAndTokenResponse, err error) {
if k.localHTTPServer == nil {
return resp, errors.New("HTTP server is disabled")
}
if resp.Token, err = k.localHTTPServer.NewToken(); err != nil {
return keybase1.SimpleFSGetHTTPAddressAndTokenResponse{}, err
}
if resp.Address, err = k.localHTTPServer.Address(); err != nil {
return keybase1.SimpleFSGetHTTPAddressAndTokenResponse{}, err
}
return resp, nil
} | go | func (k *SimpleFS) SimpleFSGetHTTPAddressAndToken(ctx context.Context) (
resp keybase1.SimpleFSGetHTTPAddressAndTokenResponse, err error) {
if k.localHTTPServer == nil {
return resp, errors.New("HTTP server is disabled")
}
if resp.Token, err = k.localHTTPServer.NewToken(); err != nil {
return keybase1.SimpleFSGetHTTPAddressAndTokenResponse{}, err
}
if resp.Address, err = k.localHTTPServer.Address(); err != nil {
return keybase1.SimpleFSGetHTTPAddressAndTokenResponse{}, err
}
return resp, nil
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSGetHTTPAddressAndToken",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"resp",
"keybase1",
".",
"SimpleFSGetHTTPAddressAndTokenResponse",
",",
"err",
"error",
")",
"{",
"if",
"k",
".",
"localHTTPServer",
"==",
"nil",
"{",
"return",
"resp",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"resp",
".",
"Token",
",",
"err",
"=",
"k",
".",
"localHTTPServer",
".",
"NewToken",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"SimpleFSGetHTTPAddressAndTokenResponse",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"resp",
".",
"Address",
",",
"err",
"=",
"k",
".",
"localHTTPServer",
".",
"Address",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"SimpleFSGetHTTPAddressAndTokenResponse",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"resp",
",",
"nil",
"\n",
"}"
] | // SimpleFSGetHTTPAddressAndToken returns a random token to be used for the
// local KBFS http server. | [
"SimpleFSGetHTTPAddressAndToken",
"returns",
"a",
"random",
"token",
"to",
"be",
"used",
"for",
"the",
"local",
"KBFS",
"http",
"server",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2068-L2081 |
158,639 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSUserEditHistory | func (k *SimpleFS) SimpleFSUserEditHistory(ctx context.Context) (
res []keybase1.FSFolderEditHistory, err error) {
session, err := idutil.GetCurrentSessionIfPossible(
ctx, k.config.KBPKI(), true)
// Return empty history if we are not logged in.
if err != nil {
return nil, nil
}
return k.config.UserHistory().Get(string(session.Name)), nil
} | go | func (k *SimpleFS) SimpleFSUserEditHistory(ctx context.Context) (
res []keybase1.FSFolderEditHistory, err error) {
session, err := idutil.GetCurrentSessionIfPossible(
ctx, k.config.KBPKI(), true)
// Return empty history if we are not logged in.
if err != nil {
return nil, nil
}
return k.config.UserHistory().Get(string(session.Name)), nil
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSUserEditHistory",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"res",
"[",
"]",
"keybase1",
".",
"FSFolderEditHistory",
",",
"err",
"error",
")",
"{",
"session",
",",
"err",
":=",
"idutil",
".",
"GetCurrentSessionIfPossible",
"(",
"ctx",
",",
"k",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"true",
")",
"\n",
"// Return empty history if we are not logged in.",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return",
"k",
".",
"config",
".",
"UserHistory",
"(",
")",
".",
"Get",
"(",
"string",
"(",
"session",
".",
"Name",
")",
")",
",",
"nil",
"\n",
"}"
] | // SimpleFSUserEditHistory returns the edit history for the logged-in user. | [
"SimpleFSUserEditHistory",
"returns",
"the",
"edit",
"history",
"for",
"the",
"logged",
"-",
"in",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2084-L2093 |
158,640 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSFolderEditHistory | func (k *SimpleFS) SimpleFSFolderEditHistory(
ctx context.Context, path keybase1.Path) (
res keybase1.FSFolderEditHistory, err error) {
ctx = k.makeContext(ctx)
fb, _, err := k.getFolderBranchFromPath(ctx, path)
if err != nil {
return keybase1.FSFolderEditHistory{}, err
}
if fb == (data.FolderBranch{}) {
return keybase1.FSFolderEditHistory{}, nil
}
// Now get the edit history.
return k.config.KBFSOps().GetEditHistory(ctx, fb)
} | go | func (k *SimpleFS) SimpleFSFolderEditHistory(
ctx context.Context, path keybase1.Path) (
res keybase1.FSFolderEditHistory, err error) {
ctx = k.makeContext(ctx)
fb, _, err := k.getFolderBranchFromPath(ctx, path)
if err != nil {
return keybase1.FSFolderEditHistory{}, err
}
if fb == (data.FolderBranch{}) {
return keybase1.FSFolderEditHistory{}, nil
}
// Now get the edit history.
return k.config.KBFSOps().GetEditHistory(ctx, fb)
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSFolderEditHistory",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"keybase1",
".",
"Path",
")",
"(",
"res",
"keybase1",
".",
"FSFolderEditHistory",
",",
"err",
"error",
")",
"{",
"ctx",
"=",
"k",
".",
"makeContext",
"(",
"ctx",
")",
"\n",
"fb",
",",
"_",
",",
"err",
":=",
"k",
".",
"getFolderBranchFromPath",
"(",
"ctx",
",",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"FSFolderEditHistory",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"fb",
"==",
"(",
"data",
".",
"FolderBranch",
"{",
"}",
")",
"{",
"return",
"keybase1",
".",
"FSFolderEditHistory",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n\n",
"// Now get the edit history.",
"return",
"k",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"GetEditHistory",
"(",
"ctx",
",",
"fb",
")",
"\n",
"}"
] | // SimpleFSFolderEditHistory returns the edit history for the given TLF. | [
"SimpleFSFolderEditHistory",
"returns",
"the",
"edit",
"history",
"for",
"the",
"given",
"TLF",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2096-L2110 |
158,641 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSReset | func (k *SimpleFS) SimpleFSReset(
ctx context.Context, path keybase1.Path) error {
t, tlfName, _, _, err := remoteTlfAndPath(path)
if err != nil {
return err
}
tlfHandle, err := libkbfs.GetHandleFromFolderNameAndType(
ctx, k.config.KBPKI(), k.config.MDOps(), k.config, tlfName, t)
if err != nil {
return err
}
return k.config.KBFSOps().Reset(ctx, tlfHandle)
} | go | func (k *SimpleFS) SimpleFSReset(
ctx context.Context, path keybase1.Path) error {
t, tlfName, _, _, err := remoteTlfAndPath(path)
if err != nil {
return err
}
tlfHandle, err := libkbfs.GetHandleFromFolderNameAndType(
ctx, k.config.KBPKI(), k.config.MDOps(), k.config, tlfName, t)
if err != nil {
return err
}
return k.config.KBFSOps().Reset(ctx, tlfHandle)
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSReset",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"keybase1",
".",
"Path",
")",
"error",
"{",
"t",
",",
"tlfName",
",",
"_",
",",
"_",
",",
"err",
":=",
"remoteTlfAndPath",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"tlfHandle",
",",
"err",
":=",
"libkbfs",
".",
"GetHandleFromFolderNameAndType",
"(",
"ctx",
",",
"k",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"k",
".",
"config",
".",
"MDOps",
"(",
")",
",",
"k",
".",
"config",
",",
"tlfName",
",",
"t",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"k",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"Reset",
"(",
"ctx",
",",
"tlfHandle",
")",
"\n",
"}"
] | // SimpleFSReset resets the given TLF. | [
"SimpleFSReset",
"resets",
"the",
"given",
"TLF",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2113-L2126 |
158,642 | keybase/client | go/kbfs/simplefs/simplefs.go | LocalChange | func (k *SimpleFS) LocalChange(
ctx context.Context, node libkbfs.Node, _ libkbfs.WriteRange) {
k.subscribeLock.RLock()
defer k.subscribeLock.RUnlock()
if node.GetFolderBranch() == k.subscribeCurrFB {
k.config.Reporter().NotifyPathUpdated(ctx, k.subscribeCurrTlfPathFromGUI)
}
} | go | func (k *SimpleFS) LocalChange(
ctx context.Context, node libkbfs.Node, _ libkbfs.WriteRange) {
k.subscribeLock.RLock()
defer k.subscribeLock.RUnlock()
if node.GetFolderBranch() == k.subscribeCurrFB {
k.config.Reporter().NotifyPathUpdated(ctx, k.subscribeCurrTlfPathFromGUI)
}
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"LocalChange",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"libkbfs",
".",
"Node",
",",
"_",
"libkbfs",
".",
"WriteRange",
")",
"{",
"k",
".",
"subscribeLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"k",
".",
"subscribeLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"node",
".",
"GetFolderBranch",
"(",
")",
"==",
"k",
".",
"subscribeCurrFB",
"{",
"k",
".",
"config",
".",
"Reporter",
"(",
")",
".",
"NotifyPathUpdated",
"(",
"ctx",
",",
"k",
".",
"subscribeCurrTlfPathFromGUI",
")",
"\n",
"}",
"\n",
"}"
] | // LocalChange implements the libkbfs.Observer interface for SimpleFS. | [
"LocalChange",
"implements",
"the",
"libkbfs",
".",
"Observer",
"interface",
"for",
"SimpleFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2131-L2138 |
158,643 | keybase/client | go/kbfs/simplefs/simplefs.go | BatchChanges | func (k *SimpleFS) BatchChanges(
ctx context.Context, changes []libkbfs.NodeChange, _ []libkbfs.NodeID) {
// Don't take any locks while processing these notifications,
// since it risks deadlock.
fbs := make(map[data.FolderBranch]bool, 1)
for _, nc := range changes {
fbs[nc.Node.GetFolderBranch()] = true
}
go func() {
k.subscribeLock.RLock()
defer k.subscribeLock.RUnlock()
if fbs[k.subscribeCurrFB] {
k.config.Reporter().NotifyPathUpdated(ctx, k.subscribeCurrTlfPathFromGUI)
}
}()
} | go | func (k *SimpleFS) BatchChanges(
ctx context.Context, changes []libkbfs.NodeChange, _ []libkbfs.NodeID) {
// Don't take any locks while processing these notifications,
// since it risks deadlock.
fbs := make(map[data.FolderBranch]bool, 1)
for _, nc := range changes {
fbs[nc.Node.GetFolderBranch()] = true
}
go func() {
k.subscribeLock.RLock()
defer k.subscribeLock.RUnlock()
if fbs[k.subscribeCurrFB] {
k.config.Reporter().NotifyPathUpdated(ctx, k.subscribeCurrTlfPathFromGUI)
}
}()
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"BatchChanges",
"(",
"ctx",
"context",
".",
"Context",
",",
"changes",
"[",
"]",
"libkbfs",
".",
"NodeChange",
",",
"_",
"[",
"]",
"libkbfs",
".",
"NodeID",
")",
"{",
"// Don't take any locks while processing these notifications,",
"// since it risks deadlock.",
"fbs",
":=",
"make",
"(",
"map",
"[",
"data",
".",
"FolderBranch",
"]",
"bool",
",",
"1",
")",
"\n",
"for",
"_",
",",
"nc",
":=",
"range",
"changes",
"{",
"fbs",
"[",
"nc",
".",
"Node",
".",
"GetFolderBranch",
"(",
")",
"]",
"=",
"true",
"\n",
"}",
"\n\n",
"go",
"func",
"(",
")",
"{",
"k",
".",
"subscribeLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"k",
".",
"subscribeLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"fbs",
"[",
"k",
".",
"subscribeCurrFB",
"]",
"{",
"k",
".",
"config",
".",
"Reporter",
"(",
")",
".",
"NotifyPathUpdated",
"(",
"ctx",
",",
"k",
".",
"subscribeCurrTlfPathFromGUI",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // BatchChanges implements the libkbfs.Observer interface for SimpleFS. | [
"BatchChanges",
"implements",
"the",
"libkbfs",
".",
"Observer",
"interface",
"for",
"SimpleFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2141-L2157 |
158,644 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSGetUserQuotaUsage | func (k *SimpleFS) SimpleFSGetUserQuotaUsage(ctx context.Context) (
res keybase1.SimpleFSQuotaUsage, err error) {
ctx = k.makeContext(ctx)
status, _, err := k.config.KBFSOps().Status(ctx)
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
res.UsageBytes = status.UsageBytes
res.ArchiveBytes = status.ArchiveBytes
res.LimitBytes = status.LimitBytes
res.GitUsageBytes = status.GitUsageBytes
res.GitArchiveBytes = status.GitArchiveBytes
res.GitLimitBytes = status.GitLimitBytes
return res, nil
} | go | func (k *SimpleFS) SimpleFSGetUserQuotaUsage(ctx context.Context) (
res keybase1.SimpleFSQuotaUsage, err error) {
ctx = k.makeContext(ctx)
status, _, err := k.config.KBFSOps().Status(ctx)
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
res.UsageBytes = status.UsageBytes
res.ArchiveBytes = status.ArchiveBytes
res.LimitBytes = status.LimitBytes
res.GitUsageBytes = status.GitUsageBytes
res.GitArchiveBytes = status.GitArchiveBytes
res.GitLimitBytes = status.GitLimitBytes
return res, nil
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSGetUserQuotaUsage",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"res",
"keybase1",
".",
"SimpleFSQuotaUsage",
",",
"err",
"error",
")",
"{",
"ctx",
"=",
"k",
".",
"makeContext",
"(",
"ctx",
")",
"\n",
"status",
",",
"_",
",",
"err",
":=",
"k",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"Status",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"SimpleFSQuotaUsage",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"res",
".",
"UsageBytes",
"=",
"status",
".",
"UsageBytes",
"\n",
"res",
".",
"ArchiveBytes",
"=",
"status",
".",
"ArchiveBytes",
"\n",
"res",
".",
"LimitBytes",
"=",
"status",
".",
"LimitBytes",
"\n",
"res",
".",
"GitUsageBytes",
"=",
"status",
".",
"GitUsageBytes",
"\n",
"res",
".",
"GitArchiveBytes",
"=",
"status",
".",
"GitArchiveBytes",
"\n",
"res",
".",
"GitLimitBytes",
"=",
"status",
".",
"GitLimitBytes",
"\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] | // SimpleFSGetUserQuotaUsage returns the quota usage information for
// the logged-in user. | [
"SimpleFSGetUserQuotaUsage",
"returns",
"the",
"quota",
"usage",
"information",
"for",
"the",
"logged",
"-",
"in",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2166-L2180 |
158,645 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSGetTeamQuotaUsage | func (k *SimpleFS) SimpleFSGetTeamQuotaUsage(
ctx context.Context, teamName keybase1.TeamName) (
res keybase1.SimpleFSQuotaUsage, err error) {
ctx = k.makeContext(ctx)
path := keybase1.NewPathWithKbfs(
fmt.Sprintf("team/%s", teamName.String()))
fb, _, err := k.getFolderBranchFromPath(ctx, path)
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
if fb == (data.FolderBranch{}) {
return keybase1.SimpleFSQuotaUsage{}, nil
}
status, _, err := k.config.KBFSOps().FolderStatus(ctx, fb)
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
res.UsageBytes = status.UsageBytes
res.ArchiveBytes = status.ArchiveBytes
res.LimitBytes = status.LimitBytes
res.GitUsageBytes = status.GitUsageBytes
res.GitArchiveBytes = status.GitArchiveBytes
res.GitLimitBytes = status.GitLimitBytes
return res, nil
} | go | func (k *SimpleFS) SimpleFSGetTeamQuotaUsage(
ctx context.Context, teamName keybase1.TeamName) (
res keybase1.SimpleFSQuotaUsage, err error) {
ctx = k.makeContext(ctx)
path := keybase1.NewPathWithKbfs(
fmt.Sprintf("team/%s", teamName.String()))
fb, _, err := k.getFolderBranchFromPath(ctx, path)
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
if fb == (data.FolderBranch{}) {
return keybase1.SimpleFSQuotaUsage{}, nil
}
status, _, err := k.config.KBFSOps().FolderStatus(ctx, fb)
if err != nil {
return keybase1.SimpleFSQuotaUsage{}, err
}
res.UsageBytes = status.UsageBytes
res.ArchiveBytes = status.ArchiveBytes
res.LimitBytes = status.LimitBytes
res.GitUsageBytes = status.GitUsageBytes
res.GitArchiveBytes = status.GitArchiveBytes
res.GitLimitBytes = status.GitLimitBytes
return res, nil
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSGetTeamQuotaUsage",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamName",
"keybase1",
".",
"TeamName",
")",
"(",
"res",
"keybase1",
".",
"SimpleFSQuotaUsage",
",",
"err",
"error",
")",
"{",
"ctx",
"=",
"k",
".",
"makeContext",
"(",
"ctx",
")",
"\n",
"path",
":=",
"keybase1",
".",
"NewPathWithKbfs",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"teamName",
".",
"String",
"(",
")",
")",
")",
"\n",
"fb",
",",
"_",
",",
"err",
":=",
"k",
".",
"getFolderBranchFromPath",
"(",
"ctx",
",",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"SimpleFSQuotaUsage",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"fb",
"==",
"(",
"data",
".",
"FolderBranch",
"{",
"}",
")",
"{",
"return",
"keybase1",
".",
"SimpleFSQuotaUsage",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n\n",
"status",
",",
"_",
",",
"err",
":=",
"k",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"FolderStatus",
"(",
"ctx",
",",
"fb",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"SimpleFSQuotaUsage",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"res",
".",
"UsageBytes",
"=",
"status",
".",
"UsageBytes",
"\n",
"res",
".",
"ArchiveBytes",
"=",
"status",
".",
"ArchiveBytes",
"\n",
"res",
".",
"LimitBytes",
"=",
"status",
".",
"LimitBytes",
"\n",
"res",
".",
"GitUsageBytes",
"=",
"status",
".",
"GitUsageBytes",
"\n",
"res",
".",
"GitArchiveBytes",
"=",
"status",
".",
"GitArchiveBytes",
"\n",
"res",
".",
"GitLimitBytes",
"=",
"status",
".",
"GitLimitBytes",
"\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] | // SimpleFSGetTeamQuotaUsage returns the quota usage information for
// the given team. | [
"SimpleFSGetTeamQuotaUsage",
"returns",
"the",
"quota",
"usage",
"information",
"for",
"the",
"given",
"team",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2184-L2210 |
158,646 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSFolderSyncConfigAndStatus | func (k *SimpleFS) SimpleFSFolderSyncConfigAndStatus(
ctx context.Context, path keybase1.Path) (
keybase1.FolderSyncConfigAndStatus, error) {
ctx = k.makeContext(ctx)
_, config, err := k.getSyncConfig(ctx, path)
if err != nil {
return keybase1.FolderSyncConfigAndStatus{}, err
}
res := keybase1.FolderSyncConfigAndStatus{Config: config}
if config.Mode != keybase1.FolderSyncMode_DISABLED {
fs, finalElem, err := k.getFSIfExists(ctx, path)
if err != nil {
return res, err
}
// Use LStat so we don't follow symlinks.
fi, err := fs.Lstat(finalElem)
if err != nil {
return res, err
}
if kmg, ok := fi.Sys().(libfs.KBFSMetadataForSimpleFSGetter); ok {
metadata, err := kmg.KBFSMetadataForSimpleFS()
if err != nil {
return keybase1.FolderSyncConfigAndStatus{}, err
}
res.Status.PrefetchStatus = metadata.PrefetchStatus
res.Status.PrefetchProgress =
metadata.PrefetchProgress.ToProtocolProgress(k.config.Clock())
dbc := k.config.DiskBlockCache()
libfs, ok := fs.(*libfs.FS)
if dbc != nil && ok {
size, err := dbc.GetTlfSize(
ctx, libfs.RootNode().GetFolderBranch().Tlf,
libkbfs.DiskBlockSyncCache)
if err != nil {
return res, err
}
res.Status.StoredBytesTotal = int64(size)
}
} else {
k.log.CDebugf(ctx,
"Could not get prefetch status from filesys: %T", fi.Sys())
}
}
res.Status.LocalDiskBytesAvailable, res.Status.LocalDiskBytesTotal =
k.getLocalDiskStats(ctx)
return res, err
} | go | func (k *SimpleFS) SimpleFSFolderSyncConfigAndStatus(
ctx context.Context, path keybase1.Path) (
keybase1.FolderSyncConfigAndStatus, error) {
ctx = k.makeContext(ctx)
_, config, err := k.getSyncConfig(ctx, path)
if err != nil {
return keybase1.FolderSyncConfigAndStatus{}, err
}
res := keybase1.FolderSyncConfigAndStatus{Config: config}
if config.Mode != keybase1.FolderSyncMode_DISABLED {
fs, finalElem, err := k.getFSIfExists(ctx, path)
if err != nil {
return res, err
}
// Use LStat so we don't follow symlinks.
fi, err := fs.Lstat(finalElem)
if err != nil {
return res, err
}
if kmg, ok := fi.Sys().(libfs.KBFSMetadataForSimpleFSGetter); ok {
metadata, err := kmg.KBFSMetadataForSimpleFS()
if err != nil {
return keybase1.FolderSyncConfigAndStatus{}, err
}
res.Status.PrefetchStatus = metadata.PrefetchStatus
res.Status.PrefetchProgress =
metadata.PrefetchProgress.ToProtocolProgress(k.config.Clock())
dbc := k.config.DiskBlockCache()
libfs, ok := fs.(*libfs.FS)
if dbc != nil && ok {
size, err := dbc.GetTlfSize(
ctx, libfs.RootNode().GetFolderBranch().Tlf,
libkbfs.DiskBlockSyncCache)
if err != nil {
return res, err
}
res.Status.StoredBytesTotal = int64(size)
}
} else {
k.log.CDebugf(ctx,
"Could not get prefetch status from filesys: %T", fi.Sys())
}
}
res.Status.LocalDiskBytesAvailable, res.Status.LocalDiskBytesTotal =
k.getLocalDiskStats(ctx)
return res, err
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSFolderSyncConfigAndStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"keybase1",
".",
"Path",
")",
"(",
"keybase1",
".",
"FolderSyncConfigAndStatus",
",",
"error",
")",
"{",
"ctx",
"=",
"k",
".",
"makeContext",
"(",
"ctx",
")",
"\n",
"_",
",",
"config",
",",
"err",
":=",
"k",
".",
"getSyncConfig",
"(",
"ctx",
",",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"FolderSyncConfigAndStatus",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"res",
":=",
"keybase1",
".",
"FolderSyncConfigAndStatus",
"{",
"Config",
":",
"config",
"}",
"\n\n",
"if",
"config",
".",
"Mode",
"!=",
"keybase1",
".",
"FolderSyncMode_DISABLED",
"{",
"fs",
",",
"finalElem",
",",
"err",
":=",
"k",
".",
"getFSIfExists",
"(",
"ctx",
",",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n",
"// Use LStat so we don't follow symlinks.",
"fi",
",",
"err",
":=",
"fs",
".",
"Lstat",
"(",
"finalElem",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"kmg",
",",
"ok",
":=",
"fi",
".",
"Sys",
"(",
")",
".",
"(",
"libfs",
".",
"KBFSMetadataForSimpleFSGetter",
")",
";",
"ok",
"{",
"metadata",
",",
"err",
":=",
"kmg",
".",
"KBFSMetadataForSimpleFS",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"FolderSyncConfigAndStatus",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"res",
".",
"Status",
".",
"PrefetchStatus",
"=",
"metadata",
".",
"PrefetchStatus",
"\n",
"res",
".",
"Status",
".",
"PrefetchProgress",
"=",
"metadata",
".",
"PrefetchProgress",
".",
"ToProtocolProgress",
"(",
"k",
".",
"config",
".",
"Clock",
"(",
")",
")",
"\n\n",
"dbc",
":=",
"k",
".",
"config",
".",
"DiskBlockCache",
"(",
")",
"\n",
"libfs",
",",
"ok",
":=",
"fs",
".",
"(",
"*",
"libfs",
".",
"FS",
")",
"\n",
"if",
"dbc",
"!=",
"nil",
"&&",
"ok",
"{",
"size",
",",
"err",
":=",
"dbc",
".",
"GetTlfSize",
"(",
"ctx",
",",
"libfs",
".",
"RootNode",
"(",
")",
".",
"GetFolderBranch",
"(",
")",
".",
"Tlf",
",",
"libkbfs",
".",
"DiskBlockSyncCache",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n",
"res",
".",
"Status",
".",
"StoredBytesTotal",
"=",
"int64",
"(",
"size",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"k",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"fi",
".",
"Sys",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"res",
".",
"Status",
".",
"LocalDiskBytesAvailable",
",",
"res",
".",
"Status",
".",
"LocalDiskBytesTotal",
"=",
"k",
".",
"getLocalDiskStats",
"(",
"ctx",
")",
"\n",
"return",
"res",
",",
"err",
"\n",
"}"
] | // SimpleFSFolderSyncConfigAndStatus gets the given folder's sync config. | [
"SimpleFSFolderSyncConfigAndStatus",
"gets",
"the",
"given",
"folder",
"s",
"sync",
"config",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2255-L2305 |
158,647 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSSetFolderSyncConfig | func (k *SimpleFS) SimpleFSSetFolderSyncConfig(
ctx context.Context, arg keybase1.SimpleFSSetFolderSyncConfigArg) error {
ctx = k.makeContext(ctx)
tlfID, _, err := k.getSyncConfig(ctx, arg.Path)
if err != nil {
return err
}
_, err = k.config.KBFSOps().SetSyncConfig(ctx, tlfID, arg.Config)
return err
} | go | func (k *SimpleFS) SimpleFSSetFolderSyncConfig(
ctx context.Context, arg keybase1.SimpleFSSetFolderSyncConfigArg) error {
ctx = k.makeContext(ctx)
tlfID, _, err := k.getSyncConfig(ctx, arg.Path)
if err != nil {
return err
}
_, err = k.config.KBFSOps().SetSyncConfig(ctx, tlfID, arg.Config)
return err
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSSetFolderSyncConfig",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"SimpleFSSetFolderSyncConfigArg",
")",
"error",
"{",
"ctx",
"=",
"k",
".",
"makeContext",
"(",
"ctx",
")",
"\n",
"tlfID",
",",
"_",
",",
"err",
":=",
"k",
".",
"getSyncConfig",
"(",
"ctx",
",",
"arg",
".",
"Path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"k",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"SetSyncConfig",
"(",
"ctx",
",",
"tlfID",
",",
"arg",
".",
"Config",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // SimpleFSSetFolderSyncConfig implements the SimpleFSInterface. | [
"SimpleFSSetFolderSyncConfig",
"implements",
"the",
"SimpleFSInterface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2308-L2318 |
158,648 | keybase/client | go/kbfs/simplefs/simplefs.go | SimpleFSClearConflictState | func (k *SimpleFS) SimpleFSClearConflictState(ctx context.Context,
path keybase1.Path) error {
ctx = k.makeContext(ctx)
t, tlfName, _, _, err := remoteTlfAndPath(path)
if err != nil {
return err
}
tlfHandle, err := libkbfs.GetHandleFromFolderNameAndType(
ctx, k.config.KBPKI(), k.config.MDOps(), k.config, tlfName, t)
if err != nil {
return err
}
tlfID := tlfHandle.TlfID()
return k.config.KBFSOps().ClearConflictView(ctx, tlfID)
} | go | func (k *SimpleFS) SimpleFSClearConflictState(ctx context.Context,
path keybase1.Path) error {
ctx = k.makeContext(ctx)
t, tlfName, _, _, err := remoteTlfAndPath(path)
if err != nil {
return err
}
tlfHandle, err := libkbfs.GetHandleFromFolderNameAndType(
ctx, k.config.KBPKI(), k.config.MDOps(), k.config, tlfName, t)
if err != nil {
return err
}
tlfID := tlfHandle.TlfID()
return k.config.KBFSOps().ClearConflictView(ctx, tlfID)
} | [
"func",
"(",
"k",
"*",
"SimpleFS",
")",
"SimpleFSClearConflictState",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"keybase1",
".",
"Path",
")",
"error",
"{",
"ctx",
"=",
"k",
".",
"makeContext",
"(",
"ctx",
")",
"\n",
"t",
",",
"tlfName",
",",
"_",
",",
"_",
",",
"err",
":=",
"remoteTlfAndPath",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"tlfHandle",
",",
"err",
":=",
"libkbfs",
".",
"GetHandleFromFolderNameAndType",
"(",
"ctx",
",",
"k",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"k",
".",
"config",
".",
"MDOps",
"(",
")",
",",
"k",
".",
"config",
",",
"tlfName",
",",
"t",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"tlfID",
":=",
"tlfHandle",
".",
"TlfID",
"(",
")",
"\n",
"return",
"k",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"ClearConflictView",
"(",
"ctx",
",",
"tlfID",
")",
"\n",
"}"
] | // SimpleFSClearConflictState implements the SimpleFS interface. | [
"SimpleFSClearConflictState",
"implements",
"the",
"SimpleFS",
"interface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/simplefs/simplefs.go#L2417-L2431 |
158,649 | keybase/client | go/kbfs/libfuse/special_files.go | handleCommonSpecialFile | func handleCommonSpecialFile(
name string, fs *FS, entryValid *time.Duration) fs.Node {
switch name {
case libkbfs.ErrorFile:
return NewErrorFile(fs, entryValid)
case libfs.MetricsFileName:
return NewMetricsFile(fs, entryValid)
case libfs.ProfileListDirName:
return ProfileList{}
case libfs.ResetCachesFileName:
return &ResetCachesFile{fs}
}
return nil
} | go | func handleCommonSpecialFile(
name string, fs *FS, entryValid *time.Duration) fs.Node {
switch name {
case libkbfs.ErrorFile:
return NewErrorFile(fs, entryValid)
case libfs.MetricsFileName:
return NewMetricsFile(fs, entryValid)
case libfs.ProfileListDirName:
return ProfileList{}
case libfs.ResetCachesFileName:
return &ResetCachesFile{fs}
}
return nil
} | [
"func",
"handleCommonSpecialFile",
"(",
"name",
"string",
",",
"fs",
"*",
"FS",
",",
"entryValid",
"*",
"time",
".",
"Duration",
")",
"fs",
".",
"Node",
"{",
"switch",
"name",
"{",
"case",
"libkbfs",
".",
"ErrorFile",
":",
"return",
"NewErrorFile",
"(",
"fs",
",",
"entryValid",
")",
"\n",
"case",
"libfs",
".",
"MetricsFileName",
":",
"return",
"NewMetricsFile",
"(",
"fs",
",",
"entryValid",
")",
"\n",
"case",
"libfs",
".",
"ProfileListDirName",
":",
"return",
"ProfileList",
"{",
"}",
"\n",
"case",
"libfs",
".",
"ResetCachesFileName",
":",
"return",
"&",
"ResetCachesFile",
"{",
"fs",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // handleCommonSpecialFile handles special files that are present both
// within a TLF and outside a TLF. | [
"handleCommonSpecialFile",
"handles",
"special",
"files",
"that",
"are",
"present",
"both",
"within",
"a",
"TLF",
"and",
"outside",
"a",
"TLF",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/special_files.go#L19-L33 |
158,650 | keybase/client | go/kbfs/libfuse/special_files.go | handleTLFSpecialFile | func handleTLFSpecialFile(
name string, folder *Folder, entryValid *time.Duration) fs.Node {
specialNode := handleCommonSpecialFile(name, folder.fs, entryValid)
if specialNode != nil {
return specialNode
}
switch name {
case libfs.UpdateHistoryFileName:
return NewUpdateHistoryFile(folder, entryValid)
case libfs.EditHistoryName:
return NewTlfEditHistoryFile(folder, entryValid)
case libfs.UnstageFileName:
return &UnstageFile{
folder: folder,
}
case libfs.DisableUpdatesFileName:
return &UpdatesFile{
folder: folder,
}
case libfs.EnableUpdatesFileName:
return &UpdatesFile{
folder: folder,
enable: true,
}
case libfs.RekeyFileName:
return &RekeyFile{
folder: folder,
}
case libfs.ReclaimQuotaFileName:
return &ReclaimQuotaFile{
folder: folder,
}
case libfs.SyncFromServerFileName:
// Don't cache the node so that the next lookup of
// this file will force the dir to be re-checked
// (i.e., loadDirHelper will be called again).
*entryValid = 0
return &SyncFromServerFile{
folder: folder,
}
case libfs.EnableJournalFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalEnable,
}
case libfs.FlushJournalFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalFlush,
}
case libfs.PauseJournalBackgroundWorkFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalPauseBackgroundWork,
}
case libfs.ResumeJournalBackgroundWorkFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalResumeBackgroundWork,
}
case libfs.DisableJournalFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalDisable,
}
case libfs.EnableSyncFileName:
return &SyncControlFile{
folder: folder,
action: libfs.SyncEnable,
}
case libfs.DisableSyncFileName:
return &SyncControlFile{
folder: folder,
action: libfs.SyncDisable,
}
}
return nil
} | go | func handleTLFSpecialFile(
name string, folder *Folder, entryValid *time.Duration) fs.Node {
specialNode := handleCommonSpecialFile(name, folder.fs, entryValid)
if specialNode != nil {
return specialNode
}
switch name {
case libfs.UpdateHistoryFileName:
return NewUpdateHistoryFile(folder, entryValid)
case libfs.EditHistoryName:
return NewTlfEditHistoryFile(folder, entryValid)
case libfs.UnstageFileName:
return &UnstageFile{
folder: folder,
}
case libfs.DisableUpdatesFileName:
return &UpdatesFile{
folder: folder,
}
case libfs.EnableUpdatesFileName:
return &UpdatesFile{
folder: folder,
enable: true,
}
case libfs.RekeyFileName:
return &RekeyFile{
folder: folder,
}
case libfs.ReclaimQuotaFileName:
return &ReclaimQuotaFile{
folder: folder,
}
case libfs.SyncFromServerFileName:
// Don't cache the node so that the next lookup of
// this file will force the dir to be re-checked
// (i.e., loadDirHelper will be called again).
*entryValid = 0
return &SyncFromServerFile{
folder: folder,
}
case libfs.EnableJournalFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalEnable,
}
case libfs.FlushJournalFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalFlush,
}
case libfs.PauseJournalBackgroundWorkFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalPauseBackgroundWork,
}
case libfs.ResumeJournalBackgroundWorkFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalResumeBackgroundWork,
}
case libfs.DisableJournalFileName:
return &JournalControlFile{
folder: folder,
action: libfs.JournalDisable,
}
case libfs.EnableSyncFileName:
return &SyncControlFile{
folder: folder,
action: libfs.SyncEnable,
}
case libfs.DisableSyncFileName:
return &SyncControlFile{
folder: folder,
action: libfs.SyncDisable,
}
}
return nil
} | [
"func",
"handleTLFSpecialFile",
"(",
"name",
"string",
",",
"folder",
"*",
"Folder",
",",
"entryValid",
"*",
"time",
".",
"Duration",
")",
"fs",
".",
"Node",
"{",
"specialNode",
":=",
"handleCommonSpecialFile",
"(",
"name",
",",
"folder",
".",
"fs",
",",
"entryValid",
")",
"\n",
"if",
"specialNode",
"!=",
"nil",
"{",
"return",
"specialNode",
"\n",
"}",
"\n\n",
"switch",
"name",
"{",
"case",
"libfs",
".",
"UpdateHistoryFileName",
":",
"return",
"NewUpdateHistoryFile",
"(",
"folder",
",",
"entryValid",
")",
"\n\n",
"case",
"libfs",
".",
"EditHistoryName",
":",
"return",
"NewTlfEditHistoryFile",
"(",
"folder",
",",
"entryValid",
")",
"\n\n",
"case",
"libfs",
".",
"UnstageFileName",
":",
"return",
"&",
"UnstageFile",
"{",
"folder",
":",
"folder",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"DisableUpdatesFileName",
":",
"return",
"&",
"UpdatesFile",
"{",
"folder",
":",
"folder",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"EnableUpdatesFileName",
":",
"return",
"&",
"UpdatesFile",
"{",
"folder",
":",
"folder",
",",
"enable",
":",
"true",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"RekeyFileName",
":",
"return",
"&",
"RekeyFile",
"{",
"folder",
":",
"folder",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"ReclaimQuotaFileName",
":",
"return",
"&",
"ReclaimQuotaFile",
"{",
"folder",
":",
"folder",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"SyncFromServerFileName",
":",
"// Don't cache the node so that the next lookup of",
"// this file will force the dir to be re-checked",
"// (i.e., loadDirHelper will be called again).",
"*",
"entryValid",
"=",
"0",
"\n",
"return",
"&",
"SyncFromServerFile",
"{",
"folder",
":",
"folder",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"EnableJournalFileName",
":",
"return",
"&",
"JournalControlFile",
"{",
"folder",
":",
"folder",
",",
"action",
":",
"libfs",
".",
"JournalEnable",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"FlushJournalFileName",
":",
"return",
"&",
"JournalControlFile",
"{",
"folder",
":",
"folder",
",",
"action",
":",
"libfs",
".",
"JournalFlush",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"PauseJournalBackgroundWorkFileName",
":",
"return",
"&",
"JournalControlFile",
"{",
"folder",
":",
"folder",
",",
"action",
":",
"libfs",
".",
"JournalPauseBackgroundWork",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"ResumeJournalBackgroundWorkFileName",
":",
"return",
"&",
"JournalControlFile",
"{",
"folder",
":",
"folder",
",",
"action",
":",
"libfs",
".",
"JournalResumeBackgroundWork",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"DisableJournalFileName",
":",
"return",
"&",
"JournalControlFile",
"{",
"folder",
":",
"folder",
",",
"action",
":",
"libfs",
".",
"JournalDisable",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"EnableSyncFileName",
":",
"return",
"&",
"SyncControlFile",
"{",
"folder",
":",
"folder",
",",
"action",
":",
"libfs",
".",
"SyncEnable",
",",
"}",
"\n\n",
"case",
"libfs",
".",
"DisableSyncFileName",
":",
"return",
"&",
"SyncControlFile",
"{",
"folder",
":",
"folder",
",",
"action",
":",
"libfs",
".",
"SyncDisable",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // handleTLFSpecialFile handles special files that are within a TLF. | [
"handleTLFSpecialFile",
"handles",
"special",
"files",
"that",
"are",
"within",
"a",
"TLF",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/special_files.go#L78-L171 |
158,651 | keybase/client | go/libkb/pprof.go | MakeCPUProfileFilename | func MakeCPUProfileFilename(dir string, start time.Time, duration time.Duration) string {
return makeProfileFilename(cpuProfilePrefix, dir, start, duration)
} | go | func MakeCPUProfileFilename(dir string, start time.Time, duration time.Duration) string {
return makeProfileFilename(cpuProfilePrefix, dir, start, duration)
} | [
"func",
"MakeCPUProfileFilename",
"(",
"dir",
"string",
",",
"start",
"time",
".",
"Time",
",",
"duration",
"time",
".",
"Duration",
")",
"string",
"{",
"return",
"makeProfileFilename",
"(",
"cpuProfilePrefix",
",",
"dir",
",",
"start",
",",
"duration",
")",
"\n",
"}"
] | // MakeCPUProfileFilename returns a filename to use for a CPU profile
// file in the given directory with the given start time and duration. | [
"MakeCPUProfileFilename",
"returns",
"a",
"filename",
"to",
"use",
"for",
"a",
"CPU",
"profile",
"file",
"in",
"the",
"given",
"directory",
"with",
"the",
"given",
"start",
"time",
"and",
"duration",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pprof.go#L37-L39 |
158,652 | keybase/client | go/libkb/pprof.go | MakeTraceFilename | func MakeTraceFilename(dir string, start time.Time, duration time.Duration) string {
return makeProfileFilename(tracePrefix, dir, start, duration)
} | go | func MakeTraceFilename(dir string, start time.Time, duration time.Duration) string {
return makeProfileFilename(tracePrefix, dir, start, duration)
} | [
"func",
"MakeTraceFilename",
"(",
"dir",
"string",
",",
"start",
"time",
".",
"Time",
",",
"duration",
"time",
".",
"Duration",
")",
"string",
"{",
"return",
"makeProfileFilename",
"(",
"tracePrefix",
",",
"dir",
",",
"start",
",",
"duration",
")",
"\n",
"}"
] | // MakeTraceFilename returns a filename to use for a trace file
// in the given directory with the given start time and duration. | [
"MakeTraceFilename",
"returns",
"a",
"filename",
"to",
"use",
"for",
"a",
"trace",
"file",
"in",
"the",
"given",
"directory",
"with",
"the",
"given",
"start",
"time",
"and",
"duration",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pprof.go#L43-L45 |
158,653 | keybase/client | go/kbcrypto/nacl_sig_info.go | verifyWithPayload | func (s NaclSigInfo) verifyWithPayload(payload []byte, checkPayloadEquality bool) (*NaclSigningKeyPublic, error) {
key := KIDToNaclSigningKeyPublic(s.Kid)
if key == nil {
return nil, BadKeyError{}
}
if payload == nil {
return nil, newVerificationErrorWithString("nil payload")
}
if len(payload) == 0 {
return nil, newVerificationErrorWithString("empty payload")
}
if checkPayloadEquality && s.Payload != nil && !SecureByteArrayEq(payload, s.Payload) {
return nil, newVerificationErrorWithString("payload mismatch")
}
switch s.Version {
case 0, 1:
if !key.Verify(payload, s.Sig) {
return nil, newVerificationErrorWithString("verify failed")
}
case 2:
if !s.Prefix.IsWhitelisted() {
return nil, newVerificationErrorWithString("unknown prefix")
}
if !key.Verify(s.Prefix.Prefix(payload), s.Sig) {
return nil, newVerificationErrorWithString("verify failed")
}
default:
return nil, UnhandledSignatureError{s.Version}
}
return key, nil
} | go | func (s NaclSigInfo) verifyWithPayload(payload []byte, checkPayloadEquality bool) (*NaclSigningKeyPublic, error) {
key := KIDToNaclSigningKeyPublic(s.Kid)
if key == nil {
return nil, BadKeyError{}
}
if payload == nil {
return nil, newVerificationErrorWithString("nil payload")
}
if len(payload) == 0 {
return nil, newVerificationErrorWithString("empty payload")
}
if checkPayloadEquality && s.Payload != nil && !SecureByteArrayEq(payload, s.Payload) {
return nil, newVerificationErrorWithString("payload mismatch")
}
switch s.Version {
case 0, 1:
if !key.Verify(payload, s.Sig) {
return nil, newVerificationErrorWithString("verify failed")
}
case 2:
if !s.Prefix.IsWhitelisted() {
return nil, newVerificationErrorWithString("unknown prefix")
}
if !key.Verify(s.Prefix.Prefix(payload), s.Sig) {
return nil, newVerificationErrorWithString("verify failed")
}
default:
return nil, UnhandledSignatureError{s.Version}
}
return key, nil
} | [
"func",
"(",
"s",
"NaclSigInfo",
")",
"verifyWithPayload",
"(",
"payload",
"[",
"]",
"byte",
",",
"checkPayloadEquality",
"bool",
")",
"(",
"*",
"NaclSigningKeyPublic",
",",
"error",
")",
"{",
"key",
":=",
"KIDToNaclSigningKeyPublic",
"(",
"s",
".",
"Kid",
")",
"\n",
"if",
"key",
"==",
"nil",
"{",
"return",
"nil",
",",
"BadKeyError",
"{",
"}",
"\n",
"}",
"\n",
"if",
"payload",
"==",
"nil",
"{",
"return",
"nil",
",",
"newVerificationErrorWithString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"payload",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"newVerificationErrorWithString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"checkPayloadEquality",
"&&",
"s",
".",
"Payload",
"!=",
"nil",
"&&",
"!",
"SecureByteArrayEq",
"(",
"payload",
",",
"s",
".",
"Payload",
")",
"{",
"return",
"nil",
",",
"newVerificationErrorWithString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"switch",
"s",
".",
"Version",
"{",
"case",
"0",
",",
"1",
":",
"if",
"!",
"key",
".",
"Verify",
"(",
"payload",
",",
"s",
".",
"Sig",
")",
"{",
"return",
"nil",
",",
"newVerificationErrorWithString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"case",
"2",
":",
"if",
"!",
"s",
".",
"Prefix",
".",
"IsWhitelisted",
"(",
")",
"{",
"return",
"nil",
",",
"newVerificationErrorWithString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"!",
"key",
".",
"Verify",
"(",
"s",
".",
"Prefix",
".",
"Prefix",
"(",
"payload",
")",
",",
"s",
".",
"Sig",
")",
"{",
"return",
"nil",
",",
"newVerificationErrorWithString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"default",
":",
"return",
"nil",
",",
"UnhandledSignatureError",
"{",
"s",
".",
"Version",
"}",
"\n",
"}",
"\n\n",
"return",
"key",
",",
"nil",
"\n",
"}"
] | // verifyWithPayload verifies the NaclSigInfo s, with the payload payload. Note that
// s may or may not have a payload already baked into it. If it does, and checkPayloadEquality
// is true, then we assert that the "baked-in" payload is equal to the specified payload.
// We'll only pass `false` for this flag from just above, to avoid checking that s.Payload == s.Payload,
// which we know it does. We need this unfortunate complexity because some signatures the client
// tries to verify are "attached," meaning the payload comes along with the sig info. And in other
// cases, the signatures are "detached", meaning they are supplied out-of-band. This function
// handles both cases. | [
"verifyWithPayload",
"verifies",
"the",
"NaclSigInfo",
"s",
"with",
"the",
"payload",
"payload",
".",
"Note",
"that",
"s",
"may",
"or",
"may",
"not",
"have",
"a",
"payload",
"already",
"baked",
"into",
"it",
".",
"If",
"it",
"does",
"and",
"checkPayloadEquality",
"is",
"true",
"then",
"we",
"assert",
"that",
"the",
"baked",
"-",
"in",
"payload",
"is",
"equal",
"to",
"the",
"specified",
"payload",
".",
"We",
"ll",
"only",
"pass",
"false",
"for",
"this",
"flag",
"from",
"just",
"above",
"to",
"avoid",
"checking",
"that",
"s",
".",
"Payload",
"==",
"s",
".",
"Payload",
"which",
"we",
"know",
"it",
"does",
".",
"We",
"need",
"this",
"unfortunate",
"complexity",
"because",
"some",
"signatures",
"the",
"client",
"tries",
"to",
"verify",
"are",
"attached",
"meaning",
"the",
"payload",
"comes",
"along",
"with",
"the",
"sig",
"info",
".",
"And",
"in",
"other",
"cases",
"the",
"signatures",
"are",
"detached",
"meaning",
"they",
"are",
"supplied",
"out",
"-",
"of",
"-",
"band",
".",
"This",
"function",
"handles",
"both",
"cases",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbcrypto/nacl_sig_info.go#L100-L133 |
158,654 | keybase/client | go/kbfs/libkbfs/channels.go | NewInfiniteChannelWrapper | func NewInfiniteChannelWrapper() *InfiniteChannelWrapper {
ch := &InfiniteChannelWrapper{
InfiniteChannel: channels.NewInfiniteChannel(),
input: make(chan interface{}, defaultInfiniteBufferSize),
shutdownCh: make(chan struct{}),
}
go ch.run()
return ch
} | go | func NewInfiniteChannelWrapper() *InfiniteChannelWrapper {
ch := &InfiniteChannelWrapper{
InfiniteChannel: channels.NewInfiniteChannel(),
input: make(chan interface{}, defaultInfiniteBufferSize),
shutdownCh: make(chan struct{}),
}
go ch.run()
return ch
} | [
"func",
"NewInfiniteChannelWrapper",
"(",
")",
"*",
"InfiniteChannelWrapper",
"{",
"ch",
":=",
"&",
"InfiniteChannelWrapper",
"{",
"InfiniteChannel",
":",
"channels",
".",
"NewInfiniteChannel",
"(",
")",
",",
"input",
":",
"make",
"(",
"chan",
"interface",
"{",
"}",
",",
"defaultInfiniteBufferSize",
")",
",",
"shutdownCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"go",
"ch",
".",
"run",
"(",
")",
"\n",
"return",
"ch",
"\n",
"}"
] | // NewInfiniteChannelWrapper returns a wrapper around a new infinite
// channel. | [
"NewInfiniteChannelWrapper",
"returns",
"a",
"wrapper",
"around",
"a",
"new",
"infinite",
"channel",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/channels.go#L30-L38 |
158,655 | keybase/client | go/libkb/config.go | Check | func (f *JSONConfigFile) Check() error {
return PickFirstError(
// Feel free to add others here..
func() error {
_, err := f.GetRunMode()
return err
}(),
)
} | go | func (f *JSONConfigFile) Check() error {
return PickFirstError(
// Feel free to add others here..
func() error {
_, err := f.GetRunMode()
return err
}(),
)
} | [
"func",
"(",
"f",
"*",
"JSONConfigFile",
")",
"Check",
"(",
")",
"error",
"{",
"return",
"PickFirstError",
"(",
"// Feel free to add others here..",
"func",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"f",
".",
"GetRunMode",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
"(",
")",
",",
")",
"\n",
"}"
] | // Check looks inside the JSON file to see if any fields are poorly specified | [
"Check",
"looks",
"inside",
"the",
"JSON",
"file",
"to",
"see",
"if",
"any",
"fields",
"are",
"poorly",
"specified"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/config.go#L32-L40 |
158,656 | keybase/client | go/libkb/config.go | getUserConfigWithLock | func (f *JSONConfigFile) getUserConfigWithLock() (ret *UserConfig, err error) {
var s string
if ret = f.userConfigWrapper.userConfig; ret != nil {
return
}
if s, err = f.jw.AtKey("current_user").GetString(); err != nil {
return
}
nu := NewNormalizedUsername(s)
if ret, err = f.GetUserConfigForUsername(nu); err != nil {
return
} else if ret != nil {
f.userConfigWrapper.userConfig = ret
} else {
err = ConfigError{f.filename,
fmt.Sprintf("Didn't find a UserConfig for %s", s)}
}
return
} | go | func (f *JSONConfigFile) getUserConfigWithLock() (ret *UserConfig, err error) {
var s string
if ret = f.userConfigWrapper.userConfig; ret != nil {
return
}
if s, err = f.jw.AtKey("current_user").GetString(); err != nil {
return
}
nu := NewNormalizedUsername(s)
if ret, err = f.GetUserConfigForUsername(nu); err != nil {
return
} else if ret != nil {
f.userConfigWrapper.userConfig = ret
} else {
err = ConfigError{f.filename,
fmt.Sprintf("Didn't find a UserConfig for %s", s)}
}
return
} | [
"func",
"(",
"f",
"*",
"JSONConfigFile",
")",
"getUserConfigWithLock",
"(",
")",
"(",
"ret",
"*",
"UserConfig",
",",
"err",
"error",
")",
"{",
"var",
"s",
"string",
"\n",
"if",
"ret",
"=",
"f",
".",
"userConfigWrapper",
".",
"userConfig",
";",
"ret",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"s",
",",
"err",
"=",
"f",
".",
"jw",
".",
"AtKey",
"(",
"\"",
"\"",
")",
".",
"GetString",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"nu",
":=",
"NewNormalizedUsername",
"(",
"s",
")",
"\n",
"if",
"ret",
",",
"err",
"=",
"f",
".",
"GetUserConfigForUsername",
"(",
"nu",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"else",
"if",
"ret",
"!=",
"nil",
"{",
"f",
".",
"userConfigWrapper",
".",
"userConfig",
"=",
"ret",
"\n",
"}",
"else",
"{",
"err",
"=",
"ConfigError",
"{",
"f",
".",
"filename",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
")",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetUserConfig looks for the `current_user` field to see if there's
// a corresponding user object in the `users` table. There really should be. | [
"GetUserConfig",
"looks",
"for",
"the",
"current_user",
"field",
"to",
"see",
"if",
"there",
"s",
"a",
"corresponding",
"user",
"object",
"in",
"the",
"users",
"table",
".",
"There",
"really",
"should",
"be",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/config.go#L91-L109 |
158,657 | keybase/client | go/libkb/config.go | NukeUser | func (f *JSONConfigFile) NukeUser(nu NormalizedUsername) error {
f.userConfigWrapper.Lock()
defer f.userConfigWrapper.Unlock()
if cu := f.getCurrentUser(); nu.IsNil() || cu.Eq(nu) {
err := f.jw.DeleteValueAtPath("current_user")
f.userConfigWrapper.userConfig = nil
if err != nil {
return err
}
if nu.IsNil() {
nu = cu
}
}
if !f.jw.AtKey("users").AtKey(nu.String()).IsNil() {
err := f.jw.DeleteValueAtPath("users." + nu.String())
if err != nil {
return err
}
}
return f.Save()
} | go | func (f *JSONConfigFile) NukeUser(nu NormalizedUsername) error {
f.userConfigWrapper.Lock()
defer f.userConfigWrapper.Unlock()
if cu := f.getCurrentUser(); nu.IsNil() || cu.Eq(nu) {
err := f.jw.DeleteValueAtPath("current_user")
f.userConfigWrapper.userConfig = nil
if err != nil {
return err
}
if nu.IsNil() {
nu = cu
}
}
if !f.jw.AtKey("users").AtKey(nu.String()).IsNil() {
err := f.jw.DeleteValueAtPath("users." + nu.String())
if err != nil {
return err
}
}
return f.Save()
} | [
"func",
"(",
"f",
"*",
"JSONConfigFile",
")",
"NukeUser",
"(",
"nu",
"NormalizedUsername",
")",
"error",
"{",
"f",
".",
"userConfigWrapper",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"userConfigWrapper",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"cu",
":=",
"f",
".",
"getCurrentUser",
"(",
")",
";",
"nu",
".",
"IsNil",
"(",
")",
"||",
"cu",
".",
"Eq",
"(",
"nu",
")",
"{",
"err",
":=",
"f",
".",
"jw",
".",
"DeleteValueAtPath",
"(",
"\"",
"\"",
")",
"\n",
"f",
".",
"userConfigWrapper",
".",
"userConfig",
"=",
"nil",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"nu",
".",
"IsNil",
"(",
")",
"{",
"nu",
"=",
"cu",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"!",
"f",
".",
"jw",
".",
"AtKey",
"(",
"\"",
"\"",
")",
".",
"AtKey",
"(",
"nu",
".",
"String",
"(",
")",
")",
".",
"IsNil",
"(",
")",
"{",
"err",
":=",
"f",
".",
"jw",
".",
"DeleteValueAtPath",
"(",
"\"",
"\"",
"+",
"nu",
".",
"String",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"f",
".",
"Save",
"(",
")",
"\n",
"}"
] | // NukeUser deletes the given user from the config file, or if
// the given user is empty, deletes the current user from the
// config file. | [
"NukeUser",
"deletes",
"the",
"given",
"user",
"from",
"the",
"config",
"file",
"or",
"if",
"the",
"given",
"user",
"is",
"empty",
"deletes",
"the",
"current",
"user",
"from",
"the",
"config",
"file",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/config.go#L185-L208 |
158,658 | keybase/client | go/libkb/config.go | GetUserConfigForUsername | func (f *JSONConfigFile) GetUserConfigForUsername(nu NormalizedUsername) (*UserConfig, error) {
if uc := f.copyUserConfigIfForUsername(nu); uc != nil {
return uc, nil
}
return ImportUserConfigFromJSONWrapper(f.jw.AtKey("users").AtKey(nu.String()))
} | go | func (f *JSONConfigFile) GetUserConfigForUsername(nu NormalizedUsername) (*UserConfig, error) {
if uc := f.copyUserConfigIfForUsername(nu); uc != nil {
return uc, nil
}
return ImportUserConfigFromJSONWrapper(f.jw.AtKey("users").AtKey(nu.String()))
} | [
"func",
"(",
"f",
"*",
"JSONConfigFile",
")",
"GetUserConfigForUsername",
"(",
"nu",
"NormalizedUsername",
")",
"(",
"*",
"UserConfig",
",",
"error",
")",
"{",
"if",
"uc",
":=",
"f",
".",
"copyUserConfigIfForUsername",
"(",
"nu",
")",
";",
"uc",
"!=",
"nil",
"{",
"return",
"uc",
",",
"nil",
"\n",
"}",
"\n",
"return",
"ImportUserConfigFromJSONWrapper",
"(",
"f",
".",
"jw",
".",
"AtKey",
"(",
"\"",
"\"",
")",
".",
"AtKey",
"(",
"nu",
".",
"String",
"(",
")",
")",
")",
"\n",
"}"
] | // GetUserConfigForUsername sees if there's a UserConfig object for the given
// username previously stored. | [
"GetUserConfigForUsername",
"sees",
"if",
"there",
"s",
"a",
"UserConfig",
"object",
"for",
"the",
"given",
"username",
"previously",
"stored",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/config.go#L212-L217 |
158,659 | keybase/client | go/libkb/config.go | GetUserConfigForUID | func (f *JSONConfigFile) GetUserConfigForUID(u keybase1.UID) (*UserConfig, error) {
if uc := f.copyUserConfigIfForUID(u); uc != nil {
return uc, nil
}
d := f.jw.AtKey("users")
keys, _ := d.Keys()
for _, key := range keys {
uc, err := f.GetUserConfigForUsername(NewNormalizedUsername(key))
if err == nil && uc != nil && uc.GetUID().Equal(u) {
return uc, nil
}
}
return nil, nil
} | go | func (f *JSONConfigFile) GetUserConfigForUID(u keybase1.UID) (*UserConfig, error) {
if uc := f.copyUserConfigIfForUID(u); uc != nil {
return uc, nil
}
d := f.jw.AtKey("users")
keys, _ := d.Keys()
for _, key := range keys {
uc, err := f.GetUserConfigForUsername(NewNormalizedUsername(key))
if err == nil && uc != nil && uc.GetUID().Equal(u) {
return uc, nil
}
}
return nil, nil
} | [
"func",
"(",
"f",
"*",
"JSONConfigFile",
")",
"GetUserConfigForUID",
"(",
"u",
"keybase1",
".",
"UID",
")",
"(",
"*",
"UserConfig",
",",
"error",
")",
"{",
"if",
"uc",
":=",
"f",
".",
"copyUserConfigIfForUID",
"(",
"u",
")",
";",
"uc",
"!=",
"nil",
"{",
"return",
"uc",
",",
"nil",
"\n",
"}",
"\n\n",
"d",
":=",
"f",
".",
"jw",
".",
"AtKey",
"(",
"\"",
"\"",
")",
"\n",
"keys",
",",
"_",
":=",
"d",
".",
"Keys",
"(",
")",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"uc",
",",
"err",
":=",
"f",
".",
"GetUserConfigForUsername",
"(",
"NewNormalizedUsername",
"(",
"key",
")",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"uc",
"!=",
"nil",
"&&",
"uc",
".",
"GetUID",
"(",
")",
".",
"Equal",
"(",
"u",
")",
"{",
"return",
"uc",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}"
] | // GetUserConfigForUID sees if there's a UserConfig object for the given UIDs previously stored. | [
"GetUserConfigForUID",
"sees",
"if",
"there",
"s",
"a",
"UserConfig",
"object",
"for",
"the",
"given",
"UIDs",
"previously",
"stored",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/config.go#L248-L263 |
158,660 | keybase/client | go/libkb/config.go | SetDeviceID | func (f *JSONConfigFile) SetDeviceID(did keybase1.DeviceID) (err error) {
f.userConfigWrapper.Lock()
defer f.userConfigWrapper.Unlock()
f.G().Log.Debug("| Setting DeviceID to %v\n", did)
var u *UserConfig
if u, err = f.getUserConfigWithLock(); err != nil {
} else if u == nil {
err = NoUserConfigError{}
} else {
u.SetDevice(did)
err = f.setUserConfigWithLock(u, true)
}
return
} | go | func (f *JSONConfigFile) SetDeviceID(did keybase1.DeviceID) (err error) {
f.userConfigWrapper.Lock()
defer f.userConfigWrapper.Unlock()
f.G().Log.Debug("| Setting DeviceID to %v\n", did)
var u *UserConfig
if u, err = f.getUserConfigWithLock(); err != nil {
} else if u == nil {
err = NoUserConfigError{}
} else {
u.SetDevice(did)
err = f.setUserConfigWithLock(u, true)
}
return
} | [
"func",
"(",
"f",
"*",
"JSONConfigFile",
")",
"SetDeviceID",
"(",
"did",
"keybase1",
".",
"DeviceID",
")",
"(",
"err",
"error",
")",
"{",
"f",
".",
"userConfigWrapper",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"userConfigWrapper",
".",
"Unlock",
"(",
")",
"\n\n",
"f",
".",
"G",
"(",
")",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\\n",
"\"",
",",
"did",
")",
"\n",
"var",
"u",
"*",
"UserConfig",
"\n",
"if",
"u",
",",
"err",
"=",
"f",
".",
"getUserConfigWithLock",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"}",
"else",
"if",
"u",
"==",
"nil",
"{",
"err",
"=",
"NoUserConfigError",
"{",
"}",
"\n",
"}",
"else",
"{",
"u",
".",
"SetDevice",
"(",
"did",
")",
"\n",
"err",
"=",
"f",
".",
"setUserConfigWithLock",
"(",
"u",
",",
"true",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // SetDeviceID sets the device field of the UserConfig object | [
"SetDeviceID",
"sets",
"the",
"device",
"field",
"of",
"the",
"UserConfig",
"object"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/config.go#L316-L330 |
158,661 | keybase/client | go/libcmdline/cmdline.go | ChooseCommand | func (p *CommandLine) ChooseCommand(cmd Command, name string, ctx *cli.Context) {
p.cmd = cmd
p.name = name
p.ctx = ctx
} | go | func (p *CommandLine) ChooseCommand(cmd Command, name string, ctx *cli.Context) {
p.cmd = cmd
p.name = name
p.ctx = ctx
} | [
"func",
"(",
"p",
"*",
"CommandLine",
")",
"ChooseCommand",
"(",
"cmd",
"Command",
",",
"name",
"string",
",",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"p",
".",
"cmd",
"=",
"cmd",
"\n",
"p",
".",
"name",
"=",
"name",
"\n",
"p",
".",
"ctx",
"=",
"ctx",
"\n",
"}"
] | // Called back from inside our subcommands, when they're picked... | [
"Called",
"back",
"from",
"inside",
"our",
"subcommands",
"when",
"they",
"re",
"picked",
"..."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libcmdline/cmdline.go#L778-L782 |
158,662 | keybase/client | go/libcmdline/cmdline.go | AddHelpTopics | func (p *CommandLine) AddHelpTopics(topics []cli.HelpTopic) {
p.app.HelpTopics = append(p.app.HelpTopics, topics...)
} | go | func (p *CommandLine) AddHelpTopics(topics []cli.HelpTopic) {
p.app.HelpTopics = append(p.app.HelpTopics, topics...)
} | [
"func",
"(",
"p",
"*",
"CommandLine",
")",
"AddHelpTopics",
"(",
"topics",
"[",
"]",
"cli",
".",
"HelpTopic",
")",
"{",
"p",
".",
"app",
".",
"HelpTopics",
"=",
"append",
"(",
"p",
".",
"app",
".",
"HelpTopics",
",",
"topics",
"...",
")",
"\n",
"}"
] | // AddHelpTopics appends topics to the list of help topics for
// this app. | [
"AddHelpTopics",
"appends",
"topics",
"to",
"the",
"list",
"of",
"help",
"topics",
"for",
"this",
"app",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libcmdline/cmdline.go#L821-L823 |
158,663 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | NewBlockServerMemory | func NewBlockServerMemory(log logger.Logger) *BlockServerMemory {
return &BlockServerMemory{
log, sync.RWMutex{}, make(map[kbfsblock.ID]blockMemEntry),
}
} | go | func NewBlockServerMemory(log logger.Logger) *BlockServerMemory {
return &BlockServerMemory{
log, sync.RWMutex{}, make(map[kbfsblock.ID]blockMemEntry),
}
} | [
"func",
"NewBlockServerMemory",
"(",
"log",
"logger",
".",
"Logger",
")",
"*",
"BlockServerMemory",
"{",
"return",
"&",
"BlockServerMemory",
"{",
"log",
",",
"sync",
".",
"RWMutex",
"{",
"}",
",",
"make",
"(",
"map",
"[",
"kbfsblock",
".",
"ID",
"]",
"blockMemEntry",
")",
",",
"}",
"\n",
"}"
] | // NewBlockServerMemory constructs a new BlockServerMemory that stores
// its data in memory. | [
"NewBlockServerMemory",
"constructs",
"a",
"new",
"BlockServerMemory",
"that",
"stores",
"its",
"data",
"in",
"memory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L42-L46 |
158,664 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | Get | func (b *BlockServerMemory) Get(
ctx context.Context, tlfID tlf.ID, id kbfsblock.ID,
context kbfsblock.Context, _ DiskBlockCacheType) (
data []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, err error) {
if err := checkContext(ctx); err != nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.Get id=%s tlfID=%s context=%s",
id, tlfID, context)
b.lock.RLock()
defer b.lock.RUnlock()
if b.m == nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{},
errBlockServerMemoryShutdown
}
entry, ok := b.m[id]
if !ok {
return nil, kbfscrypto.BlockCryptKeyServerHalf{},
kbfsblock.ServerErrorBlockNonExistent{
Msg: fmt.Sprintf("Block ID %s does not exist.", id)}
}
if entry.tlfID != tlfID {
return nil, kbfscrypto.BlockCryptKeyServerHalf{},
fmt.Errorf("TLF ID mismatch: expected %s, got %s",
entry.tlfID, tlfID)
}
exists, _, err := entry.refs.checkExists(context)
if err != nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err
}
if !exists {
return nil, kbfscrypto.BlockCryptKeyServerHalf{},
blockNonExistentError{id}
}
return entry.blockData, entry.keyServerHalf, nil
} | go | func (b *BlockServerMemory) Get(
ctx context.Context, tlfID tlf.ID, id kbfsblock.ID,
context kbfsblock.Context, _ DiskBlockCacheType) (
data []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, err error) {
if err := checkContext(ctx); err != nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.Get id=%s tlfID=%s context=%s",
id, tlfID, context)
b.lock.RLock()
defer b.lock.RUnlock()
if b.m == nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{},
errBlockServerMemoryShutdown
}
entry, ok := b.m[id]
if !ok {
return nil, kbfscrypto.BlockCryptKeyServerHalf{},
kbfsblock.ServerErrorBlockNonExistent{
Msg: fmt.Sprintf("Block ID %s does not exist.", id)}
}
if entry.tlfID != tlfID {
return nil, kbfscrypto.BlockCryptKeyServerHalf{},
fmt.Errorf("TLF ID mismatch: expected %s, got %s",
entry.tlfID, tlfID)
}
exists, _, err := entry.refs.checkExists(context)
if err != nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err
}
if !exists {
return nil, kbfscrypto.BlockCryptKeyServerHalf{},
blockNonExistentError{id}
}
return entry.blockData, entry.keyServerHalf, nil
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"id",
"kbfsblock",
".",
"ID",
",",
"context",
"kbfsblock",
".",
"Context",
",",
"_",
"DiskBlockCacheType",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"serverHalf",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"translateToBlockServerError",
"(",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"b",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"id",
",",
"tlfID",
",",
"context",
")",
"\n",
"b",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"b",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"b",
".",
"m",
"==",
"nil",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
"{",
"}",
",",
"errBlockServerMemoryShutdown",
"\n",
"}",
"\n\n",
"entry",
",",
"ok",
":=",
"b",
".",
"m",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
"{",
"}",
",",
"kbfsblock",
".",
"ServerErrorBlockNonExistent",
"{",
"Msg",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"id",
")",
"}",
"\n",
"}",
"\n\n",
"if",
"entry",
".",
"tlfID",
"!=",
"tlfID",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"entry",
".",
"tlfID",
",",
"tlfID",
")",
"\n",
"}",
"\n\n",
"exists",
",",
"_",
",",
"err",
":=",
"entry",
".",
"refs",
".",
"checkExists",
"(",
"context",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"exists",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
"{",
"}",
",",
"blockNonExistentError",
"{",
"id",
"}",
"\n",
"}",
"\n\n",
"return",
"entry",
".",
"blockData",
",",
"entry",
".",
"keyServerHalf",
",",
"nil",
"\n",
"}"
] | // Get implements the BlockServer interface for BlockServerMemory. | [
"Get",
"implements",
"the",
"BlockServer",
"interface",
"for",
"BlockServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L51-L95 |
158,665 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | doPut | func (b *BlockServerMemory) doPut(isRegularPut bool, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context,
buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf) (err error) {
defer func() {
err = translateToBlockServerError(err)
}()
err = validateBlockPut(isRegularPut, id, context, buf)
if err != nil {
return err
}
b.lock.Lock()
defer b.lock.Unlock()
if b.m == nil {
return errBlockServerMemoryShutdown
}
var refs blockRefMap
if entry, ok := b.m[id]; ok {
// If the entry already exists, everything should be
// the same, except for possibly additional
// references.
if entry.tlfID != tlfID {
return fmt.Errorf(
"TLF ID mismatch: expected %s, got %s",
entry.tlfID, tlfID)
}
// We checked that buf hashes to id, so no need to
// check that it's equal to entry.data (since that was
// presumably already checked previously).
if isRegularPut && entry.keyServerHalf != serverHalf {
return fmt.Errorf(
"key server half mismatch: expected %s, got %s",
entry.keyServerHalf, serverHalf)
}
refs = entry.refs
} else {
data := make([]byte, len(buf))
copy(data, buf)
refs = make(blockRefMap)
b.m[id] = blockMemEntry{
tlfID: tlfID,
blockData: data,
keyServerHalf: serverHalf,
refs: refs,
}
}
return refs.put(context, liveBlockRef, "")
} | go | func (b *BlockServerMemory) doPut(isRegularPut bool, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context,
buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf) (err error) {
defer func() {
err = translateToBlockServerError(err)
}()
err = validateBlockPut(isRegularPut, id, context, buf)
if err != nil {
return err
}
b.lock.Lock()
defer b.lock.Unlock()
if b.m == nil {
return errBlockServerMemoryShutdown
}
var refs blockRefMap
if entry, ok := b.m[id]; ok {
// If the entry already exists, everything should be
// the same, except for possibly additional
// references.
if entry.tlfID != tlfID {
return fmt.Errorf(
"TLF ID mismatch: expected %s, got %s",
entry.tlfID, tlfID)
}
// We checked that buf hashes to id, so no need to
// check that it's equal to entry.data (since that was
// presumably already checked previously).
if isRegularPut && entry.keyServerHalf != serverHalf {
return fmt.Errorf(
"key server half mismatch: expected %s, got %s",
entry.keyServerHalf, serverHalf)
}
refs = entry.refs
} else {
data := make([]byte, len(buf))
copy(data, buf)
refs = make(blockRefMap)
b.m[id] = blockMemEntry{
tlfID: tlfID,
blockData: data,
keyServerHalf: serverHalf,
refs: refs,
}
}
return refs.put(context, liveBlockRef, "")
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"doPut",
"(",
"isRegularPut",
"bool",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"id",
"kbfsblock",
".",
"ID",
",",
"context",
"kbfsblock",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
",",
"serverHalf",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"translateToBlockServerError",
"(",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"err",
"=",
"validateBlockPut",
"(",
"isRegularPut",
",",
"id",
",",
"context",
",",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"b",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"b",
".",
"m",
"==",
"nil",
"{",
"return",
"errBlockServerMemoryShutdown",
"\n",
"}",
"\n\n",
"var",
"refs",
"blockRefMap",
"\n",
"if",
"entry",
",",
"ok",
":=",
"b",
".",
"m",
"[",
"id",
"]",
";",
"ok",
"{",
"// If the entry already exists, everything should be",
"// the same, except for possibly additional",
"// references.",
"if",
"entry",
".",
"tlfID",
"!=",
"tlfID",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"entry",
".",
"tlfID",
",",
"tlfID",
")",
"\n",
"}",
"\n\n",
"// We checked that buf hashes to id, so no need to",
"// check that it's equal to entry.data (since that was",
"// presumably already checked previously).",
"if",
"isRegularPut",
"&&",
"entry",
".",
"keyServerHalf",
"!=",
"serverHalf",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"entry",
".",
"keyServerHalf",
",",
"serverHalf",
")",
"\n",
"}",
"\n\n",
"refs",
"=",
"entry",
".",
"refs",
"\n",
"}",
"else",
"{",
"data",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"buf",
")",
")",
"\n",
"copy",
"(",
"data",
",",
"buf",
")",
"\n",
"refs",
"=",
"make",
"(",
"blockRefMap",
")",
"\n",
"b",
".",
"m",
"[",
"id",
"]",
"=",
"blockMemEntry",
"{",
"tlfID",
":",
"tlfID",
",",
"blockData",
":",
"data",
",",
"keyServerHalf",
":",
"serverHalf",
",",
"refs",
":",
"refs",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"refs",
".",
"put",
"(",
"context",
",",
"liveBlockRef",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // doPut consolidates the put logic for implementing both the Put and PutAgain interface. | [
"doPut",
"consolidates",
"the",
"put",
"logic",
"for",
"implementing",
"both",
"the",
"Put",
"and",
"PutAgain",
"interface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L162-L215 |
158,666 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | PutAgain | func (b *BlockServerMemory) PutAgain(
ctx context.Context, tlfID tlf.ID, id kbfsblock.ID,
context kbfsblock.Context, buf []byte,
serverHalf kbfscrypto.BlockCryptKeyServerHalf,
_ DiskBlockCacheType) (err error) {
if err := checkContext(ctx); err != nil {
return err
}
b.log.CDebugf(ctx, "BlockServerMemory.PutAgain id=%s tlfID=%s context=%s "+
"size=%d", id, tlfID, context, len(buf))
return b.doPut(false, tlfID, id, context, buf, serverHalf)
} | go | func (b *BlockServerMemory) PutAgain(
ctx context.Context, tlfID tlf.ID, id kbfsblock.ID,
context kbfsblock.Context, buf []byte,
serverHalf kbfscrypto.BlockCryptKeyServerHalf,
_ DiskBlockCacheType) (err error) {
if err := checkContext(ctx); err != nil {
return err
}
b.log.CDebugf(ctx, "BlockServerMemory.PutAgain id=%s tlfID=%s context=%s "+
"size=%d", id, tlfID, context, len(buf))
return b.doPut(false, tlfID, id, context, buf, serverHalf)
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"PutAgain",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"id",
"kbfsblock",
".",
"ID",
",",
"context",
"kbfsblock",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
",",
"serverHalf",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
",",
"_",
"DiskBlockCacheType",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"b",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"id",
",",
"tlfID",
",",
"context",
",",
"len",
"(",
"buf",
")",
")",
"\n\n",
"return",
"b",
".",
"doPut",
"(",
"false",
",",
"tlfID",
",",
"id",
",",
"context",
",",
"buf",
",",
"serverHalf",
")",
"\n",
"}"
] | // PutAgain implements the BlockServer interface for BlockServerMemory. | [
"PutAgain",
"implements",
"the",
"BlockServer",
"interface",
"for",
"BlockServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L233-L245 |
158,667 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | AddBlockReference | func (b *BlockServerMemory) AddBlockReference(ctx context.Context, tlfID tlf.ID,
id kbfsblock.ID, context kbfsblock.Context) (err error) {
if err := checkContext(ctx); err != nil {
return err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.AddBlockReference id=%s "+
"tlfID=%s context=%s", id, tlfID, context)
b.lock.Lock()
defer b.lock.Unlock()
if b.m == nil {
return errBlockServerMemoryShutdown
}
entry, ok := b.m[id]
if !ok {
return kbfsblock.ServerErrorBlockNonExistent{
Msg: fmt.Sprintf("Block ID %s doesn't "+
"exist and cannot be referenced.", id)}
}
if entry.tlfID != tlfID {
return fmt.Errorf("TLF ID mismatch: expected %s, got %s",
entry.tlfID, tlfID)
}
return entry.refs.put(context, liveBlockRef, "")
} | go | func (b *BlockServerMemory) AddBlockReference(ctx context.Context, tlfID tlf.ID,
id kbfsblock.ID, context kbfsblock.Context) (err error) {
if err := checkContext(ctx); err != nil {
return err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.AddBlockReference id=%s "+
"tlfID=%s context=%s", id, tlfID, context)
b.lock.Lock()
defer b.lock.Unlock()
if b.m == nil {
return errBlockServerMemoryShutdown
}
entry, ok := b.m[id]
if !ok {
return kbfsblock.ServerErrorBlockNonExistent{
Msg: fmt.Sprintf("Block ID %s doesn't "+
"exist and cannot be referenced.", id)}
}
if entry.tlfID != tlfID {
return fmt.Errorf("TLF ID mismatch: expected %s, got %s",
entry.tlfID, tlfID)
}
return entry.refs.put(context, liveBlockRef, "")
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"AddBlockReference",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"id",
"kbfsblock",
".",
"ID",
",",
"context",
"kbfsblock",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"translateToBlockServerError",
"(",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"b",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"id",
",",
"tlfID",
",",
"context",
")",
"\n\n",
"b",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"b",
".",
"m",
"==",
"nil",
"{",
"return",
"errBlockServerMemoryShutdown",
"\n",
"}",
"\n\n",
"entry",
",",
"ok",
":=",
"b",
".",
"m",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"kbfsblock",
".",
"ServerErrorBlockNonExistent",
"{",
"Msg",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"id",
")",
"}",
"\n",
"}",
"\n\n",
"if",
"entry",
".",
"tlfID",
"!=",
"tlfID",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"entry",
".",
"tlfID",
",",
"tlfID",
")",
"\n",
"}",
"\n\n",
"return",
"entry",
".",
"refs",
".",
"put",
"(",
"context",
",",
"liveBlockRef",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // AddBlockReference implements the BlockServer interface for BlockServerMemory. | [
"AddBlockReference",
"implements",
"the",
"BlockServer",
"interface",
"for",
"BlockServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L248-L280 |
158,668 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | RemoveBlockReferences | func (b *BlockServerMemory) RemoveBlockReferences(ctx context.Context,
tlfID tlf.ID, contexts kbfsblock.ContextMap) (
liveCounts map[kbfsblock.ID]int, err error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.RemoveBlockReference "+
"tlfID=%s contexts=%v", tlfID, contexts)
liveCounts = make(map[kbfsblock.ID]int)
for id, idContexts := range contexts {
count, err := b.removeBlockReference(tlfID, id, idContexts)
if err != nil {
return nil, err
}
liveCounts[id] = count
}
return liveCounts, nil
} | go | func (b *BlockServerMemory) RemoveBlockReferences(ctx context.Context,
tlfID tlf.ID, contexts kbfsblock.ContextMap) (
liveCounts map[kbfsblock.ID]int, err error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.RemoveBlockReference "+
"tlfID=%s contexts=%v", tlfID, contexts)
liveCounts = make(map[kbfsblock.ID]int)
for id, idContexts := range contexts {
count, err := b.removeBlockReference(tlfID, id, idContexts)
if err != nil {
return nil, err
}
liveCounts[id] = count
}
return liveCounts, nil
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"RemoveBlockReferences",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"contexts",
"kbfsblock",
".",
"ContextMap",
")",
"(",
"liveCounts",
"map",
"[",
"kbfsblock",
".",
"ID",
"]",
"int",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"translateToBlockServerError",
"(",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"b",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"tlfID",
",",
"contexts",
")",
"\n",
"liveCounts",
"=",
"make",
"(",
"map",
"[",
"kbfsblock",
".",
"ID",
"]",
"int",
")",
"\n",
"for",
"id",
",",
"idContexts",
":=",
"range",
"contexts",
"{",
"count",
",",
"err",
":=",
"b",
".",
"removeBlockReference",
"(",
"tlfID",
",",
"id",
",",
"idContexts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"liveCounts",
"[",
"id",
"]",
"=",
"count",
"\n",
"}",
"\n",
"return",
"liveCounts",
",",
"nil",
"\n",
"}"
] | // RemoveBlockReferences implements the BlockServer interface for
// BlockServerMemory. | [
"RemoveBlockReferences",
"implements",
"the",
"BlockServer",
"interface",
"for",
"BlockServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L318-L339 |
158,669 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | ArchiveBlockReferences | func (b *BlockServerMemory) ArchiveBlockReferences(ctx context.Context,
tlfID tlf.ID, contexts kbfsblock.ContextMap) (err error) {
if err := checkContext(ctx); err != nil {
return err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.ArchiveBlockReferences "+
"tlfID=%s contexts=%v", tlfID, contexts)
for id, idContexts := range contexts {
for _, context := range idContexts {
err := b.archiveBlockReference(tlfID, id, context)
if err != nil {
return err
}
}
}
return nil
} | go | func (b *BlockServerMemory) ArchiveBlockReferences(ctx context.Context,
tlfID tlf.ID, contexts kbfsblock.ContextMap) (err error) {
if err := checkContext(ctx); err != nil {
return err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.ArchiveBlockReferences "+
"tlfID=%s contexts=%v", tlfID, contexts)
for id, idContexts := range contexts {
for _, context := range idContexts {
err := b.archiveBlockReference(tlfID, id, context)
if err != nil {
return err
}
}
}
return nil
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"ArchiveBlockReferences",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"contexts",
"kbfsblock",
".",
"ContextMap",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"translateToBlockServerError",
"(",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"b",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"tlfID",
",",
"contexts",
")",
"\n\n",
"for",
"id",
",",
"idContexts",
":=",
"range",
"contexts",
"{",
"for",
"_",
",",
"context",
":=",
"range",
"idContexts",
"{",
"err",
":=",
"b",
".",
"archiveBlockReference",
"(",
"tlfID",
",",
"id",
",",
"context",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // ArchiveBlockReferences implements the BlockServer interface for
// BlockServerMemory. | [
"ArchiveBlockReferences",
"implements",
"the",
"BlockServer",
"interface",
"for",
"BlockServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L378-L400 |
158,670 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | GetLiveBlockReferences | func (b *BlockServerMemory) GetLiveBlockReferences(
ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) (
liveCounts map[kbfsblock.ID]int, err error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.GetLiveBlockReferences "+
"tlfID=%s contexts=%v", tlfID, contexts)
b.lock.Lock()
defer b.lock.Unlock()
if b.m == nil {
return nil, errBlockServerMemoryShutdown
}
liveCounts = make(map[kbfsblock.ID]int)
for id := range contexts {
count := 0
entry, ok := b.m[id]
if ok {
count = entry.refs.getLiveCount()
}
liveCounts[id] = count
}
return liveCounts, nil
} | go | func (b *BlockServerMemory) GetLiveBlockReferences(
ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) (
liveCounts map[kbfsblock.ID]int, err error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
defer func() {
err = translateToBlockServerError(err)
}()
b.log.CDebugf(ctx, "BlockServerMemory.GetLiveBlockReferences "+
"tlfID=%s contexts=%v", tlfID, contexts)
b.lock.Lock()
defer b.lock.Unlock()
if b.m == nil {
return nil, errBlockServerMemoryShutdown
}
liveCounts = make(map[kbfsblock.ID]int)
for id := range contexts {
count := 0
entry, ok := b.m[id]
if ok {
count = entry.refs.getLiveCount()
}
liveCounts[id] = count
}
return liveCounts, nil
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"GetLiveBlockReferences",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"contexts",
"kbfsblock",
".",
"ContextMap",
")",
"(",
"liveCounts",
"map",
"[",
"kbfsblock",
".",
"ID",
"]",
"int",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"translateToBlockServerError",
"(",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"b",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"tlfID",
",",
"contexts",
")",
"\n\n",
"b",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"b",
".",
"m",
"==",
"nil",
"{",
"return",
"nil",
",",
"errBlockServerMemoryShutdown",
"\n",
"}",
"\n\n",
"liveCounts",
"=",
"make",
"(",
"map",
"[",
"kbfsblock",
".",
"ID",
"]",
"int",
")",
"\n",
"for",
"id",
":=",
"range",
"contexts",
"{",
"count",
":=",
"0",
"\n",
"entry",
",",
"ok",
":=",
"b",
".",
"m",
"[",
"id",
"]",
"\n",
"if",
"ok",
"{",
"count",
"=",
"entry",
".",
"refs",
".",
"getLiveCount",
"(",
")",
"\n",
"}",
"\n",
"liveCounts",
"[",
"id",
"]",
"=",
"count",
"\n",
"}",
"\n",
"return",
"liveCounts",
",",
"nil",
"\n",
"}"
] | // GetLiveBlockReferences implements the BlockServer interface for
// BlockServerMemory. | [
"GetLiveBlockReferences",
"implements",
"the",
"BlockServer",
"interface",
"for",
"BlockServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L404-L434 |
158,671 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | IsUnflushed | func (b *BlockServerMemory) IsUnflushed(ctx context.Context, tlfID tlf.ID,
_ kbfsblock.ID) (bool, error) {
b.lock.RLock()
defer b.lock.RUnlock()
if b.m == nil {
return false, errBlockServerMemoryShutdown
}
return false, nil
} | go | func (b *BlockServerMemory) IsUnflushed(ctx context.Context, tlfID tlf.ID,
_ kbfsblock.ID) (bool, error) {
b.lock.RLock()
defer b.lock.RUnlock()
if b.m == nil {
return false, errBlockServerMemoryShutdown
}
return false, nil
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"IsUnflushed",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"_",
"kbfsblock",
".",
"ID",
")",
"(",
"bool",
",",
"error",
")",
"{",
"b",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"b",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"b",
".",
"m",
"==",
"nil",
"{",
"return",
"false",
",",
"errBlockServerMemoryShutdown",
"\n",
"}",
"\n\n",
"return",
"false",
",",
"nil",
"\n",
"}"
] | // IsUnflushed implements the BlockServer interface for BlockServerMemory. | [
"IsUnflushed",
"implements",
"the",
"BlockServer",
"interface",
"for",
"BlockServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L465-L475 |
158,672 | keybase/client | go/kbfs/libkbfs/bserver_memory.go | Shutdown | func (b *BlockServerMemory) Shutdown(ctx context.Context) {
b.lock.Lock()
defer b.lock.Unlock()
// Make further accesses error out.
b.m = nil
} | go | func (b *BlockServerMemory) Shutdown(ctx context.Context) {
b.lock.Lock()
defer b.lock.Unlock()
// Make further accesses error out.
b.m = nil
} | [
"func",
"(",
"b",
"*",
"BlockServerMemory",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"b",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"// Make further accesses error out.",
"b",
".",
"m",
"=",
"nil",
"\n",
"}"
] | // Shutdown implements the BlockServer interface for BlockServerMemory. | [
"Shutdown",
"implements",
"the",
"BlockServer",
"interface",
"for",
"BlockServerMemory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_memory.go#L478-L483 |
158,673 | keybase/client | go/kbfs/libkbfs/kcache_measured.go | NewKeyCacheMeasured | func NewKeyCacheMeasured(delegate KeyCache, r metrics.Registry) KeyCacheMeasured {
getTimer := metrics.GetOrRegisterTimer("KeyCache.GetTLFCryptKey", r)
putTimer := metrics.GetOrRegisterTimer("KeyCache.PutTLFCryptKey", r)
// TODO: Implement RatioGauge (
// http://metrics.dropwizard.io/3.1.0/manual/core/#ratio-gauges
// ) so we can actually display a hit ratio.
hitCountMeter := metrics.GetOrRegisterMeter("KeyCache.HitCount", r)
return KeyCacheMeasured{
delegate: delegate,
getTimer: getTimer,
putTimer: putTimer,
hitCountMeter: hitCountMeter,
}
} | go | func NewKeyCacheMeasured(delegate KeyCache, r metrics.Registry) KeyCacheMeasured {
getTimer := metrics.GetOrRegisterTimer("KeyCache.GetTLFCryptKey", r)
putTimer := metrics.GetOrRegisterTimer("KeyCache.PutTLFCryptKey", r)
// TODO: Implement RatioGauge (
// http://metrics.dropwizard.io/3.1.0/manual/core/#ratio-gauges
// ) so we can actually display a hit ratio.
hitCountMeter := metrics.GetOrRegisterMeter("KeyCache.HitCount", r)
return KeyCacheMeasured{
delegate: delegate,
getTimer: getTimer,
putTimer: putTimer,
hitCountMeter: hitCountMeter,
}
} | [
"func",
"NewKeyCacheMeasured",
"(",
"delegate",
"KeyCache",
",",
"r",
"metrics",
".",
"Registry",
")",
"KeyCacheMeasured",
"{",
"getTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"putTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"// TODO: Implement RatioGauge (",
"// http://metrics.dropwizard.io/3.1.0/manual/core/#ratio-gauges",
"// ) so we can actually display a hit ratio.",
"hitCountMeter",
":=",
"metrics",
".",
"GetOrRegisterMeter",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"return",
"KeyCacheMeasured",
"{",
"delegate",
":",
"delegate",
",",
"getTimer",
":",
"getTimer",
",",
"putTimer",
":",
"putTimer",
",",
"hitCountMeter",
":",
"hitCountMeter",
",",
"}",
"\n",
"}"
] | // NewKeyCacheMeasured creates and returns a new KeyCacheMeasured
// instance with the given delegate and registry. | [
"NewKeyCacheMeasured",
"creates",
"and",
"returns",
"a",
"new",
"KeyCacheMeasured",
"instance",
"with",
"the",
"given",
"delegate",
"and",
"registry",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/kcache_measured.go#L27-L40 |
158,674 | keybase/client | go/kbfs/libkbfs/kcache_measured.go | GetTLFCryptKey | func (b KeyCacheMeasured) GetTLFCryptKey(
tlfID tlf.ID, keyGen kbfsmd.KeyGen) (key kbfscrypto.TLFCryptKey, err error) {
b.getTimer.Time(func() {
key, err = b.delegate.GetTLFCryptKey(tlfID, keyGen)
})
if err == nil {
b.hitCountMeter.Mark(1)
}
return key, err
} | go | func (b KeyCacheMeasured) GetTLFCryptKey(
tlfID tlf.ID, keyGen kbfsmd.KeyGen) (key kbfscrypto.TLFCryptKey, err error) {
b.getTimer.Time(func() {
key, err = b.delegate.GetTLFCryptKey(tlfID, keyGen)
})
if err == nil {
b.hitCountMeter.Mark(1)
}
return key, err
} | [
"func",
"(",
"b",
"KeyCacheMeasured",
")",
"GetTLFCryptKey",
"(",
"tlfID",
"tlf",
".",
"ID",
",",
"keyGen",
"kbfsmd",
".",
"KeyGen",
")",
"(",
"key",
"kbfscrypto",
".",
"TLFCryptKey",
",",
"err",
"error",
")",
"{",
"b",
".",
"getTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"key",
",",
"err",
"=",
"b",
".",
"delegate",
".",
"GetTLFCryptKey",
"(",
"tlfID",
",",
"keyGen",
")",
"\n",
"}",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"b",
".",
"hitCountMeter",
".",
"Mark",
"(",
"1",
")",
"\n",
"}",
"\n",
"return",
"key",
",",
"err",
"\n",
"}"
] | // GetTLFCryptKey implements the KeyCache interface for
// KeyCacheMeasured. | [
"GetTLFCryptKey",
"implements",
"the",
"KeyCache",
"interface",
"for",
"KeyCacheMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/kcache_measured.go#L44-L53 |
158,675 | keybase/client | go/kbfs/libkbfs/kcache_measured.go | PutTLFCryptKey | func (b KeyCacheMeasured) PutTLFCryptKey(
tlfID tlf.ID, keyGen kbfsmd.KeyGen, key kbfscrypto.TLFCryptKey) (err error) {
b.putTimer.Time(func() {
err = b.delegate.PutTLFCryptKey(tlfID, keyGen, key)
})
return err
} | go | func (b KeyCacheMeasured) PutTLFCryptKey(
tlfID tlf.ID, keyGen kbfsmd.KeyGen, key kbfscrypto.TLFCryptKey) (err error) {
b.putTimer.Time(func() {
err = b.delegate.PutTLFCryptKey(tlfID, keyGen, key)
})
return err
} | [
"func",
"(",
"b",
"KeyCacheMeasured",
")",
"PutTLFCryptKey",
"(",
"tlfID",
"tlf",
".",
"ID",
",",
"keyGen",
"kbfsmd",
".",
"KeyGen",
",",
"key",
"kbfscrypto",
".",
"TLFCryptKey",
")",
"(",
"err",
"error",
")",
"{",
"b",
".",
"putTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"b",
".",
"delegate",
".",
"PutTLFCryptKey",
"(",
"tlfID",
",",
"keyGen",
",",
"key",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // PutTLFCryptKey implements the KeyCache interface for
// KeyCacheMeasured. | [
"PutTLFCryptKey",
"implements",
"the",
"KeyCache",
"interface",
"for",
"KeyCacheMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/kcache_measured.go#L57-L63 |
158,676 | keybase/client | go/kbfs/redirector/main.go | mountpointMatchesRunmode | func mountpointMatchesRunmode(mp, runmode string) bool {
i := strings.Index(mp, runmode)
if i < 0 {
return false
}
if len(mp) == i+len(runmode) || mp[i+len(runmode)] == '/' ||
mp[i+len(runmode)] == ' ' {
return true
}
return false
} | go | func mountpointMatchesRunmode(mp, runmode string) bool {
i := strings.Index(mp, runmode)
if i < 0 {
return false
}
if len(mp) == i+len(runmode) || mp[i+len(runmode)] == '/' ||
mp[i+len(runmode)] == ' ' {
return true
}
return false
} | [
"func",
"mountpointMatchesRunmode",
"(",
"mp",
",",
"runmode",
"string",
")",
"bool",
"{",
"i",
":=",
"strings",
".",
"Index",
"(",
"mp",
",",
"runmode",
")",
"\n",
"if",
"i",
"<",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"len",
"(",
"mp",
")",
"==",
"i",
"+",
"len",
"(",
"runmode",
")",
"||",
"mp",
"[",
"i",
"+",
"len",
"(",
"runmode",
")",
"]",
"==",
"'/'",
"||",
"mp",
"[",
"i",
"+",
"len",
"(",
"runmode",
")",
"]",
"==",
"' '",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // mountpointMatchesRunmode returns true if `mp` contains `runmode` at
// the end of a component of the path, or followed by a space. | [
"mountpointMatchesRunmode",
"returns",
"true",
"if",
"mp",
"contains",
"runmode",
"at",
"the",
"end",
"of",
"a",
"component",
"of",
"the",
"path",
"or",
"followed",
"by",
"a",
"space",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/redirector/main.go#L129-L139 |
158,677 | keybase/client | go/libkb/kbsig.go | SignJSON | func SignJSON(jw *jsonw.Wrapper, key GenericKey) (out string, id keybase1.SigID, lid LinkID, err error) {
var tmp []byte
if tmp, err = jw.Marshal(); err != nil {
return
}
out, id, err = key.SignToString(tmp)
lid = ComputeLinkID(tmp)
return
} | go | func SignJSON(jw *jsonw.Wrapper, key GenericKey) (out string, id keybase1.SigID, lid LinkID, err error) {
var tmp []byte
if tmp, err = jw.Marshal(); err != nil {
return
}
out, id, err = key.SignToString(tmp)
lid = ComputeLinkID(tmp)
return
} | [
"func",
"SignJSON",
"(",
"jw",
"*",
"jsonw",
".",
"Wrapper",
",",
"key",
"GenericKey",
")",
"(",
"out",
"string",
",",
"id",
"keybase1",
".",
"SigID",
",",
"lid",
"LinkID",
",",
"err",
"error",
")",
"{",
"var",
"tmp",
"[",
"]",
"byte",
"\n",
"if",
"tmp",
",",
"err",
"=",
"jw",
".",
"Marshal",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"out",
",",
"id",
",",
"err",
"=",
"key",
".",
"SignToString",
"(",
"tmp",
")",
"\n",
"lid",
"=",
"ComputeLinkID",
"(",
"tmp",
")",
"\n",
"return",
"\n",
"}"
] | // SimpleSignJson marshals the given Json structure and then signs it. | [
"SimpleSignJson",
"marshals",
"the",
"given",
"Json",
"structure",
"and",
"then",
"signs",
"it",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/kbsig.go#L562-L570 |
158,678 | keybase/client | go/libkb/kbsig.go | PerUserKeyProof | func PerUserKeyProof(m MetaContext,
me *User,
pukSigKID keybase1.KID,
pukEncKID keybase1.KID,
generation keybase1.PerUserKeyGeneration,
signingKey GenericKey) (*ProofMetadataRes, error) {
if me == nil {
return nil, fmt.Errorf("missing user object for proof")
}
ret, err := ProofMetadata{
Me: me,
LinkType: LinkTypePerUserKey,
SigningKey: signingKey,
}.ToJSON2(m)
if err != nil {
return nil, err
}
pukSection := jsonw.NewDictionary()
pukSection.SetKey("signing_kid", jsonw.NewString(pukSigKID.String()))
pukSection.SetKey("encryption_kid", jsonw.NewString(pukEncKID.String()))
pukSection.SetKey("generation", jsonw.NewInt(int(generation)))
// The caller is responsible for overwriting reverse_sig after signing.
pukSection.SetKey("reverse_sig", jsonw.NewNil())
body := ret.J.AtKey("body")
body.SetKey("per_user_key", pukSection)
return ret, nil
} | go | func PerUserKeyProof(m MetaContext,
me *User,
pukSigKID keybase1.KID,
pukEncKID keybase1.KID,
generation keybase1.PerUserKeyGeneration,
signingKey GenericKey) (*ProofMetadataRes, error) {
if me == nil {
return nil, fmt.Errorf("missing user object for proof")
}
ret, err := ProofMetadata{
Me: me,
LinkType: LinkTypePerUserKey,
SigningKey: signingKey,
}.ToJSON2(m)
if err != nil {
return nil, err
}
pukSection := jsonw.NewDictionary()
pukSection.SetKey("signing_kid", jsonw.NewString(pukSigKID.String()))
pukSection.SetKey("encryption_kid", jsonw.NewString(pukEncKID.String()))
pukSection.SetKey("generation", jsonw.NewInt(int(generation)))
// The caller is responsible for overwriting reverse_sig after signing.
pukSection.SetKey("reverse_sig", jsonw.NewNil())
body := ret.J.AtKey("body")
body.SetKey("per_user_key", pukSection)
return ret, nil
} | [
"func",
"PerUserKeyProof",
"(",
"m",
"MetaContext",
",",
"me",
"*",
"User",
",",
"pukSigKID",
"keybase1",
".",
"KID",
",",
"pukEncKID",
"keybase1",
".",
"KID",
",",
"generation",
"keybase1",
".",
"PerUserKeyGeneration",
",",
"signingKey",
"GenericKey",
")",
"(",
"*",
"ProofMetadataRes",
",",
"error",
")",
"{",
"if",
"me",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"ret",
",",
"err",
":=",
"ProofMetadata",
"{",
"Me",
":",
"me",
",",
"LinkType",
":",
"LinkTypePerUserKey",
",",
"SigningKey",
":",
"signingKey",
",",
"}",
".",
"ToJSON2",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"pukSection",
":=",
"jsonw",
".",
"NewDictionary",
"(",
")",
"\n",
"pukSection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewString",
"(",
"pukSigKID",
".",
"String",
"(",
")",
")",
")",
"\n",
"pukSection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewString",
"(",
"pukEncKID",
".",
"String",
"(",
")",
")",
")",
"\n",
"pukSection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewInt",
"(",
"int",
"(",
"generation",
")",
")",
")",
"\n",
"// The caller is responsible for overwriting reverse_sig after signing.",
"pukSection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewNil",
"(",
")",
")",
"\n\n",
"body",
":=",
"ret",
".",
"J",
".",
"AtKey",
"(",
"\"",
"\"",
")",
"\n",
"body",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"pukSection",
")",
"\n\n",
"return",
"ret",
",",
"nil",
"\n",
"}"
] | // PerUserKeyProof creates a proof introducing a new per-user-key generation.
// `signingKey` is the key signing in this new key. Not to be confused with the derived per-user-key signing key. | [
"PerUserKeyProof",
"creates",
"a",
"proof",
"introducing",
"a",
"new",
"per",
"-",
"user",
"-",
"key",
"generation",
".",
"signingKey",
"is",
"the",
"key",
"signing",
"in",
"this",
"new",
"key",
".",
"Not",
"to",
"be",
"confused",
"with",
"the",
"derived",
"per",
"-",
"user",
"-",
"key",
"signing",
"key",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/kbsig.go#L746-L777 |
158,679 | keybase/client | go/libkb/kbsig.go | StellarProof | func StellarProof(m MetaContext, me *User, walletAddress stellar1.AccountID,
signingKey GenericKey) (*ProofMetadataRes, error) {
if me == nil {
return nil, fmt.Errorf("missing user object for proof")
}
walletPubKey, err := MakeNaclSigningKeyPairFromStellarAccountID(walletAddress)
if err != nil {
return nil, err
}
walletKID := walletPubKey.GetKID()
ret, err := ProofMetadata{
Me: me,
LinkType: LinkTypeWalletStellar,
SigningKey: signingKey,
SigVersion: KeybaseSignatureV2,
IgnoreIfUnsupported: SigIgnoreIfUnsupported(true),
}.ToJSON2(m)
if err != nil {
return nil, err
}
walletSection := jsonw.NewDictionary()
walletSection.SetKey("address", jsonw.NewString(walletAddress.String()))
walletSection.SetKey("network", jsonw.NewString(string(WalletNetworkStellar)))
// Inner links can be hidden. To prevent an attacker from figuring out the
// contents from the hash of the inner link, add 18 random bytes.
entropy, err := LinkEntropy()
if err != nil {
return nil, err
}
walletSection.SetKey("entropy", jsonw.NewString(entropy))
walletKeySection := jsonw.NewDictionary()
walletKeySection.SetKey("kid", jsonw.NewString(walletKID.String()))
// The caller is responsible for overwriting reverse_sig after signing.
walletKeySection.SetKey("reverse_sig", jsonw.NewNil())
body := ret.J.AtKey("body")
body.SetKey("wallet", walletSection)
body.SetKey("wallet_key", walletKeySection)
return ret, nil
} | go | func StellarProof(m MetaContext, me *User, walletAddress stellar1.AccountID,
signingKey GenericKey) (*ProofMetadataRes, error) {
if me == nil {
return nil, fmt.Errorf("missing user object for proof")
}
walletPubKey, err := MakeNaclSigningKeyPairFromStellarAccountID(walletAddress)
if err != nil {
return nil, err
}
walletKID := walletPubKey.GetKID()
ret, err := ProofMetadata{
Me: me,
LinkType: LinkTypeWalletStellar,
SigningKey: signingKey,
SigVersion: KeybaseSignatureV2,
IgnoreIfUnsupported: SigIgnoreIfUnsupported(true),
}.ToJSON2(m)
if err != nil {
return nil, err
}
walletSection := jsonw.NewDictionary()
walletSection.SetKey("address", jsonw.NewString(walletAddress.String()))
walletSection.SetKey("network", jsonw.NewString(string(WalletNetworkStellar)))
// Inner links can be hidden. To prevent an attacker from figuring out the
// contents from the hash of the inner link, add 18 random bytes.
entropy, err := LinkEntropy()
if err != nil {
return nil, err
}
walletSection.SetKey("entropy", jsonw.NewString(entropy))
walletKeySection := jsonw.NewDictionary()
walletKeySection.SetKey("kid", jsonw.NewString(walletKID.String()))
// The caller is responsible for overwriting reverse_sig after signing.
walletKeySection.SetKey("reverse_sig", jsonw.NewNil())
body := ret.J.AtKey("body")
body.SetKey("wallet", walletSection)
body.SetKey("wallet_key", walletKeySection)
return ret, nil
} | [
"func",
"StellarProof",
"(",
"m",
"MetaContext",
",",
"me",
"*",
"User",
",",
"walletAddress",
"stellar1",
".",
"AccountID",
",",
"signingKey",
"GenericKey",
")",
"(",
"*",
"ProofMetadataRes",
",",
"error",
")",
"{",
"if",
"me",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"walletPubKey",
",",
"err",
":=",
"MakeNaclSigningKeyPairFromStellarAccountID",
"(",
"walletAddress",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"walletKID",
":=",
"walletPubKey",
".",
"GetKID",
"(",
")",
"\n\n",
"ret",
",",
"err",
":=",
"ProofMetadata",
"{",
"Me",
":",
"me",
",",
"LinkType",
":",
"LinkTypeWalletStellar",
",",
"SigningKey",
":",
"signingKey",
",",
"SigVersion",
":",
"KeybaseSignatureV2",
",",
"IgnoreIfUnsupported",
":",
"SigIgnoreIfUnsupported",
"(",
"true",
")",
",",
"}",
".",
"ToJSON2",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"walletSection",
":=",
"jsonw",
".",
"NewDictionary",
"(",
")",
"\n",
"walletSection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewString",
"(",
"walletAddress",
".",
"String",
"(",
")",
")",
")",
"\n",
"walletSection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewString",
"(",
"string",
"(",
"WalletNetworkStellar",
")",
")",
")",
"\n\n",
"// Inner links can be hidden. To prevent an attacker from figuring out the",
"// contents from the hash of the inner link, add 18 random bytes.",
"entropy",
",",
"err",
":=",
"LinkEntropy",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"walletSection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewString",
"(",
"entropy",
")",
")",
"\n\n",
"walletKeySection",
":=",
"jsonw",
".",
"NewDictionary",
"(",
")",
"\n",
"walletKeySection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewString",
"(",
"walletKID",
".",
"String",
"(",
")",
")",
")",
"\n",
"// The caller is responsible for overwriting reverse_sig after signing.",
"walletKeySection",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"jsonw",
".",
"NewNil",
"(",
")",
")",
"\n\n",
"body",
":=",
"ret",
".",
"J",
".",
"AtKey",
"(",
"\"",
"\"",
")",
"\n",
"body",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"walletSection",
")",
"\n",
"body",
".",
"SetKey",
"(",
"\"",
"\"",
",",
"walletKeySection",
")",
"\n\n",
"return",
"ret",
",",
"nil",
"\n",
"}"
] | // StellarProof creates a proof of a stellar wallet. | [
"StellarProof",
"creates",
"a",
"proof",
"of",
"a",
"stellar",
"wallet",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/kbsig.go#L846-L890 |
158,680 | keybase/client | go/kbfs/kbfsmd/root_metadata.go | DecodeRootMetadata | func DecodeRootMetadata(codec kbfscodec.Codec, tlfID tlf.ID,
ver, max MetadataVer, buf []byte) (MutableRootMetadata, error) {
rmd, err := makeMutableRootMetadataForDecode(codec, tlfID, ver, max, buf)
if err != nil {
return nil, err
}
if err := codec.Decode(buf, rmd); err != nil {
return nil, err
}
if ver < ImplicitTeamsVer && tlfID.Type() != tlf.SingleTeam &&
rmd.TypeForKeying() == tlf.TeamKeying {
return nil, errors.Errorf(
"Can't make an implicit teams TLF with version %s", ver)
}
return rmd, nil
} | go | func DecodeRootMetadata(codec kbfscodec.Codec, tlfID tlf.ID,
ver, max MetadataVer, buf []byte) (MutableRootMetadata, error) {
rmd, err := makeMutableRootMetadataForDecode(codec, tlfID, ver, max, buf)
if err != nil {
return nil, err
}
if err := codec.Decode(buf, rmd); err != nil {
return nil, err
}
if ver < ImplicitTeamsVer && tlfID.Type() != tlf.SingleTeam &&
rmd.TypeForKeying() == tlf.TeamKeying {
return nil, errors.Errorf(
"Can't make an implicit teams TLF with version %s", ver)
}
return rmd, nil
} | [
"func",
"DecodeRootMetadata",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"ver",
",",
"max",
"MetadataVer",
",",
"buf",
"[",
"]",
"byte",
")",
"(",
"MutableRootMetadata",
",",
"error",
")",
"{",
"rmd",
",",
"err",
":=",
"makeMutableRootMetadataForDecode",
"(",
"codec",
",",
"tlfID",
",",
"ver",
",",
"max",
",",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"codec",
".",
"Decode",
"(",
"buf",
",",
"rmd",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"ver",
"<",
"ImplicitTeamsVer",
"&&",
"tlfID",
".",
"Type",
"(",
")",
"!=",
"tlf",
".",
"SingleTeam",
"&&",
"rmd",
".",
"TypeForKeying",
"(",
")",
"==",
"tlf",
".",
"TeamKeying",
"{",
"return",
"nil",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ver",
")",
"\n",
"}",
"\n",
"return",
"rmd",
",",
"nil",
"\n",
"}"
] | // DecodeRootMetadata deserializes a metadata block into the specified
// versioned structure. | [
"DecodeRootMetadata",
"deserializes",
"a",
"metadata",
"block",
"into",
"the",
"specified",
"versioned",
"structure",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata.go#L356-L371 |
158,681 | keybase/client | go/kbfs/kbfsmd/root_metadata.go | DumpRootMetadata | func DumpRootMetadata(
codec kbfscodec.Codec, rmd RootMetadata) (string, error) {
serializedRMD, err := codec.Encode(rmd)
if err != nil {
return "", err
}
// Make a copy so we can zero out SerializedPrivateMetadata.
rmdCopy, err := rmd.DeepCopy(codec)
if err != nil {
return "", err
}
rmdCopy.SetSerializedPrivateMetadata(nil)
s := fmt.Sprintf("MD revision: %s\n"+
"MD size: %d bytes\n"+
"Private MD size: %d bytes\n"+
"MD version: %s\n\n",
rmd.RevisionNumber(),
len(serializedRMD),
len(rmd.GetSerializedPrivateMetadata()),
rmd.Version())
s += DumpConfig().Sdump(rmdCopy)
return s, nil
} | go | func DumpRootMetadata(
codec kbfscodec.Codec, rmd RootMetadata) (string, error) {
serializedRMD, err := codec.Encode(rmd)
if err != nil {
return "", err
}
// Make a copy so we can zero out SerializedPrivateMetadata.
rmdCopy, err := rmd.DeepCopy(codec)
if err != nil {
return "", err
}
rmdCopy.SetSerializedPrivateMetadata(nil)
s := fmt.Sprintf("MD revision: %s\n"+
"MD size: %d bytes\n"+
"Private MD size: %d bytes\n"+
"MD version: %s\n\n",
rmd.RevisionNumber(),
len(serializedRMD),
len(rmd.GetSerializedPrivateMetadata()),
rmd.Version())
s += DumpConfig().Sdump(rmdCopy)
return s, nil
} | [
"func",
"DumpRootMetadata",
"(",
"codec",
"kbfscodec",
".",
"Codec",
",",
"rmd",
"RootMetadata",
")",
"(",
"string",
",",
"error",
")",
"{",
"serializedRMD",
",",
"err",
":=",
"codec",
".",
"Encode",
"(",
"rmd",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"// Make a copy so we can zero out SerializedPrivateMetadata.",
"rmdCopy",
",",
"err",
":=",
"rmd",
".",
"DeepCopy",
"(",
"codec",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"rmdCopy",
".",
"SetSerializedPrivateMetadata",
"(",
"nil",
")",
"\n",
"s",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
"+",
"\"",
"\\n",
"\"",
"+",
"\"",
"\\n",
"\"",
"+",
"\"",
"\\n",
"\\n",
"\"",
",",
"rmd",
".",
"RevisionNumber",
"(",
")",
",",
"len",
"(",
"serializedRMD",
")",
",",
"len",
"(",
"rmd",
".",
"GetSerializedPrivateMetadata",
"(",
")",
")",
",",
"rmd",
".",
"Version",
"(",
")",
")",
"\n",
"s",
"+=",
"DumpConfig",
"(",
")",
".",
"Sdump",
"(",
"rmdCopy",
")",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // DumpRootMetadata returns a detailed dump of the given
// RootMetadata's contents. | [
"DumpRootMetadata",
"returns",
"a",
"detailed",
"dump",
"of",
"the",
"given",
"RootMetadata",
"s",
"contents",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/root_metadata.go#L386-L410 |
158,682 | keybase/client | go/protocol/keybase1/favorite.go | FavoriteAdd | func (c FavoriteClient) FavoriteAdd(ctx context.Context, __arg FavoriteAddArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.favorite.favoriteAdd", []interface{}{__arg}, nil)
return
} | go | func (c FavoriteClient) FavoriteAdd(ctx context.Context, __arg FavoriteAddArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.favorite.favoriteAdd", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"FavoriteClient",
")",
"FavoriteAdd",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"FavoriteAddArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Adds a folder to a user's list of favorite folders. | [
"Adds",
"a",
"folder",
"to",
"a",
"user",
"s",
"list",
"of",
"favorite",
"folders",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/favorite.go#L207-L210 |
158,683 | keybase/client | go/protocol/keybase1/favorite.go | FavoriteIgnore | func (c FavoriteClient) FavoriteIgnore(ctx context.Context, __arg FavoriteIgnoreArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.favorite.favoriteIgnore", []interface{}{__arg}, nil)
return
} | go | func (c FavoriteClient) FavoriteIgnore(ctx context.Context, __arg FavoriteIgnoreArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.favorite.favoriteIgnore", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"FavoriteClient",
")",
"FavoriteIgnore",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"FavoriteIgnoreArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Removes a folder from a user's list of favorite folders. | [
"Removes",
"a",
"folder",
"from",
"a",
"user",
"s",
"list",
"of",
"favorite",
"folders",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/favorite.go#L213-L216 |
158,684 | keybase/client | go/protocol/keybase1/favorite.go | GetFavorites | func (c FavoriteClient) GetFavorites(ctx context.Context, sessionID int) (res FavoritesResult, err error) {
__arg := GetFavoritesArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.favorite.getFavorites", []interface{}{__arg}, &res)
return
} | go | func (c FavoriteClient) GetFavorites(ctx context.Context, sessionID int) (res FavoritesResult, err error) {
__arg := GetFavoritesArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.favorite.getFavorites", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"FavoriteClient",
")",
"GetFavorites",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"res",
"FavoritesResult",
",",
"err",
"error",
")",
"{",
"__arg",
":=",
"GetFavoritesArg",
"{",
"SessionID",
":",
"sessionID",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // Returns all of a user's favorite folders. | [
"Returns",
"all",
"of",
"a",
"user",
"s",
"favorite",
"folders",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/favorite.go#L219-L223 |
158,685 | keybase/client | go/client/cmd_ctl_watchdog2.go | NewCmdWatchdog2 | func NewCmdWatchdog2(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "watchdog2",
Usage: "Start and monitor background services",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdWatchdog2{Contextified: libkb.NewContextified(g)}, "watchdog2", c)
cl.SetForkCmd(libcmdline.NoFork)
cl.SetLogForward(libcmdline.LogForwardNone)
},
}
} | go | func NewCmdWatchdog2(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "watchdog2",
Usage: "Start and monitor background services",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdWatchdog2{Contextified: libkb.NewContextified(g)}, "watchdog2", c)
cl.SetForkCmd(libcmdline.NoFork)
cl.SetLogForward(libcmdline.LogForwardNone)
},
}
} | [
"func",
"NewCmdWatchdog2",
"(",
"cl",
"*",
"libcmdline",
".",
"CommandLine",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"Action",
":",
"func",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"cl",
".",
"ChooseCommand",
"(",
"&",
"CmdWatchdog2",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
"}",
",",
"\"",
"\"",
",",
"c",
")",
"\n",
"cl",
".",
"SetForkCmd",
"(",
"libcmdline",
".",
"NoFork",
")",
"\n",
"cl",
".",
"SetLogForward",
"(",
"libcmdline",
".",
"LogForwardNone",
")",
"\n",
"}",
",",
"}",
"\n",
"}"
] | // NewCmdWatchdog2 constructs watchdog command | [
"NewCmdWatchdog2",
"constructs",
"watchdog",
"command"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_ctl_watchdog2.go#L120-L130 |
158,686 | keybase/client | go/kbfs/kbfsmd/key_bundle.go | Equals | func (dpk DevicePublicKeys) Equals(other DevicePublicKeys) bool {
if len(dpk) != len(other) {
return false
}
for k := range dpk {
if !other[k] {
return false
}
}
return true
} | go | func (dpk DevicePublicKeys) Equals(other DevicePublicKeys) bool {
if len(dpk) != len(other) {
return false
}
for k := range dpk {
if !other[k] {
return false
}
}
return true
} | [
"func",
"(",
"dpk",
"DevicePublicKeys",
")",
"Equals",
"(",
"other",
"DevicePublicKeys",
")",
"bool",
"{",
"if",
"len",
"(",
"dpk",
")",
"!=",
"len",
"(",
"other",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"k",
":=",
"range",
"dpk",
"{",
"if",
"!",
"other",
"[",
"k",
"]",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] | // Equals returns whether both sets of keys are equal. | [
"Equals",
"returns",
"whether",
"both",
"sets",
"of",
"keys",
"are",
"equal",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle.go#L30-L42 |
158,687 | keybase/client | go/kbfs/kbfsmd/key_bundle.go | Equals | func (udpk UserDevicePublicKeys) Equals(other UserDevicePublicKeys) bool {
if len(udpk) != len(other) {
return false
}
for u, dpk := range udpk {
if !dpk.Equals(other[u]) {
return false
}
}
return true
} | go | func (udpk UserDevicePublicKeys) Equals(other UserDevicePublicKeys) bool {
if len(udpk) != len(other) {
return false
}
for u, dpk := range udpk {
if !dpk.Equals(other[u]) {
return false
}
}
return true
} | [
"func",
"(",
"udpk",
"UserDevicePublicKeys",
")",
"Equals",
"(",
"other",
"UserDevicePublicKeys",
")",
"bool",
"{",
"if",
"len",
"(",
"udpk",
")",
"!=",
"len",
"(",
"other",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"u",
",",
"dpk",
":=",
"range",
"udpk",
"{",
"if",
"!",
"dpk",
".",
"Equals",
"(",
"other",
"[",
"u",
"]",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] | // Equals returns whether both sets of users are equal, and they all
// have corresponding equal sets of keys. | [
"Equals",
"returns",
"whether",
"both",
"sets",
"of",
"users",
"are",
"equal",
"and",
"they",
"all",
"have",
"corresponding",
"equal",
"sets",
"of",
"keys",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle.go#L61-L73 |
158,688 | keybase/client | go/kbfs/kbfsmd/key_bundle.go | MergeUsers | func (serverHalves UserDeviceKeyServerHalves) MergeUsers(
other UserDeviceKeyServerHalves) (UserDeviceKeyServerHalves, error) {
merged := make(UserDeviceKeyServerHalves,
len(serverHalves)+len(other))
for uid, deviceServerHalves := range serverHalves {
merged[uid] = deviceServerHalves
}
for uid, deviceServerHalves := range other {
if _, ok := merged[uid]; ok {
return nil, fmt.Errorf(
"user %s is in both UserDeviceKeyServerHalves",
uid)
}
merged[uid] = deviceServerHalves
}
return merged, nil
} | go | func (serverHalves UserDeviceKeyServerHalves) MergeUsers(
other UserDeviceKeyServerHalves) (UserDeviceKeyServerHalves, error) {
merged := make(UserDeviceKeyServerHalves,
len(serverHalves)+len(other))
for uid, deviceServerHalves := range serverHalves {
merged[uid] = deviceServerHalves
}
for uid, deviceServerHalves := range other {
if _, ok := merged[uid]; ok {
return nil, fmt.Errorf(
"user %s is in both UserDeviceKeyServerHalves",
uid)
}
merged[uid] = deviceServerHalves
}
return merged, nil
} | [
"func",
"(",
"serverHalves",
"UserDeviceKeyServerHalves",
")",
"MergeUsers",
"(",
"other",
"UserDeviceKeyServerHalves",
")",
"(",
"UserDeviceKeyServerHalves",
",",
"error",
")",
"{",
"merged",
":=",
"make",
"(",
"UserDeviceKeyServerHalves",
",",
"len",
"(",
"serverHalves",
")",
"+",
"len",
"(",
"other",
")",
")",
"\n",
"for",
"uid",
",",
"deviceServerHalves",
":=",
"range",
"serverHalves",
"{",
"merged",
"[",
"uid",
"]",
"=",
"deviceServerHalves",
"\n",
"}",
"\n",
"for",
"uid",
",",
"deviceServerHalves",
":=",
"range",
"other",
"{",
"if",
"_",
",",
"ok",
":=",
"merged",
"[",
"uid",
"]",
";",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"uid",
")",
"\n",
"}",
"\n",
"merged",
"[",
"uid",
"]",
"=",
"deviceServerHalves",
"\n",
"}",
"\n",
"return",
"merged",
",",
"nil",
"\n",
"}"
] | // MergeUsers returns a UserDeviceKeyServerHalves that contains all
// the users in serverHalves and other, which must be disjoint. This
// isn't a deep copy. | [
"MergeUsers",
"returns",
"a",
"UserDeviceKeyServerHalves",
"that",
"contains",
"all",
"the",
"users",
"in",
"serverHalves",
"and",
"other",
"which",
"must",
"be",
"disjoint",
".",
"This",
"isn",
"t",
"a",
"deep",
"copy",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle.go#L87-L103 |
158,689 | keybase/client | go/kbfs/kbfsmd/key_bundle.go | MergeUsers | func (info ServerHalfRemovalInfo) MergeUsers(
other ServerHalfRemovalInfo) (ServerHalfRemovalInfo, error) {
merged := make(ServerHalfRemovalInfo, len(info)+len(other))
for uid, removalInfo := range info {
merged[uid] = removalInfo
}
for uid, removalInfo := range other {
if _, ok := merged[uid]; ok {
return nil, fmt.Errorf(
"user %s is in both ServerHalfRemovalInfos",
uid)
}
merged[uid] = removalInfo
}
return merged, nil
} | go | func (info ServerHalfRemovalInfo) MergeUsers(
other ServerHalfRemovalInfo) (ServerHalfRemovalInfo, error) {
merged := make(ServerHalfRemovalInfo, len(info)+len(other))
for uid, removalInfo := range info {
merged[uid] = removalInfo
}
for uid, removalInfo := range other {
if _, ok := merged[uid]; ok {
return nil, fmt.Errorf(
"user %s is in both ServerHalfRemovalInfos",
uid)
}
merged[uid] = removalInfo
}
return merged, nil
} | [
"func",
"(",
"info",
"ServerHalfRemovalInfo",
")",
"MergeUsers",
"(",
"other",
"ServerHalfRemovalInfo",
")",
"(",
"ServerHalfRemovalInfo",
",",
"error",
")",
"{",
"merged",
":=",
"make",
"(",
"ServerHalfRemovalInfo",
",",
"len",
"(",
"info",
")",
"+",
"len",
"(",
"other",
")",
")",
"\n",
"for",
"uid",
",",
"removalInfo",
":=",
"range",
"info",
"{",
"merged",
"[",
"uid",
"]",
"=",
"removalInfo",
"\n",
"}",
"\n",
"for",
"uid",
",",
"removalInfo",
":=",
"range",
"other",
"{",
"if",
"_",
",",
"ok",
":=",
"merged",
"[",
"uid",
"]",
";",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"uid",
")",
"\n",
"}",
"\n",
"merged",
"[",
"uid",
"]",
"=",
"removalInfo",
"\n",
"}",
"\n",
"return",
"merged",
",",
"nil",
"\n",
"}"
] | // MergeUsers returns a ServerHalfRemovalInfo that contains all the
// users in info and other, which must be disjoint. This isn't a deep
// copy. | [
"MergeUsers",
"returns",
"a",
"ServerHalfRemovalInfo",
"that",
"contains",
"all",
"the",
"users",
"in",
"info",
"and",
"other",
"which",
"must",
"be",
"disjoint",
".",
"This",
"isn",
"t",
"a",
"deep",
"copy",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/key_bundle.go#L237-L252 |
158,690 | keybase/client | go/kbfs/libkbfs/journal_block_cache.go | CheckForKnownPtr | func (j journalBlockCache) CheckForKnownPtr(
tlfID tlf.ID, block *data.FileBlock) (data.BlockPointer, error) {
_, ok := j.jManager.getTLFJournal(tlfID, nil)
if !ok {
return j.BlockCache.CheckForKnownPtr(tlfID, block)
}
// Temporarily disable de-duping for the journal server until
// KBFS-1149 is fixed. (See also
// journalBlockServer.AddReference.)
return data.BlockPointer{}, nil
} | go | func (j journalBlockCache) CheckForKnownPtr(
tlfID tlf.ID, block *data.FileBlock) (data.BlockPointer, error) {
_, ok := j.jManager.getTLFJournal(tlfID, nil)
if !ok {
return j.BlockCache.CheckForKnownPtr(tlfID, block)
}
// Temporarily disable de-duping for the journal server until
// KBFS-1149 is fixed. (See also
// journalBlockServer.AddReference.)
return data.BlockPointer{}, nil
} | [
"func",
"(",
"j",
"journalBlockCache",
")",
"CheckForKnownPtr",
"(",
"tlfID",
"tlf",
".",
"ID",
",",
"block",
"*",
"data",
".",
"FileBlock",
")",
"(",
"data",
".",
"BlockPointer",
",",
"error",
")",
"{",
"_",
",",
"ok",
":=",
"j",
".",
"jManager",
".",
"getTLFJournal",
"(",
"tlfID",
",",
"nil",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"j",
".",
"BlockCache",
".",
"CheckForKnownPtr",
"(",
"tlfID",
",",
"block",
")",
"\n",
"}",
"\n\n",
"// Temporarily disable de-duping for the journal server until",
"// KBFS-1149 is fixed. (See also",
"// journalBlockServer.AddReference.)",
"return",
"data",
".",
"BlockPointer",
"{",
"}",
",",
"nil",
"\n",
"}"
] | // CheckForKnownPtr implements BlockCache. | [
"CheckForKnownPtr",
"implements",
"BlockCache",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/journal_block_cache.go#L20-L31 |
158,691 | keybase/client | go/client/cmd_simplefs_history.go | ParseArgv | func (c *CmdSimpleFSHistory) ParseArgv(ctx *cli.Context) error {
c.deletes = ctx.Bool("deletes")
if len(ctx.Args()) > 1 {
return fmt.Errorf("wrong number of arguments")
} else if len(ctx.Args()) == 1 {
p, err := makeSimpleFSPath(ctx.Args()[0])
if err != nil {
return err
}
c.path = p
}
return nil
} | go | func (c *CmdSimpleFSHistory) ParseArgv(ctx *cli.Context) error {
c.deletes = ctx.Bool("deletes")
if len(ctx.Args()) > 1 {
return fmt.Errorf("wrong number of arguments")
} else if len(ctx.Args()) == 1 {
p, err := makeSimpleFSPath(ctx.Args()[0])
if err != nil {
return err
}
c.path = p
}
return nil
} | [
"func",
"(",
"c",
"*",
"CmdSimpleFSHistory",
")",
"ParseArgv",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"c",
".",
"deletes",
"=",
"ctx",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
">",
"1",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"==",
"1",
"{",
"p",
",",
"err",
":=",
"makeSimpleFSPath",
"(",
"ctx",
".",
"Args",
"(",
")",
"[",
"0",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"c",
".",
"path",
"=",
"p",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // ParseArgv gets the optional path, if any. | [
"ParseArgv",
"gets",
"the",
"optional",
"path",
"if",
"any",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_simplefs_history.go#L93-L106 |
158,692 | keybase/client | go/chat/search/session.go | searchConv | func (s *searchSession) searchConv(ctx context.Context, convID chat1.ConversationID) (msgIDs []chat1.MessageID, err error) {
defer s.indexer.Trace(ctx, func() error { return err }, fmt.Sprintf("searchConv convID: %s", convID))()
var allMsgIDs mapset.Set
for token := range s.tokens {
matchedIDs := mapset.NewThreadUnsafeSet()
idMap, err := s.indexer.store.GetHits(ctx, s.uid, convID, token)
if err != nil {
return nil, err
}
for msgID := range idMap {
matchedIDs.Add(msgID)
}
if allMsgIDs == nil {
allMsgIDs = matchedIDs
} else {
allMsgIDs = allMsgIDs.Intersect(matchedIDs)
if allMsgIDs.Cardinality() == 0 {
// no matches in this conversation..
return nil, nil
}
}
}
msgIDSlice := msgIDsFromSet(allMsgIDs)
// Sort so we can truncate if necessary, returning the newest results first.
sort.Sort(utils.ByMsgID(msgIDSlice))
return msgIDSlice, nil
} | go | func (s *searchSession) searchConv(ctx context.Context, convID chat1.ConversationID) (msgIDs []chat1.MessageID, err error) {
defer s.indexer.Trace(ctx, func() error { return err }, fmt.Sprintf("searchConv convID: %s", convID))()
var allMsgIDs mapset.Set
for token := range s.tokens {
matchedIDs := mapset.NewThreadUnsafeSet()
idMap, err := s.indexer.store.GetHits(ctx, s.uid, convID, token)
if err != nil {
return nil, err
}
for msgID := range idMap {
matchedIDs.Add(msgID)
}
if allMsgIDs == nil {
allMsgIDs = matchedIDs
} else {
allMsgIDs = allMsgIDs.Intersect(matchedIDs)
if allMsgIDs.Cardinality() == 0 {
// no matches in this conversation..
return nil, nil
}
}
}
msgIDSlice := msgIDsFromSet(allMsgIDs)
// Sort so we can truncate if necessary, returning the newest results first.
sort.Sort(utils.ByMsgID(msgIDSlice))
return msgIDSlice, nil
} | [
"func",
"(",
"s",
"*",
"searchSession",
")",
"searchConv",
"(",
"ctx",
"context",
".",
"Context",
",",
"convID",
"chat1",
".",
"ConversationID",
")",
"(",
"msgIDs",
"[",
"]",
"chat1",
".",
"MessageID",
",",
"err",
"error",
")",
"{",
"defer",
"s",
".",
"indexer",
".",
"Trace",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"convID",
")",
")",
"(",
")",
"\n",
"var",
"allMsgIDs",
"mapset",
".",
"Set",
"\n",
"for",
"token",
":=",
"range",
"s",
".",
"tokens",
"{",
"matchedIDs",
":=",
"mapset",
".",
"NewThreadUnsafeSet",
"(",
")",
"\n",
"idMap",
",",
"err",
":=",
"s",
".",
"indexer",
".",
"store",
".",
"GetHits",
"(",
"ctx",
",",
"s",
".",
"uid",
",",
"convID",
",",
"token",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"for",
"msgID",
":=",
"range",
"idMap",
"{",
"matchedIDs",
".",
"Add",
"(",
"msgID",
")",
"\n",
"}",
"\n",
"if",
"allMsgIDs",
"==",
"nil",
"{",
"allMsgIDs",
"=",
"matchedIDs",
"\n",
"}",
"else",
"{",
"allMsgIDs",
"=",
"allMsgIDs",
".",
"Intersect",
"(",
"matchedIDs",
")",
"\n",
"if",
"allMsgIDs",
".",
"Cardinality",
"(",
")",
"==",
"0",
"{",
"// no matches in this conversation..",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"msgIDSlice",
":=",
"msgIDsFromSet",
"(",
"allMsgIDs",
")",
"\n\n",
"// Sort so we can truncate if necessary, returning the newest results first.",
"sort",
".",
"Sort",
"(",
"utils",
".",
"ByMsgID",
"(",
"msgIDSlice",
")",
")",
"\n",
"return",
"msgIDSlice",
",",
"nil",
"\n",
"}"
] | // searchConv finds all messages that match the given set of tokens and opts,
// results are ordered desc by msg id. | [
"searchConv",
"finds",
"all",
"messages",
"that",
"match",
"the",
"given",
"set",
"of",
"tokens",
"and",
"opts",
"results",
"are",
"ordered",
"desc",
"by",
"msg",
"id",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/session.go#L82-L109 |
158,693 | keybase/client | go/chat/search/session.go | preSearch | func (s *searchSession) preSearch(ctx context.Context) (err error) {
defer s.indexer.Trace(ctx, func() error { return err }, "searchSession.preSearch")()
for _, conv := range s.convList {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
s.updateInboxIndex(ctx, conv.Conv)
switch s.opts.ReindexMode {
case chat1.ReIndexingMode_POSTSEARCH_SYNC:
fullyIndexed, err := s.convFullyIndexed(ctx, conv.Conv)
if err != nil || !fullyIndexed {
if err != nil {
s.indexer.Debug(ctx, "Search: failed to compute full indexed: %s", err)
}
s.reindexConvs = append(s.reindexConvs, conv.GetConvID())
}
}
}
percentIndexed, err := s.inboxIndexStatus.updateUI(ctx)
if err != nil {
return err
}
s.indexer.Debug(ctx, "Search: percent: %d", percentIndexed)
for _, conv := range s.convList {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
switch s.opts.ReindexMode {
case chat1.ReIndexingMode_PRESEARCH_SYNC:
if err := s.reindexConvWithUIUpdate(ctx, conv); err != nil {
s.indexer.Debug(ctx, "Search: Unable to reindexConv: %v, %v, %v", conv.GetName(), conv.GetConvID(), err)
s.inboxIndexStatus.rmConv(conv.Conv)
continue
}
s.updateInboxIndex(ctx, conv.Conv)
}
}
return nil
} | go | func (s *searchSession) preSearch(ctx context.Context) (err error) {
defer s.indexer.Trace(ctx, func() error { return err }, "searchSession.preSearch")()
for _, conv := range s.convList {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
s.updateInboxIndex(ctx, conv.Conv)
switch s.opts.ReindexMode {
case chat1.ReIndexingMode_POSTSEARCH_SYNC:
fullyIndexed, err := s.convFullyIndexed(ctx, conv.Conv)
if err != nil || !fullyIndexed {
if err != nil {
s.indexer.Debug(ctx, "Search: failed to compute full indexed: %s", err)
}
s.reindexConvs = append(s.reindexConvs, conv.GetConvID())
}
}
}
percentIndexed, err := s.inboxIndexStatus.updateUI(ctx)
if err != nil {
return err
}
s.indexer.Debug(ctx, "Search: percent: %d", percentIndexed)
for _, conv := range s.convList {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
switch s.opts.ReindexMode {
case chat1.ReIndexingMode_PRESEARCH_SYNC:
if err := s.reindexConvWithUIUpdate(ctx, conv); err != nil {
s.indexer.Debug(ctx, "Search: Unable to reindexConv: %v, %v, %v", conv.GetName(), conv.GetConvID(), err)
s.inboxIndexStatus.rmConv(conv.Conv)
continue
}
s.updateInboxIndex(ctx, conv.Conv)
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"searchSession",
")",
"preSearch",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"s",
".",
"indexer",
".",
"Trace",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
",",
"\"",
"\"",
")",
"(",
")",
"\n",
"for",
"_",
",",
"conv",
":=",
"range",
"s",
".",
"convList",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"default",
":",
"}",
"\n",
"s",
".",
"updateInboxIndex",
"(",
"ctx",
",",
"conv",
".",
"Conv",
")",
"\n",
"switch",
"s",
".",
"opts",
".",
"ReindexMode",
"{",
"case",
"chat1",
".",
"ReIndexingMode_POSTSEARCH_SYNC",
":",
"fullyIndexed",
",",
"err",
":=",
"s",
".",
"convFullyIndexed",
"(",
"ctx",
",",
"conv",
".",
"Conv",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"!",
"fullyIndexed",
"{",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"indexer",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"s",
".",
"reindexConvs",
"=",
"append",
"(",
"s",
".",
"reindexConvs",
",",
"conv",
".",
"GetConvID",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"percentIndexed",
",",
"err",
":=",
"s",
".",
"inboxIndexStatus",
".",
"updateUI",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"s",
".",
"indexer",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"percentIndexed",
")",
"\n\n",
"for",
"_",
",",
"conv",
":=",
"range",
"s",
".",
"convList",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"default",
":",
"}",
"\n",
"switch",
"s",
".",
"opts",
".",
"ReindexMode",
"{",
"case",
"chat1",
".",
"ReIndexingMode_PRESEARCH_SYNC",
":",
"if",
"err",
":=",
"s",
".",
"reindexConvWithUIUpdate",
"(",
"ctx",
",",
"conv",
")",
";",
"err",
"!=",
"nil",
"{",
"s",
".",
"indexer",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"conv",
".",
"GetName",
"(",
")",
",",
"conv",
".",
"GetConvID",
"(",
")",
",",
"err",
")",
"\n",
"s",
".",
"inboxIndexStatus",
".",
"rmConv",
"(",
"conv",
".",
"Conv",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"s",
".",
"updateInboxIndex",
"(",
"ctx",
",",
"conv",
".",
"Conv",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // preSearch is the first pipeline stage, blocking on reindexing conversations
// if PRESEARCH_SYNC is set. As conversations are processed they are passed to
// the `search` stage via `preSearchCh`. | [
"preSearch",
"is",
"the",
"first",
"pipeline",
"stage",
"blocking",
"on",
"reindexing",
"conversations",
"if",
"PRESEARCH_SYNC",
"is",
"set",
".",
"As",
"conversations",
"are",
"processed",
"they",
"are",
"passed",
"to",
"the",
"search",
"stage",
"via",
"preSearchCh",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/session.go#L330-L374 |
158,694 | keybase/client | go/chat/search/session.go | search | func (s *searchSession) search(ctx context.Context) (err error) {
defer s.indexer.Trace(ctx, func() error { return err }, "searchSession.search")()
for _, conv := range s.convList {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
if err := s.searchConvWithUIUpdate(ctx, conv.GetConvID()); err != nil {
return err
}
if s.searchDone(ctx, "search") {
return nil
}
}
return nil
} | go | func (s *searchSession) search(ctx context.Context) (err error) {
defer s.indexer.Trace(ctx, func() error { return err }, "searchSession.search")()
for _, conv := range s.convList {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
if err := s.searchConvWithUIUpdate(ctx, conv.GetConvID()); err != nil {
return err
}
if s.searchDone(ctx, "search") {
return nil
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"searchSession",
")",
"search",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"s",
".",
"indexer",
".",
"Trace",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
",",
"\"",
"\"",
")",
"(",
")",
"\n",
"for",
"_",
",",
"conv",
":=",
"range",
"s",
".",
"convList",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"default",
":",
"}",
"\n",
"if",
"err",
":=",
"s",
".",
"searchConvWithUIUpdate",
"(",
"ctx",
",",
"conv",
".",
"GetConvID",
"(",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"s",
".",
"searchDone",
"(",
"ctx",
",",
"\"",
"\"",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // search performs the actual search on each conversation after it completes
// preSearch via `preSearchCh` | [
"search",
"performs",
"the",
"actual",
"search",
"on",
"each",
"conversation",
"after",
"it",
"completes",
"preSearch",
"via",
"preSearchCh"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/session.go#L378-L394 |
158,695 | keybase/client | go/chat/search/session.go | postSearch | func (s *searchSession) postSearch(ctx context.Context) (err error) {
defer s.indexer.Trace(ctx, func() error { return err }, "searchSession.postSearch")()
switch s.opts.ReindexMode {
case chat1.ReIndexingMode_POSTSEARCH_SYNC:
default:
return nil
}
for _, convID := range s.reindexConvs {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
conv := s.getConv(convID)
// ignore any fully indexed convs since we respect
// opts.MaxConvsSearched
fullyIndexed, err := s.convFullyIndexed(ctx, conv.Conv)
if err != nil {
return err
}
if fullyIndexed {
continue
}
if err := s.reindexConvWithUIUpdate(ctx, conv); err != nil {
s.indexer.Debug(ctx, "Search: postSearch: error reindexing: conv: %v convID: %v err: %v",
conv.GetName(), conv.GetConvID(), err)
s.inboxIndexStatus.rmConv(conv.Conv)
continue
}
if s.searchDone(ctx, "postSearch") {
continue
}
if err := s.searchConvWithUIUpdate(ctx, convID); err != nil {
return err
}
}
return nil
} | go | func (s *searchSession) postSearch(ctx context.Context) (err error) {
defer s.indexer.Trace(ctx, func() error { return err }, "searchSession.postSearch")()
switch s.opts.ReindexMode {
case chat1.ReIndexingMode_POSTSEARCH_SYNC:
default:
return nil
}
for _, convID := range s.reindexConvs {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
conv := s.getConv(convID)
// ignore any fully indexed convs since we respect
// opts.MaxConvsSearched
fullyIndexed, err := s.convFullyIndexed(ctx, conv.Conv)
if err != nil {
return err
}
if fullyIndexed {
continue
}
if err := s.reindexConvWithUIUpdate(ctx, conv); err != nil {
s.indexer.Debug(ctx, "Search: postSearch: error reindexing: conv: %v convID: %v err: %v",
conv.GetName(), conv.GetConvID(), err)
s.inboxIndexStatus.rmConv(conv.Conv)
continue
}
if s.searchDone(ctx, "postSearch") {
continue
}
if err := s.searchConvWithUIUpdate(ctx, convID); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"searchSession",
")",
"postSearch",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"s",
".",
"indexer",
".",
"Trace",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
",",
"\"",
"\"",
")",
"(",
")",
"\n",
"switch",
"s",
".",
"opts",
".",
"ReindexMode",
"{",
"case",
"chat1",
".",
"ReIndexingMode_POSTSEARCH_SYNC",
":",
"default",
":",
"return",
"nil",
"\n",
"}",
"\n",
"for",
"_",
",",
"convID",
":=",
"range",
"s",
".",
"reindexConvs",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"default",
":",
"}",
"\n",
"conv",
":=",
"s",
".",
"getConv",
"(",
"convID",
")",
"\n",
"// ignore any fully indexed convs since we respect",
"// opts.MaxConvsSearched",
"fullyIndexed",
",",
"err",
":=",
"s",
".",
"convFullyIndexed",
"(",
"ctx",
",",
"conv",
".",
"Conv",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"fullyIndexed",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"err",
":=",
"s",
".",
"reindexConvWithUIUpdate",
"(",
"ctx",
",",
"conv",
")",
";",
"err",
"!=",
"nil",
"{",
"s",
".",
"indexer",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"conv",
".",
"GetName",
"(",
")",
",",
"conv",
".",
"GetConvID",
"(",
")",
",",
"err",
")",
"\n",
"s",
".",
"inboxIndexStatus",
".",
"rmConv",
"(",
"conv",
".",
"Conv",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"if",
"s",
".",
"searchDone",
"(",
"ctx",
",",
"\"",
"\"",
")",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"err",
":=",
"s",
".",
"searchConvWithUIUpdate",
"(",
"ctx",
",",
"convID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // postSearch is the final pipeline stage, reindexing conversations if
// POSTSEARCH_SYNC is set. | [
"postSearch",
"is",
"the",
"final",
"pipeline",
"stage",
"reindexing",
"conversations",
"if",
"POSTSEARCH_SYNC",
"is",
"set",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/session.go#L398-L435 |
158,696 | keybase/client | go/chat/attachments/progress.go | initialReport | func (p *progressWriter) initialReport() {
if p.progress == nil {
return
}
p.progress(0, p.total)
} | go | func (p *progressWriter) initialReport() {
if p.progress == nil {
return
}
p.progress(0, p.total)
} | [
"func",
"(",
"p",
"*",
"progressWriter",
")",
"initialReport",
"(",
")",
"{",
"if",
"p",
".",
"progress",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"p",
".",
"progress",
"(",
"0",
",",
"p",
".",
"total",
")",
"\n",
"}"
] | // send 0% progress | [
"send",
"0%",
"progress"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/progress.go#L57-L63 |
158,697 | keybase/client | go/engine/scanproofs.go | LoadScanProofsIgnore | func LoadScanProofsIgnore(filepath string) ([]string, error) {
f, err := os.Open(filepath)
if err != nil {
return nil, err
}
defer f.Close()
scanner := bufio.NewScanner(f)
scanner.Split(bufio.ScanLines)
var ignored []string
for scanner.Scan() {
x := strings.TrimSpace(scanner.Text())
if strings.HasPrefix(x, "//") {
continue
}
ignored = append(ignored, x)
}
return ignored, nil
} | go | func LoadScanProofsIgnore(filepath string) ([]string, error) {
f, err := os.Open(filepath)
if err != nil {
return nil, err
}
defer f.Close()
scanner := bufio.NewScanner(f)
scanner.Split(bufio.ScanLines)
var ignored []string
for scanner.Scan() {
x := strings.TrimSpace(scanner.Text())
if strings.HasPrefix(x, "//") {
continue
}
ignored = append(ignored, x)
}
return ignored, nil
} | [
"func",
"LoadScanProofsIgnore",
"(",
"filepath",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filepath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"f",
".",
"Close",
"(",
")",
"\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"f",
")",
"\n",
"scanner",
".",
"Split",
"(",
"bufio",
".",
"ScanLines",
")",
"\n",
"var",
"ignored",
"[",
"]",
"string",
"\n",
"for",
"scanner",
".",
"Scan",
"(",
")",
"{",
"x",
":=",
"strings",
".",
"TrimSpace",
"(",
"scanner",
".",
"Text",
"(",
")",
")",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"x",
",",
"\"",
"\"",
")",
"{",
"continue",
"\n",
"}",
"\n",
"ignored",
"=",
"append",
"(",
"ignored",
",",
"x",
")",
"\n",
"}",
"\n",
"return",
"ignored",
",",
"nil",
"\n",
"}"
] | // LoadScanProofsIgnore loads an ignore file and returns the list of proofids to ignore. | [
"LoadScanProofsIgnore",
"loads",
"an",
"ignore",
"file",
"and",
"returns",
"the",
"list",
"of",
"proofids",
"to",
"ignore",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/scanproofs.go#L480-L497 |
158,698 | keybase/client | go/client/chat_api_handler.go | Valid | func (c ChatChannel) Valid() bool {
if len(c.Name) == 0 {
return false
}
if len(c.MembersType) > 0 && !isValidMembersType(c.MembersType) {
return false
}
return true
} | go | func (c ChatChannel) Valid() bool {
if len(c.Name) == 0 {
return false
}
if len(c.MembersType) > 0 && !isValidMembersType(c.MembersType) {
return false
}
return true
} | [
"func",
"(",
"c",
"ChatChannel",
")",
"Valid",
"(",
")",
"bool",
"{",
"if",
"len",
"(",
"c",
".",
"Name",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"len",
"(",
"c",
".",
"MembersType",
")",
">",
"0",
"&&",
"!",
"isValidMembersType",
"(",
"c",
".",
"MembersType",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // Valid returns true if the ChatChannel has at least a Name. | [
"Valid",
"returns",
"true",
"if",
"the",
"ChatChannel",
"has",
"at",
"least",
"a",
"Name",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/chat_api_handler.go#L95-L103 |
158,699 | keybase/client | go/kbfs/libkbfs/tlf_journal.go | doBackgroundWork | func (j *tlfJournal) doBackgroundWork(ctx context.Context) <-chan error {
errCh := make(chan error, 1)
// TODO: Handle panics.
go func() {
defer j.wg.Done()
errCh <- j.flush(ctx)
close(errCh)
}()
return errCh
} | go | func (j *tlfJournal) doBackgroundWork(ctx context.Context) <-chan error {
errCh := make(chan error, 1)
// TODO: Handle panics.
go func() {
defer j.wg.Done()
errCh <- j.flush(ctx)
close(errCh)
}()
return errCh
} | [
"func",
"(",
"j",
"*",
"tlfJournal",
")",
"doBackgroundWork",
"(",
"ctx",
"context",
".",
"Context",
")",
"<-",
"chan",
"error",
"{",
"errCh",
":=",
"make",
"(",
"chan",
"error",
",",
"1",
")",
"\n",
"// TODO: Handle panics.",
"go",
"func",
"(",
")",
"{",
"defer",
"j",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
"errCh",
"<-",
"j",
".",
"flush",
"(",
"ctx",
")",
"\n",
"close",
"(",
"errCh",
")",
"\n",
"}",
"(",
")",
"\n",
"return",
"errCh",
"\n",
"}"
] | // doBackgroundWork currently only does auto-flushing. It assumes that
// ctx is canceled when the background processing should stop. | [
"doBackgroundWork",
"currently",
"only",
"does",
"auto",
"-",
"flushing",
".",
"It",
"assumes",
"that",
"ctx",
"is",
"canceled",
"when",
"the",
"background",
"processing",
"should",
"stop",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/tlf_journal.go#L719-L728 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.