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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
160,700
keybase/client
go/chat/ephemeral_purger.go
loop
func (b *BackgroundEphemeralPurger) loop(shutdownCh chan struct{}) { bgctx := context.Background() b.Debug(bgctx, "loop: starting for %s", b.uid) for { select { case <-b.purgeTimer.C: b.Debug(bgctx, "loop: looping for %s", b.uid) b.queuePurges(bgctx) case <-shutdownCh: b.Debug(bgctx, "loop: shutting down for %s", b.uid) return } } }
go
func (b *BackgroundEphemeralPurger) loop(shutdownCh chan struct{}) { bgctx := context.Background() b.Debug(bgctx, "loop: starting for %s", b.uid) for { select { case <-b.purgeTimer.C: b.Debug(bgctx, "loop: looping for %s", b.uid) b.queuePurges(bgctx) case <-shutdownCh: b.Debug(bgctx, "loop: shutting down for %s", b.uid) return } } }
[ "func", "(", "b", "*", "BackgroundEphemeralPurger", ")", "loop", "(", "shutdownCh", "chan", "struct", "{", "}", ")", "{", "bgctx", ":=", "context", ".", "Background", "(", ")", "\n", "b", ".", "Debug", "(", "bgctx", ",", "\"", "\"", ",", "b", ".", ...
// This runs when we are waiting to run a job but will shut itself down if we // have no work.
[ "This", "runs", "when", "we", "are", "waiting", "to", "run", "a", "job", "but", "will", "shut", "itself", "down", "if", "we", "have", "no", "work", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/ephemeral_purger.go#L257-L271
160,701
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
currLocked
func (state *LockState) currLocked() *exclusionState { stateCount := len(state.exclusionStates) if stateCount == 0 { return nil } return &state.exclusionStates[stateCount-1] }
go
func (state *LockState) currLocked() *exclusionState { stateCount := len(state.exclusionStates) if stateCount == 0 { return nil } return &state.exclusionStates[stateCount-1] }
[ "func", "(", "state", "*", "LockState", ")", "currLocked", "(", ")", "*", "exclusionState", "{", "stateCount", ":=", "len", "(", "state", ".", "exclusionStates", ")", "\n", "if", "stateCount", "==", "0", "{", "return", "nil", "\n", "}", "\n", "return", ...
// currLocked returns the current exclusion state, or nil if there is // none.
[ "currLocked", "returns", "the", "current", "exclusion", "state", "or", "nil", "if", "there", "is", "none", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L112-L118
160,702
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
getExclusionType
func (state *LockState) getExclusionType(level MutexLevel) exclusionType { state.exclusionStatesLock.lock() defer state.exclusionStatesLock.unlock() // Not worth it to do anything more complicated than a // brute-force search. for _, state := range state.exclusionStates { if state.level > level { break } if state.level == level { return state.exclusionType } } return nonExclusion }
go
func (state *LockState) getExclusionType(level MutexLevel) exclusionType { state.exclusionStatesLock.lock() defer state.exclusionStatesLock.unlock() // Not worth it to do anything more complicated than a // brute-force search. for _, state := range state.exclusionStates { if state.level > level { break } if state.level == level { return state.exclusionType } } return nonExclusion }
[ "func", "(", "state", "*", "LockState", ")", "getExclusionType", "(", "level", "MutexLevel", ")", "exclusionType", "{", "state", ".", "exclusionStatesLock", ".", "lock", "(", ")", "\n", "defer", "state", ".", "exclusionStatesLock", ".", "unlock", "(", ")", "...
// getExclusionType returns returns the exclusionType for the given // MutexLevel, or nonExclusion if there is none.
[ "getExclusionType", "returns", "returns", "the", "exclusionType", "for", "the", "given", "MutexLevel", "or", "nonExclusion", "if", "there", "is", "none", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L215-L231
160,703
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
MakeLeveledMutex
func MakeLeveledMutex(level MutexLevel, locker sync.Locker) LeveledMutex { return LeveledMutex{ level: level, locker: locker, } }
go
func MakeLeveledMutex(level MutexLevel, locker sync.Locker) LeveledMutex { return LeveledMutex{ level: level, locker: locker, } }
[ "func", "MakeLeveledMutex", "(", "level", "MutexLevel", ",", "locker", "sync", ".", "Locker", ")", "LeveledMutex", "{", "return", "LeveledMutex", "{", "level", ":", "level", ",", "locker", ":", "locker", ",", "}", "\n", "}" ]
// MakeLeveledMutex makes a mutex with the given level, backed by the // given locker.
[ "MakeLeveledMutex", "makes", "a", "mutex", "with", "the", "given", "level", "backed", "by", "the", "given", "locker", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L243-L248
160,704
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
Unlock
func (m LeveledMutex) Unlock(lockState *LockState) { err := lockState.doUnlock(m.level, writeExclusion, m.locker) if err != nil { panic(err) } }
go
func (m LeveledMutex) Unlock(lockState *LockState) { err := lockState.doUnlock(m.level, writeExclusion, m.locker) if err != nil { panic(err) } }
[ "func", "(", "m", "LeveledMutex", ")", "Unlock", "(", "lockState", "*", "LockState", ")", "{", "err", ":=", "lockState", ".", "doUnlock", "(", "m", ".", "level", ",", "writeExclusion", ",", "m", ".", "locker", ")", "\n", "if", "err", "!=", "nil", "{"...
// Unlock locks the associated locker.
[ "Unlock", "locks", "the", "associated", "locker", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L259-L264
160,705
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
MakeLeveledRWMutex
func MakeLeveledRWMutex(level MutexLevel, rwLocker rwLocker) LeveledRWMutex { return LeveledRWMutex{ level: level, rwLocker: rwLocker, } }
go
func MakeLeveledRWMutex(level MutexLevel, rwLocker rwLocker) LeveledRWMutex { return LeveledRWMutex{ level: level, rwLocker: rwLocker, } }
[ "func", "MakeLeveledRWMutex", "(", "level", "MutexLevel", ",", "rwLocker", "rwLocker", ")", "LeveledRWMutex", "{", "return", "LeveledRWMutex", "{", "level", ":", "level", ",", "rwLocker", ":", "rwLocker", ",", "}", "\n", "}" ]
// MakeLeveledRWMutex makes a reader-writer mutex with the given // level, backed by the given rwLocker.
[ "MakeLeveledRWMutex", "makes", "a", "reader", "-", "writer", "mutex", "with", "the", "given", "level", "backed", "by", "the", "given", "rwLocker", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L336-L341
160,706
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
Unlock
func (rw LeveledRWMutex) Unlock(lockState *LockState) { err := lockState.doUnlock(rw.level, writeExclusion, rw.rwLocker) if err != nil { panic(err) } }
go
func (rw LeveledRWMutex) Unlock(lockState *LockState) { err := lockState.doUnlock(rw.level, writeExclusion, rw.rwLocker) if err != nil { panic(err) } }
[ "func", "(", "rw", "LeveledRWMutex", ")", "Unlock", "(", "lockState", "*", "LockState", ")", "{", "err", ":=", "lockState", ".", "doUnlock", "(", "rw", ".", "level", ",", "writeExclusion", ",", "rw", ".", "rwLocker", ")", "\n", "if", "err", "!=", "nil"...
// Unlock unlocks the associated locker.
[ "Unlock", "unlocks", "the", "associated", "locker", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L352-L357
160,707
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
RLock
func (rw LeveledRWMutex) RLock(lockState *LockState) { err := lockState.doLock(rw.level, readExclusion, rw.rwLocker.RLocker()) if err != nil { panic(err) } }
go
func (rw LeveledRWMutex) RLock(lockState *LockState) { err := lockState.doLock(rw.level, readExclusion, rw.rwLocker.RLocker()) if err != nil { panic(err) } }
[ "func", "(", "rw", "LeveledRWMutex", ")", "RLock", "(", "lockState", "*", "LockState", ")", "{", "err", ":=", "lockState", ".", "doLock", "(", "rw", ".", "level", ",", "readExclusion", ",", "rw", ".", "rwLocker", ".", "RLocker", "(", ")", ")", "\n", ...
// RLock locks the associated locker for reading.
[ "RLock", "locks", "the", "associated", "locker", "for", "reading", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L360-L365
160,708
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
RUnlock
func (rw LeveledRWMutex) RUnlock(lockState *LockState) { err := lockState.doUnlock(rw.level, readExclusion, rw.rwLocker.RLocker()) if err != nil { panic(err) } }
go
func (rw LeveledRWMutex) RUnlock(lockState *LockState) { err := lockState.doUnlock(rw.level, readExclusion, rw.rwLocker.RLocker()) if err != nil { panic(err) } }
[ "func", "(", "rw", "LeveledRWMutex", ")", "RUnlock", "(", "lockState", "*", "LockState", ")", "{", "err", ":=", "lockState", ".", "doUnlock", "(", "rw", ".", "level", ",", "readExclusion", ",", "rw", ".", "rwLocker", ".", "RLocker", "(", ")", ")", "\n"...
// RUnlock unlocks the associated locker for reading.
[ "RUnlock", "unlocks", "the", "associated", "locker", "for", "reading", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L368-L373
160,709
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
AssertRLocked
func (rw LeveledRWMutex) AssertRLocked(lockState *LockState) { et := lockState.getExclusionType(rw.level) if et != readExclusion { panic(unexpectedExclusionTypeError{ levelToString: lockState.levelToString, level: rw.level, expectedExclusionType: readExclusion, exclusionType: et, }) } }
go
func (rw LeveledRWMutex) AssertRLocked(lockState *LockState) { et := lockState.getExclusionType(rw.level) if et != readExclusion { panic(unexpectedExclusionTypeError{ levelToString: lockState.levelToString, level: rw.level, expectedExclusionType: readExclusion, exclusionType: et, }) } }
[ "func", "(", "rw", "LeveledRWMutex", ")", "AssertRLocked", "(", "lockState", "*", "LockState", ")", "{", "et", ":=", "lockState", ".", "getExclusionType", "(", "rw", ".", "level", ")", "\n", "if", "et", "!=", "readExclusion", "{", "panic", "(", "unexpected...
// AssertRLocked does nothing if m is r-locked with respect to the // given LockState. Otherwise, it panics.
[ "AssertRLocked", "does", "nothing", "if", "m", "is", "r", "-", "locked", "with", "respect", "to", "the", "given", "LockState", ".", "Otherwise", "it", "panics", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L404-L414
160,710
keybase/client
go/kbfs/kbfssync/leveled_mutex.go
AssertAnyLocked
func (rw LeveledRWMutex) AssertAnyLocked(lockState *LockState) { et := lockState.getExclusionType(rw.level) if et == nonExclusion { panic(unexpectedNonExclusionError{ levelToString: lockState.levelToString, level: rw.level, }) } }
go
func (rw LeveledRWMutex) AssertAnyLocked(lockState *LockState) { et := lockState.getExclusionType(rw.level) if et == nonExclusion { panic(unexpectedNonExclusionError{ levelToString: lockState.levelToString, level: rw.level, }) } }
[ "func", "(", "rw", "LeveledRWMutex", ")", "AssertAnyLocked", "(", "lockState", "*", "LockState", ")", "{", "et", ":=", "lockState", ".", "getExclusionType", "(", "rw", ".", "level", ")", "\n", "if", "et", "==", "nonExclusion", "{", "panic", "(", "unexpecte...
// AssertAnyLocked does nothing if m is locked or r-locked with // respect to the given LockState. Otherwise, it panics.
[ "AssertAnyLocked", "does", "nothing", "if", "m", "is", "locked", "or", "r", "-", "locked", "with", "respect", "to", "the", "given", "LockState", ".", "Otherwise", "it", "panics", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/leveled_mutex.go#L427-L435
160,711
keybase/client
go/kbfs/data/file_data.go
NewFileData
func NewFileData( file Path, chargedTo keybase1.UserOrTeamID, bsplit BlockSplitter, kmd libkey.KeyMetadata, getter FileBlockGetter, cacher dirtyBlockCacher, log logger.Logger, vlog *libkb.VDebugLog) *FileData { fd := &FileData{ getter: getter, } fd.tree = &blockTree{ file: file, chargedTo: chargedTo, kmd: kmd, bsplit: bsplit, getter: fd.blockGetter, cacher: cacher, log: log, vlog: vlog, } return fd }
go
func NewFileData( file Path, chargedTo keybase1.UserOrTeamID, bsplit BlockSplitter, kmd libkey.KeyMetadata, getter FileBlockGetter, cacher dirtyBlockCacher, log logger.Logger, vlog *libkb.VDebugLog) *FileData { fd := &FileData{ getter: getter, } fd.tree = &blockTree{ file: file, chargedTo: chargedTo, kmd: kmd, bsplit: bsplit, getter: fd.blockGetter, cacher: cacher, log: log, vlog: vlog, } return fd }
[ "func", "NewFileData", "(", "file", "Path", ",", "chargedTo", "keybase1", ".", "UserOrTeamID", ",", "bsplit", "BlockSplitter", ",", "kmd", "libkey", ".", "KeyMetadata", ",", "getter", "FileBlockGetter", ",", "cacher", "dirtyBlockCacher", ",", "log", "logger", "....
// NewFileData makes a new file data object for the given `file` // within the given `kmd`.
[ "NewFileData", "makes", "a", "new", "file", "data", "object", "for", "the", "given", "file", "within", "the", "given", "kmd", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/file_data.go#L37-L56
160,712
keybase/client
go/kbfs/data/file_data.go
Read
func (fd *FileData) Read(ctx context.Context, dest []byte, startOff Int64Offset) (int64, error) { if len(dest) == 0 { return 0, nil } // If we have a large enough timeout add a temporary timeout that is // readTimeoutSmallerBy. Use that for reading so short reads get returned // upstream without triggering the global timeout. now := time.Now() deadline, haveTimeout := ctx.Deadline() if haveTimeout { rem := deadline.Sub(now) - readTimeoutSmallerBy if rem > 0 { var cancel func() ctx, cancel = context.WithTimeout(ctx, rem) defer cancel() } } bytes, err := fd.getByteSlicesInOffsetRange(ctx, startOff, startOff+Int64Offset(len(dest)), true) if err != nil { return 0, err } currLen := int64(0) for _, b := range bytes { bLen := int64(len(b)) copy(dest[currLen:currLen+bLen], b) currLen += bLen } return currLen, nil }
go
func (fd *FileData) Read(ctx context.Context, dest []byte, startOff Int64Offset) (int64, error) { if len(dest) == 0 { return 0, nil } // If we have a large enough timeout add a temporary timeout that is // readTimeoutSmallerBy. Use that for reading so short reads get returned // upstream without triggering the global timeout. now := time.Now() deadline, haveTimeout := ctx.Deadline() if haveTimeout { rem := deadline.Sub(now) - readTimeoutSmallerBy if rem > 0 { var cancel func() ctx, cancel = context.WithTimeout(ctx, rem) defer cancel() } } bytes, err := fd.getByteSlicesInOffsetRange(ctx, startOff, startOff+Int64Offset(len(dest)), true) if err != nil { return 0, err } currLen := int64(0) for _, b := range bytes { bLen := int64(len(b)) copy(dest[currLen:currLen+bLen], b) currLen += bLen } return currLen, nil }
[ "func", "(", "fd", "*", "FileData", ")", "Read", "(", "ctx", "context", ".", "Context", ",", "dest", "[", "]", "byte", ",", "startOff", "Int64Offset", ")", "(", "int64", ",", "error", ")", "{", "if", "len", "(", "dest", ")", "==", "0", "{", "retu...
// read fills the `dest` buffer with data from the file, starting at // `startOff`. Returns the number of bytes copied. If the read // operation nears the deadline set in `ctx`, it returns as big a // prefix as possible before reaching the deadline.
[ "read", "fills", "the", "dest", "buffer", "with", "data", "from", "the", "file", "starting", "at", "startOff", ".", "Returns", "the", "number", "of", "bytes", "copied", ".", "If", "the", "read", "operation", "nears", "the", "deadline", "set", "in", "ctx", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/file_data.go#L251-L284
160,713
keybase/client
go/kbfs/data/file_data.go
GetBytes
func (fd *FileData) GetBytes(ctx context.Context, startOff, endOff Int64Offset) (data []byte, err error) { bytes, err := fd.getByteSlicesInOffsetRange(ctx, startOff, endOff, false) if err != nil { return nil, err } bufSize := 0 for _, b := range bytes { bufSize += len(b) } data = make([]byte, bufSize) currLen := 0 for _, b := range bytes { copy(data[currLen:currLen+len(b)], b) currLen += len(b) } return data, nil }
go
func (fd *FileData) GetBytes(ctx context.Context, startOff, endOff Int64Offset) (data []byte, err error) { bytes, err := fd.getByteSlicesInOffsetRange(ctx, startOff, endOff, false) if err != nil { return nil, err } bufSize := 0 for _, b := range bytes { bufSize += len(b) } data = make([]byte, bufSize) currLen := 0 for _, b := range bytes { copy(data[currLen:currLen+len(b)], b) currLen += len(b) } return data, nil }
[ "func", "(", "fd", "*", "FileData", ")", "GetBytes", "(", "ctx", "context", ".", "Context", ",", "startOff", ",", "endOff", "Int64Offset", ")", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "bytes", ",", "err", ":=", "fd", ".", "get...
// GetBytes returns a buffer containing data from the file, in the // half-inclusive range `[startOff, endOff)`. If `endOff` == -1, it // returns data until the end of the file.
[ "GetBytes", "returns", "a", "buffer", "containing", "data", "from", "the", "file", "in", "the", "half", "-", "inclusive", "range", "[", "startOff", "endOff", ")", ".", "If", "endOff", "==", "-", "1", "it", "returns", "data", "until", "the", "end", "of", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/file_data.go#L289-L308
160,714
keybase/client
go/kbfs/data/file_data.go
GetFileBlockAtOffset
func (fd *FileData) GetFileBlockAtOffset(ctx context.Context, topBlock *FileBlock, off Int64Offset, rtype BlockReqType) ( ptr BlockPointer, parentBlocks []ParentBlockAndChildIndex, block *FileBlock, nextBlockStartOff, startOff Int64Offset, wasDirty bool, err error) { ptr, parentBlocks, b, nbso, so, wasDirty, err := fd.tree.getBlockAtOffset( ctx, topBlock, off, rtype) if err != nil { return ZeroPtr, nil, nil, 0, 0, false, err } if b != nil { block = b.(*FileBlock) } if nbso != nil { nextBlockStartOff = nbso.(Int64Offset) } else { nextBlockStartOff = -1 } if so != nil { startOff = so.(Int64Offset) } return ptr, parentBlocks, block, nextBlockStartOff, startOff, wasDirty, nil }
go
func (fd *FileData) GetFileBlockAtOffset(ctx context.Context, topBlock *FileBlock, off Int64Offset, rtype BlockReqType) ( ptr BlockPointer, parentBlocks []ParentBlockAndChildIndex, block *FileBlock, nextBlockStartOff, startOff Int64Offset, wasDirty bool, err error) { ptr, parentBlocks, b, nbso, so, wasDirty, err := fd.tree.getBlockAtOffset( ctx, topBlock, off, rtype) if err != nil { return ZeroPtr, nil, nil, 0, 0, false, err } if b != nil { block = b.(*FileBlock) } if nbso != nil { nextBlockStartOff = nbso.(Int64Offset) } else { nextBlockStartOff = -1 } if so != nil { startOff = so.(Int64Offset) } return ptr, parentBlocks, block, nextBlockStartOff, startOff, wasDirty, nil }
[ "func", "(", "fd", "*", "FileData", ")", "GetFileBlockAtOffset", "(", "ctx", "context", ".", "Context", ",", "topBlock", "*", "FileBlock", ",", "off", "Int64Offset", ",", "rtype", "BlockReqType", ")", "(", "ptr", "BlockPointer", ",", "parentBlocks", "[", "]"...
// GetFileBlockAtOffset returns the leaf file block responsible for // the given offset.
[ "GetFileBlockAtOffset", "returns", "the", "leaf", "file", "block", "responsible", "for", "the", "given", "offset", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/file_data.go#L359-L381
160,715
keybase/client
go/kbfs/data/file_data.go
Ready
func (fd *FileData) Ready(ctx context.Context, id tlf.ID, bcache BlockCache, dirtyBcache IsDirtyProvider, rp ReadyProvider, bps BlockPutState, topBlock *FileBlock, df *DirtyFile) ( map[BlockInfo]BlockPointer, error) { return fd.tree.ready( ctx, id, bcache, dirtyBcache, rp, bps, topBlock, func(ptr BlockPointer) func() error { if df != nil { return func() error { return df.setBlockSynced(ptr) } } return nil }) }
go
func (fd *FileData) Ready(ctx context.Context, id tlf.ID, bcache BlockCache, dirtyBcache IsDirtyProvider, rp ReadyProvider, bps BlockPutState, topBlock *FileBlock, df *DirtyFile) ( map[BlockInfo]BlockPointer, error) { return fd.tree.ready( ctx, id, bcache, dirtyBcache, rp, bps, topBlock, func(ptr BlockPointer) func() error { if df != nil { return func() error { return df.setBlockSynced(ptr) } } return nil }) }
[ "func", "(", "fd", "*", "FileData", ")", "Ready", "(", "ctx", "context", ".", "Context", ",", "id", "tlf", ".", "ID", ",", "bcache", "BlockCache", ",", "dirtyBcache", "IsDirtyProvider", ",", "rp", "ReadyProvider", ",", "bps", "BlockPutState", ",", "topBloc...
// Ready readies, if given an indirect top-block, all the dirty child // blocks, and updates their block IDs in their parent block's list of // indirect pointers. It returns a map pointing from the new block // info from any readied block to its corresponding old block pointer.
[ "Ready", "readies", "if", "given", "an", "indirect", "top", "-", "block", "all", "the", "dirty", "child", "blocks", "and", "updates", "their", "block", "IDs", "in", "their", "parent", "block", "s", "list", "of", "indirect", "pointers", ".", "It", "returns"...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/file_data.go#L1005-L1017
160,716
keybase/client
go/kbfs/data/file_data.go
GetIndirectFileBlockInfosWithTopBlock
func (fd *FileData) GetIndirectFileBlockInfosWithTopBlock( ctx context.Context, topBlock *FileBlock) ([]BlockInfo, error) { return fd.tree.getIndirectBlockInfosWithTopBlock(ctx, topBlock) }
go
func (fd *FileData) GetIndirectFileBlockInfosWithTopBlock( ctx context.Context, topBlock *FileBlock) ([]BlockInfo, error) { return fd.tree.getIndirectBlockInfosWithTopBlock(ctx, topBlock) }
[ "func", "(", "fd", "*", "FileData", ")", "GetIndirectFileBlockInfosWithTopBlock", "(", "ctx", "context", ".", "Context", ",", "topBlock", "*", "FileBlock", ")", "(", "[", "]", "BlockInfo", ",", "error", ")", "{", "return", "fd", ".", "tree", ".", "getIndir...
// GetIndirectFileBlockInfosWithTopBlock returns the block infos // contained in all the indirect blocks in this file tree, given an // already-fetched top block.
[ "GetIndirectFileBlockInfosWithTopBlock", "returns", "the", "block", "infos", "contained", "in", "all", "the", "indirect", "blocks", "in", "this", "file", "tree", "given", "an", "already", "-", "fetched", "top", "block", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/file_data.go#L1022-L1025
160,717
keybase/client
go/kbfs/data/file_data.go
GetIndirectFileBlockInfos
func (fd *FileData) GetIndirectFileBlockInfos(ctx context.Context) ( []BlockInfo, error) { return fd.tree.getIndirectBlockInfos(ctx) }
go
func (fd *FileData) GetIndirectFileBlockInfos(ctx context.Context) ( []BlockInfo, error) { return fd.tree.getIndirectBlockInfos(ctx) }
[ "func", "(", "fd", "*", "FileData", ")", "GetIndirectFileBlockInfos", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "BlockInfo", ",", "error", ")", "{", "return", "fd", ".", "tree", ".", "getIndirectBlockInfos", "(", "ctx", ")", "\n", "}" ]
// GetIndirectFileBlockInfos returns the block infos contained in all // the indirect blocks in this file tree.
[ "GetIndirectFileBlockInfos", "returns", "the", "block", "infos", "contained", "in", "all", "the", "indirect", "blocks", "in", "this", "file", "tree", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/file_data.go#L1029-L1032
160,718
keybase/client
go/kbfs/data/file_data.go
FindIPtrsAndClearSize
func (fd *FileData) FindIPtrsAndClearSize( ctx context.Context, topBlock *FileBlock, ptrs map[BlockPointer]bool) ( found map[BlockPointer]bool, err error) { if !topBlock.IsInd || len(ptrs) == 0 { return nil, nil } pfr, err := fd.tree.getIndirectBlocksForOffsetRange( ctx, topBlock, Int64Offset(0), nil) if err != nil { return nil, err } found = make(map[BlockPointer]bool) // Search all paths for the given block pointer, clear its encoded // size, and dirty all its parents up to the root. infoSeen := make(map[BlockPointer]bool) for _, Path := range pfr { parentPtr := fd.rootBlockPointer() for level, pb := range Path { if infoSeen[parentPtr] { parentPtr = pb.childBlockPtr() continue } infoSeen[parentPtr] = true for i, iptr := range pb.pblock.(*FileBlock).IPtrs { if ptrs[iptr.BlockPointer] { // Mark this pointer, and all parent blocks, as dirty. parentPtr := fd.rootBlockPointer() for i := 0; i <= level; i++ { // Get a writeable copy for each block. pblock, _, err := fd.getter( ctx, fd.tree.kmd, parentPtr, fd.tree.file, BlockWrite) if err != nil { return nil, err } Path[i].pblock = pblock parentPtr = Path[i].childBlockPtr() } // Because we only check each parent once, the // `path` we're using here will be the one with a // childIndex of 0. But, that's not necessarily // the one that matches the pointer that needs to // be dirty. So make a new path and set the // childIndex to the correct pointer instead. newPath := make([]ParentBlockAndChildIndex, level+1) copy(newPath, Path[:level+1]) newPath[level].childIndex = i _, _, err = fd.tree.markParentsDirty(ctx, newPath) if err != nil { return nil, err } found[iptr.BlockPointer] = true if len(found) == len(ptrs) { return found, nil } } } parentPtr = pb.childBlockPtr() } } return found, nil }
go
func (fd *FileData) FindIPtrsAndClearSize( ctx context.Context, topBlock *FileBlock, ptrs map[BlockPointer]bool) ( found map[BlockPointer]bool, err error) { if !topBlock.IsInd || len(ptrs) == 0 { return nil, nil } pfr, err := fd.tree.getIndirectBlocksForOffsetRange( ctx, topBlock, Int64Offset(0), nil) if err != nil { return nil, err } found = make(map[BlockPointer]bool) // Search all paths for the given block pointer, clear its encoded // size, and dirty all its parents up to the root. infoSeen := make(map[BlockPointer]bool) for _, Path := range pfr { parentPtr := fd.rootBlockPointer() for level, pb := range Path { if infoSeen[parentPtr] { parentPtr = pb.childBlockPtr() continue } infoSeen[parentPtr] = true for i, iptr := range pb.pblock.(*FileBlock).IPtrs { if ptrs[iptr.BlockPointer] { // Mark this pointer, and all parent blocks, as dirty. parentPtr := fd.rootBlockPointer() for i := 0; i <= level; i++ { // Get a writeable copy for each block. pblock, _, err := fd.getter( ctx, fd.tree.kmd, parentPtr, fd.tree.file, BlockWrite) if err != nil { return nil, err } Path[i].pblock = pblock parentPtr = Path[i].childBlockPtr() } // Because we only check each parent once, the // `path` we're using here will be the one with a // childIndex of 0. But, that's not necessarily // the one that matches the pointer that needs to // be dirty. So make a new path and set the // childIndex to the correct pointer instead. newPath := make([]ParentBlockAndChildIndex, level+1) copy(newPath, Path[:level+1]) newPath[level].childIndex = i _, _, err = fd.tree.markParentsDirty(ctx, newPath) if err != nil { return nil, err } found[iptr.BlockPointer] = true if len(found) == len(ptrs) { return found, nil } } } parentPtr = pb.childBlockPtr() } } return found, nil }
[ "func", "(", "fd", "*", "FileData", ")", "FindIPtrsAndClearSize", "(", "ctx", "context", ".", "Context", ",", "topBlock", "*", "FileBlock", ",", "ptrs", "map", "[", "BlockPointer", "]", "bool", ")", "(", "found", "map", "[", "BlockPointer", "]", "bool", ...
// FindIPtrsAndClearSize looks for the given set of indirect pointers, // and returns whether they could be found. As a side effect, it also // clears the encoded size for those indirect pointers.
[ "FindIPtrsAndClearSize", "looks", "for", "the", "given", "set", "of", "indirect", "pointers", "and", "returns", "whether", "they", "could", "be", "found", ".", "As", "a", "side", "effect", "it", "also", "clears", "the", "encoded", "size", "for", "those", "in...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/file_data.go#L1037-L1103
160,719
keybase/client
go/kbfs/kbfssync/repeated_wait_group.go
Add
func (rwg *RepeatedWaitGroup) Add(delta int) { rwg.lock.Lock() defer rwg.lock.Unlock() if rwg.isIdleCh == nil { rwg.isIdleCh = make(chan struct{}) } if rwg.num+delta < 0 { panic("RepeatedWaitGroup count would be negative") } rwg.num += delta if rwg.num == 0 { close(rwg.isIdleCh) rwg.isIdleCh = nil } }
go
func (rwg *RepeatedWaitGroup) Add(delta int) { rwg.lock.Lock() defer rwg.lock.Unlock() if rwg.isIdleCh == nil { rwg.isIdleCh = make(chan struct{}) } if rwg.num+delta < 0 { panic("RepeatedWaitGroup count would be negative") } rwg.num += delta if rwg.num == 0 { close(rwg.isIdleCh) rwg.isIdleCh = nil } }
[ "func", "(", "rwg", "*", "RepeatedWaitGroup", ")", "Add", "(", "delta", "int", ")", "{", "rwg", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rwg", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "rwg", ".", "isIdleCh", "==", "nil", "{", ...
// Add indicates that a number of tasks have begun.
[ "Add", "indicates", "that", "a", "number", "of", "tasks", "have", "begun", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/repeated_wait_group.go#L32-L46
160,720
keybase/client
go/kbfs/kbfssync/repeated_wait_group.go
Wait
func (rwg *RepeatedWaitGroup) Wait(ctx context.Context) error { isIdleCh := func() chan struct{} { rwg.lock.Lock() defer rwg.lock.Unlock() return rwg.isIdleCh }() if isIdleCh == nil { return nil } select { case <-isIdleCh: return nil case <-ctx.Done(): return ctx.Err() } }
go
func (rwg *RepeatedWaitGroup) Wait(ctx context.Context) error { isIdleCh := func() chan struct{} { rwg.lock.Lock() defer rwg.lock.Unlock() return rwg.isIdleCh }() if isIdleCh == nil { return nil } select { case <-isIdleCh: return nil case <-ctx.Done(): return ctx.Err() } }
[ "func", "(", "rwg", "*", "RepeatedWaitGroup", ")", "Wait", "(", "ctx", "context", ".", "Context", ")", "error", "{", "isIdleCh", ":=", "func", "(", ")", "chan", "struct", "{", "}", "{", "rwg", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rwg...
// Wait blocks until either the underlying task count goes to 0, or // the given context is canceled.
[ "Wait", "blocks", "until", "either", "the", "underlying", "task", "count", "goes", "to", "0", "or", "the", "given", "context", "is", "canceled", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/repeated_wait_group.go#L50-L67
160,721
keybase/client
go/kbfs/kbfssync/repeated_wait_group.go
WaitUnlessPaused
func (rwg *RepeatedWaitGroup) WaitUnlessPaused(ctx context.Context) ( bool, error) { paused, isIdleCh, pauseCh := func() (bool, chan struct{}, chan struct{}) { rwg.lock.Lock() defer rwg.lock.Unlock() if !rwg.paused && rwg.pauseCh == nil { rwg.pauseCh = make(chan struct{}) } return rwg.paused, rwg.isIdleCh, rwg.pauseCh }() if isIdleCh == nil { return false, nil } if paused { return true, nil } select { case <-isIdleCh: return false, nil case <-pauseCh: return true, nil case <-ctx.Done(): return false, ctx.Err() } }
go
func (rwg *RepeatedWaitGroup) WaitUnlessPaused(ctx context.Context) ( bool, error) { paused, isIdleCh, pauseCh := func() (bool, chan struct{}, chan struct{}) { rwg.lock.Lock() defer rwg.lock.Unlock() if !rwg.paused && rwg.pauseCh == nil { rwg.pauseCh = make(chan struct{}) } return rwg.paused, rwg.isIdleCh, rwg.pauseCh }() if isIdleCh == nil { return false, nil } if paused { return true, nil } select { case <-isIdleCh: return false, nil case <-pauseCh: return true, nil case <-ctx.Done(): return false, ctx.Err() } }
[ "func", "(", "rwg", "*", "RepeatedWaitGroup", ")", "WaitUnlessPaused", "(", "ctx", "context", ".", "Context", ")", "(", "bool", ",", "error", ")", "{", "paused", ",", "isIdleCh", ",", "pauseCh", ":=", "func", "(", ")", "(", "bool", ",", "chan", "struct...
// WaitUnlessPaused works like Wait, except it can return early if the // wait group is paused. It returns whether it was paused with // outstanding work still left in the group.
[ "WaitUnlessPaused", "works", "like", "Wait", "except", "it", "can", "return", "early", "if", "the", "wait", "group", "is", "paused", ".", "It", "returns", "whether", "it", "was", "paused", "with", "outstanding", "work", "still", "left", "in", "the", "group",...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/repeated_wait_group.go#L72-L99
160,722
keybase/client
go/kbfs/kbfssync/repeated_wait_group.go
Pause
func (rwg *RepeatedWaitGroup) Pause() { rwg.lock.Lock() defer rwg.lock.Unlock() rwg.paused = true if rwg.pauseCh != nil { close(rwg.pauseCh) rwg.pauseCh = nil } }
go
func (rwg *RepeatedWaitGroup) Pause() { rwg.lock.Lock() defer rwg.lock.Unlock() rwg.paused = true if rwg.pauseCh != nil { close(rwg.pauseCh) rwg.pauseCh = nil } }
[ "func", "(", "rwg", "*", "RepeatedWaitGroup", ")", "Pause", "(", ")", "{", "rwg", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rwg", ".", "lock", ".", "Unlock", "(", ")", "\n", "rwg", ".", "paused", "=", "true", "\n", "if", "rwg", ".", "...
// Pause causes any current or future callers of `WaitUnlessPaused` to // return immediately.
[ "Pause", "causes", "any", "current", "or", "future", "callers", "of", "WaitUnlessPaused", "to", "return", "immediately", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/repeated_wait_group.go#L103-L111
160,723
keybase/client
go/kbfs/kbfssync/repeated_wait_group.go
Resume
func (rwg *RepeatedWaitGroup) Resume() { rwg.lock.Lock() defer rwg.lock.Unlock() if rwg.pauseCh != nil { panic("Non-nil pauseCh on resume!") } rwg.paused = false }
go
func (rwg *RepeatedWaitGroup) Resume() { rwg.lock.Lock() defer rwg.lock.Unlock() if rwg.pauseCh != nil { panic("Non-nil pauseCh on resume!") } rwg.paused = false }
[ "func", "(", "rwg", "*", "RepeatedWaitGroup", ")", "Resume", "(", ")", "{", "rwg", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rwg", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "rwg", ".", "pauseCh", "!=", "nil", "{", "panic", "(", ...
// Resume unpauses the wait group, allowing future callers of // `WaitUnlessPaused` to wait until all the outstanding work is // completed.
[ "Resume", "unpauses", "the", "wait", "group", "allowing", "future", "callers", "of", "WaitUnlessPaused", "to", "wait", "until", "all", "the", "outstanding", "work", "is", "completed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/repeated_wait_group.go#L116-L123
160,724
keybase/client
go/engine/template.go
NewTemplate
func NewTemplate(g *libkb.GlobalContext) *Template { return &Template{ Contextified: libkb.NewContextified(g), } }
go
func NewTemplate(g *libkb.GlobalContext) *Template { return &Template{ Contextified: libkb.NewContextified(g), } }
[ "func", "NewTemplate", "(", "g", "*", "libkb", ".", "GlobalContext", ")", "*", "Template", "{", "return", "&", "Template", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewTemplate creates a Template engine.
[ "NewTemplate", "creates", "a", "Template", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/template.go#L23-L27
160,725
keybase/client
go/kbfs/kbfscrypto/pad.go
PadBlock
func PadBlock(block []byte) ([]byte, error) { totalLen := powerOfTwoEqualOrGreater(len(block)) buf := make([]byte, padPrefixSize+totalLen) binary.LittleEndian.PutUint32(buf, uint32(len(block))) copy(buf[padPrefixSize:], block) return buf, nil }
go
func PadBlock(block []byte) ([]byte, error) { totalLen := powerOfTwoEqualOrGreater(len(block)) buf := make([]byte, padPrefixSize+totalLen) binary.LittleEndian.PutUint32(buf, uint32(len(block))) copy(buf[padPrefixSize:], block) return buf, nil }
[ "func", "PadBlock", "(", "block", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "totalLen", ":=", "powerOfTwoEqualOrGreater", "(", "len", "(", "block", ")", ")", "\n\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "padP...
// PadBlock adds zero padding to an encoded block.
[ "PadBlock", "adds", "zero", "padding", "to", "an", "encoded", "block", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/pad.go#L44-L52
160,726
keybase/client
go/kbfs/kbfscrypto/pad.go
DepadBlock
func DepadBlock(paddedBlock []byte) ([]byte, error) { totalLen := len(paddedBlock) if totalLen < padPrefixSize { return nil, errors.WithStack(io.ErrUnexpectedEOF) } blockLen := binary.LittleEndian.Uint32(paddedBlock) blockEndPos := int(blockLen + padPrefixSize) if totalLen < blockEndPos { return nil, errors.WithStack( PaddedBlockReadError{ ActualLen: totalLen, ExpectedLen: blockEndPos, }) } return paddedBlock[padPrefixSize:blockEndPos], nil }
go
func DepadBlock(paddedBlock []byte) ([]byte, error) { totalLen := len(paddedBlock) if totalLen < padPrefixSize { return nil, errors.WithStack(io.ErrUnexpectedEOF) } blockLen := binary.LittleEndian.Uint32(paddedBlock) blockEndPos := int(blockLen + padPrefixSize) if totalLen < blockEndPos { return nil, errors.WithStack( PaddedBlockReadError{ ActualLen: totalLen, ExpectedLen: blockEndPos, }) } return paddedBlock[padPrefixSize:blockEndPos], nil }
[ "func", "DepadBlock", "(", "paddedBlock", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "totalLen", ":=", "len", "(", "paddedBlock", ")", "\n", "if", "totalLen", "<", "padPrefixSize", "{", "return", "nil", ",", "errors", ".", ...
// DepadBlock extracts the actual block data from a padded block.
[ "DepadBlock", "extracts", "the", "actual", "block", "data", "from", "a", "padded", "block", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/pad.go#L55-L72
160,727
keybase/client
go/client/cmd_prove.go
ParseArgv
func (p *CmdProve) ParseArgv(ctx *cli.Context) error { nargs := len(ctx.Args()) p.arg.Force = ctx.Bool("force") p.listServices = ctx.Bool("list-services") p.output = ctx.String("output") if p.listServices { return nil } if nargs > 2 || nargs == 0 { return fmt.Errorf("prove takes 1 or 2 args: <service> [<username>]") } p.arg.Service = ctx.Args()[0] if nargs == 2 { p.arg.Username = ctx.Args()[1] } if libkb.RemoteServiceTypes[p.arg.Service] == keybase1.ProofType_ROOTER { p.arg.Auto = ctx.Bool("auto") if p.arg.Auto && len(p.arg.Username) == 0 { return fmt.Errorf("must specify the username when using auto flag") } } return nil }
go
func (p *CmdProve) ParseArgv(ctx *cli.Context) error { nargs := len(ctx.Args()) p.arg.Force = ctx.Bool("force") p.listServices = ctx.Bool("list-services") p.output = ctx.String("output") if p.listServices { return nil } if nargs > 2 || nargs == 0 { return fmt.Errorf("prove takes 1 or 2 args: <service> [<username>]") } p.arg.Service = ctx.Args()[0] if nargs == 2 { p.arg.Username = ctx.Args()[1] } if libkb.RemoteServiceTypes[p.arg.Service] == keybase1.ProofType_ROOTER { p.arg.Auto = ctx.Bool("auto") if p.arg.Auto && len(p.arg.Username) == 0 { return fmt.Errorf("must specify the username when using auto flag") } } return nil }
[ "func", "(", "p", "*", "CmdProve", ")", "ParseArgv", "(", "ctx", "*", "cli", ".", "Context", ")", "error", "{", "nargs", ":=", "len", "(", "ctx", ".", "Args", "(", ")", ")", "\n", "p", ".", "arg", ".", "Force", "=", "ctx", ".", "Bool", "(", "...
// ParseArgv parses arguments for the prove command.
[ "ParseArgv", "parses", "arguments", "for", "the", "prove", "command", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_prove.go#L30-L55
160,728
keybase/client
go/client/cmd_prove.go
NewCmdProve
func NewCmdProve(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { cmd := cli.Command{ Name: "prove", ArgumentHelp: "<service> [service username]", Usage: "Generate a new proof", Description: "Run keybase prove --list-services to see available services.", Flags: []cli.Flag{ cli.StringFlag{ Name: "output, o", Usage: "Output proof text to a file (rather than standard out).", }, cli.BoolFlag{ Name: "force, f", Usage: "Don't prompt.", }, cli.BoolFlag{ Name: "list-services, l", Usage: "List all available services", }, }, Action: func(c *cli.Context) { cl.ChooseCommand(&CmdProve{Contextified: libkb.NewContextified(g)}, "prove", c) }, } cmd.Flags = append(cmd.Flags, restrictedProveFlags...) return cmd }
go
func NewCmdProve(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { cmd := cli.Command{ Name: "prove", ArgumentHelp: "<service> [service username]", Usage: "Generate a new proof", Description: "Run keybase prove --list-services to see available services.", Flags: []cli.Flag{ cli.StringFlag{ Name: "output, o", Usage: "Output proof text to a file (rather than standard out).", }, cli.BoolFlag{ Name: "force, f", Usage: "Don't prompt.", }, cli.BoolFlag{ Name: "list-services, l", Usage: "List all available services", }, }, Action: func(c *cli.Context) { cl.ChooseCommand(&CmdProve{Contextified: libkb.NewContextified(g)}, "prove", c) }, } cmd.Flags = append(cmd.Flags, restrictedProveFlags...) return cmd }
[ "func", "NewCmdProve", "(", "cl", "*", "libcmdline", ".", "CommandLine", ",", "g", "*", "libkb", ".", "GlobalContext", ")", "cli", ".", "Command", "{", "cmd", ":=", "cli", ".", "Command", "{", "Name", ":", "\"", "\"", ",", "ArgumentHelp", ":", "\"", ...
// NewCmdProve makes a new prove command from the given CLI parameters.
[ "NewCmdProve", "makes", "a", "new", "prove", "command", "from", "the", "given", "CLI", "parameters", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_prove.go#L121-L147
160,729
keybase/client
go/client/cmd_prove.go
NewCmdProveRooterRunner
func NewCmdProveRooterRunner(g *libkb.GlobalContext, username string) *CmdProve { return &CmdProve{ Contextified: libkb.NewContextified(g), arg: keybase1.StartProofArg{ Service: "rooter", Username: username, Auto: true, }, } }
go
func NewCmdProveRooterRunner(g *libkb.GlobalContext, username string) *CmdProve { return &CmdProve{ Contextified: libkb.NewContextified(g), arg: keybase1.StartProofArg{ Service: "rooter", Username: username, Auto: true, }, } }
[ "func", "NewCmdProveRooterRunner", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "username", "string", ")", "*", "CmdProve", "{", "return", "&", "CmdProve", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "arg", ":", "ke...
// NewCmdProveRooterRunner creates a CmdProve for proving rooter in tests.
[ "NewCmdProveRooterRunner", "creates", "a", "CmdProve", "for", "proving", "rooter", "in", "tests", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_prove.go#L150-L159
160,730
keybase/client
go/client/cmd_prove.go
GetUsage
func (p *CmdProve) GetUsage() libkb.Usage { return libkb.Usage{ Config: true, API: true, KbKeyring: true, } }
go
func (p *CmdProve) GetUsage() libkb.Usage { return libkb.Usage{ Config: true, API: true, KbKeyring: true, } }
[ "func", "(", "p", "*", "CmdProve", ")", "GetUsage", "(", ")", "libkb", ".", "Usage", "{", "return", "libkb", ".", "Usage", "{", "Config", ":", "true", ",", "API", ":", "true", ",", "KbKeyring", ":", "true", ",", "}", "\n", "}" ]
// GetUsage specifics the library features that the prove command needs.
[ "GetUsage", "specifics", "the", "library", "features", "that", "the", "prove", "command", "needs", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_prove.go#L162-L168
160,731
keybase/client
go/kbfs/tlf/handle_extension.go
String
func (et HandleExtensionType) String(username kbname.NormalizedUsername) string { switch et { case HandleExtensionConflict: return handleExtensionConflictString case HandleExtensionFinalized: if len(username) != 0 { username += " " } return fmt.Sprintf(handleExtensionFinalizedString, username) } return "<unknown extension type>" }
go
func (et HandleExtensionType) String(username kbname.NormalizedUsername) string { switch et { case HandleExtensionConflict: return handleExtensionConflictString case HandleExtensionFinalized: if len(username) != 0 { username += " " } return fmt.Sprintf(handleExtensionFinalizedString, username) } return "<unknown extension type>" }
[ "func", "(", "et", "HandleExtensionType", ")", "String", "(", "username", "kbname", ".", "NormalizedUsername", ")", "string", "{", "switch", "et", "{", "case", "HandleExtensionConflict", ":", "return", "handleExtensionConflictString", "\n", "case", "HandleExtensionFin...
// String implements the fmt.Stringer interface for HandleExtensionType
[ "String", "implements", "the", "fmt", ".", "Stringer", "interface", "for", "HandleExtensionType" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle_extension.go#L72-L83
160,732
keybase/client
go/kbfs/tlf/handle_extension.go
parseHandleExtensionString
func parseHandleExtensionString(s string) (HandleExtensionType, kbname.NormalizedUsername) { if handleExtensionConflictString == s { return HandleExtensionConflict, "" } m := handleExtensionFinalizedRegex.FindStringSubmatch(s) if len(m) < 2 { return HandleExtensionUnknown, "" } return HandleExtensionFinalized, kbname.NewNormalizedUsername(m[1]) }
go
func parseHandleExtensionString(s string) (HandleExtensionType, kbname.NormalizedUsername) { if handleExtensionConflictString == s { return HandleExtensionConflict, "" } m := handleExtensionFinalizedRegex.FindStringSubmatch(s) if len(m) < 2 { return HandleExtensionUnknown, "" } return HandleExtensionFinalized, kbname.NewNormalizedUsername(m[1]) }
[ "func", "parseHandleExtensionString", "(", "s", "string", ")", "(", "HandleExtensionType", ",", "kbname", ".", "NormalizedUsername", ")", "{", "if", "handleExtensionConflictString", "==", "s", "{", "return", "HandleExtensionConflict", ",", "\"", "\"", "\n", "}", "...
// parseHandleExtensionString parses an extension type and optional username from a string.
[ "parseHandleExtensionString", "parses", "an", "extension", "type", "and", "optional", "username", "from", "a", "string", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle_extension.go#L86-L95
160,733
keybase/client
go/kbfs/tlf/handle_extension.go
NewHandleExtension
func NewHandleExtension(extType HandleExtensionType, num uint16, un kbname.NormalizedUsername, now time.Time) ( *HandleExtension, error) { return newHandleExtension(extType, num, un, now) }
go
func NewHandleExtension(extType HandleExtensionType, num uint16, un kbname.NormalizedUsername, now time.Time) ( *HandleExtension, error) { return newHandleExtension(extType, num, un, now) }
[ "func", "NewHandleExtension", "(", "extType", "HandleExtensionType", ",", "num", "uint16", ",", "un", "kbname", ".", "NormalizedUsername", ",", "now", "time", ".", "Time", ")", "(", "*", "HandleExtension", ",", "error", ")", "{", "return", "newHandleExtension", ...
// NewHandleExtension returns a new HandleExtension struct // populated with the date from the given time and conflict number.
[ "NewHandleExtension", "returns", "a", "new", "HandleExtension", "struct", "populated", "with", "the", "date", "from", "the", "given", "time", "and", "conflict", "number", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle_extension.go#L150-L153
160,734
keybase/client
go/kbfs/tlf/handle_extension.go
newHandleExtension
func newHandleExtension(extType HandleExtensionType, num uint16, un kbname.NormalizedUsername, now time.Time) ( *HandleExtension, error) { if num == 0 { return nil, errHandleExtensionInvalidNumber } // mask out everything but the date date := now.UTC().Format(handleExtensionDateFormat) now, err := time.Parse(handleExtensionDateFormat, date) if err != nil { return nil, err } return &HandleExtension{ Date: now.UTC().Unix(), Number: num, Type: extType, Username: un, }, nil }
go
func newHandleExtension(extType HandleExtensionType, num uint16, un kbname.NormalizedUsername, now time.Time) ( *HandleExtension, error) { if num == 0 { return nil, errHandleExtensionInvalidNumber } // mask out everything but the date date := now.UTC().Format(handleExtensionDateFormat) now, err := time.Parse(handleExtensionDateFormat, date) if err != nil { return nil, err } return &HandleExtension{ Date: now.UTC().Unix(), Number: num, Type: extType, Username: un, }, nil }
[ "func", "newHandleExtension", "(", "extType", "HandleExtensionType", ",", "num", "uint16", ",", "un", "kbname", ".", "NormalizedUsername", ",", "now", "time", ".", "Time", ")", "(", "*", "HandleExtension", ",", "error", ")", "{", "if", "num", "==", "0", "{...
// Helper to instantiate a HandleExtension object.
[ "Helper", "to", "instantiate", "a", "HandleExtension", "object", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle_extension.go#L164-L181
160,735
keybase/client
go/kbfs/tlf/handle_extension.go
parseHandleExtension
func parseHandleExtension(fields []string) (*HandleExtension, error) { if len(fields) != 4 { return nil, errHandleExtensionInvalidString } extType, un := parseHandleExtensionString(fields[1]) if extType == HandleExtensionUnknown { return nil, errHandleExtensionInvalidString } date, err := time.Parse(handleExtensionDateFormat, fields[2]) if err != nil { return nil, err } var num uint64 = 1 if len(fields[3]) != 0 { num, err = strconv.ParseUint(fields[3], 10, 16) if err != nil { return nil, err } if num < 1 { return nil, errHandleExtensionInvalidNumber } } return &HandleExtension{ Date: date.UTC().Unix(), Number: uint16(num), Type: extType, Username: un, }, nil }
go
func parseHandleExtension(fields []string) (*HandleExtension, error) { if len(fields) != 4 { return nil, errHandleExtensionInvalidString } extType, un := parseHandleExtensionString(fields[1]) if extType == HandleExtensionUnknown { return nil, errHandleExtensionInvalidString } date, err := time.Parse(handleExtensionDateFormat, fields[2]) if err != nil { return nil, err } var num uint64 = 1 if len(fields[3]) != 0 { num, err = strconv.ParseUint(fields[3], 10, 16) if err != nil { return nil, err } if num < 1 { return nil, errHandleExtensionInvalidNumber } } return &HandleExtension{ Date: date.UTC().Unix(), Number: uint16(num), Type: extType, Username: un, }, nil }
[ "func", "parseHandleExtension", "(", "fields", "[", "]", "string", ")", "(", "*", "HandleExtension", ",", "error", ")", "{", "if", "len", "(", "fields", ")", "!=", "4", "{", "return", "nil", ",", "errHandleExtensionInvalidString", "\n", "}", "\n", "extType...
// parseHandleExtension parses a HandleExtension array of string fields.
[ "parseHandleExtension", "parses", "a", "HandleExtension", "array", "of", "string", "fields", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle_extension.go#L184-L212
160,736
keybase/client
go/kbfs/tlf/handle_extension.go
ParseHandleExtensionSuffix
func ParseHandleExtensionSuffix(s string) ([]HandleExtension, error) { exts := handleExtensionRegex.FindAllStringSubmatch(s, 2) if len(exts) < 1 || len(exts) > 2 { return nil, errHandleExtensionInvalidString } extMap := make(map[HandleExtensionType]bool) var extensions []HandleExtension for _, e := range exts { ext, err := parseHandleExtension(e) if err != nil { return nil, err } if extMap[ext.Type] { // No duplicate extension types in the same suffix. return nil, errHandleExtensionInvalidString } extMap[ext.Type] = true extensions = append(extensions, *ext) } return extensions, nil }
go
func ParseHandleExtensionSuffix(s string) ([]HandleExtension, error) { exts := handleExtensionRegex.FindAllStringSubmatch(s, 2) if len(exts) < 1 || len(exts) > 2 { return nil, errHandleExtensionInvalidString } extMap := make(map[HandleExtensionType]bool) var extensions []HandleExtension for _, e := range exts { ext, err := parseHandleExtension(e) if err != nil { return nil, err } if extMap[ext.Type] { // No duplicate extension types in the same suffix. return nil, errHandleExtensionInvalidString } extMap[ext.Type] = true extensions = append(extensions, *ext) } return extensions, nil }
[ "func", "ParseHandleExtensionSuffix", "(", "s", "string", ")", "(", "[", "]", "HandleExtension", ",", "error", ")", "{", "exts", ":=", "handleExtensionRegex", ".", "FindAllStringSubmatch", "(", "s", ",", "2", ")", "\n", "if", "len", "(", "exts", ")", "<", ...
// ParseHandleExtensionSuffix parses a TLF handle extension suffix string.
[ "ParseHandleExtensionSuffix", "parses", "a", "TLF", "handle", "extension", "suffix", "string", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle_extension.go#L215-L235
160,737
keybase/client
go/kbfs/tlf/handle_extension.go
newHandleExtensionSuffix
func newHandleExtensionSuffix( extensions []HandleExtension, isBackedByTeam bool) string { var suffix string for _, extension := range extensions { suffix += HandleExtensionSep suffix += extension.string(isBackedByTeam) } return suffix }
go
func newHandleExtensionSuffix( extensions []HandleExtension, isBackedByTeam bool) string { var suffix string for _, extension := range extensions { suffix += HandleExtensionSep suffix += extension.string(isBackedByTeam) } return suffix }
[ "func", "newHandleExtensionSuffix", "(", "extensions", "[", "]", "HandleExtension", ",", "isBackedByTeam", "bool", ")", "string", "{", "var", "suffix", "string", "\n", "for", "_", ",", "extension", ":=", "range", "extensions", "{", "suffix", "+=", "HandleExtensi...
// newHandleExtensionSuffix creates a suffix string given a set of extensions.
[ "newHandleExtensionSuffix", "creates", "a", "suffix", "string", "given", "a", "set", "of", "extensions", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/handle_extension.go#L238-L246
160,738
keybase/client
go/chat/storage/storage_delh.go
setDeletedUpto
func (t *delhTracker) setDeletedUpto(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, msgid chat1.MessageID) Error { entry, err := t.getEntry(ctx, convID, uid) switch err.(type) { case nil: case MissError: default: return err } entry.MaxDeleteHistoryUpto = msgid entry.MinDeletableMessage = msgid return t.setEntry(ctx, convID, uid, entry) }
go
func (t *delhTracker) setDeletedUpto(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, msgid chat1.MessageID) Error { entry, err := t.getEntry(ctx, convID, uid) switch err.(type) { case nil: case MissError: default: return err } entry.MaxDeleteHistoryUpto = msgid entry.MinDeletableMessage = msgid return t.setEntry(ctx, convID, uid, entry) }
[ "func", "(", "t", "*", "delhTracker", ")", "setDeletedUpto", "(", "ctx", "context", ".", "Context", ",", "convID", "chat1", ".", "ConversationID", ",", "uid", "gregor1", ".", "UID", ",", "msgid", "chat1", ".", "MessageID", ")", "Error", "{", "entry", ","...
// Set both values to msgid
[ "Set", "both", "values", "to", "msgid" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/storage_delh.go#L120-L133
160,739
keybase/client
go/kbfs/libfuse/updates_file.go
Write
func (f *UpdatesFile) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) (err error) { f.folder.fs.log.CDebugf(ctx, "UpdatesFile (enable: %t) Write", f.enable) defer func() { err = f.folder.processError(ctx, libkbfs.WriteMode, err) }() if len(req.Data) == 0 { return nil } f.folder.updateMu.Lock() defer f.folder.updateMu.Unlock() if f.enable { if f.folder.updateChan == nil { return errors.New("Updates are already enabled") } err = libkbfs.RestartCRForTesting( libcontext.BackgroundContextWithCancellationDelayer(), f.folder.fs.config, f.folder.getFolderBranch()) if err != nil { return err } f.folder.updateChan <- struct{}{} close(f.folder.updateChan) f.folder.updateChan = nil } else { if f.folder.updateChan != nil { return errors.New("Updates are already disabled") } f.folder.updateChan, err = libkbfs.DisableUpdatesForTesting(f.folder.fs.config, f.folder.getFolderBranch()) if err != nil { return err } err = libkbfs.DisableCRForTesting(f.folder.fs.config, f.folder.getFolderBranch()) if err != nil { return err } } resp.Size = len(req.Data) return nil }
go
func (f *UpdatesFile) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) (err error) { f.folder.fs.log.CDebugf(ctx, "UpdatesFile (enable: %t) Write", f.enable) defer func() { err = f.folder.processError(ctx, libkbfs.WriteMode, err) }() if len(req.Data) == 0 { return nil } f.folder.updateMu.Lock() defer f.folder.updateMu.Unlock() if f.enable { if f.folder.updateChan == nil { return errors.New("Updates are already enabled") } err = libkbfs.RestartCRForTesting( libcontext.BackgroundContextWithCancellationDelayer(), f.folder.fs.config, f.folder.getFolderBranch()) if err != nil { return err } f.folder.updateChan <- struct{}{} close(f.folder.updateChan) f.folder.updateChan = nil } else { if f.folder.updateChan != nil { return errors.New("Updates are already disabled") } f.folder.updateChan, err = libkbfs.DisableUpdatesForTesting(f.folder.fs.config, f.folder.getFolderBranch()) if err != nil { return err } err = libkbfs.DisableCRForTesting(f.folder.fs.config, f.folder.getFolderBranch()) if err != nil { return err } } resp.Size = len(req.Data) return nil }
[ "func", "(", "f", "*", "UpdatesFile", ")", "Write", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "WriteRequest", ",", "resp", "*", "fuse", ".", "WriteResponse", ")", "(", "err", "error", ")", "{", "f", ".", "folder", ".", "f...
// Write implements the fs.HandleWriter interface for UpdatesFile.
[ "Write", "implements", "the", "fs", ".", "HandleWriter", "interface", "for", "UpdatesFile", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/updates_file.go#L42-L84
160,740
keybase/client
go/bind/extension.go
ExtensionForceGC
func ExtensionForceGC() { var m runtime.MemStats runtime.ReadMemStats(&m) // Free up gc memory first fmt.Printf("mem stats (before): alloc: %v sys: %v\n", m.Alloc, m.Sys) fmt.Printf("Starting force gc\n") debug.FreeOSMemory() fmt.Printf("Done force gc\n") runtime.ReadMemStats(&m) fmt.Printf("mem stats (after): alloc: %v sys: %v\n", m.Alloc, m.Sys) if !ExtensionIsInited() { fmt.Printf("Not initialized, bailing\n") return } // Free all caches, and run gc again to clear out anything fmt.Printf("Flushing global caches\n") kbCtx.FlushCaches() if _, ok := kbCtx.LocalChatDb.GetEngine().(*libkb.MemDb); ok { fmt.Printf("Nuking in memory chat db\n") kbCtx.LocalChatDb.Nuke() } if _, ok := kbCtx.LocalDb.GetEngine().(*libkb.MemDb); ok { fmt.Printf("Nuking in memory local db\n") kbCtx.LocalDb.Nuke() } debug.FreeOSMemory() fmt.Printf("Done flushing global caches\n") runtime.ReadMemStats(&m) fmt.Printf("mem stats (after flush): alloc: %v sys: %v\n", m.Alloc, m.Sys) }
go
func ExtensionForceGC() { var m runtime.MemStats runtime.ReadMemStats(&m) // Free up gc memory first fmt.Printf("mem stats (before): alloc: %v sys: %v\n", m.Alloc, m.Sys) fmt.Printf("Starting force gc\n") debug.FreeOSMemory() fmt.Printf("Done force gc\n") runtime.ReadMemStats(&m) fmt.Printf("mem stats (after): alloc: %v sys: %v\n", m.Alloc, m.Sys) if !ExtensionIsInited() { fmt.Printf("Not initialized, bailing\n") return } // Free all caches, and run gc again to clear out anything fmt.Printf("Flushing global caches\n") kbCtx.FlushCaches() if _, ok := kbCtx.LocalChatDb.GetEngine().(*libkb.MemDb); ok { fmt.Printf("Nuking in memory chat db\n") kbCtx.LocalChatDb.Nuke() } if _, ok := kbCtx.LocalDb.GetEngine().(*libkb.MemDb); ok { fmt.Printf("Nuking in memory local db\n") kbCtx.LocalDb.Nuke() } debug.FreeOSMemory() fmt.Printf("Done flushing global caches\n") runtime.ReadMemStats(&m) fmt.Printf("mem stats (after flush): alloc: %v sys: %v\n", m.Alloc, m.Sys) }
[ "func", "ExtensionForceGC", "(", ")", "{", "var", "m", "runtime", ".", "MemStats", "\n", "runtime", ".", "ReadMemStats", "(", "&", "m", ")", "\n\n", "// Free up gc memory first", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "m", ".", "Alloc", ",", ...
// ExtensionForceGC Forces a gc
[ "ExtensionForceGC", "Forces", "a", "gc" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/extension.go#L715-L747
160,741
keybase/client
go/libkb/identify2_cache.go
NewIdentify2Cache
func NewIdentify2Cache(maxAge time.Duration) *Identify2Cache { res := &Identify2Cache{ cache: ramcache.New(), } res.cache.MaxAge = maxAge res.cache.TTL = maxAge return res }
go
func NewIdentify2Cache(maxAge time.Duration) *Identify2Cache { res := &Identify2Cache{ cache: ramcache.New(), } res.cache.MaxAge = maxAge res.cache.TTL = maxAge return res }
[ "func", "NewIdentify2Cache", "(", "maxAge", "time", ".", "Duration", ")", "*", "Identify2Cache", "{", "res", ":=", "&", "Identify2Cache", "{", "cache", ":", "ramcache", ".", "New", "(", ")", ",", "}", "\n", "res", ".", "cache", ".", "MaxAge", "=", "max...
// NewIdentify2Cache creates a Identify2Cache and sets the object max age to // maxAge. Once a user is inserted, after maxAge duration passes, // the user will be removed from the cache.
[ "NewIdentify2Cache", "creates", "a", "Identify2Cache", "and", "sets", "the", "object", "max", "age", "to", "maxAge", ".", "Once", "a", "user", "is", "inserted", "after", "maxAge", "duration", "passes", "the", "user", "will", "be", "removed", "from", "the", "...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/identify2_cache.go#L35-L42
160,742
keybase/client
go/libkb/identify2_cache.go
Get
func (c *Identify2Cache) Get(uid keybase1.UID, gctf GetCheckTimeFunc, gcdf GetCacheDurationFunc, breaksOK bool) (*keybase1.Identify2ResUPK2, error) { v, err := c.cache.Get(string(uid)) if err != nil { if err == ramcache.ErrNotFound { return nil, nil } return nil, err } up, ok := v.(*keybase1.Identify2ResUPK2) if !ok { return nil, fmt.Errorf("invalid type in cache: %T", v) } if gctf != nil { then := gctf(*up) if then == 0 { return nil, IdentifyTimeoutError{} } if up.TrackBreaks != nil && !breaksOK { return nil, TrackBrokenError{} } thenTime := keybase1.FromTime(then) timeout := gcdf(*up) if time.Since(thenTime) > timeout { return nil, IdentifyTimeoutError{} } } return up, nil }
go
func (c *Identify2Cache) Get(uid keybase1.UID, gctf GetCheckTimeFunc, gcdf GetCacheDurationFunc, breaksOK bool) (*keybase1.Identify2ResUPK2, error) { v, err := c.cache.Get(string(uid)) if err != nil { if err == ramcache.ErrNotFound { return nil, nil } return nil, err } up, ok := v.(*keybase1.Identify2ResUPK2) if !ok { return nil, fmt.Errorf("invalid type in cache: %T", v) } if gctf != nil { then := gctf(*up) if then == 0 { return nil, IdentifyTimeoutError{} } if up.TrackBreaks != nil && !breaksOK { return nil, TrackBrokenError{} } thenTime := keybase1.FromTime(then) timeout := gcdf(*up) if time.Since(thenTime) > timeout { return nil, IdentifyTimeoutError{} } } return up, nil }
[ "func", "(", "c", "*", "Identify2Cache", ")", "Get", "(", "uid", "keybase1", ".", "UID", ",", "gctf", "GetCheckTimeFunc", ",", "gcdf", "GetCacheDurationFunc", ",", "breaksOK", "bool", ")", "(", "*", "keybase1", ".", "Identify2ResUPK2", ",", "error", ")", "...
// Get returns a user object. If none exists for uid, it will return nil.
[ "Get", "returns", "a", "user", "object", ".", "If", "none", "exists", "for", "uid", "it", "will", "return", "nil", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/identify2_cache.go#L45-L75
160,743
keybase/client
go/libkb/identify2_cache.go
Insert
func (c *Identify2Cache) Insert(up *keybase1.Identify2ResUPK2) error { tmp := *up copy := &tmp copy.Upk.Uvv.CachedAt = keybase1.ToTime(time.Now()) return c.cache.Set(string(up.Upk.GetUID()), copy) }
go
func (c *Identify2Cache) Insert(up *keybase1.Identify2ResUPK2) error { tmp := *up copy := &tmp copy.Upk.Uvv.CachedAt = keybase1.ToTime(time.Now()) return c.cache.Set(string(up.Upk.GetUID()), copy) }
[ "func", "(", "c", "*", "Identify2Cache", ")", "Insert", "(", "up", "*", "keybase1", ".", "Identify2ResUPK2", ")", "error", "{", "tmp", ":=", "*", "up", "\n", "copy", ":=", "&", "tmp", "\n", "copy", ".", "Upk", ".", "Uvv", ".", "CachedAt", "=", "key...
// Insert adds a user to the cache, keyed on UID.
[ "Insert", "adds", "a", "user", "to", "the", "cache", "keyed", "on", "UID", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/identify2_cache.go#L78-L83
160,744
keybase/client
go/kbfs/data/bsplitter_simple.go
NewBlockSplitterSimple
func NewBlockSplitterSimple(desiredBlockSize int64, blockChangeEmbedMaxSize uint64, codec kbfscodec.Codec) ( *BlockSplitterSimple, error) { // If the desired block size is exactly a power of 2, subtract one // from it to account for the padding we will do, which rounds up // when the encoded size is exactly a power of 2. if desiredBlockSize&(desiredBlockSize-1) == 0 { desiredBlockSize-- } // Make a FileBlock of the expected size to see what the encoded // overhead is. block := NewFileBlock().(*FileBlock) fullData := make([]byte, desiredBlockSize) // Fill in the block with varying data to make sure not to trigger // any encoding optimizations. for i := range fullData { fullData[i] = byte(i) } maxSize := desiredBlockSize var encodedLen int64 // Iterate until we find the right size (up to a maximum number of // attempts), because the overhead is not constant across // different Contents lengths (probably due to variable length // encoding of the buffer size). for i := 0; i < 10; i++ { block.Contents = fullData[:maxSize] encodedBlock, err := codec.Encode(block) if err != nil { return nil, err } encodedLen = int64(len(encodedBlock)) if encodedLen >= 2*desiredBlockSize { return nil, fmt.Errorf("Encoded block of %d bytes is more than "+ "twice as big as the desired block size %d", encodedLen, desiredBlockSize) } if encodedLen == desiredBlockSize { break } maxSize += (desiredBlockSize - encodedLen) } if encodedLen != desiredBlockSize { return nil, fmt.Errorf("Couldn't converge on a max block size for a "+ "desired size of %d", desiredBlockSize) } // Trial and error shows that this magic 75% constant maximizes // the number of realistic indirect pointers you can fit into the // default block size. TODO: calculate this number more exactly // during initialization for a given `maxSize`. maxPtrs := int(.75 * float64(maxSize/int64(BPSize))) if maxPtrs < 2 { maxPtrs = 2 } maxDirEntriesPerBlock, err := getMaxDirEntriesPerBlock() if err != nil { return nil, err } return &BlockSplitterSimple{ maxSize: maxSize, maxPtrsPerBlock: maxPtrs, blockChangeEmbedMaxSize: blockChangeEmbedMaxSize, maxDirEntriesPerBlock: maxDirEntriesPerBlock, }, nil }
go
func NewBlockSplitterSimple(desiredBlockSize int64, blockChangeEmbedMaxSize uint64, codec kbfscodec.Codec) ( *BlockSplitterSimple, error) { // If the desired block size is exactly a power of 2, subtract one // from it to account for the padding we will do, which rounds up // when the encoded size is exactly a power of 2. if desiredBlockSize&(desiredBlockSize-1) == 0 { desiredBlockSize-- } // Make a FileBlock of the expected size to see what the encoded // overhead is. block := NewFileBlock().(*FileBlock) fullData := make([]byte, desiredBlockSize) // Fill in the block with varying data to make sure not to trigger // any encoding optimizations. for i := range fullData { fullData[i] = byte(i) } maxSize := desiredBlockSize var encodedLen int64 // Iterate until we find the right size (up to a maximum number of // attempts), because the overhead is not constant across // different Contents lengths (probably due to variable length // encoding of the buffer size). for i := 0; i < 10; i++ { block.Contents = fullData[:maxSize] encodedBlock, err := codec.Encode(block) if err != nil { return nil, err } encodedLen = int64(len(encodedBlock)) if encodedLen >= 2*desiredBlockSize { return nil, fmt.Errorf("Encoded block of %d bytes is more than "+ "twice as big as the desired block size %d", encodedLen, desiredBlockSize) } if encodedLen == desiredBlockSize { break } maxSize += (desiredBlockSize - encodedLen) } if encodedLen != desiredBlockSize { return nil, fmt.Errorf("Couldn't converge on a max block size for a "+ "desired size of %d", desiredBlockSize) } // Trial and error shows that this magic 75% constant maximizes // the number of realistic indirect pointers you can fit into the // default block size. TODO: calculate this number more exactly // during initialization for a given `maxSize`. maxPtrs := int(.75 * float64(maxSize/int64(BPSize))) if maxPtrs < 2 { maxPtrs = 2 } maxDirEntriesPerBlock, err := getMaxDirEntriesPerBlock() if err != nil { return nil, err } return &BlockSplitterSimple{ maxSize: maxSize, maxPtrsPerBlock: maxPtrs, blockChangeEmbedMaxSize: blockChangeEmbedMaxSize, maxDirEntriesPerBlock: maxDirEntriesPerBlock, }, nil }
[ "func", "NewBlockSplitterSimple", "(", "desiredBlockSize", "int64", ",", "blockChangeEmbedMaxSize", "uint64", ",", "codec", "kbfscodec", ".", "Codec", ")", "(", "*", "BlockSplitterSimple", ",", "error", ")", "{", "// If the desired block size is exactly a power of 2, subtra...
// NewBlockSplitterSimple creates a new BlockSplittleSimple and // adjusts the max size to try to match the desired size for file // blocks, given the overhead of encoding a file block and the // round-up padding we do.
[ "NewBlockSplitterSimple", "creates", "a", "new", "BlockSplittleSimple", "and", "adjusts", "the", "max", "size", "to", "try", "to", "match", "the", "desired", "size", "for", "file", "blocks", "given", "the", "overhead", "of", "encoding", "a", "file", "block", "...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/bsplitter_simple.go#L42-L114
160,745
keybase/client
go/kbfs/data/bsplitter_simple.go
NewBlockSplitterSimpleExact
func NewBlockSplitterSimpleExact( maxSize int64, maxPtrsPerBlock int, blockChangeEmbedMaxSize uint64) ( *BlockSplitterSimple, error) { maxDirEntriesPerBlock, err := getMaxDirEntriesPerBlock() if err != nil { return nil, err } return &BlockSplitterSimple{ maxSize: maxSize, maxPtrsPerBlock: maxPtrsPerBlock, blockChangeEmbedMaxSize: blockChangeEmbedMaxSize, maxDirEntriesPerBlock: maxDirEntriesPerBlock, }, nil }
go
func NewBlockSplitterSimpleExact( maxSize int64, maxPtrsPerBlock int, blockChangeEmbedMaxSize uint64) ( *BlockSplitterSimple, error) { maxDirEntriesPerBlock, err := getMaxDirEntriesPerBlock() if err != nil { return nil, err } return &BlockSplitterSimple{ maxSize: maxSize, maxPtrsPerBlock: maxPtrsPerBlock, blockChangeEmbedMaxSize: blockChangeEmbedMaxSize, maxDirEntriesPerBlock: maxDirEntriesPerBlock, }, nil }
[ "func", "NewBlockSplitterSimpleExact", "(", "maxSize", "int64", ",", "maxPtrsPerBlock", "int", ",", "blockChangeEmbedMaxSize", "uint64", ")", "(", "*", "BlockSplitterSimple", ",", "error", ")", "{", "maxDirEntriesPerBlock", ",", "err", ":=", "getMaxDirEntriesPerBlock", ...
// NewBlockSplitterSimpleExact returns a BlockSplitterSimple with the // max block size set to an exact value.
[ "NewBlockSplitterSimpleExact", "returns", "a", "BlockSplitterSimple", "with", "the", "max", "block", "size", "set", "to", "an", "exact", "value", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/bsplitter_simple.go#L118-L131
160,746
keybase/client
go/kbfs/data/bsplitter_simple.go
SetMaxDirEntriesByBlockSize
func (b *BlockSplitterSimple) SetMaxDirEntriesByBlockSize( codec kbfscodec.Codec) error { dirEnv := os.Getenv("KEYBASE_BSPLIT_MAX_DIR_ENTRIES") if len(dirEnv) > 0 { // Don't override the environment variable. return nil } block := NewDirBlock().(*DirBlock) bigName := strings.Repeat("a", MaxNameBytesDefault) // Make "typical" DirEntry, though the max dir entry is a bit // bigger than this (can contain a variable-length symlink path, // for example). de := DirEntry{ BlockInfo: BlockInfo{ BlockPointer: BlockPointer{ DirectType: DirectBlock, }, }, EntryInfo: EntryInfo{ PrevRevisions: PrevRevisions{ {Revision: 0, Count: 0}, {Revision: 1, Count: 1}, {Revision: 2, Count: 2}, {Revision: 3, Count: 3}, {Revision: 4, Count: 4}, }, }, } block.Children[bigName] = de encodedBlock, err := codec.Encode(block) if err != nil { return err } oneEntrySize := int64(len(encodedBlock)) b.maxDirEntriesPerBlock = int(b.maxSize / oneEntrySize) if b.maxDirEntriesPerBlock == 0 { b.maxDirEntriesPerBlock = 1 } return nil }
go
func (b *BlockSplitterSimple) SetMaxDirEntriesByBlockSize( codec kbfscodec.Codec) error { dirEnv := os.Getenv("KEYBASE_BSPLIT_MAX_DIR_ENTRIES") if len(dirEnv) > 0 { // Don't override the environment variable. return nil } block := NewDirBlock().(*DirBlock) bigName := strings.Repeat("a", MaxNameBytesDefault) // Make "typical" DirEntry, though the max dir entry is a bit // bigger than this (can contain a variable-length symlink path, // for example). de := DirEntry{ BlockInfo: BlockInfo{ BlockPointer: BlockPointer{ DirectType: DirectBlock, }, }, EntryInfo: EntryInfo{ PrevRevisions: PrevRevisions{ {Revision: 0, Count: 0}, {Revision: 1, Count: 1}, {Revision: 2, Count: 2}, {Revision: 3, Count: 3}, {Revision: 4, Count: 4}, }, }, } block.Children[bigName] = de encodedBlock, err := codec.Encode(block) if err != nil { return err } oneEntrySize := int64(len(encodedBlock)) b.maxDirEntriesPerBlock = int(b.maxSize / oneEntrySize) if b.maxDirEntriesPerBlock == 0 { b.maxDirEntriesPerBlock = 1 } return nil }
[ "func", "(", "b", "*", "BlockSplitterSimple", ")", "SetMaxDirEntriesByBlockSize", "(", "codec", "kbfscodec", ".", "Codec", ")", "error", "{", "dirEnv", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "len", "(", "dirEnv", ")", ">", "0", "{...
// SetMaxDirEntriesByBlockSize sets the maximum number of directory // entries per directory block, based on the maximum block size. If // the `KEYBASE_BSPLIT_MAX_DIR_ENTRIES` is set, this function does // nothing.
[ "SetMaxDirEntriesByBlockSize", "sets", "the", "maximum", "number", "of", "directory", "entries", "per", "directory", "block", "based", "on", "the", "maximum", "block", "size", ".", "If", "the", "KEYBASE_BSPLIT_MAX_DIR_ENTRIES", "is", "set", "this", "function", "does...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/bsplitter_simple.go#L137-L177
160,747
keybase/client
go/kbfs/data/bsplitter_simple.go
CopyUntilSplit
func (b *BlockSplitterSimple) CopyUntilSplit( block *FileBlock, lastBlock bool, data []byte, off int64) int64 { n := int64(len(data)) currLen := int64(len(block.Contents)) // lastBlock is irrelevant since we only copy fixed sizes toCopy := n if currLen < (off + n) { moreNeeded := (n + off) - currLen // Reduce the number of additional bytes if it will take this block // over maxSize. if moreNeeded+currLen > b.maxSize { moreNeeded = b.maxSize - currLen if moreNeeded < 0 { // If it is already over maxSize w/o any added bytes, // just give up. return 0 } // only copy to the end of the block toCopy = b.maxSize - off } if moreNeeded > 0 { block.Contents = append(block.Contents, make([]byte, moreNeeded)...) } } // we may have filled out the block above, but we still can't copy anything if off > int64(len(block.Contents)) { return 0 } copy(block.Contents[off:off+toCopy], data[:toCopy]) return toCopy }
go
func (b *BlockSplitterSimple) CopyUntilSplit( block *FileBlock, lastBlock bool, data []byte, off int64) int64 { n := int64(len(data)) currLen := int64(len(block.Contents)) // lastBlock is irrelevant since we only copy fixed sizes toCopy := n if currLen < (off + n) { moreNeeded := (n + off) - currLen // Reduce the number of additional bytes if it will take this block // over maxSize. if moreNeeded+currLen > b.maxSize { moreNeeded = b.maxSize - currLen if moreNeeded < 0 { // If it is already over maxSize w/o any added bytes, // just give up. return 0 } // only copy to the end of the block toCopy = b.maxSize - off } if moreNeeded > 0 { block.Contents = append(block.Contents, make([]byte, moreNeeded)...) } } // we may have filled out the block above, but we still can't copy anything if off > int64(len(block.Contents)) { return 0 } copy(block.Contents[off:off+toCopy], data[:toCopy]) return toCopy }
[ "func", "(", "b", "*", "BlockSplitterSimple", ")", "CopyUntilSplit", "(", "block", "*", "FileBlock", ",", "lastBlock", "bool", ",", "data", "[", "]", "byte", ",", "off", "int64", ")", "int64", "{", "n", ":=", "int64", "(", "len", "(", "data", ")", ")...
// CopyUntilSplit implements the BlockSplitter interface for // BlockSplitterSimple.
[ "CopyUntilSplit", "implements", "the", "BlockSplitter", "interface", "for", "BlockSplitterSimple", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/bsplitter_simple.go#L181-L215
160,748
keybase/client
go/kbfs/data/bsplitter_simple.go
SplitDirIfNeeded
func (b *BlockSplitterSimple) SplitDirIfNeeded(block *DirBlock) ( []*DirBlock, *StringOffset) { if block.IsIndirect() { panic("SplitDirIfNeeded must be given only a direct block") } if b.maxDirEntriesPerBlock == 0 || len(block.Children) <= b.maxDirEntriesPerBlock { return []*DirBlock{block}, nil } // Sort the entries and split them down the middle. names := make([]string, 0, len(block.Children)) for name := range block.Children { names = append(names, name) } sort.Strings(names) // Delete the second half of the names from the original block, // and add to the new block. newBlock := NewDirBlock().(*DirBlock) startOff := int(len(names) / 2) for _, name := range names[int(len(names)/2):] { newBlock.Children[name] = block.Children[name] delete(block.Children, name) } newOffset := StringOffset(names[startOff]) return []*DirBlock{block, newBlock}, &newOffset }
go
func (b *BlockSplitterSimple) SplitDirIfNeeded(block *DirBlock) ( []*DirBlock, *StringOffset) { if block.IsIndirect() { panic("SplitDirIfNeeded must be given only a direct block") } if b.maxDirEntriesPerBlock == 0 || len(block.Children) <= b.maxDirEntriesPerBlock { return []*DirBlock{block}, nil } // Sort the entries and split them down the middle. names := make([]string, 0, len(block.Children)) for name := range block.Children { names = append(names, name) } sort.Strings(names) // Delete the second half of the names from the original block, // and add to the new block. newBlock := NewDirBlock().(*DirBlock) startOff := int(len(names) / 2) for _, name := range names[int(len(names)/2):] { newBlock.Children[name] = block.Children[name] delete(block.Children, name) } newOffset := StringOffset(names[startOff]) return []*DirBlock{block, newBlock}, &newOffset }
[ "func", "(", "b", "*", "BlockSplitterSimple", ")", "SplitDirIfNeeded", "(", "block", "*", "DirBlock", ")", "(", "[", "]", "*", "DirBlock", ",", "*", "StringOffset", ")", "{", "if", "block", ".", "IsIndirect", "(", ")", "{", "panic", "(", "\"", "\"", ...
// SplitDirIfNeeded implements the BlockSplitter interface for // BlockSplitterSimple.
[ "SplitDirIfNeeded", "implements", "the", "BlockSplitter", "interface", "for", "BlockSplitterSimple", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/bsplitter_simple.go#L238-L266
160,749
keybase/client
go/logger/adapter.go
Debugf
func (l logf) Debugf(s string, args ...interface{}) { l.log.Debug(s, args...) }
go
func (l logf) Debugf(s string, args ...interface{}) { l.log.Debug(s, args...) }
[ "func", "(", "l", "logf", ")", "Debugf", "(", "s", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "log", ".", "Debug", "(", "s", ",", "args", "...", ")", "\n", "}" ]
// Debugf forwards to Logger.Debug
[ "Debugf", "forwards", "to", "Logger", ".", "Debug" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/logger/adapter.go#L31-L33
160,750
keybase/client
go/logger/adapter.go
Infof
func (l logf) Infof(s string, args ...interface{}) { l.log.Info(s, args...) }
go
func (l logf) Infof(s string, args ...interface{}) { l.log.Info(s, args...) }
[ "func", "(", "l", "logf", ")", "Infof", "(", "s", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "log", ".", "Info", "(", "s", ",", "args", "...", ")", "\n", "}" ]
// Infof forwards to Logger.Info
[ "Infof", "forwards", "to", "Logger", ".", "Info" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/logger/adapter.go#L36-L38
160,751
keybase/client
go/logger/adapter.go
Warningf
func (l logf) Warningf(s string, args ...interface{}) { l.log.Warning(s, args...) }
go
func (l logf) Warningf(s string, args ...interface{}) { l.log.Warning(s, args...) }
[ "func", "(", "l", "logf", ")", "Warningf", "(", "s", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "log", ".", "Warning", "(", "s", ",", "args", "...", ")", "\n", "}" ]
// Warningf forwards to Logger.Warning
[ "Warningf", "forwards", "to", "Logger", ".", "Warning" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/logger/adapter.go#L41-L43
160,752
keybase/client
go/logger/adapter.go
Errorf
func (l logf) Errorf(s string, args ...interface{}) { l.log.Errorf(s, args...) }
go
func (l logf) Errorf(s string, args ...interface{}) { l.log.Errorf(s, args...) }
[ "func", "(", "l", "logf", ")", "Errorf", "(", "s", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "log", ".", "Errorf", "(", "s", ",", "args", "...", ")", "\n", "}" ]
// Errorf forwards to Logger.Errorf
[ "Errorf", "forwards", "to", "Logger", ".", "Errorf" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/logger/adapter.go#L46-L48
160,753
keybase/client
go/libkb/delegatekeyaggregator.go
AddPerUserKeyServerArg
func AddPerUserKeyServerArg(serverArg JSONPayload, generation keybase1.PerUserKeyGeneration, pukBoxes []keybase1.PerUserKeyBox, pukPrev *PerUserKeyPrev) { section := make(JSONPayload) section["boxes"] = pukBoxes section["generation"] = generation if pukPrev != nil { section["prev"] = *pukPrev } serverArg["per_user_key"] = section }
go
func AddPerUserKeyServerArg(serverArg JSONPayload, generation keybase1.PerUserKeyGeneration, pukBoxes []keybase1.PerUserKeyBox, pukPrev *PerUserKeyPrev) { section := make(JSONPayload) section["boxes"] = pukBoxes section["generation"] = generation if pukPrev != nil { section["prev"] = *pukPrev } serverArg["per_user_key"] = section }
[ "func", "AddPerUserKeyServerArg", "(", "serverArg", "JSONPayload", ",", "generation", "keybase1", ".", "PerUserKeyGeneration", ",", "pukBoxes", "[", "]", "keybase1", ".", "PerUserKeyBox", ",", "pukPrev", "*", "PerUserKeyPrev", ")", "{", "section", ":=", "make", "(...
// Make the "per_user_key" section of an API arg. // Requires one or more `pukBoxes` // `pukPrev` is optional. // Modifies `serverArg`.
[ "Make", "the", "per_user_key", "section", "of", "an", "API", "arg", ".", "Requires", "one", "or", "more", "pukBoxes", "pukPrev", "is", "optional", ".", "Modifies", "serverArg", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/delegatekeyaggregator.go#L88-L97
160,754
keybase/client
go/libkb/delegatekeyaggregator.go
AddUserEKReBoxServerArg
func AddUserEKReBoxServerArg(serverArg JSONPayload, arg *keybase1.UserEkReboxArg) { if arg == nil { return } serverArg["device_eks"] = map[string]string{string(arg.DeviceID): arg.DeviceEkStatementSig} serverArg["user_ek_rebox"] = arg.UserEkBoxMetadata }
go
func AddUserEKReBoxServerArg(serverArg JSONPayload, arg *keybase1.UserEkReboxArg) { if arg == nil { return } serverArg["device_eks"] = map[string]string{string(arg.DeviceID): arg.DeviceEkStatementSig} serverArg["user_ek_rebox"] = arg.UserEkBoxMetadata }
[ "func", "AddUserEKReBoxServerArg", "(", "serverArg", "JSONPayload", ",", "arg", "*", "keybase1", ".", "UserEkReboxArg", ")", "{", "if", "arg", "==", "nil", "{", "return", "\n", "}", "\n", "serverArg", "[", "\"", "\"", "]", "=", "map", "[", "string", "]",...
// Make the "user_ek_rebox" and "device_eks" section of an API arg. Modifies // `serverArg` unless arg is nil.
[ "Make", "the", "user_ek_rebox", "and", "device_eks", "section", "of", "an", "API", "arg", ".", "Modifies", "serverArg", "unless", "arg", "is", "nil", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/delegatekeyaggregator.go#L101-L107
160,755
keybase/client
go/service/scanproofs.go
ScanProofs
func (h *ScanProofsHandler) ScanProofs(ctx context.Context, arg keybase1.ScanProofsArg) error { uis := libkb.UIs{ LogUI: h.getLogUI(arg.SessionID), SessionID: arg.SessionID, } eng := engine.NewScanProofsEngine(arg.Infile, arg.Indices, arg.Sigid, arg.Ratelimit, arg.Cachefile, arg.Ignorefile, h.G()) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) return engine.RunEngine2(m, eng) }
go
func (h *ScanProofsHandler) ScanProofs(ctx context.Context, arg keybase1.ScanProofsArg) error { uis := libkb.UIs{ LogUI: h.getLogUI(arg.SessionID), SessionID: arg.SessionID, } eng := engine.NewScanProofsEngine(arg.Infile, arg.Indices, arg.Sigid, arg.Ratelimit, arg.Cachefile, arg.Ignorefile, h.G()) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) return engine.RunEngine2(m, eng) }
[ "func", "(", "h", "*", "ScanProofsHandler", ")", "ScanProofs", "(", "ctx", "context", ".", "Context", ",", "arg", "keybase1", ".", "ScanProofsArg", ")", "error", "{", "uis", ":=", "libkb", ".", "UIs", "{", "LogUI", ":", "h", ".", "getLogUI", "(", "arg"...
// ScanProofs creates a ScanProofsEngine and runs it.
[ "ScanProofs", "creates", "a", "ScanProofsEngine", "and", "runs", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/scanproofs.go#L27-L35
160,756
keybase/client
go/chat/s3/s3.go
New
func New(signer Signer, region Region, client ...*http.Client) *S3 { var httpclient *http.Client if len(client) > 0 { httpclient = client[0] } return &S3{ Signer: signer, Region: region, AttemptStrategy: DefaultAttemptStrategy, client: httpclient, } }
go
func New(signer Signer, region Region, client ...*http.Client) *S3 { var httpclient *http.Client if len(client) > 0 { httpclient = client[0] } return &S3{ Signer: signer, Region: region, AttemptStrategy: DefaultAttemptStrategy, client: httpclient, } }
[ "func", "New", "(", "signer", "Signer", ",", "region", "Region", ",", "client", "...", "*", "http", ".", "Client", ")", "*", "S3", "{", "var", "httpclient", "*", "http", ".", "Client", "\n\n", "if", "len", "(", "client", ")", ">", "0", "{", "httpcl...
// New creates a new S3. Optional client argument allows for custom http.clients to be used.
[ "New", "creates", "a", "new", "S3", ".", "Optional", "client", "argument", "allows", "for", "custom", "http", ".", "clients", "to", "be", "used", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L136-L150
160,757
keybase/client
go/chat/s3/s3.go
GetReader
func (b *Bucket) GetReader(ctx context.Context, path string) (rc io.ReadCloser, err error) { resp, err := b.GetResponse(ctx, path) if resp != nil { return resp.Body, err } return nil, err }
go
func (b *Bucket) GetReader(ctx context.Context, path string) (rc io.ReadCloser, err error) { resp, err := b.GetResponse(ctx, path) if resp != nil { return resp.Body, err } return nil, err }
[ "func", "(", "b", "*", "Bucket", ")", "GetReader", "(", "ctx", "context", ".", "Context", ",", "path", "string", ")", "(", "rc", "io", ".", "ReadCloser", ",", "err", "error", ")", "{", "resp", ",", "err", ":=", "b", ".", "GetResponse", "(", "ctx", ...
// GetReader retrieves an object from an S3 bucket, // returning the body of the HTTP response. // It is the caller's responsibility to call Close on rc when // finished reading.
[ "GetReader", "retrieves", "an", "object", "from", "an", "S3", "bucket", "returning", "the", "body", "of", "the", "HTTP", "response", ".", "It", "is", "the", "caller", "s", "responsibility", "to", "call", "Close", "on", "rc", "when", "finished", "reading", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L248-L254
160,758
keybase/client
go/chat/s3/s3.go
GetReaderWithRange
func (b *Bucket) GetReaderWithRange(ctx context.Context, path string, begin, end int64) (rc io.ReadCloser, err error) { header := make(http.Header) header.Add("Range", fmt.Sprintf("bytes=%d-%d", begin, end-1)) resp, err := b.GetResponseWithHeaders(ctx, path, header) if resp != nil { return resp.Body, err } return nil, err }
go
func (b *Bucket) GetReaderWithRange(ctx context.Context, path string, begin, end int64) (rc io.ReadCloser, err error) { header := make(http.Header) header.Add("Range", fmt.Sprintf("bytes=%d-%d", begin, end-1)) resp, err := b.GetResponseWithHeaders(ctx, path, header) if resp != nil { return resp.Body, err } return nil, err }
[ "func", "(", "b", "*", "Bucket", ")", "GetReaderWithRange", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "begin", ",", "end", "int64", ")", "(", "rc", "io", ".", "ReadCloser", ",", "err", "error", ")", "{", "header", ":=", "make...
// GetReaderWithRange retrieves an object from an S3 bucket using the specified range, // returning the body of the HTTP response. // It is the caller's responsibility to call Close on rc when // finished reading.
[ "GetReaderWithRange", "retrieves", "an", "object", "from", "an", "S3", "bucket", "using", "the", "specified", "range", "returning", "the", "body", "of", "the", "HTTP", "response", ".", "It", "is", "the", "caller", "s", "responsibility", "to", "call", "Close", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L260-L268
160,759
keybase/client
go/chat/s3/s3.go
GetResponse
func (b *Bucket) GetResponse(ctx context.Context, path string) (resp *http.Response, err error) { return b.GetResponseWithHeaders(ctx, path, make(http.Header)) }
go
func (b *Bucket) GetResponse(ctx context.Context, path string) (resp *http.Response, err error) { return b.GetResponseWithHeaders(ctx, path, make(http.Header)) }
[ "func", "(", "b", "*", "Bucket", ")", "GetResponse", "(", "ctx", "context", ".", "Context", ",", "path", "string", ")", "(", "resp", "*", "http", ".", "Response", ",", "err", "error", ")", "{", "return", "b", ".", "GetResponseWithHeaders", "(", "ctx", ...
// GetResponse retrieves an object from an S3 bucket, // returning the HTTP response. // It is the caller's responsibility to call Close on rc when // finished reading
[ "GetResponse", "retrieves", "an", "object", "from", "an", "S3", "bucket", "returning", "the", "HTTP", "response", ".", "It", "is", "the", "caller", "s", "responsibility", "to", "call", "Close", "on", "rc", "when", "finished", "reading" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L274-L276
160,760
keybase/client
go/chat/s3/s3.go
GetResponseWithHeaders
func (b *Bucket) GetResponseWithHeaders(ctx context.Context, path string, headers map[string][]string) (resp *http.Response, err error) { req := &request{ bucket: b.Name, path: path, headers: headers, } err = b.S3.prepare(req) if err != nil { return nil, err } for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); { resp, err := b.S3.run(ctx, req, nil) if shouldRetry(err) && attempt.HasNext() { continue } if err != nil { return nil, err } return resp, nil } panic("unreachable") }
go
func (b *Bucket) GetResponseWithHeaders(ctx context.Context, path string, headers map[string][]string) (resp *http.Response, err error) { req := &request{ bucket: b.Name, path: path, headers: headers, } err = b.S3.prepare(req) if err != nil { return nil, err } for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); { resp, err := b.S3.run(ctx, req, nil) if shouldRetry(err) && attempt.HasNext() { continue } if err != nil { return nil, err } return resp, nil } panic("unreachable") }
[ "func", "(", "b", "*", "Bucket", ")", "GetResponseWithHeaders", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "headers", "map", "[", "string", "]", "[", "]", "string", ")", "(", "resp", "*", "http", ".", "Response", ",", "err", "...
// GetReaderWithHeaders retrieves an object from an S3 bucket // Accepts custom headers to be sent as the second parameter // returning the body of the HTTP response. // It is the caller's responsibility to call Close on rc when // finished reading
[ "GetReaderWithHeaders", "retrieves", "an", "object", "from", "an", "S3", "bucket", "Accepts", "custom", "headers", "to", "be", "sent", "as", "the", "second", "parameter", "returning", "the", "body", "of", "the", "HTTP", "response", ".", "It", "is", "the", "c...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L283-L304
160,761
keybase/client
go/chat/s3/s3.go
Exists
func (b *Bucket) Exists(path string) (exists bool, err error) { req := &request{ method: "HEAD", bucket: b.Name, path: path, } err = b.S3.prepare(req) if err != nil { return } for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); { resp, err := b.S3.run(context.Background(), req, nil) if shouldRetry(err) && attempt.HasNext() { continue } if err != nil { // We can treat a 403 or 404 as non existence if e, ok := err.(*Error); ok && (e.StatusCode == 403 || e.StatusCode == 404) { return false, nil } return false, err } if resp.StatusCode/100 == 2 { exists = true } return exists, err } return false, fmt.Errorf("S3 Currently Unreachable") }
go
func (b *Bucket) Exists(path string) (exists bool, err error) { req := &request{ method: "HEAD", bucket: b.Name, path: path, } err = b.S3.prepare(req) if err != nil { return } for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); { resp, err := b.S3.run(context.Background(), req, nil) if shouldRetry(err) && attempt.HasNext() { continue } if err != nil { // We can treat a 403 or 404 as non existence if e, ok := err.(*Error); ok && (e.StatusCode == 403 || e.StatusCode == 404) { return false, nil } return false, err } if resp.StatusCode/100 == 2 { exists = true } return exists, err } return false, fmt.Errorf("S3 Currently Unreachable") }
[ "func", "(", "b", "*", "Bucket", ")", "Exists", "(", "path", "string", ")", "(", "exists", "bool", ",", "err", "error", ")", "{", "req", ":=", "&", "request", "{", "method", ":", "\"", "\"", ",", "bucket", ":", "b", ".", "Name", ",", "path", ":...
// Exists checks whether or not an object exists on an S3 bucket using a HEAD request.
[ "Exists", "checks", "whether", "or", "not", "an", "object", "exists", "on", "an", "S3", "bucket", "using", "a", "HEAD", "request", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L307-L338
160,762
keybase/client
go/chat/s3/s3.go
PutCopy
func (b *Bucket) PutCopy(path string, perm ACL, options CopyOptions, source string) (result *CopyObjectResult, err error) { headers := map[string][]string{ "x-amz-acl": {string(perm)}, "x-amz-copy-source": {source}, } options.addHeaders(headers) req := &request{ method: "PUT", bucket: b.Name, path: path, headers: headers, } result = &CopyObjectResult{} for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); { err = b.S3.query(context.Background(), req, result) if !shouldRetry(err) { break } } if err != nil { return nil, err } return result, nil }
go
func (b *Bucket) PutCopy(path string, perm ACL, options CopyOptions, source string) (result *CopyObjectResult, err error) { headers := map[string][]string{ "x-amz-acl": {string(perm)}, "x-amz-copy-source": {source}, } options.addHeaders(headers) req := &request{ method: "PUT", bucket: b.Name, path: path, headers: headers, } result = &CopyObjectResult{} for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); { err = b.S3.query(context.Background(), req, result) if !shouldRetry(err) { break } } if err != nil { return nil, err } return result, nil }
[ "func", "(", "b", "*", "Bucket", ")", "PutCopy", "(", "path", "string", ",", "perm", "ACL", ",", "options", "CopyOptions", ",", "source", "string", ")", "(", "result", "*", "CopyObjectResult", ",", "err", "error", ")", "{", "headers", ":=", "map", "[",...
// PutCopy puts a copy of an object given by the key path into bucket b using b.Path as the target key
[ "PutCopy", "puts", "a", "copy", "of", "an", "object", "given", "by", "the", "key", "path", "into", "bucket", "b", "using", "b", ".", "Path", "as", "the", "target", "key" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L376-L399
160,763
keybase/client
go/chat/s3/s3.go
PutReader
func (b *Bucket) PutReader(ctx context.Context, path string, r io.Reader, length int64, contType string, perm ACL, options Options) error { headers := map[string][]string{ "Content-Length": {strconv.FormatInt(length, 10)}, "Content-Type": {contType}, "x-amz-acl": {string(perm)}, } options.addHeaders(headers) req := &request{ method: "PUT", bucket: b.Name, path: path, headers: headers, payload: r, } return b.S3.query(ctx, req, nil) }
go
func (b *Bucket) PutReader(ctx context.Context, path string, r io.Reader, length int64, contType string, perm ACL, options Options) error { headers := map[string][]string{ "Content-Length": {strconv.FormatInt(length, 10)}, "Content-Type": {contType}, "x-amz-acl": {string(perm)}, } options.addHeaders(headers) req := &request{ method: "PUT", bucket: b.Name, path: path, headers: headers, payload: r, } return b.S3.query(ctx, req, nil) }
[ "func", "(", "b", "*", "Bucket", ")", "PutReader", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "r", "io", ".", "Reader", ",", "length", "int64", ",", "contType", "string", ",", "perm", "ACL", ",", "options", "Options", ")", "er...
// PutReader inserts an object into the S3 bucket by consuming data // from r until EOF.
[ "PutReader", "inserts", "an", "object", "into", "the", "S3", "bucket", "by", "consuming", "data", "from", "r", "until", "EOF", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L412-L427
160,764
keybase/client
go/chat/s3/s3.go
GetBucketContents
func (b *Bucket) GetBucketContents() (*map[string]Key, error) { bucketContents := map[string]Key{} prefix := "" pathSeparator := "" marker := "" for { contents, err := b.List(prefix, pathSeparator, marker, 1000) if err != nil { return &bucketContents, err } for _, key := range contents.Contents { bucketContents[key.Key] = key } if contents.IsTruncated { marker = contents.NextMarker } else { break } } return &bucketContents, nil }
go
func (b *Bucket) GetBucketContents() (*map[string]Key, error) { bucketContents := map[string]Key{} prefix := "" pathSeparator := "" marker := "" for { contents, err := b.List(prefix, pathSeparator, marker, 1000) if err != nil { return &bucketContents, err } for _, key := range contents.Contents { bucketContents[key.Key] = key } if contents.IsTruncated { marker = contents.NextMarker } else { break } } return &bucketContents, nil }
[ "func", "(", "b", "*", "Bucket", ")", "GetBucketContents", "(", ")", "(", "*", "map", "[", "string", "]", "Key", ",", "error", ")", "{", "bucketContents", ":=", "map", "[", "string", "]", "Key", "{", "}", "\n", "prefix", ":=", "\"", "\"", "\n", "...
// Returns a mapping of all key names in this bucket to Key objects
[ "Returns", "a", "mapping", "of", "all", "key", "names", "in", "this", "bucket", "to", "Key", "objects" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L766-L787
160,765
keybase/client
go/chat/s3/s3.go
prepare
func (s3 *S3) prepare(req *request) error { var signpath = req.path if !req.prepared { req.prepared = true if req.method == "" { req.method = "GET" } // Copy so they can be mutated without affecting on retries. params := make(url.Values) headers := make(http.Header) for k, v := range req.params { params[k] = v } for k, v := range req.headers { headers[k] = v } req.params = params req.headers = headers if !strings.HasPrefix(req.path, "/") { req.path = "/" + req.path } signpath = req.path if req.bucket != "" { req.baseurl = s3.Region.S3BucketEndpoint if req.baseurl == "" { // Use the path method to address the bucket. req.baseurl = s3.Region.S3Endpoint req.path = "/" + req.bucket + req.path } else { // Just in case, prevent injection. if strings.IndexAny(req.bucket, "/:@") >= 0 { return fmt.Errorf("bad S3 bucket: %q", req.bucket) } req.baseurl = strings.Replace(req.baseurl, "${bucket}", req.bucket, -1) } signpath = "/" + req.bucket + signpath } } // Always sign again as it's not clear how far the // server has handled a previous attempt. u, err := url.Parse(req.baseurl) if err != nil { return fmt.Errorf("bad S3 endpoint URL %q: %v", req.baseurl, err) } reqSignpathSpaceFix := (&url.URL{Path: signpath}).String() req.headers["Host"] = []string{u.Host} req.headers["Date"] = []string{time.Now().In(time.UTC).Format(time.RFC1123)} return s3.sign(req.method, reqSignpathSpaceFix, req.params, req.headers) }
go
func (s3 *S3) prepare(req *request) error { var signpath = req.path if !req.prepared { req.prepared = true if req.method == "" { req.method = "GET" } // Copy so they can be mutated without affecting on retries. params := make(url.Values) headers := make(http.Header) for k, v := range req.params { params[k] = v } for k, v := range req.headers { headers[k] = v } req.params = params req.headers = headers if !strings.HasPrefix(req.path, "/") { req.path = "/" + req.path } signpath = req.path if req.bucket != "" { req.baseurl = s3.Region.S3BucketEndpoint if req.baseurl == "" { // Use the path method to address the bucket. req.baseurl = s3.Region.S3Endpoint req.path = "/" + req.bucket + req.path } else { // Just in case, prevent injection. if strings.IndexAny(req.bucket, "/:@") >= 0 { return fmt.Errorf("bad S3 bucket: %q", req.bucket) } req.baseurl = strings.Replace(req.baseurl, "${bucket}", req.bucket, -1) } signpath = "/" + req.bucket + signpath } } // Always sign again as it's not clear how far the // server has handled a previous attempt. u, err := url.Parse(req.baseurl) if err != nil { return fmt.Errorf("bad S3 endpoint URL %q: %v", req.baseurl, err) } reqSignpathSpaceFix := (&url.URL{Path: signpath}).String() req.headers["Host"] = []string{u.Host} req.headers["Date"] = []string{time.Now().In(time.UTC).Format(time.RFC1123)} return s3.sign(req.method, reqSignpathSpaceFix, req.params, req.headers) }
[ "func", "(", "s3", "*", "S3", ")", "prepare", "(", "req", "*", "request", ")", "error", "{", "var", "signpath", "=", "req", ".", "path", "\n\n", "if", "!", "req", ".", "prepared", "{", "req", ".", "prepared", "=", "true", "\n", "if", "req", ".", ...
// prepare sets up req to be delivered to S3.
[ "prepare", "sets", "up", "req", "to", "be", "delivered", "to", "S3", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/s3/s3.go#L866-L916
160,766
keybase/client
go/kbfs/dokan/cgo.go
getRequestorToken
func (fi *FileInfo) getRequestorToken() (syscall.Token, error) { hdl := syscall.Handle(C.kbfsLibdokan_OpenRequestorToken(fi.ptr)) var err error if hdl == syscall.InvalidHandle { // Tokens are value types, so returning nil is impossible, // returning an InvalidHandle is the best way. err = errors.New("Invalid handle from DokanOpenRequestorHandle") } return syscall.Token(hdl), err }
go
func (fi *FileInfo) getRequestorToken() (syscall.Token, error) { hdl := syscall.Handle(C.kbfsLibdokan_OpenRequestorToken(fi.ptr)) var err error if hdl == syscall.InvalidHandle { // Tokens are value types, so returning nil is impossible, // returning an InvalidHandle is the best way. err = errors.New("Invalid handle from DokanOpenRequestorHandle") } return syscall.Token(hdl), err }
[ "func", "(", "fi", "*", "FileInfo", ")", "getRequestorToken", "(", ")", "(", "syscall", ".", "Token", ",", "error", ")", "{", "hdl", ":=", "syscall", ".", "Handle", "(", "C", ".", "kbfsLibdokan_OpenRequestorToken", "(", "fi", ".", "ptr", ")", ")", "\n"...
// getRequestorToken returns the syscall.Token associated with // the requestor of this file system operation. Remember to // call Close on the Token.
[ "getRequestorToken", "returns", "the", "syscall", ".", "Token", "associated", "with", "the", "requestor", "of", "this", "file", "system", "operation", ".", "Remember", "to", "call", "Close", "on", "the", "Token", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/cgo.go#L695-L704
160,767
keybase/client
go/kbfs/dokan/cgo.go
isRequestorUserSidEqualTo
func (fi *FileInfo) isRequestorUserSidEqualTo(sid *winacl.SID) bool { tok, err := fi.getRequestorToken() if err != nil { debug("IsRequestorUserSidEqualTo:", err) return false } defer tok.Close() tokUser, err := tok.GetTokenUser() if err != nil { debug("IsRequestorUserSidEqualTo: GetTokenUser:", err) return false } res, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(tokUser.User.Sid)), 0) if isDebug { u1, _ := (*syscall.SID)(sid).String() u2, _ := tokUser.User.Sid.String() debugf("IsRequestorUserSidEqualTo: EqualSID(%q,%q) => %v (expecting non-zero)\n", u1, u2, res) } runtime.KeepAlive(sid) runtime.KeepAlive(tokUser.User.Sid) return res != 0 }
go
func (fi *FileInfo) isRequestorUserSidEqualTo(sid *winacl.SID) bool { tok, err := fi.getRequestorToken() if err != nil { debug("IsRequestorUserSidEqualTo:", err) return false } defer tok.Close() tokUser, err := tok.GetTokenUser() if err != nil { debug("IsRequestorUserSidEqualTo: GetTokenUser:", err) return false } res, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(tokUser.User.Sid)), 0) if isDebug { u1, _ := (*syscall.SID)(sid).String() u2, _ := tokUser.User.Sid.String() debugf("IsRequestorUserSidEqualTo: EqualSID(%q,%q) => %v (expecting non-zero)\n", u1, u2, res) } runtime.KeepAlive(sid) runtime.KeepAlive(tokUser.User.Sid) return res != 0 }
[ "func", "(", "fi", "*", "FileInfo", ")", "isRequestorUserSidEqualTo", "(", "sid", "*", "winacl", ".", "SID", ")", "bool", "{", "tok", ",", "err", ":=", "fi", ".", "getRequestorToken", "(", ")", "\n", "if", "err", "!=", "nil", "{", "debug", "(", "\"",...
// isRequestorUserSidEqualTo returns true if the sid passed as // the argument is equal to the sid of the user associated with // the filesystem request.
[ "isRequestorUserSidEqualTo", "returns", "true", "if", "the", "sid", "passed", "as", "the", "argument", "is", "equal", "to", "the", "sid", "of", "the", "user", "associated", "with", "the", "filesystem", "request", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/cgo.go#L709-L733
160,768
keybase/client
go/kbfs/dokan/cgo.go
unmount
func unmount(path string) error { debug("Unmount: Calling Dokan.Unmount") res := C.kbfsLibdokan_RemoveMountPoint((*C.WCHAR)(stringToUtf16Ptr(path))) if res == C.FALSE { debug("Unmount: Failed!") return errors.New("kbfsLibdokan_RemoveMountPoint failed") } debug("Unmount: Success!") return nil }
go
func unmount(path string) error { debug("Unmount: Calling Dokan.Unmount") res := C.kbfsLibdokan_RemoveMountPoint((*C.WCHAR)(stringToUtf16Ptr(path))) if res == C.FALSE { debug("Unmount: Failed!") return errors.New("kbfsLibdokan_RemoveMountPoint failed") } debug("Unmount: Success!") return nil }
[ "func", "unmount", "(", "path", "string", ")", "error", "{", "debug", "(", "\"", "\"", ")", "\n", "res", ":=", "C", ".", "kbfsLibdokan_RemoveMountPoint", "(", "(", "*", "C", ".", "WCHAR", ")", "(", "stringToUtf16Ptr", "(", "path", ")", ")", ")", "\n"...
// unmount a drive mounted by dokan.
[ "unmount", "a", "drive", "mounted", "by", "dokan", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/cgo.go#L741-L750
160,769
keybase/client
go/kbfs/dokan/cgo.go
stringToUtf16Buffer
func stringToUtf16Buffer(s string, ptr C.LPWSTR, blenUcs2 C.DWORD) bool { return stringToUtf16BufferPtr(s, unsafe.Pointer(ptr), blenUcs2) }
go
func stringToUtf16Buffer(s string, ptr C.LPWSTR, blenUcs2 C.DWORD) bool { return stringToUtf16BufferPtr(s, unsafe.Pointer(ptr), blenUcs2) }
[ "func", "stringToUtf16Buffer", "(", "s", "string", ",", "ptr", "C", ".", "LPWSTR", ",", "blenUcs2", "C", ".", "DWORD", ")", "bool", "{", "return", "stringToUtf16BufferPtr", "(", "s", ",", "unsafe", ".", "Pointer", "(", "ptr", ")", ",", "blenUcs2", ")", ...
// stringToUtf16Buffer pokes a string into a Windows wide string buffer. // On overflow does not poke anything and returns false.
[ "stringToUtf16Buffer", "pokes", "a", "string", "into", "a", "Windows", "wide", "string", "buffer", ".", "On", "overflow", "does", "not", "poke", "anything", "and", "returns", "false", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/cgo.go#L767-L769
160,770
keybase/client
go/kbfs/dokan/cgo.go
stringToUtf16Ptr
func stringToUtf16Ptr(s string) unsafe.Pointer { tmp := utf16.Encode([]rune(s + "\000")) return unsafe.Pointer(&tmp[0]) }
go
func stringToUtf16Ptr(s string) unsafe.Pointer { tmp := utf16.Encode([]rune(s + "\000")) return unsafe.Pointer(&tmp[0]) }
[ "func", "stringToUtf16Ptr", "(", "s", "string", ")", "unsafe", ".", "Pointer", "{", "tmp", ":=", "utf16", ".", "Encode", "(", "[", "]", "rune", "(", "s", "+", "\"", "\\000", "\"", ")", ")", "\n", "return", "unsafe", ".", "Pointer", "(", "&", "tmp",...
// stringToUtf16Ptr return a pointer to the string as utf16 with zero // termination.
[ "stringToUtf16Ptr", "return", "a", "pointer", "to", "the", "string", "as", "utf16", "with", "zero", "termination", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/cgo.go#L787-L790
160,771
keybase/client
go/libkb/runmode.go
StringToRunMode
func StringToRunMode(s string) (RunMode, error) { switch s { case string(DevelRunMode): return DevelRunMode, nil case string(ProductionRunMode): return ProductionRunMode, nil case string(StagingRunMode): return StagingRunMode, nil case "": return NoRunMode, nil default: return NoRunMode, fmt.Errorf("unknown run mode: '%s'", s) } }
go
func StringToRunMode(s string) (RunMode, error) { switch s { case string(DevelRunMode): return DevelRunMode, nil case string(ProductionRunMode): return ProductionRunMode, nil case string(StagingRunMode): return StagingRunMode, nil case "": return NoRunMode, nil default: return NoRunMode, fmt.Errorf("unknown run mode: '%s'", s) } }
[ "func", "StringToRunMode", "(", "s", "string", ")", "(", "RunMode", ",", "error", ")", "{", "switch", "s", "{", "case", "string", "(", "DevelRunMode", ")", ":", "return", "DevelRunMode", ",", "nil", "\n", "case", "string", "(", "ProductionRunMode", ")", ...
// StringToRunMode turns a string into a run-mode
[ "StringToRunMode", "turns", "a", "string", "into", "a", "run", "-", "mode" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/runmode.go#L11-L24
160,772
keybase/client
go/client/cmd_list_followers.go
ParseArgv
func (c *CmdListTrackers) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) == 1 { c.assertion = ctx.Args()[0] } c.verbose = ctx.Bool("verbose") return nil }
go
func (c *CmdListTrackers) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) == 1 { c.assertion = ctx.Args()[0] } c.verbose = ctx.Bool("verbose") return nil }
[ "func", "(", "c", "*", "CmdListTrackers", ")", "ParseArgv", "(", "ctx", "*", "cli", ".", "Context", ")", "error", "{", "if", "len", "(", "ctx", ".", "Args", "(", ")", ")", "==", "1", "{", "c", ".", "assertion", "=", "ctx", ".", "Args", "(", ")"...
// ParseArgv parses the command args.
[ "ParseArgv", "parses", "the", "command", "args", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_list_followers.go#L81-L88
160,773
keybase/client
go/client/cmd_list_followers.go
GetUsage
func (c *CmdListTrackers) GetUsage() libkb.Usage { return libkb.Usage{ Config: true, API: true, } }
go
func (c *CmdListTrackers) GetUsage() libkb.Usage { return libkb.Usage{ Config: true, API: true, } }
[ "func", "(", "c", "*", "CmdListTrackers", ")", "GetUsage", "(", ")", "libkb", ".", "Usage", "{", "return", "libkb", ".", "Usage", "{", "Config", ":", "true", ",", "API", ":", "true", ",", "}", "\n", "}" ]
// GetUsage says what this command needs to operate.
[ "GetUsage", "says", "what", "this", "command", "needs", "to", "operate", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_list_followers.go#L91-L96
160,774
keybase/client
go/libkb/keyring.go
LockedLocalSecretKey
func LockedLocalSecretKey(m MetaContext, ska SecretKeyArg) (*SKB, error) { var ret *SKB me := ska.Me keyring, err := m.Keyring() if err != nil { return nil, err } if keyring == nil { m.Debug("| No secret keyring found: %s", err) return nil, NoKeyringsError{} } ckf := me.GetComputedKeyFamily() if ckf == nil { m.Warning("No ComputedKeyFamily found for %s", me.name) return nil, KeyFamilyError{Msg: "not found for " + me.name} } if (ska.KeyType == DeviceSigningKeyType) || (ska.KeyType == DeviceEncryptionKeyType) { key, err := getDeviceKey(m, ckf, ska.KeyType, me.GetNormalizedName()) if err != nil { m.Debug("| No key for current device: %s", err) return nil, err } if key == nil { m.Debug("| Key for current device is nil") return nil, NoKeyError{Msg: "Key for current device is nil"} } kid := key.GetKID() m.Debug("| Found KID for current device: %s", kid) ret = keyring.LookupByKid(kid) if ret != nil { m.Debug("| Using device key: %s", kid) } } else { m.Debug("| Looking up secret key in local keychain") blocks := keyring.SearchWithComputedKeyFamily(ckf, ska) if len(blocks) > 0 { ret = blocks[0] } } if ret != nil { ret.SetUID(me.GetUID()) } return ret, nil }
go
func LockedLocalSecretKey(m MetaContext, ska SecretKeyArg) (*SKB, error) { var ret *SKB me := ska.Me keyring, err := m.Keyring() if err != nil { return nil, err } if keyring == nil { m.Debug("| No secret keyring found: %s", err) return nil, NoKeyringsError{} } ckf := me.GetComputedKeyFamily() if ckf == nil { m.Warning("No ComputedKeyFamily found for %s", me.name) return nil, KeyFamilyError{Msg: "not found for " + me.name} } if (ska.KeyType == DeviceSigningKeyType) || (ska.KeyType == DeviceEncryptionKeyType) { key, err := getDeviceKey(m, ckf, ska.KeyType, me.GetNormalizedName()) if err != nil { m.Debug("| No key for current device: %s", err) return nil, err } if key == nil { m.Debug("| Key for current device is nil") return nil, NoKeyError{Msg: "Key for current device is nil"} } kid := key.GetKID() m.Debug("| Found KID for current device: %s", kid) ret = keyring.LookupByKid(kid) if ret != nil { m.Debug("| Using device key: %s", kid) } } else { m.Debug("| Looking up secret key in local keychain") blocks := keyring.SearchWithComputedKeyFamily(ckf, ska) if len(blocks) > 0 { ret = blocks[0] } } if ret != nil { ret.SetUID(me.GetUID()) } return ret, nil }
[ "func", "LockedLocalSecretKey", "(", "m", "MetaContext", ",", "ska", "SecretKeyArg", ")", "(", "*", "SKB", ",", "error", ")", "{", "var", "ret", "*", "SKB", "\n", "me", ":=", "ska", ".", "Me", "\n\n", "keyring", ",", "err", ":=", "m", ".", "Keyring",...
// LockedLocalSecretKey looks in the local keyring to find a key // for the given user. Returns non-nil if one was found, and nil // otherwise.
[ "LockedLocalSecretKey", "looks", "in", "the", "local", "keyring", "to", "find", "a", "key", "for", "the", "given", "user", ".", "Returns", "non", "-", "nil", "if", "one", "was", "found", "and", "nil", "otherwise", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyring.go#L214-L264
160,775
keybase/client
go/libkb/keyring.go
GetSecretKeyLocked
func (k *Keyrings) GetSecretKeyLocked(m MetaContext, ska SecretKeyArg) (ret *SKB, err error) { defer m.Trace("Keyrings#GetSecretKeyLocked()", func() error { return err })() m.Debug("| LoadMe w/ Secrets on") if ska.Me == nil { if ska.Me, err = LoadMe(NewLoadUserArg(k.G())); err != nil { return nil, err } } ret, err = LockedLocalSecretKey(m, ska) if err != nil { return nil, err } if ret != nil { m.Debug("| Getting local secret key") return ret, nil } var pub GenericKey if ska.KeyType != PGPKeyType { m.Debug("| Skipped Synced PGP key (via options)") err = NoSecretKeyError{} return nil, err } if ret, err = ska.Me.SyncedSecretKey(m); err != nil { m.Warning("Error fetching synced PGP secret key: %s", err) return nil, err } if ret == nil { err = NoSecretKeyError{} return nil, err } if pub, err = ret.GetPubKey(); err != nil { return nil, err } if !KeyMatchesQuery(pub, ska.KeyQuery, ska.ExactMatch) { m.Debug("| Can't use Synced PGP key; doesn't match query %s", ska.KeyQuery) err = NoSecretKeyError{} return nil, err } return ret, nil }
go
func (k *Keyrings) GetSecretKeyLocked(m MetaContext, ska SecretKeyArg) (ret *SKB, err error) { defer m.Trace("Keyrings#GetSecretKeyLocked()", func() error { return err })() m.Debug("| LoadMe w/ Secrets on") if ska.Me == nil { if ska.Me, err = LoadMe(NewLoadUserArg(k.G())); err != nil { return nil, err } } ret, err = LockedLocalSecretKey(m, ska) if err != nil { return nil, err } if ret != nil { m.Debug("| Getting local secret key") return ret, nil } var pub GenericKey if ska.KeyType != PGPKeyType { m.Debug("| Skipped Synced PGP key (via options)") err = NoSecretKeyError{} return nil, err } if ret, err = ska.Me.SyncedSecretKey(m); err != nil { m.Warning("Error fetching synced PGP secret key: %s", err) return nil, err } if ret == nil { err = NoSecretKeyError{} return nil, err } if pub, err = ret.GetPubKey(); err != nil { return nil, err } if !KeyMatchesQuery(pub, ska.KeyQuery, ska.ExactMatch) { m.Debug("| Can't use Synced PGP key; doesn't match query %s", ska.KeyQuery) err = NoSecretKeyError{} return nil, err } return ret, nil }
[ "func", "(", "k", "*", "Keyrings", ")", "GetSecretKeyLocked", "(", "m", "MetaContext", ",", "ska", "SecretKeyArg", ")", "(", "ret", "*", "SKB", ",", "err", "error", ")", "{", "defer", "m", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "erro...
// GetSecretKeyLocked gets a secret key for the current user by first // looking for keys synced from the server, and if that fails, tries // those in the local Keyring that are also active for the user. // In any case, the key will be locked.
[ "GetSecretKeyLocked", "gets", "a", "secret", "key", "for", "the", "current", "user", "by", "first", "looking", "for", "keys", "synced", "from", "the", "server", "and", "if", "that", "fails", "tries", "those", "in", "the", "local", "Keyring", "that", "are", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyring.go#L270-L318
160,776
keybase/client
go/kbfs/libkbfs/shared_keybase_transport.go
NewSharedKeybaseConnection
func NewSharedKeybaseConnection(kbCtx Context, config Config, handler rpc.ConnectionHandler) *rpc.Connection { transport := &SharedKeybaseTransport{kbCtx: kbCtx} constBackoff := backoff.NewConstantBackOff(RPCReconnectInterval) opts := rpc.ConnectionOpts{ WrapErrorFunc: libkb.WrapError, TagsFunc: libkb.LogTagsFromContext, ReconnectBackoff: func() backoff.BackOff { return constBackoff }, } return rpc.NewConnectionWithTransport( handler, transport, libkb.ErrorUnwrapper{}, logger.LogOutputWithDepthAdder{Logger: config.MakeLogger("")}, opts) }
go
func NewSharedKeybaseConnection(kbCtx Context, config Config, handler rpc.ConnectionHandler) *rpc.Connection { transport := &SharedKeybaseTransport{kbCtx: kbCtx} constBackoff := backoff.NewConstantBackOff(RPCReconnectInterval) opts := rpc.ConnectionOpts{ WrapErrorFunc: libkb.WrapError, TagsFunc: libkb.LogTagsFromContext, ReconnectBackoff: func() backoff.BackOff { return constBackoff }, } return rpc.NewConnectionWithTransport( handler, transport, libkb.ErrorUnwrapper{}, logger.LogOutputWithDepthAdder{Logger: config.MakeLogger("")}, opts) }
[ "func", "NewSharedKeybaseConnection", "(", "kbCtx", "Context", ",", "config", "Config", ",", "handler", "rpc", ".", "ConnectionHandler", ")", "*", "rpc", ".", "Connection", "{", "transport", ":=", "&", "SharedKeybaseTransport", "{", "kbCtx", ":", "kbCtx", "}", ...
// NewSharedKeybaseConnection returns a connection that tries to // connect to the local keybase daemon.
[ "NewSharedKeybaseConnection", "returns", "a", "connection", "that", "tries", "to", "connect", "to", "the", "local", "keybase", "daemon", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/shared_keybase_transport.go#L19-L31
160,777
keybase/client
go/kbfs/libkbfs/shared_keybase_transport.go
Dial
func (kt *SharedKeybaseTransport) Dial(ctx context.Context) ( rpc.Transporter, error) { _, transport, _, err := kt.kbCtx.GetSocket(true) if err != nil { return nil, err } kt.mutex.Lock() defer kt.mutex.Unlock() kt.stagedTransport = transport return transport, nil }
go
func (kt *SharedKeybaseTransport) Dial(ctx context.Context) ( rpc.Transporter, error) { _, transport, _, err := kt.kbCtx.GetSocket(true) if err != nil { return nil, err } kt.mutex.Lock() defer kt.mutex.Unlock() kt.stagedTransport = transport return transport, nil }
[ "func", "(", "kt", "*", "SharedKeybaseTransport", ")", "Dial", "(", "ctx", "context", ".", "Context", ")", "(", "rpc", ".", "Transporter", ",", "error", ")", "{", "_", ",", "transport", ",", "_", ",", "err", ":=", "kt", ".", "kbCtx", ".", "GetSocket"...
// Dial is an implementation of the ConnectionTransport interface.
[ "Dial", "is", "an", "implementation", "of", "the", "ConnectionTransport", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/shared_keybase_transport.go#L49-L60
160,778
keybase/client
go/kbfs/libkbfs/shared_keybase_transport.go
IsConnected
func (kt *SharedKeybaseTransport) IsConnected() bool { kt.mutex.Lock() defer kt.mutex.Unlock() return kt.transport != nil && kt.transport.IsConnected() }
go
func (kt *SharedKeybaseTransport) IsConnected() bool { kt.mutex.Lock() defer kt.mutex.Unlock() return kt.transport != nil && kt.transport.IsConnected() }
[ "func", "(", "kt", "*", "SharedKeybaseTransport", ")", "IsConnected", "(", ")", "bool", "{", "kt", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "kt", ".", "mutex", ".", "Unlock", "(", ")", "\n", "return", "kt", ".", "transport", "!=", "nil", ...
// IsConnected is an implementation of the ConnectionTransport interface.
[ "IsConnected", "is", "an", "implementation", "of", "the", "ConnectionTransport", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/shared_keybase_transport.go#L63-L67
160,779
keybase/client
go/kbfs/libkbfs/shared_keybase_transport.go
Finalize
func (kt *SharedKeybaseTransport) Finalize() { kt.mutex.Lock() defer kt.mutex.Unlock() kt.transport = kt.stagedTransport kt.stagedTransport = nil }
go
func (kt *SharedKeybaseTransport) Finalize() { kt.mutex.Lock() defer kt.mutex.Unlock() kt.transport = kt.stagedTransport kt.stagedTransport = nil }
[ "func", "(", "kt", "*", "SharedKeybaseTransport", ")", "Finalize", "(", ")", "{", "kt", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "kt", ".", "mutex", ".", "Unlock", "(", ")", "\n", "kt", ".", "transport", "=", "kt", ".", "stagedTransport", ...
// Finalize is an implementation of the ConnectionTransport interface.
[ "Finalize", "is", "an", "implementation", "of", "the", "ConnectionTransport", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/shared_keybase_transport.go#L70-L75
160,780
keybase/client
go/kbfs/libkbfs/md_ops.go
NewMDOpsStandard
func NewMDOpsStandard(config Config) *MDOpsStandard { log := config.MakeLogger("") return &MDOpsStandard{ config: config, log: log, vlog: config.MakeVLogger(log), leafChainsValidated: make( map[tlf.ID]map[kbfsmd.Revision]kbfsmd.Revision), } }
go
func NewMDOpsStandard(config Config) *MDOpsStandard { log := config.MakeLogger("") return &MDOpsStandard{ config: config, log: log, vlog: config.MakeVLogger(log), leafChainsValidated: make( map[tlf.ID]map[kbfsmd.Revision]kbfsmd.Revision), } }
[ "func", "NewMDOpsStandard", "(", "config", "Config", ")", "*", "MDOpsStandard", "{", "log", ":=", "config", ".", "MakeLogger", "(", "\"", "\"", ")", "\n", "return", "&", "MDOpsStandard", "{", "config", ":", "config", ",", "log", ":", "log", ",", "vlog", ...
// NewMDOpsStandard returns a new MDOpsStandard
[ "NewMDOpsStandard", "returns", "a", "new", "MDOpsStandard" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L74-L83
160,781
keybase/client
go/kbfs/libkbfs/md_ops.go
convertVerifyingKeyError
func (md *MDOpsStandard) convertVerifyingKeyError(ctx context.Context, rmds *RootMetadataSigned, handle *tlfhandle.Handle, err error) error { if _, ok := err.(VerifyingKeyNotFoundError); !ok { return err } tlf := handle.GetCanonicalPath() writer, nameErr := md.config.KBPKI().GetNormalizedUsername( ctx, rmds.MD.LastModifyingWriter().AsUserOrTeam(), md.config.OfflineAvailabilityForPath(tlf)) if nameErr != nil { writer = kbname.NormalizedUsername("uid: " + rmds.MD.LastModifyingWriter().String()) } md.log.CDebugf(ctx, "Unverifiable update for TLF %s: %+v", rmds.MD.TlfID(), err) return UnverifiableTlfUpdateError{tlf, writer, err} }
go
func (md *MDOpsStandard) convertVerifyingKeyError(ctx context.Context, rmds *RootMetadataSigned, handle *tlfhandle.Handle, err error) error { if _, ok := err.(VerifyingKeyNotFoundError); !ok { return err } tlf := handle.GetCanonicalPath() writer, nameErr := md.config.KBPKI().GetNormalizedUsername( ctx, rmds.MD.LastModifyingWriter().AsUserOrTeam(), md.config.OfflineAvailabilityForPath(tlf)) if nameErr != nil { writer = kbname.NormalizedUsername("uid: " + rmds.MD.LastModifyingWriter().String()) } md.log.CDebugf(ctx, "Unverifiable update for TLF %s: %+v", rmds.MD.TlfID(), err) return UnverifiableTlfUpdateError{tlf, writer, err} }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "convertVerifyingKeyError", "(", "ctx", "context", ".", "Context", ",", "rmds", "*", "RootMetadataSigned", ",", "handle", "*", "tlfhandle", ".", "Handle", ",", "err", "error", ")", "error", "{", "if", "_", ",",...
// convertVerifyingKeyError gives a better error when the TLF was // signed by a key that is no longer associated with the last writer.
[ "convertVerifyingKeyError", "gives", "a", "better", "error", "when", "the", "TLF", "was", "signed", "by", "a", "key", "that", "is", "no", "longer", "associated", "with", "the", "last", "writer", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L87-L104
160,782
keybase/client
go/kbfs/libkbfs/md_ops.go
startOfValidatedChainForLeaf
func (md *MDOpsStandard) startOfValidatedChainForLeaf( tlfID tlf.ID, leafRev kbfsmd.Revision) kbfsmd.Revision { md.lock.Lock() defer md.lock.Unlock() revs, ok := md.leafChainsValidated[tlfID] if !ok { return leafRev } min, ok := revs[leafRev] if !ok { return leafRev } return min }
go
func (md *MDOpsStandard) startOfValidatedChainForLeaf( tlfID tlf.ID, leafRev kbfsmd.Revision) kbfsmd.Revision { md.lock.Lock() defer md.lock.Unlock() revs, ok := md.leafChainsValidated[tlfID] if !ok { return leafRev } min, ok := revs[leafRev] if !ok { return leafRev } return min }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "startOfValidatedChainForLeaf", "(", "tlfID", "tlf", ".", "ID", ",", "leafRev", "kbfsmd", ".", "Revision", ")", "kbfsmd", ".", "Revision", "{", "md", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "md", ...
// startOfValidatedChainForLeaf returns the earliest revision in the // chain leading up to `leafRev` that's been validated so far. If no // validations have occurred yet, it returns `leafRev`.
[ "startOfValidatedChainForLeaf", "returns", "the", "earliest", "revision", "in", "the", "chain", "leading", "up", "to", "leafRev", "that", "s", "been", "validated", "so", "far", ".", "If", "no", "validations", "have", "occurred", "yet", "it", "returns", "leafRev"...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L334-L347
160,783
keybase/client
go/kbfs/libkbfs/md_ops.go
GetIDForHandle
func (md *MDOpsStandard) GetIDForHandle( ctx context.Context, handle *tlfhandle.Handle) (id tlf.ID, err error) { mdcache := md.config.MDCache() id, err = mdcache.GetIDForHandle(handle) switch errors.Cause(err).(type) { case NoSuchTlfIDError: // Do the server-based lookup below. case nil: return id, nil default: return tlf.NullID, err } id, _, err = md.getForHandle(ctx, handle, kbfsmd.Merged, nil) switch errors.Cause(err).(type) { case kbfsmd.ServerErrorClassicTLFDoesNotExist: // The server thinks we should create an implicit team for this TLF. return tlf.NullID, nil case nil: default: return tlf.NullID, err } err = mdcache.PutIDForHandle(handle, id) if err != nil { return tlf.NullID, err } return id, nil }
go
func (md *MDOpsStandard) GetIDForHandle( ctx context.Context, handle *tlfhandle.Handle) (id tlf.ID, err error) { mdcache := md.config.MDCache() id, err = mdcache.GetIDForHandle(handle) switch errors.Cause(err).(type) { case NoSuchTlfIDError: // Do the server-based lookup below. case nil: return id, nil default: return tlf.NullID, err } id, _, err = md.getForHandle(ctx, handle, kbfsmd.Merged, nil) switch errors.Cause(err).(type) { case kbfsmd.ServerErrorClassicTLFDoesNotExist: // The server thinks we should create an implicit team for this TLF. return tlf.NullID, nil case nil: default: return tlf.NullID, err } err = mdcache.PutIDForHandle(handle, id) if err != nil { return tlf.NullID, err } return id, nil }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "GetIDForHandle", "(", "ctx", "context", ".", "Context", ",", "handle", "*", "tlfhandle", ".", "Handle", ")", "(", "id", "tlf", ".", "ID", ",", "err", "error", ")", "{", "mdcache", ":=", "md", ".", "confi...
// GetIDForHandle implements the MDOps interface for MDOpsStandard.
[ "GetIDForHandle", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L988-L1014
160,784
keybase/client
go/kbfs/libkbfs/md_ops.go
GetForTLF
func (md *MDOpsStandard) GetForTLF( ctx context.Context, id tlf.ID, lockBeforeGet *keybase1.LockID) ( ImmutableRootMetadata, error) { return md.getForTLF(ctx, id, kbfsmd.NullBranchID, kbfsmd.Merged, lockBeforeGet) }
go
func (md *MDOpsStandard) GetForTLF( ctx context.Context, id tlf.ID, lockBeforeGet *keybase1.LockID) ( ImmutableRootMetadata, error) { return md.getForTLF(ctx, id, kbfsmd.NullBranchID, kbfsmd.Merged, lockBeforeGet) }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "GetForTLF", "(", "ctx", "context", ".", "Context", ",", "id", "tlf", ".", "ID", ",", "lockBeforeGet", "*", "keybase1", ".", "LockID", ")", "(", "ImmutableRootMetadata", ",", "error", ")", "{", "return", "md"...
// GetForTLF implements the MDOps interface for MDOpsStandard.
[ "GetForTLF", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1083-L1087
160,785
keybase/client
go/kbfs/libkbfs/md_ops.go
GetForTLFByTime
func (md *MDOpsStandard) GetForTLFByTime( ctx context.Context, id tlf.ID, serverTime time.Time) ( irmd ImmutableRootMetadata, err error) { md.log.CDebugf(ctx, "GetForTLFByTime %s %s", id, serverTime) defer func() { if err == nil { md.log.CDebugf(ctx, "GetForTLFByTime %s %s done: %d", id, serverTime, irmd.Revision()) } else { md.log.CDebugf(ctx, "GetForTLFByTime %s %s done: %+v", id, serverTime, err) } }() mdserv, err := md.mdserver(ctx) if err != nil { return ImmutableRootMetadata{}, err } rmds, err := mdserv.GetForTLFByTime(ctx, id, serverTime) if err != nil { return ImmutableRootMetadata{}, err } return md.processSignedMD(ctx, id, kbfsmd.NullBranchID, rmds) }
go
func (md *MDOpsStandard) GetForTLFByTime( ctx context.Context, id tlf.ID, serverTime time.Time) ( irmd ImmutableRootMetadata, err error) { md.log.CDebugf(ctx, "GetForTLFByTime %s %s", id, serverTime) defer func() { if err == nil { md.log.CDebugf(ctx, "GetForTLFByTime %s %s done: %d", id, serverTime, irmd.Revision()) } else { md.log.CDebugf(ctx, "GetForTLFByTime %s %s done: %+v", id, serverTime, err) } }() mdserv, err := md.mdserver(ctx) if err != nil { return ImmutableRootMetadata{}, err } rmds, err := mdserv.GetForTLFByTime(ctx, id, serverTime) if err != nil { return ImmutableRootMetadata{}, err } return md.processSignedMD(ctx, id, kbfsmd.NullBranchID, rmds) }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "GetForTLFByTime", "(", "ctx", "context", ".", "Context", ",", "id", "tlf", ".", "ID", ",", "serverTime", "time", ".", "Time", ")", "(", "irmd", "ImmutableRootMetadata", ",", "err", "error", ")", "{", "md", ...
// GetForTLFByTime implements the MDOps interface for MDOpsStandard.
[ "GetForTLFByTime", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1090-L1113
160,786
keybase/client
go/kbfs/libkbfs/md_ops.go
GetUnmergedForTLF
func (md *MDOpsStandard) GetUnmergedForTLF( ctx context.Context, id tlf.ID, bid kbfsmd.BranchID) ( ImmutableRootMetadata, error) { return md.getForTLF(ctx, id, bid, kbfsmd.Unmerged, nil) }
go
func (md *MDOpsStandard) GetUnmergedForTLF( ctx context.Context, id tlf.ID, bid kbfsmd.BranchID) ( ImmutableRootMetadata, error) { return md.getForTLF(ctx, id, bid, kbfsmd.Unmerged, nil) }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "GetUnmergedForTLF", "(", "ctx", "context", ".", "Context", ",", "id", "tlf", ".", "ID", ",", "bid", "kbfsmd", ".", "BranchID", ")", "(", "ImmutableRootMetadata", ",", "error", ")", "{", "return", "md", ".", ...
// GetUnmergedForTLF implements the MDOps interface for MDOpsStandard.
[ "GetUnmergedForTLF", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1116-L1120
160,787
keybase/client
go/kbfs/libkbfs/md_ops.go
GetRange
func (md *MDOpsStandard) GetRange(ctx context.Context, id tlf.ID, start, stop kbfsmd.Revision, lockBeforeGet *keybase1.LockID) ( []ImmutableRootMetadata, error) { return md.getRange( ctx, id, kbfsmd.NullBranchID, kbfsmd.Merged, start, stop, lockBeforeGet) }
go
func (md *MDOpsStandard) GetRange(ctx context.Context, id tlf.ID, start, stop kbfsmd.Revision, lockBeforeGet *keybase1.LockID) ( []ImmutableRootMetadata, error) { return md.getRange( ctx, id, kbfsmd.NullBranchID, kbfsmd.Merged, start, stop, lockBeforeGet) }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "GetRange", "(", "ctx", "context", ".", "Context", ",", "id", "tlf", ".", "ID", ",", "start", ",", "stop", "kbfsmd", ".", "Revision", ",", "lockBeforeGet", "*", "keybase1", ".", "LockID", ")", "(", "[", "...
// GetRange implements the MDOps interface for MDOpsStandard.
[ "GetRange", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1249-L1254
160,788
keybase/client
go/kbfs/libkbfs/md_ops.go
GetUnmergedRange
func (md *MDOpsStandard) GetUnmergedRange(ctx context.Context, id tlf.ID, bid kbfsmd.BranchID, start, stop kbfsmd.Revision) ( []ImmutableRootMetadata, error) { return md.getRange(ctx, id, bid, kbfsmd.Unmerged, start, stop, nil) }
go
func (md *MDOpsStandard) GetUnmergedRange(ctx context.Context, id tlf.ID, bid kbfsmd.BranchID, start, stop kbfsmd.Revision) ( []ImmutableRootMetadata, error) { return md.getRange(ctx, id, bid, kbfsmd.Unmerged, start, stop, nil) }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "GetUnmergedRange", "(", "ctx", "context", ".", "Context", ",", "id", "tlf", ".", "ID", ",", "bid", "kbfsmd", ".", "BranchID", ",", "start", ",", "stop", "kbfsmd", ".", "Revision", ")", "(", "[", "]", "Im...
// GetUnmergedRange implements the MDOps interface for MDOpsStandard.
[ "GetUnmergedRange", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1257-L1261
160,789
keybase/client
go/kbfs/libkbfs/md_ops.go
Put
func (md *MDOpsStandard) Put(ctx context.Context, rmd *RootMetadata, verifyingKey kbfscrypto.VerifyingKey, lockContext *keybase1.LockContext, priority keybase1.MDPriority) (ImmutableRootMetadata, error) { if rmd.MergedStatus() == kbfsmd.Unmerged { return ImmutableRootMetadata{}, UnexpectedUnmergedPutError{} } return md.put(ctx, rmd, verifyingKey, lockContext, priority) }
go
func (md *MDOpsStandard) Put(ctx context.Context, rmd *RootMetadata, verifyingKey kbfscrypto.VerifyingKey, lockContext *keybase1.LockContext, priority keybase1.MDPriority) (ImmutableRootMetadata, error) { if rmd.MergedStatus() == kbfsmd.Unmerged { return ImmutableRootMetadata{}, UnexpectedUnmergedPutError{} } return md.put(ctx, rmd, verifyingKey, lockContext, priority) }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "Put", "(", "ctx", "context", ".", "Context", ",", "rmd", "*", "RootMetadata", ",", "verifyingKey", "kbfscrypto", ".", "VerifyingKey", ",", "lockContext", "*", "keybase1", ".", "LockContext", ",", "priority", "ke...
// Put implements the MDOps interface for MDOpsStandard.
[ "Put", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1322-L1329
160,790
keybase/client
go/kbfs/libkbfs/md_ops.go
PutUnmerged
func (md *MDOpsStandard) PutUnmerged( ctx context.Context, rmd *RootMetadata, verifyingKey kbfscrypto.VerifyingKey) (ImmutableRootMetadata, error) { rmd.SetUnmerged() if rmd.BID() == kbfsmd.NullBranchID { // new branch ID bid, err := md.config.Crypto().MakeRandomBranchID() if err != nil { return ImmutableRootMetadata{}, err } rmd.SetBranchID(bid) } return md.put(ctx, rmd, verifyingKey, nil, keybase1.MDPriorityNormal) }
go
func (md *MDOpsStandard) PutUnmerged( ctx context.Context, rmd *RootMetadata, verifyingKey kbfscrypto.VerifyingKey) (ImmutableRootMetadata, error) { rmd.SetUnmerged() if rmd.BID() == kbfsmd.NullBranchID { // new branch ID bid, err := md.config.Crypto().MakeRandomBranchID() if err != nil { return ImmutableRootMetadata{}, err } rmd.SetBranchID(bid) } return md.put(ctx, rmd, verifyingKey, nil, keybase1.MDPriorityNormal) }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "PutUnmerged", "(", "ctx", "context", ".", "Context", ",", "rmd", "*", "RootMetadata", ",", "verifyingKey", "kbfscrypto", ".", "VerifyingKey", ")", "(", "ImmutableRootMetadata", ",", "error", ")", "{", "rmd", "."...
// PutUnmerged implements the MDOps interface for MDOpsStandard.
[ "PutUnmerged", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1332-L1345
160,791
keybase/client
go/kbfs/libkbfs/md_ops.go
PruneBranch
func (md *MDOpsStandard) PruneBranch( ctx context.Context, id tlf.ID, bid kbfsmd.BranchID) error { mdserv, err := md.mdserver(ctx) if err != nil { return err } return mdserv.PruneBranch(ctx, id, bid) }
go
func (md *MDOpsStandard) PruneBranch( ctx context.Context, id tlf.ID, bid kbfsmd.BranchID) error { mdserv, err := md.mdserver(ctx) if err != nil { return err } return mdserv.PruneBranch(ctx, id, bid) }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "PruneBranch", "(", "ctx", "context", ".", "Context", ",", "id", "tlf", ".", "ID", ",", "bid", "kbfsmd", ".", "BranchID", ")", "error", "{", "mdserv", ",", "err", ":=", "md", ".", "mdserver", "(", "ctx", ...
// PruneBranch implements the MDOps interface for MDOpsStandard.
[ "PruneBranch", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1348-L1355
160,792
keybase/client
go/kbfs/libkbfs/md_ops.go
ResolveBranch
func (md *MDOpsStandard) ResolveBranch( ctx context.Context, id tlf.ID, bid kbfsmd.BranchID, _ []kbfsblock.ID, rmd *RootMetadata, verifyingKey kbfscrypto.VerifyingKey) ( ImmutableRootMetadata, error) { // Put the MD first. irmd, err := md.Put(ctx, rmd, verifyingKey, nil, keybase1.MDPriorityNormal) if err != nil { return ImmutableRootMetadata{}, err } // Prune the branch ia the journal, if there is one. If the // client fails before this is completed, we'll need to check for // resolutions on the next restart (see KBFS-798). err = md.PruneBranch(ctx, id, bid) if err != nil { return ImmutableRootMetadata{}, err } return irmd, nil }
go
func (md *MDOpsStandard) ResolveBranch( ctx context.Context, id tlf.ID, bid kbfsmd.BranchID, _ []kbfsblock.ID, rmd *RootMetadata, verifyingKey kbfscrypto.VerifyingKey) ( ImmutableRootMetadata, error) { // Put the MD first. irmd, err := md.Put(ctx, rmd, verifyingKey, nil, keybase1.MDPriorityNormal) if err != nil { return ImmutableRootMetadata{}, err } // Prune the branch ia the journal, if there is one. If the // client fails before this is completed, we'll need to check for // resolutions on the next restart (see KBFS-798). err = md.PruneBranch(ctx, id, bid) if err != nil { return ImmutableRootMetadata{}, err } return irmd, nil }
[ "func", "(", "md", "*", "MDOpsStandard", ")", "ResolveBranch", "(", "ctx", "context", ".", "Context", ",", "id", "tlf", ".", "ID", ",", "bid", "kbfsmd", ".", "BranchID", ",", "_", "[", "]", "kbfsblock", ".", "ID", ",", "rmd", "*", "RootMetadata", ","...
// ResolveBranch implements the MDOps interface for MDOpsStandard.
[ "ResolveBranch", "implements", "the", "MDOps", "interface", "for", "MDOpsStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_ops.go#L1358-L1376
160,793
keybase/client
go/engine/pgp_common.go
OutputSignatureSuccess
func OutputSignatureSuccess(m libkb.MetaContext, fingerprint libkb.PGPFingerprint, owner *libkb.User, signatureTime time.Time) error { arg := keybase1.OutputSignatureSuccessArg{ Fingerprint: fingerprint.String(), Username: owner.GetName(), SignedAt: keybase1.TimeFromSeconds(signatureTime.Unix()), } return m.UIs().PgpUI.OutputSignatureSuccess(m.Ctx(), arg) }
go
func OutputSignatureSuccess(m libkb.MetaContext, fingerprint libkb.PGPFingerprint, owner *libkb.User, signatureTime time.Time) error { arg := keybase1.OutputSignatureSuccessArg{ Fingerprint: fingerprint.String(), Username: owner.GetName(), SignedAt: keybase1.TimeFromSeconds(signatureTime.Unix()), } return m.UIs().PgpUI.OutputSignatureSuccess(m.Ctx(), arg) }
[ "func", "OutputSignatureSuccess", "(", "m", "libkb", ".", "MetaContext", ",", "fingerprint", "libkb", ".", "PGPFingerprint", ",", "owner", "*", "libkb", ".", "User", ",", "signatureTime", "time", ".", "Time", ")", "error", "{", "arg", ":=", "keybase1", ".", ...
// OutputSignatureSuccess prints the details of a successful verification.
[ "OutputSignatureSuccess", "prints", "the", "details", "of", "a", "successful", "verification", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_common.go#L15-L22
160,794
keybase/client
go/engine/pgp_common.go
OutputSignatureSuccessNonKeybase
func OutputSignatureSuccessNonKeybase(m libkb.MetaContext, keyID uint64, signatureTime time.Time) error { arg := keybase1.OutputSignatureSuccessNonKeybaseArg{ KeyID: fmt.Sprintf("%X", keyID), SignedAt: keybase1.TimeFromSeconds(signatureTime.Unix()), } return m.UIs().PgpUI.OutputSignatureSuccessNonKeybase(m.Ctx(), arg) }
go
func OutputSignatureSuccessNonKeybase(m libkb.MetaContext, keyID uint64, signatureTime time.Time) error { arg := keybase1.OutputSignatureSuccessNonKeybaseArg{ KeyID: fmt.Sprintf("%X", keyID), SignedAt: keybase1.TimeFromSeconds(signatureTime.Unix()), } return m.UIs().PgpUI.OutputSignatureSuccessNonKeybase(m.Ctx(), arg) }
[ "func", "OutputSignatureSuccessNonKeybase", "(", "m", "libkb", ".", "MetaContext", ",", "keyID", "uint64", ",", "signatureTime", "time", ".", "Time", ")", "error", "{", "arg", ":=", "keybase1", ".", "OutputSignatureSuccessNonKeybaseArg", "{", "KeyID", ":", "fmt", ...
// OutputSignatureSuccessNonKeybase prints the details of successful signature verification // when signing key is not known to keybase.
[ "OutputSignatureSuccessNonKeybase", "prints", "the", "details", "of", "successful", "signature", "verification", "when", "signing", "key", "is", "not", "known", "to", "keybase", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_common.go#L26-L32
160,795
keybase/client
go/engine/wallet_upkeep_background.go
NewWalletUpkeepBackground
func NewWalletUpkeepBackground(g *libkb.GlobalContext, args *WalletUpkeepBackgroundArgs) *WalletUpkeepBackground { task := NewBackgroundTask(g, &BackgroundTaskArgs{ Name: "WalletUpkeepBackground", F: WalletUpkeepBackgroundRound, Settings: WalletUpkeepBackgroundSettings, testingMetaCh: args.testingMetaCh, testingRoundResCh: args.testingRoundResCh, }) return &WalletUpkeepBackground{ Contextified: libkb.NewContextified(g), args: args, // Install the task early so that Shutdown can be called before RunEngine. task: task, } }
go
func NewWalletUpkeepBackground(g *libkb.GlobalContext, args *WalletUpkeepBackgroundArgs) *WalletUpkeepBackground { task := NewBackgroundTask(g, &BackgroundTaskArgs{ Name: "WalletUpkeepBackground", F: WalletUpkeepBackgroundRound, Settings: WalletUpkeepBackgroundSettings, testingMetaCh: args.testingMetaCh, testingRoundResCh: args.testingRoundResCh, }) return &WalletUpkeepBackground{ Contextified: libkb.NewContextified(g), args: args, // Install the task early so that Shutdown can be called before RunEngine. task: task, } }
[ "func", "NewWalletUpkeepBackground", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "args", "*", "WalletUpkeepBackgroundArgs", ")", "*", "WalletUpkeepBackground", "{", "task", ":=", "NewBackgroundTask", "(", "g", ",", "&", "BackgroundTaskArgs", "{", "Name", ":...
// NewWalletUpkeepBackground creates a WalletUpkeepBackground engine.
[ "NewWalletUpkeepBackground", "creates", "a", "WalletUpkeepBackground", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/wallet_upkeep_background.go#L39-L54
160,796
keybase/client
go/chat/boxer.go
UnboxThread
func (b *Boxer) UnboxThread(ctx context.Context, boxed chat1.ThreadViewBoxed, conv types.UnboxConversationInfo) (thread chat1.ThreadView, err error) { thread = chat1.ThreadView{ Pagination: boxed.Pagination, } if thread.Messages, err = b.UnboxMessages(ctx, boxed.Messages, conv); err != nil { return chat1.ThreadView{}, err } return thread, nil }
go
func (b *Boxer) UnboxThread(ctx context.Context, boxed chat1.ThreadViewBoxed, conv types.UnboxConversationInfo) (thread chat1.ThreadView, err error) { thread = chat1.ThreadView{ Pagination: boxed.Pagination, } if thread.Messages, err = b.UnboxMessages(ctx, boxed.Messages, conv); err != nil { return chat1.ThreadView{}, err } return thread, nil }
[ "func", "(", "b", "*", "Boxer", ")", "UnboxThread", "(", "ctx", "context", ".", "Context", ",", "boxed", "chat1", ".", "ThreadViewBoxed", ",", "conv", "types", ".", "UnboxConversationInfo", ")", "(", "thread", "chat1", ".", "ThreadView", ",", "err", "error...
// unboxThread transforms a chat1.ThreadViewBoxed to a keybase1.ThreadView.
[ "unboxThread", "transforms", "a", "chat1", ".", "ThreadViewBoxed", "to", "a", "keybase1", ".", "ThreadView", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1114-L1125
160,797
keybase/client
go/chat/boxer.go
dummySigningKey
func dummySigningKey() libkb.NaclSigningKeyPair { dummySigningKeyOnce.Do(func() { var allZeroSecretKey [libkb.NaclSigningKeySecretSize]byte dummyKeypair, err := libkb.MakeNaclSigningKeyPairFromSecret(allZeroSecretKey) if err != nil { panic("errors in key generation should be impossible: " + err.Error()) } dummySigningKeyPtr = &dummyKeypair }) return *dummySigningKeyPtr }
go
func dummySigningKey() libkb.NaclSigningKeyPair { dummySigningKeyOnce.Do(func() { var allZeroSecretKey [libkb.NaclSigningKeySecretSize]byte dummyKeypair, err := libkb.MakeNaclSigningKeyPairFromSecret(allZeroSecretKey) if err != nil { panic("errors in key generation should be impossible: " + err.Error()) } dummySigningKeyPtr = &dummyKeypair }) return *dummySigningKeyPtr }
[ "func", "dummySigningKey", "(", ")", "libkb", ".", "NaclSigningKeyPair", "{", "dummySigningKeyOnce", ".", "Do", "(", "func", "(", ")", "{", "var", "allZeroSecretKey", "[", "libkb", ".", "NaclSigningKeySecretSize", "]", "byte", "\n", "dummyKeypair", ",", "err", ...
// We use this constant key when we already have pairwiseMACs providing // authentication. Creating a keypair requires a curve multiply, so we cache it // here, in case someone uses it in a tight loop.
[ "We", "use", "this", "constant", "key", "when", "we", "already", "have", "pairwiseMACs", "providing", "authentication", ".", "Creating", "a", "keypair", "requires", "a", "curve", "multiply", "so", "we", "cache", "it", "here", "in", "case", "someone", "uses", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1289-L1299
160,798
keybase/client
go/chat/boxer.go
BoxMessage
func (b *Boxer) BoxMessage(ctx context.Context, msg chat1.MessagePlaintext, membersType chat1.ConversationMembersType, signingKeyPair libkb.NaclSigningKeyPair, info *types.BoxerEncryptionInfo) (res chat1.MessageBoxed, err error) { defer b.Trace(ctx, func() error { return err }, "BoxMessage")() tlfName := msg.ClientHeader.TlfName if len(tlfName) == 0 { return res, NewBoxingError("blank TLF name given", true) } version, err := b.GetBoxedVersion(msg) if err != nil { return res, err } if err = b.attachMerkleRoot(ctx, &msg, version); err != nil { return res, err } if info == nil { info = new(types.BoxerEncryptionInfo) if *info, err = b.GetEncryptionInfo(ctx, &msg, membersType, signingKeyPair); err != nil { return res, err } if len(msg.ClientHeader.TlfName) == 0 { msg := fmt.Sprintf("blank TLF name received: original: %s canonical: %s", tlfName, msg.ClientHeader.TlfName) return res, NewBoxingError(msg, true) } } boxed, err := b.box(ctx, msg, info.Key, info.EphemeralSeed, info.SigningKeyPair, info.Version, info.PairwiseMACRecipients) if err != nil { return res, NewBoxingError(err.Error(), true) } return boxed, nil }
go
func (b *Boxer) BoxMessage(ctx context.Context, msg chat1.MessagePlaintext, membersType chat1.ConversationMembersType, signingKeyPair libkb.NaclSigningKeyPair, info *types.BoxerEncryptionInfo) (res chat1.MessageBoxed, err error) { defer b.Trace(ctx, func() error { return err }, "BoxMessage")() tlfName := msg.ClientHeader.TlfName if len(tlfName) == 0 { return res, NewBoxingError("blank TLF name given", true) } version, err := b.GetBoxedVersion(msg) if err != nil { return res, err } if err = b.attachMerkleRoot(ctx, &msg, version); err != nil { return res, err } if info == nil { info = new(types.BoxerEncryptionInfo) if *info, err = b.GetEncryptionInfo(ctx, &msg, membersType, signingKeyPair); err != nil { return res, err } if len(msg.ClientHeader.TlfName) == 0 { msg := fmt.Sprintf("blank TLF name received: original: %s canonical: %s", tlfName, msg.ClientHeader.TlfName) return res, NewBoxingError(msg, true) } } boxed, err := b.box(ctx, msg, info.Key, info.EphemeralSeed, info.SigningKeyPair, info.Version, info.PairwiseMACRecipients) if err != nil { return res, NewBoxingError(err.Error(), true) } return boxed, nil }
[ "func", "(", "b", "*", "Boxer", ")", "BoxMessage", "(", "ctx", "context", ".", "Context", ",", "msg", "chat1", ".", "MessagePlaintext", ",", "membersType", "chat1", ".", "ConversationMembersType", ",", "signingKeyPair", "libkb", ".", "NaclSigningKeyPair", ",", ...
// BoxMessage encrypts a keybase1.MessagePlaintext into a chat1.MessageBoxed. It // finds the most recent key for the TLF.
[ "BoxMessage", "encrypts", "a", "keybase1", ".", "MessagePlaintext", "into", "a", "chat1", ".", "MessageBoxed", ".", "It", "finds", "the", "most", "recent", "key", "for", "the", "TLF", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1394-L1426
160,799
keybase/client
go/chat/boxer.go
attachMerkleRoot
func (b *Boxer) attachMerkleRoot(ctx context.Context, msg *chat1.MessagePlaintext, version chat1.MessageBoxedVersion) error { switch version { case chat1.MessageBoxedVersion_V1: if msg.ClientHeader.MerkleRoot != nil { return NewBoxingError("cannot send v1 message with merkle root", true) } case chat1.MessageBoxedVersion_V2, chat1.MessageBoxedVersion_V3, chat1.MessageBoxedVersion_V4: merkleRoot, err := b.latestMerkleRoot(ctx) if err != nil { return NewBoxingError(err.Error(), false) } msg.ClientHeader.MerkleRoot = merkleRoot if msg.ClientHeader.MerkleRoot == nil { return NewBoxingError("cannot send message without merkle root", false) } default: return fmt.Errorf("attachMerkleRoot unrecognized version: %s", version) } return nil }
go
func (b *Boxer) attachMerkleRoot(ctx context.Context, msg *chat1.MessagePlaintext, version chat1.MessageBoxedVersion) error { switch version { case chat1.MessageBoxedVersion_V1: if msg.ClientHeader.MerkleRoot != nil { return NewBoxingError("cannot send v1 message with merkle root", true) } case chat1.MessageBoxedVersion_V2, chat1.MessageBoxedVersion_V3, chat1.MessageBoxedVersion_V4: merkleRoot, err := b.latestMerkleRoot(ctx) if err != nil { return NewBoxingError(err.Error(), false) } msg.ClientHeader.MerkleRoot = merkleRoot if msg.ClientHeader.MerkleRoot == nil { return NewBoxingError("cannot send message without merkle root", false) } default: return fmt.Errorf("attachMerkleRoot unrecognized version: %s", version) } return nil }
[ "func", "(", "b", "*", "Boxer", ")", "attachMerkleRoot", "(", "ctx", "context", ".", "Context", ",", "msg", "*", "chat1", ".", "MessagePlaintext", ",", "version", "chat1", ".", "MessageBoxedVersion", ")", "error", "{", "switch", "version", "{", "case", "ch...
// Attach a merkle root to the message to send. // Modifies msg. // For MessageBoxedV1 makes sure there is no MR. // For MessageBoxedV2 attaches a MR that is no more out of date than ChatBoxerMerkleFreshness.
[ "Attach", "a", "merkle", "root", "to", "the", "message", "to", "send", ".", "Modifies", "msg", ".", "For", "MessageBoxedV1", "makes", "sure", "there", "is", "no", "MR", ".", "For", "MessageBoxedV2", "attaches", "a", "MR", "that", "is", "no", "more", "out...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1432-L1451