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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
127,400
ipfs/go-ipfs
tar/format.go
ImportTar
func ImportTar(ctx context.Context, r io.Reader, ds ipld.DAGService) (*dag.ProtoNode, error) { tr := tar.NewReader(r) root := new(dag.ProtoNode) root.SetData([]byte("ipfs/tar")) e := dagutils.NewDagEditor(root, ds) for { h, err := tr.Next() if err != nil { if err == io.EOF { break } return nil,...
go
func ImportTar(ctx context.Context, r io.Reader, ds ipld.DAGService) (*dag.ProtoNode, error) { tr := tar.NewReader(r) root := new(dag.ProtoNode) root.SetData([]byte("ipfs/tar")) e := dagutils.NewDagEditor(root, ds) for { h, err := tr.Next() if err != nil { if err == io.EOF { break } return nil,...
[ "func", "ImportTar", "(", "ctx", "context", ".", "Context", ",", "r", "io", ".", "Reader", ",", "ds", "ipld", ".", "DAGService", ")", "(", "*", "dag", ".", "ProtoNode", ",", "error", ")", "{", "tr", ":=", "tar", ".", "NewReader", "(", "r", ")", "...
// ImportTar imports a tar file into the given DAGService and returns the root // node.
[ "ImportTar", "imports", "a", "tar", "file", "into", "the", "given", "DAGService", "and", "returns", "the", "root", "node", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/tar/format.go#L39-L91
127,401
ipfs/go-ipfs
tar/format.go
escapePath
func escapePath(pth string) string { elems := path.SplitList(strings.Trim(pth, "/")) for i, e := range elems { elems[i] = "-" + e } return path.Join(elems) }
go
func escapePath(pth string) string { elems := path.SplitList(strings.Trim(pth, "/")) for i, e := range elems { elems[i] = "-" + e } return path.Join(elems) }
[ "func", "escapePath", "(", "pth", "string", ")", "string", "{", "elems", ":=", "path", ".", "SplitList", "(", "strings", ".", "Trim", "(", "pth", ",", "\"", "\"", ")", ")", "\n", "for", "i", ",", "e", ":=", "range", "elems", "{", "elems", "[", "i...
// adds a '-' to the beginning of each path element so we can use 'data' as a // special link in the structure without having to worry about
[ "adds", "a", "-", "to", "the", "beginning", "of", "each", "path", "element", "so", "we", "can", "use", "data", "as", "a", "special", "link", "in", "the", "structure", "without", "having", "to", "worry", "about" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/tar/format.go#L95-L101
127,402
ipfs/go-ipfs
tar/format.go
ExportTar
func ExportTar(ctx context.Context, root *dag.ProtoNode, ds ipld.DAGService) (io.Reader, error) { if string(root.Data()) != "ipfs/tar" { return nil, errors.New("not an IPFS tarchive") } return &tarReader{ links: root.Links(), ds: ds, ctx: ctx, }, nil }
go
func ExportTar(ctx context.Context, root *dag.ProtoNode, ds ipld.DAGService) (io.Reader, error) { if string(root.Data()) != "ipfs/tar" { return nil, errors.New("not an IPFS tarchive") } return &tarReader{ links: root.Links(), ds: ds, ctx: ctx, }, nil }
[ "func", "ExportTar", "(", "ctx", "context", ".", "Context", ",", "root", "*", "dag", ".", "ProtoNode", ",", "ds", "ipld", ".", "DAGService", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "if", "string", "(", "root", ".", "Data", "(", ")", ...
// ExportTar exports the passed DAG as a tar file. This function is the inverse // of ImportTar.
[ "ExportTar", "exports", "the", "passed", "DAG", "as", "a", "tar", "file", ".", "This", "function", "is", "the", "inverse", "of", "ImportTar", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/tar/format.go#L201-L210
127,403
ipfs/go-ipfs
repo/fsrepo/migrations/migrations.go
osWithVariant
func osWithVariant() (string, error) { if runtime.GOOS != "linux" { return runtime.GOOS, nil } // ldd outputs the system's kind of libc. // - on standard ubuntu: ldd (Ubuntu GLIBC 2.23-0ubuntu5) 2.23 // - on alpine: musl libc (x86_64) // // we use the combined stdout+stderr, // because ldd --version prints d...
go
func osWithVariant() (string, error) { if runtime.GOOS != "linux" { return runtime.GOOS, nil } // ldd outputs the system's kind of libc. // - on standard ubuntu: ldd (Ubuntu GLIBC 2.23-0ubuntu5) 2.23 // - on alpine: musl libc (x86_64) // // we use the combined stdout+stderr, // because ldd --version prints d...
[ "func", "osWithVariant", "(", ")", "(", "string", ",", "error", ")", "{", "if", "runtime", ".", "GOOS", "!=", "\"", "\"", "{", "return", "runtime", ".", "GOOS", ",", "nil", "\n", "}", "\n\n", "// ldd outputs the system's kind of libc.", "// - on standard ubunt...
// osWithVariant returns the OS name with optional variant. // Currently returns either runtime.GOOS, or "linux-musl".
[ "osWithVariant", "returns", "the", "OS", "name", "with", "optional", "variant", ".", "Currently", "returns", "either", "runtime", ".", "GOOS", "or", "linux", "-", "musl", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/migrations/migrations.go#L248-L277
127,404
ipfs/go-ipfs
core/corehttp/corehttp.go
makeHandler
func makeHandler(n *core.IpfsNode, l net.Listener, options ...ServeOption) (http.Handler, error) { topMux := http.NewServeMux() mux := topMux for _, option := range options { var err error mux, err = option(n, l, mux) if err != nil { return nil, err } } return topMux, nil }
go
func makeHandler(n *core.IpfsNode, l net.Listener, options ...ServeOption) (http.Handler, error) { topMux := http.NewServeMux() mux := topMux for _, option := range options { var err error mux, err = option(n, l, mux) if err != nil { return nil, err } } return topMux, nil }
[ "func", "makeHandler", "(", "n", "*", "core", ".", "IpfsNode", ",", "l", "net", ".", "Listener", ",", "options", "...", "ServeOption", ")", "(", "http", ".", "Handler", ",", "error", ")", "{", "topMux", ":=", "http", ".", "NewServeMux", "(", ")", "\n...
// makeHandler turns a list of ServeOptions into a http.Handler that implements // all of the given options, in order.
[ "makeHandler", "turns", "a", "list", "of", "ServeOptions", "into", "a", "http", ".", "Handler", "that", "implements", "all", "of", "the", "given", "options", "in", "order", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/corehttp/corehttp.go#L36-L47
127,405
ipfs/go-ipfs
core/corehttp/proxy.go
ProxyOption
func ProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/p2p/", func(w http.ResponseWriter, request *http.Request) { // parse request parsedRequest, err := parseRequest(request) if err != nil { handleError(w, "fa...
go
func ProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/p2p/", func(w http.ResponseWriter, request *http.Request) { // parse request parsedRequest, err := parseRequest(request) if err != nil { handleError(w, "fa...
[ "func", "ProxyOption", "(", ")", "ServeOption", "{", "return", "func", "(", "ipfsNode", "*", "core", ".", "IpfsNode", ",", "_", "net", ".", "Listener", ",", "mux", "*", "http", ".", "ServeMux", ")", "(", "*", "http", ".", "ServeMux", ",", "error", ")...
// ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer
[ "ProxyOption", "is", "an", "endpoint", "for", "proxying", "a", "HTTP", "request", "to", "another", "ipfs", "peer" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/corehttp/proxy.go#L18-L43
127,406
ipfs/go-ipfs
core/commands/cmdenv/file.go
GetFileArg
func GetFileArg(it files.DirIterator) (files.File, error) { if !it.Next() { err := it.Err() if err == nil { err = fmt.Errorf("expected a file argument") } return nil, err } file := files.FileFromEntry(it) if file == nil { return nil, fmt.Errorf("file argument was nil") } return file, nil }
go
func GetFileArg(it files.DirIterator) (files.File, error) { if !it.Next() { err := it.Err() if err == nil { err = fmt.Errorf("expected a file argument") } return nil, err } file := files.FileFromEntry(it) if file == nil { return nil, fmt.Errorf("file argument was nil") } return file, nil }
[ "func", "GetFileArg", "(", "it", "files", ".", "DirIterator", ")", "(", "files", ".", "File", ",", "error", ")", "{", "if", "!", "it", ".", "Next", "(", ")", "{", "err", ":=", "it", ".", "Err", "(", ")", "\n", "if", "err", "==", "nil", "{", "...
// GetFileArg returns the next file from the directory or an error
[ "GetFileArg", "returns", "the", "next", "file", "from", "the", "directory", "or", "an", "error" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/cmdenv/file.go#L10-L23
127,407
ipfs/go-ipfs
core/node/builder.go
options
func (cfg *BuildCfg) options(ctx context.Context) (fx.Option, *cfg.Config) { err := cfg.fillDefaults() if err != nil { return fx.Error(err), nil } repoOption := fx.Provide(func(lc fx.Lifecycle) repo.Repo { lc.Append(fx.Hook{ OnStop: func(ctx context.Context) error { return cfg.Repo.Close() }, }) ...
go
func (cfg *BuildCfg) options(ctx context.Context) (fx.Option, *cfg.Config) { err := cfg.fillDefaults() if err != nil { return fx.Error(err), nil } repoOption := fx.Provide(func(lc fx.Lifecycle) repo.Repo { lc.Append(fx.Hook{ OnStop: func(ctx context.Context) error { return cfg.Repo.Close() }, }) ...
[ "func", "(", "cfg", "*", "BuildCfg", ")", "options", "(", "ctx", "context", ".", "Context", ")", "(", "fx", ".", "Option", ",", "*", "cfg", ".", "Config", ")", "{", "err", ":=", "cfg", ".", "fillDefaults", "(", ")", "\n", "if", "err", "!=", "nil"...
// options creates fx option group from this build config
[ "options", "creates", "fx", "option", "group", "from", "this", "build", "config" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/builder.go#L87-L126
127,408
ipfs/go-ipfs
cmd/ipfs/daemon.go
serveHTTPGateway
func serveHTTPGateway(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, error) { cfg, err := cctx.GetConfig() if err != nil { return nil, fmt.Errorf("serveHTTPGateway: GetConfig() failed: %s", err) } writable, writableOptionFound := req.Options[writableKwd].(bool) if !writableOptionFound { writable = c...
go
func serveHTTPGateway(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, error) { cfg, err := cctx.GetConfig() if err != nil { return nil, fmt.Errorf("serveHTTPGateway: GetConfig() failed: %s", err) } writable, writableOptionFound := req.Options[writableKwd].(bool) if !writableOptionFound { writable = c...
[ "func", "serveHTTPGateway", "(", "req", "*", "cmds", ".", "Request", ",", "cctx", "*", "oldcmds", ".", "Context", ")", "(", "<-", "chan", "error", ",", "error", ")", "{", "cfg", ",", "err", ":=", "cctx", ".", "GetConfig", "(", ")", "\n", "if", "err...
// serveHTTPGateway collects options, creates listener, prints status message and starts serving requests
[ "serveHTTPGateway", "collects", "options", "creates", "listener", "prints", "status", "message", "and", "starts", "serving", "requests" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/ipfs/daemon.go#L557-L633
127,409
ipfs/go-ipfs
cmd/ipfs/daemon.go
mountFuse
func mountFuse(req *cmds.Request, cctx *oldcmds.Context) error { cfg, err := cctx.GetConfig() if err != nil { return fmt.Errorf("mountFuse: GetConfig() failed: %s", err) } fsdir, found := req.Options[ipfsMountKwd].(string) if !found { fsdir = cfg.Mounts.IPFS } nsdir, found := req.Options[ipnsMountKwd].(str...
go
func mountFuse(req *cmds.Request, cctx *oldcmds.Context) error { cfg, err := cctx.GetConfig() if err != nil { return fmt.Errorf("mountFuse: GetConfig() failed: %s", err) } fsdir, found := req.Options[ipfsMountKwd].(string) if !found { fsdir = cfg.Mounts.IPFS } nsdir, found := req.Options[ipnsMountKwd].(str...
[ "func", "mountFuse", "(", "req", "*", "cmds", ".", "Request", ",", "cctx", "*", "oldcmds", ".", "Context", ")", "error", "{", "cfg", ",", "err", ":=", "cctx", ".", "GetConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", ...
//collects options and opens the fuse mountpoint
[ "collects", "options", "and", "opens", "the", "fuse", "mountpoint" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/ipfs/daemon.go#L636-L664
127,410
ipfs/go-ipfs
p2p/listener.go
Register
func (r *Listeners) Register(l Listener) error { r.Lock() defer r.Unlock() if _, ok := r.Listeners[l.key()]; ok { return errors.New("listener already registered") } r.Listeners[l.key()] = l return nil }
go
func (r *Listeners) Register(l Listener) error { r.Lock() defer r.Unlock() if _, ok := r.Listeners[l.key()]; ok { return errors.New("listener already registered") } r.Listeners[l.key()] = l return nil }
[ "func", "(", "r", "*", "Listeners", ")", "Register", "(", "l", "Listener", ")", "error", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "ok", ":=", "r", ".", "Listeners", "[", "l", ".", "...
// Register registers listenerInfo into this registry and starts it
[ "Register", "registers", "listenerInfo", "into", "this", "registry", "and", "starts", "it" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/p2p/listener.go#L64-L74
127,411
ipfs/go-ipfs
core/commands/id.go
printSelf
func printSelf(node *core.IpfsNode) (interface{}, error) { info := new(IdOutput) info.ID = node.Identity.Pretty() pk := node.PrivateKey.GetPublic() pkb, err := ic.MarshalPublicKey(pk) if err != nil { return nil, err } info.PublicKey = base64.StdEncoding.EncodeToString(pkb) if node.PeerHost != nil { for _,...
go
func printSelf(node *core.IpfsNode) (interface{}, error) { info := new(IdOutput) info.ID = node.Identity.Pretty() pk := node.PrivateKey.GetPublic() pkb, err := ic.MarshalPublicKey(pk) if err != nil { return nil, err } info.PublicKey = base64.StdEncoding.EncodeToString(pkb) if node.PeerHost != nil { for _,...
[ "func", "printSelf", "(", "node", "*", "core", ".", "IpfsNode", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "info", ":=", "new", "(", "IdOutput", ")", "\n", "info", ".", "ID", "=", "node", ".", "Identity", ".", "Pretty", "(", ")", "\...
// printing self is special cased as we get values differently.
[ "printing", "self", "is", "special", "cased", "as", "we", "get", "values", "differently", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/id.go#L175-L195
127,412
ipfs/go-ipfs
core/commands/refs.go
WriteRefs
func (rw *RefWriter) WriteRefs(n ipld.Node, enc cidenc.Encoder) (int, error) { return rw.writeRefsRecursive(n, 0, enc) }
go
func (rw *RefWriter) WriteRefs(n ipld.Node, enc cidenc.Encoder) (int, error) { return rw.writeRefsRecursive(n, 0, enc) }
[ "func", "(", "rw", "*", "RefWriter", ")", "WriteRefs", "(", "n", "ipld", ".", "Node", ",", "enc", "cidenc", ".", "Encoder", ")", "(", "int", ",", "error", ")", "{", "return", "rw", ".", "writeRefsRecursive", "(", "n", ",", "0", ",", "enc", ")", "...
// WriteRefs writes refs of the given object to the underlying writer.
[ "WriteRefs", "writes", "refs", "of", "the", "given", "object", "to", "the", "underlying", "writer", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/refs.go#L204-L206
127,413
ipfs/go-ipfs
core/commands/refs.go
WriteEdge
func (rw *RefWriter) WriteEdge(from, to cid.Cid, linkname string, enc cidenc.Encoder) error { if rw.Ctx != nil { select { case <-rw.Ctx.Done(): // just in case. return rw.Ctx.Err() default: } } var s string switch { case rw.PrintFmt != "": s = rw.PrintFmt s = strings.Replace(s, "<src>", enc.Encode(...
go
func (rw *RefWriter) WriteEdge(from, to cid.Cid, linkname string, enc cidenc.Encoder) error { if rw.Ctx != nil { select { case <-rw.Ctx.Done(): // just in case. return rw.Ctx.Err() default: } } var s string switch { case rw.PrintFmt != "": s = rw.PrintFmt s = strings.Replace(s, "<src>", enc.Encode(...
[ "func", "(", "rw", "*", "RefWriter", ")", "WriteEdge", "(", "from", ",", "to", "cid", ".", "Cid", ",", "linkname", "string", ",", "enc", "cidenc", ".", "Encoder", ")", "error", "{", "if", "rw", ".", "Ctx", "!=", "nil", "{", "select", "{", "case", ...
// Write one edge
[ "Write", "one", "edge" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/refs.go#L319-L340
127,414
ipfs/go-ipfs
core/node/groups.go
Storage
func Storage(bcfg *BuildCfg, cfg *config.Config) fx.Option { cacheOpts := blockstore.DefaultCacheOpts() cacheOpts.HasBloomFilterSize = cfg.Datastore.BloomFilterSize if !bcfg.Permanent { cacheOpts.HasBloomFilterSize = 0 } finalBstore := fx.Provide(GcBlockstoreCtor) if cfg.Experimental.FilestoreEnabled || cfg.Ex...
go
func Storage(bcfg *BuildCfg, cfg *config.Config) fx.Option { cacheOpts := blockstore.DefaultCacheOpts() cacheOpts.HasBloomFilterSize = cfg.Datastore.BloomFilterSize if !bcfg.Permanent { cacheOpts.HasBloomFilterSize = 0 } finalBstore := fx.Provide(GcBlockstoreCtor) if cfg.Experimental.FilestoreEnabled || cfg.Ex...
[ "func", "Storage", "(", "bcfg", "*", "BuildCfg", ",", "cfg", "*", "config", ".", "Config", ")", "fx", ".", "Option", "{", "cacheOpts", ":=", "blockstore", ".", "DefaultCacheOpts", "(", ")", "\n", "cacheOpts", ".", "HasBloomFilterSize", "=", "cfg", ".", "...
// Storage groups units which setup datastore based persistence and blockstore layers
[ "Storage", "groups", "units", "which", "setup", "datastore", "based", "persistence", "and", "blockstore", "layers" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/groups.go#L126-L144
127,415
ipfs/go-ipfs
core/node/groups.go
Identity
func Identity(cfg *config.Config) fx.Option { // PeerID cid := cfg.Identity.PeerID if cid == "" { return fx.Error(errors.New("identity was not set in config (was 'ipfs init' run?)")) } if len(cid) == 0 { return fx.Error(errors.New("no peer ID in config! (was 'ipfs init' run?)")) } id, err := peer.IDB58Deco...
go
func Identity(cfg *config.Config) fx.Option { // PeerID cid := cfg.Identity.PeerID if cid == "" { return fx.Error(errors.New("identity was not set in config (was 'ipfs init' run?)")) } if len(cid) == 0 { return fx.Error(errors.New("no peer ID in config! (was 'ipfs init' run?)")) } id, err := peer.IDB58Deco...
[ "func", "Identity", "(", "cfg", "*", "config", ".", "Config", ")", "fx", ".", "Option", "{", "// PeerID", "cid", ":=", "cfg", ".", "Identity", ".", "PeerID", "\n", "if", "cid", "==", "\"", "\"", "{", "return", "fx", ".", "Error", "(", "errors", "."...
// Identity groups units providing cryptographic identity
[ "Identity", "groups", "units", "providing", "cryptographic", "identity" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/groups.go#L147-L184
127,416
ipfs/go-ipfs
core/node/groups.go
Providers
func Providers(cfg *config.Config) fx.Option { reproviderInterval := kReprovideFrequency if cfg.Reprovider.Interval != "" { dur, err := time.ParseDuration(cfg.Reprovider.Interval) if err != nil { return fx.Error(err) } reproviderInterval = dur } var keyProvider fx.Option switch cfg.Reprovider.Strategy...
go
func Providers(cfg *config.Config) fx.Option { reproviderInterval := kReprovideFrequency if cfg.Reprovider.Interval != "" { dur, err := time.ParseDuration(cfg.Reprovider.Interval) if err != nil { return fx.Error(err) } reproviderInterval = dur } var keyProvider fx.Option switch cfg.Reprovider.Strategy...
[ "func", "Providers", "(", "cfg", "*", "config", ".", "Config", ")", "fx", ".", "Option", "{", "reproviderInterval", ":=", "kReprovideFrequency", "\n", "if", "cfg", ".", "Reprovider", ".", "Interval", "!=", "\"", "\"", "{", "dur", ",", "err", ":=", "time"...
// Providers groups units managing provider routing records
[ "Providers", "groups", "units", "managing", "provider", "routing", "records" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/groups.go#L192-L225
127,417
ipfs/go-ipfs
core/node/groups.go
Online
func Online(bcfg *BuildCfg, cfg *config.Config) fx.Option { // Namesys params ipnsCacheSize := cfg.Ipns.ResolveCacheSize if ipnsCacheSize == 0 { ipnsCacheSize = DefaultIpnsCacheSize } if ipnsCacheSize < 0 { return fx.Error(fmt.Errorf("cannot specify negative resolve cache size")) } // Republisher params ...
go
func Online(bcfg *BuildCfg, cfg *config.Config) fx.Option { // Namesys params ipnsCacheSize := cfg.Ipns.ResolveCacheSize if ipnsCacheSize == 0 { ipnsCacheSize = DefaultIpnsCacheSize } if ipnsCacheSize < 0 { return fx.Error(fmt.Errorf("cannot specify negative resolve cache size")) } // Republisher params ...
[ "func", "Online", "(", "bcfg", "*", "BuildCfg", ",", "cfg", "*", "config", ".", "Config", ")", "fx", ".", "Option", "{", "// Namesys params", "ipnsCacheSize", ":=", "cfg", ".", "Ipns", ".", "ResolveCacheSize", "\n", "if", "ipnsCacheSize", "==", "0", "{", ...
// Online groups online-only units
[ "Online", "groups", "online", "-", "only", "units" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/groups.go#L228-L277
127,418
ipfs/go-ipfs
core/node/groups.go
IPFS
func IPFS(ctx context.Context, bcfg *BuildCfg) fx.Option { if bcfg == nil { bcfg = new(BuildCfg) } bcfgOpts, cfg := bcfg.options(ctx) if cfg == nil { return bcfgOpts // error } // TEMP: setting global sharding switch here uio.UseHAMTSharding = cfg.Experimental.ShardingEnabled return fx.Options( bcfgOpt...
go
func IPFS(ctx context.Context, bcfg *BuildCfg) fx.Option { if bcfg == nil { bcfg = new(BuildCfg) } bcfgOpts, cfg := bcfg.options(ctx) if cfg == nil { return bcfgOpts // error } // TEMP: setting global sharding switch here uio.UseHAMTSharding = cfg.Experimental.ShardingEnabled return fx.Options( bcfgOpt...
[ "func", "IPFS", "(", "ctx", "context", ".", "Context", ",", "bcfg", "*", "BuildCfg", ")", "fx", ".", "Option", "{", "if", "bcfg", "==", "nil", "{", "bcfg", "=", "new", "(", "BuildCfg", ")", "\n", "}", "\n\n", "bcfgOpts", ",", "cfg", ":=", "bcfg", ...
// IPFS builds a group of fx Options based on the passed BuildCfg
[ "IPFS", "builds", "a", "group", "of", "fx", "Options", "based", "on", "the", "passed", "BuildCfg" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/groups.go#L304-L329
127,419
ipfs/go-ipfs
namesys/base.go
resolve
func resolve(ctx context.Context, r resolver, name string, options opts.ResolveOpts) (path.Path, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() err := ErrResolveFailed var p path.Path resCh := resolveAsync(ctx, r, name, options) for res := range resCh { p, err = res.Path, res.Err if err != ...
go
func resolve(ctx context.Context, r resolver, name string, options opts.ResolveOpts) (path.Path, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() err := ErrResolveFailed var p path.Path resCh := resolveAsync(ctx, r, name, options) for res := range resCh { p, err = res.Path, res.Err if err != ...
[ "func", "resolve", "(", "ctx", "context", ".", "Context", ",", "r", "resolver", ",", "name", "string", ",", "options", "opts", ".", "ResolveOpts", ")", "(", "path", ".", "Path", ",", "error", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "Wit...
// resolve is a helper for implementing Resolver.ResolveN using resolveOnce.
[ "resolve", "is", "a", "helper", "for", "implementing", "Resolver", ".", "ResolveN", "using", "resolveOnce", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/base.go#L23-L40
127,420
ipfs/go-ipfs
filestore/filestore.go
NewFilestore
func NewFilestore(bs blockstore.Blockstore, fm *FileManager) *Filestore { return &Filestore{fm, bs} }
go
func NewFilestore(bs blockstore.Blockstore, fm *FileManager) *Filestore { return &Filestore{fm, bs} }
[ "func", "NewFilestore", "(", "bs", "blockstore", ".", "Blockstore", ",", "fm", "*", "FileManager", ")", "*", "Filestore", "{", "return", "&", "Filestore", "{", "fm", ",", "bs", "}", "\n", "}" ]
// NewFilestore creates one using the given Blockstore and FileManager.
[ "NewFilestore", "creates", "one", "using", "the", "given", "Blockstore", "and", "FileManager", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/filestore.go#L46-L48
127,421
ipfs/go-ipfs
filestore/filestore.go
AllKeysChan
func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) { ctx, cancel := context.WithCancel(ctx) a, err := f.bs.AllKeysChan(ctx) if err != nil { cancel() return nil, err } out := make(chan cid.Cid, dsq.KeysOnlyBufSize) go func() { defer cancel() defer close(out) var done bool f...
go
func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) { ctx, cancel := context.WithCancel(ctx) a, err := f.bs.AllKeysChan(ctx) if err != nil { cancel() return nil, err } out := make(chan cid.Cid, dsq.KeysOnlyBufSize) go func() { defer cancel() defer close(out) var done bool f...
[ "func", "(", "f", "*", "Filestore", ")", "AllKeysChan", "(", "ctx", "context", ".", "Context", ")", "(", "<-", "chan", "cid", ".", "Cid", ",", "error", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n\n", "a"...
// AllKeysChan returns a channel from which to read the keys stored in // the blockstore. If the given context is cancelled the channel will be closed.
[ "AllKeysChan", "returns", "a", "channel", "from", "which", "to", "read", "the", "keys", "stored", "in", "the", "blockstore", ".", "If", "the", "given", "context", "is", "cancelled", "the", "channel", "will", "be", "closed", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/filestore.go#L52-L112
127,422
ipfs/go-ipfs
filestore/filestore.go
DeleteBlock
func (f *Filestore) DeleteBlock(c cid.Cid) error { err1 := f.bs.DeleteBlock(c) if err1 != nil && err1 != blockstore.ErrNotFound { return err1 } err2 := f.fm.DeleteBlock(c) // if we successfully removed something from the blockstore, but the // filestore didnt have it, return success switch err2 { case nil: ...
go
func (f *Filestore) DeleteBlock(c cid.Cid) error { err1 := f.bs.DeleteBlock(c) if err1 != nil && err1 != blockstore.ErrNotFound { return err1 } err2 := f.fm.DeleteBlock(c) // if we successfully removed something from the blockstore, but the // filestore didnt have it, return success switch err2 { case nil: ...
[ "func", "(", "f", "*", "Filestore", ")", "DeleteBlock", "(", "c", "cid", ".", "Cid", ")", "error", "{", "err1", ":=", "f", ".", "bs", ".", "DeleteBlock", "(", "c", ")", "\n", "if", "err1", "!=", "nil", "&&", "err1", "!=", "blockstore", ".", "ErrN...
// DeleteBlock deletes the block with the given key from the // blockstore. As expected, in the case of FileManager blocks, only the // reference is deleted, not its contents. It may return // ErrNotFound when the block is not stored.
[ "DeleteBlock", "deletes", "the", "block", "with", "the", "given", "key", "from", "the", "blockstore", ".", "As", "expected", "in", "the", "case", "of", "FileManager", "blocks", "only", "the", "reference", "is", "deleted", "not", "its", "contents", ".", "It",...
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/filestore.go#L118-L139
127,423
ipfs/go-ipfs
filestore/filestore.go
Get
func (f *Filestore) Get(c cid.Cid) (blocks.Block, error) { blk, err := f.bs.Get(c) switch err { case nil: return blk, nil case blockstore.ErrNotFound: return f.fm.Get(c) default: return nil, err } }
go
func (f *Filestore) Get(c cid.Cid) (blocks.Block, error) { blk, err := f.bs.Get(c) switch err { case nil: return blk, nil case blockstore.ErrNotFound: return f.fm.Get(c) default: return nil, err } }
[ "func", "(", "f", "*", "Filestore", ")", "Get", "(", "c", "cid", ".", "Cid", ")", "(", "blocks", ".", "Block", ",", "error", ")", "{", "blk", ",", "err", ":=", "f", ".", "bs", ".", "Get", "(", "c", ")", "\n", "switch", "err", "{", "case", "...
// Get retrieves the block with the given Cid. It may return // ErrNotFound when the block is not stored.
[ "Get", "retrieves", "the", "block", "with", "the", "given", "Cid", ".", "It", "may", "return", "ErrNotFound", "when", "the", "block", "is", "not", "stored", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/filestore.go#L143-L153
127,424
ipfs/go-ipfs
filestore/filestore.go
GetSize
func (f *Filestore) GetSize(c cid.Cid) (int, error) { size, err := f.bs.GetSize(c) switch err { case nil: return size, nil case blockstore.ErrNotFound: return f.fm.GetSize(c) default: return -1, err } }
go
func (f *Filestore) GetSize(c cid.Cid) (int, error) { size, err := f.bs.GetSize(c) switch err { case nil: return size, nil case blockstore.ErrNotFound: return f.fm.GetSize(c) default: return -1, err } }
[ "func", "(", "f", "*", "Filestore", ")", "GetSize", "(", "c", "cid", ".", "Cid", ")", "(", "int", ",", "error", ")", "{", "size", ",", "err", ":=", "f", ".", "bs", ".", "GetSize", "(", "c", ")", "\n", "switch", "err", "{", "case", "nil", ":",...
// GetSize returns the size of the requested block. It may return ErrNotFound // when the block is not stored.
[ "GetSize", "returns", "the", "size", "of", "the", "requested", "block", ".", "It", "may", "return", "ErrNotFound", "when", "the", "block", "is", "not", "stored", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/filestore.go#L157-L167
127,425
ipfs/go-ipfs
filestore/filestore.go
Has
func (f *Filestore) Has(c cid.Cid) (bool, error) { has, err := f.bs.Has(c) if err != nil { return false, err } if has { return true, nil } return f.fm.Has(c) }
go
func (f *Filestore) Has(c cid.Cid) (bool, error) { has, err := f.bs.Has(c) if err != nil { return false, err } if has { return true, nil } return f.fm.Has(c) }
[ "func", "(", "f", "*", "Filestore", ")", "Has", "(", "c", "cid", ".", "Cid", ")", "(", "bool", ",", "error", ")", "{", "has", ",", "err", ":=", "f", ".", "bs", ".", "Has", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false...
// Has returns true if the block with the given Cid is // stored in the Filestore.
[ "Has", "returns", "true", "if", "the", "block", "with", "the", "given", "Cid", "is", "stored", "in", "the", "Filestore", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/filestore.go#L171-L182
127,426
ipfs/go-ipfs
filestore/filestore.go
Put
func (f *Filestore) Put(b blocks.Block) error { has, err := f.Has(b.Cid()) if err != nil { return err } if has { return nil } switch b := b.(type) { case *posinfo.FilestoreNode: return f.fm.Put(b) default: return f.bs.Put(b) } }
go
func (f *Filestore) Put(b blocks.Block) error { has, err := f.Has(b.Cid()) if err != nil { return err } if has { return nil } switch b := b.(type) { case *posinfo.FilestoreNode: return f.fm.Put(b) default: return f.bs.Put(b) } }
[ "func", "(", "f", "*", "Filestore", ")", "Put", "(", "b", "blocks", ".", "Block", ")", "error", "{", "has", ",", "err", ":=", "f", ".", "Has", "(", "b", ".", "Cid", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", ...
// Put stores a block in the Filestore. For blocks of // underlying type FilestoreNode, the operation is // delegated to the FileManager, while the rest of blocks // are handled by the regular blockstore.
[ "Put", "stores", "a", "block", "in", "the", "Filestore", ".", "For", "blocks", "of", "underlying", "type", "FilestoreNode", "the", "operation", "is", "delegated", "to", "the", "FileManager", "while", "the", "rest", "of", "blocks", "are", "handled", "by", "th...
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/filestore.go#L188-L204
127,427
ipfs/go-ipfs
filestore/fsrefstore.go
NewFileManager
func NewFileManager(ds ds.Batching, root string) *FileManager { return &FileManager{ds: dsns.Wrap(ds, FilestorePrefix), root: root} }
go
func NewFileManager(ds ds.Batching, root string) *FileManager { return &FileManager{ds: dsns.Wrap(ds, FilestorePrefix), root: root} }
[ "func", "NewFileManager", "(", "ds", "ds", ".", "Batching", ",", "root", "string", ")", "*", "FileManager", "{", "return", "&", "FileManager", "{", "ds", ":", "dsns", ".", "Wrap", "(", "ds", ",", "FilestorePrefix", ")", ",", "root", ":", "root", "}", ...
// NewFileManager initializes a new file manager with the given // datastore and root. All FilestoreNodes paths are relative to the // root path given here, which is prepended for any operations.
[ "NewFileManager", "initializes", "a", "new", "file", "manager", "with", "the", "given", "datastore", "and", "root", ".", "All", "FilestoreNodes", "paths", "are", "relative", "to", "the", "root", "path", "given", "here", "which", "is", "prepended", "for", "any"...
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/fsrefstore.go#L56-L58
127,428
ipfs/go-ipfs
filestore/fsrefstore.go
AllKeysChan
func (f *FileManager) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) { q := dsq.Query{KeysOnly: true} res, err := f.ds.Query(q) if err != nil { return nil, err } out := make(chan cid.Cid, dsq.KeysOnlyBufSize) go func() { defer close(out) for { v, ok := res.NextSync() if !ok { return ...
go
func (f *FileManager) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) { q := dsq.Query{KeysOnly: true} res, err := f.ds.Query(q) if err != nil { return nil, err } out := make(chan cid.Cid, dsq.KeysOnlyBufSize) go func() { defer close(out) for { v, ok := res.NextSync() if !ok { return ...
[ "func", "(", "f", "*", "FileManager", ")", "AllKeysChan", "(", "ctx", "context", ".", "Context", ")", "(", "<-", "chan", "cid", ".", "Cid", ",", "error", ")", "{", "q", ":=", "dsq", ".", "Query", "{", "KeysOnly", ":", "true", "}", "\n\n", "res", ...
// AllKeysChan returns a channel from which to read the keys stored in // the FileManager. If the given context is cancelled the channel will be // closed.
[ "AllKeysChan", "returns", "a", "channel", "from", "which", "to", "read", "the", "keys", "stored", "in", "the", "FileManager", ".", "If", "the", "given", "context", "is", "cancelled", "the", "channel", "will", "be", "closed", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/fsrefstore.go#L63-L96
127,429
ipfs/go-ipfs
filestore/fsrefstore.go
DeleteBlock
func (f *FileManager) DeleteBlock(c cid.Cid) error { err := f.ds.Delete(dshelp.CidToDsKey(c)) if err == ds.ErrNotFound { return blockstore.ErrNotFound } return err }
go
func (f *FileManager) DeleteBlock(c cid.Cid) error { err := f.ds.Delete(dshelp.CidToDsKey(c)) if err == ds.ErrNotFound { return blockstore.ErrNotFound } return err }
[ "func", "(", "f", "*", "FileManager", ")", "DeleteBlock", "(", "c", "cid", ".", "Cid", ")", "error", "{", "err", ":=", "f", ".", "ds", ".", "Delete", "(", "dshelp", ".", "CidToDsKey", "(", "c", ")", ")", "\n", "if", "err", "==", "ds", ".", "Err...
// DeleteBlock deletes the reference-block from the underlying // datastore. It does not touch the referenced data.
[ "DeleteBlock", "deletes", "the", "reference", "-", "block", "from", "the", "underlying", "datastore", ".", "It", "does", "not", "touch", "the", "referenced", "data", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/fsrefstore.go#L100-L106
127,430
ipfs/go-ipfs
filestore/fsrefstore.go
GetSize
func (f *FileManager) GetSize(c cid.Cid) (int, error) { dobj, err := f.getDataObj(c) if err != nil { return -1, err } return int(dobj.GetSize_()), nil }
go
func (f *FileManager) GetSize(c cid.Cid) (int, error) { dobj, err := f.getDataObj(c) if err != nil { return -1, err } return int(dobj.GetSize_()), nil }
[ "func", "(", "f", "*", "FileManager", ")", "GetSize", "(", "c", "cid", ".", "Cid", ")", "(", "int", ",", "error", ")", "{", "dobj", ",", "err", ":=", "f", ".", "getDataObj", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "...
// GetSize gets the size of the block from the datastore. // // This method may successfully return the size even if returning the block // would fail because the associated file is no longer available.
[ "GetSize", "gets", "the", "size", "of", "the", "block", "from", "the", "datastore", ".", "This", "method", "may", "successfully", "return", "the", "size", "even", "if", "returning", "the", "block", "would", "fail", "because", "the", "associated", "file", "is...
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/fsrefstore.go#L129-L135
127,431
ipfs/go-ipfs
filestore/fsrefstore.go
readURLDataObj
func (f *FileManager) readURLDataObj(c cid.Cid, d *pb.DataObj) ([]byte, error) { if !f.AllowUrls { return nil, ErrUrlstoreNotEnabled } req, err := http.NewRequest("GET", d.GetFilePath(), nil) if err != nil { return nil, err } req.Header.Add("Range", fmt.Sprintf("bytes=%d-%d", d.GetOffset(), d.GetOffset()+d....
go
func (f *FileManager) readURLDataObj(c cid.Cid, d *pb.DataObj) ([]byte, error) { if !f.AllowUrls { return nil, ErrUrlstoreNotEnabled } req, err := http.NewRequest("GET", d.GetFilePath(), nil) if err != nil { return nil, err } req.Header.Add("Range", fmt.Sprintf("bytes=%d-%d", d.GetOffset(), d.GetOffset()+d....
[ "func", "(", "f", "*", "FileManager", ")", "readURLDataObj", "(", "c", "cid", ".", "Cid", ",", "d", "*", "pb", ".", "DataObj", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "!", "f", ".", "AllowUrls", "{", "return", "nil", ",", "Err...
// reads and verifies the block from URL
[ "reads", "and", "verifies", "the", "block", "from", "URL" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/fsrefstore.go#L210-L251
127,432
ipfs/go-ipfs
filestore/fsrefstore.go
Has
func (f *FileManager) Has(c cid.Cid) (bool, error) { // NOTE: interesting thing to consider. Has doesnt validate the data. // So the data on disk could be invalid, and we could think we have it. dsk := dshelp.CidToDsKey(c) return f.ds.Has(dsk) }
go
func (f *FileManager) Has(c cid.Cid) (bool, error) { // NOTE: interesting thing to consider. Has doesnt validate the data. // So the data on disk could be invalid, and we could think we have it. dsk := dshelp.CidToDsKey(c) return f.ds.Has(dsk) }
[ "func", "(", "f", "*", "FileManager", ")", "Has", "(", "c", "cid", ".", "Cid", ")", "(", "bool", ",", "error", ")", "{", "// NOTE: interesting thing to consider. Has doesnt validate the data.", "// So the data on disk could be invalid, and we could think we have it.", "dsk"...
// Has returns if the FileManager is storing a block reference. It does not // validate the data, nor checks if the reference is valid.
[ "Has", "returns", "if", "the", "FileManager", "is", "storing", "a", "block", "reference", ".", "It", "does", "not", "validate", "the", "data", "nor", "checks", "if", "the", "reference", "is", "valid", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/fsrefstore.go#L255-L260
127,433
ipfs/go-ipfs
filestore/fsrefstore.go
Put
func (f *FileManager) Put(b *posinfo.FilestoreNode) error { return f.putTo(b, f.ds) }
go
func (f *FileManager) Put(b *posinfo.FilestoreNode) error { return f.putTo(b, f.ds) }
[ "func", "(", "f", "*", "FileManager", ")", "Put", "(", "b", "*", "posinfo", ".", "FilestoreNode", ")", "error", "{", "return", "f", ".", "putTo", "(", "b", ",", "f", ".", "ds", ")", "\n", "}" ]
// Put adds a new reference block to the FileManager. It does not check // that the reference is valid.
[ "Put", "adds", "a", "new", "reference", "block", "to", "the", "FileManager", ".", "It", "does", "not", "check", "that", "the", "reference", "is", "valid", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/fsrefstore.go#L268-L270
127,434
ipfs/go-ipfs
core/coreapi/path.go
ResolvePath
func (api *CoreAPI) ResolvePath(ctx context.Context, p path.Path) (path.Resolved, error) { if _, ok := p.(path.Resolved); ok { return p.(path.Resolved), nil } if err := p.IsValid(); err != nil { return nil, err } ipath := ipfspath.Path(p.String()) ipath, err := resolve.ResolveIPNS(ctx, api.namesys, ipath) i...
go
func (api *CoreAPI) ResolvePath(ctx context.Context, p path.Path) (path.Resolved, error) { if _, ok := p.(path.Resolved); ok { return p.(path.Resolved), nil } if err := p.IsValid(); err != nil { return nil, err } ipath := ipfspath.Path(p.String()) ipath, err := resolve.ResolveIPNS(ctx, api.namesys, ipath) i...
[ "func", "(", "api", "*", "CoreAPI", ")", "ResolvePath", "(", "ctx", "context", ".", "Context", ",", "p", "path", ".", "Path", ")", "(", "path", ".", "Resolved", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "p", ".", "(", "path", ".", "Re...
// ResolvePath resolves the path `p` using Unixfs resolver, returns the // resolved path.
[ "ResolvePath", "resolves", "the", "path", "p", "using", "Unixfs", "resolver", "returns", "the", "resolved", "path", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/path.go#L36-L79
127,435
ipfs/go-ipfs
core/node/ipns.go
RecordValidator
func RecordValidator(ps peerstore.Peerstore) record.Validator { return record.NamespacedValidator{ "pk": record.PublicKeyValidator{}, "ipns": ipns.Validator{KeyBook: ps}, } }
go
func RecordValidator(ps peerstore.Peerstore) record.Validator { return record.NamespacedValidator{ "pk": record.PublicKeyValidator{}, "ipns": ipns.Validator{KeyBook: ps}, } }
[ "func", "RecordValidator", "(", "ps", "peerstore", ".", "Peerstore", ")", "record", ".", "Validator", "{", "return", "record", ".", "NamespacedValidator", "{", "\"", "\"", ":", "record", ".", "PublicKeyValidator", "{", "}", ",", "\"", "\"", ":", "ipns", "....
// RecordValidator provides namesys compatible routing record validator
[ "RecordValidator", "provides", "namesys", "compatible", "routing", "record", "validator" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/ipns.go#L22-L27
127,436
ipfs/go-ipfs
core/node/ipns.go
Namesys
func Namesys(cacheSize int) func(rt routing.IpfsRouting, repo repo.Repo) (namesys.NameSystem, error) { return func(rt routing.IpfsRouting, repo repo.Repo) (namesys.NameSystem, error) { return namesys.NewNameSystem(rt, repo.Datastore(), cacheSize), nil } }
go
func Namesys(cacheSize int) func(rt routing.IpfsRouting, repo repo.Repo) (namesys.NameSystem, error) { return func(rt routing.IpfsRouting, repo repo.Repo) (namesys.NameSystem, error) { return namesys.NewNameSystem(rt, repo.Datastore(), cacheSize), nil } }
[ "func", "Namesys", "(", "cacheSize", "int", ")", "func", "(", "rt", "routing", ".", "IpfsRouting", ",", "repo", "repo", ".", "Repo", ")", "(", "namesys", ".", "NameSystem", ",", "error", ")", "{", "return", "func", "(", "rt", "routing", ".", "IpfsRouti...
// Namesys creates new name system
[ "Namesys", "creates", "new", "name", "system" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/ipns.go#L30-L34
127,437
ipfs/go-ipfs
core/node/ipns.go
IpnsRepublisher
func IpnsRepublisher(repubPeriod time.Duration, recordLifetime time.Duration) func(lcProcess, namesys.NameSystem, repo.Repo, crypto.PrivKey) error { return func(lc lcProcess, namesys namesys.NameSystem, repo repo.Repo, privKey crypto.PrivKey) error { repub := republisher.NewRepublisher(namesys, repo.Datastore(), pri...
go
func IpnsRepublisher(repubPeriod time.Duration, recordLifetime time.Duration) func(lcProcess, namesys.NameSystem, repo.Repo, crypto.PrivKey) error { return func(lc lcProcess, namesys namesys.NameSystem, repo repo.Repo, privKey crypto.PrivKey) error { repub := republisher.NewRepublisher(namesys, repo.Datastore(), pri...
[ "func", "IpnsRepublisher", "(", "repubPeriod", "time", ".", "Duration", ",", "recordLifetime", "time", ".", "Duration", ")", "func", "(", "lcProcess", ",", "namesys", ".", "NameSystem", ",", "repo", ".", "Repo", ",", "crypto", ".", "PrivKey", ")", "error", ...
// IpnsRepublisher runs new IPNS republisher service
[ "IpnsRepublisher", "runs", "new", "IPNS", "republisher", "service" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/ipns.go#L37-L56
127,438
ipfs/go-ipfs
core/node/provider.go
ProviderQueue
func ProviderQueue(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo) (*provider.Queue, error) { return provider.NewQueue(helpers.LifecycleCtx(mctx, lc), "provider-v1", repo.Datastore()) }
go
func ProviderQueue(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo) (*provider.Queue, error) { return provider.NewQueue(helpers.LifecycleCtx(mctx, lc), "provider-v1", repo.Datastore()) }
[ "func", "ProviderQueue", "(", "mctx", "helpers", ".", "MetricsCtx", ",", "lc", "fx", ".", "Lifecycle", ",", "repo", "repo", ".", "Repo", ")", "(", "*", "provider", ".", "Queue", ",", "error", ")", "{", "return", "provider", ".", "NewQueue", "(", "helpe...
// ProviderQueue creates new datastore backed provider queue
[ "ProviderQueue", "creates", "new", "datastore", "backed", "provider", "queue" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/provider.go#L19-L21
127,439
ipfs/go-ipfs
core/node/provider.go
ProviderCtor
func ProviderCtor(mctx helpers.MetricsCtx, lc fx.Lifecycle, queue *provider.Queue, rt routing.IpfsRouting) provider.Provider { p := provider.NewProvider(helpers.LifecycleCtx(mctx, lc), queue, rt) lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { p.Run() return nil }, OnStop: func(ctx context....
go
func ProviderCtor(mctx helpers.MetricsCtx, lc fx.Lifecycle, queue *provider.Queue, rt routing.IpfsRouting) provider.Provider { p := provider.NewProvider(helpers.LifecycleCtx(mctx, lc), queue, rt) lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { p.Run() return nil }, OnStop: func(ctx context....
[ "func", "ProviderCtor", "(", "mctx", "helpers", ".", "MetricsCtx", ",", "lc", "fx", ".", "Lifecycle", ",", "queue", "*", "provider", ".", "Queue", ",", "rt", "routing", ".", "IpfsRouting", ")", "provider", ".", "Provider", "{", "p", ":=", "provider", "."...
// ProviderCtor creates new record provider
[ "ProviderCtor", "creates", "new", "record", "provider" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/provider.go#L24-L38
127,440
ipfs/go-ipfs
core/node/provider.go
ReproviderCtor
func ReproviderCtor(reproviderInterval time.Duration) func(helpers.MetricsCtx, fx.Lifecycle, routing.IpfsRouting, reprovide.KeyChanFunc) (*reprovide.Reprovider, error) { return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, rt routing.IpfsRouting, keyProvider reprovide.KeyChanFunc) (*reprovide.Reprovider, error) { r...
go
func ReproviderCtor(reproviderInterval time.Duration) func(helpers.MetricsCtx, fx.Lifecycle, routing.IpfsRouting, reprovide.KeyChanFunc) (*reprovide.Reprovider, error) { return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, rt routing.IpfsRouting, keyProvider reprovide.KeyChanFunc) (*reprovide.Reprovider, error) { r...
[ "func", "ReproviderCtor", "(", "reproviderInterval", "time", ".", "Duration", ")", "func", "(", "helpers", ".", "MetricsCtx", ",", "fx", ".", "Lifecycle", ",", "routing", ".", "IpfsRouting", ",", "reprovide", ".", "KeyChanFunc", ")", "(", "*", "reprovide", "...
// ReproviderCtor creates new reprovider
[ "ReproviderCtor", "creates", "new", "reprovider" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/provider.go#L41-L45
127,441
ipfs/go-ipfs
core/node/provider.go
Reprovider
func Reprovider(lp lcProcess, reprovider *reprovide.Reprovider) error { lp.Append(reprovider.Run) return nil }
go
func Reprovider(lp lcProcess, reprovider *reprovide.Reprovider) error { lp.Append(reprovider.Run) return nil }
[ "func", "Reprovider", "(", "lp", "lcProcess", ",", "reprovider", "*", "reprovide", ".", "Reprovider", ")", "error", "{", "lp", ".", "Append", "(", "reprovider", ".", "Run", ")", "\n", "return", "nil", "\n", "}" ]
// Reprovider runs the reprovider service
[ "Reprovider", "runs", "the", "reprovider", "service" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/provider.go#L48-L51
127,442
ipfs/go-ipfs
p2p/p2p.go
New
func New(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *P2P { return &P2P{ identity: identity, peerHost: peerHost, peerstore: peerstore, ListenersLocal: newListenersLocal(), ListenersP2P: newListenersP2P(peerHost), Streams: &StreamRegistry{ Streams: map[uint64]*Stream{},...
go
func New(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *P2P { return &P2P{ identity: identity, peerHost: peerHost, peerstore: peerstore, ListenersLocal: newListenersLocal(), ListenersP2P: newListenersP2P(peerHost), Streams: &StreamRegistry{ Streams: map[uint64]*Stream{},...
[ "func", "New", "(", "identity", "peer", ".", "ID", ",", "peerHost", "p2phost", ".", "Host", ",", "peerstore", "pstore", ".", "Peerstore", ")", "*", "P2P", "{", "return", "&", "P2P", "{", "identity", ":", "identity", ",", "peerHost", ":", "peerHost", ",...
// New creates new P2P struct
[ "New", "creates", "new", "P2P", "struct" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/p2p/p2p.go#L24-L39
127,443
ipfs/go-ipfs
p2p/p2p.go
CheckProtoExists
func (p2p *P2P) CheckProtoExists(proto string) bool { protos := p2p.peerHost.Mux().Protocols() for _, p := range protos { if p != proto { continue } return true } return false }
go
func (p2p *P2P) CheckProtoExists(proto string) bool { protos := p2p.peerHost.Mux().Protocols() for _, p := range protos { if p != proto { continue } return true } return false }
[ "func", "(", "p2p", "*", "P2P", ")", "CheckProtoExists", "(", "proto", "string", ")", "bool", "{", "protos", ":=", "p2p", ".", "peerHost", ".", "Mux", "(", ")", ".", "Protocols", "(", ")", "\n\n", "for", "_", ",", "p", ":=", "range", "protos", "{",...
// CheckProtoExists checks whether a proto handler is registered to // mux handler
[ "CheckProtoExists", "checks", "whether", "a", "proto", "handler", "is", "registered", "to", "mux", "handler" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/p2p/p2p.go#L43-L53
127,444
ipfs/go-ipfs
core/commands/cmdenv/env.go
GetNode
func GetNode(env interface{}) (*core.IpfsNode, error) { ctx, ok := env.(*commands.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) } return ctx.GetNode() }
go
func GetNode(env interface{}) (*core.IpfsNode, error) { ctx, ok := env.(*commands.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) } return ctx.GetNode() }
[ "func", "GetNode", "(", "env", "interface", "{", "}", ")", "(", "*", "core", ".", "IpfsNode", ",", "error", ")", "{", "ctx", ",", "ok", ":=", "env", ".", "(", "*", "commands", ".", "Context", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",...
// GetNode extracts the node from the environment.
[ "GetNode", "extracts", "the", "node", "from", "the", "environment", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/cmdenv/env.go#L20-L27
127,445
ipfs/go-ipfs
core/commands/cmdenv/env.go
GetApi
func GetApi(env cmds.Environment, req *cmds.Request) (coreiface.CoreAPI, error) { ctx, ok := env.(*commands.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) } offline, _ := req.Options["offline"].(bool) if !offline { offline, _ = req.Options["local"].(bool) if offl...
go
func GetApi(env cmds.Environment, req *cmds.Request) (coreiface.CoreAPI, error) { ctx, ok := env.(*commands.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) } offline, _ := req.Options["offline"].(bool) if !offline { offline, _ = req.Options["local"].(bool) if offl...
[ "func", "GetApi", "(", "env", "cmds", ".", "Environment", ",", "req", "*", "cmds", ".", "Request", ")", "(", "coreiface", ".", "CoreAPI", ",", "error", ")", "{", "ctx", ",", "ok", ":=", "env", ".", "(", "*", "commands", ".", "Context", ")", "\n", ...
// GetApi extracts CoreAPI instance from the environment.
[ "GetApi", "extracts", "CoreAPI", "instance", "from", "the", "environment", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/cmdenv/env.go#L30-L52
127,446
ipfs/go-ipfs
core/commands/cmdenv/env.go
GetConfig
func GetConfig(env cmds.Environment) (*config.Config, error) { ctx, ok := env.(*commands.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) } return ctx.GetConfig() }
go
func GetConfig(env cmds.Environment) (*config.Config, error) { ctx, ok := env.(*commands.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) } return ctx.GetConfig() }
[ "func", "GetConfig", "(", "env", "cmds", ".", "Environment", ")", "(", "*", "config", ".", "Config", ",", "error", ")", "{", "ctx", ",", "ok", ":=", "env", ".", "(", "*", "commands", ".", "Context", ")", "\n", "if", "!", "ok", "{", "return", "nil...
// GetConfig extracts the config from the environment.
[ "GetConfig", "extracts", "the", "config", "from", "the", "environment", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/cmdenv/env.go#L55-L62
127,447
ipfs/go-ipfs
core/commands/cmdenv/env.go
GetConfigRoot
func GetConfigRoot(env cmds.Environment) (string, error) { ctx, ok := env.(*commands.Context) if !ok { return "", fmt.Errorf("expected env to be of type %T, got %T", ctx, env) } return ctx.ConfigRoot, nil }
go
func GetConfigRoot(env cmds.Environment) (string, error) { ctx, ok := env.(*commands.Context) if !ok { return "", fmt.Errorf("expected env to be of type %T, got %T", ctx, env) } return ctx.ConfigRoot, nil }
[ "func", "GetConfigRoot", "(", "env", "cmds", ".", "Environment", ")", "(", "string", ",", "error", ")", "{", "ctx", ",", "ok", ":=", "env", ".", "(", "*", "commands", ".", "Context", ")", "\n", "if", "!", "ok", "{", "return", "\"", "\"", ",", "fm...
// GetConfigRoot extracts the config root from the environment
[ "GetConfigRoot", "extracts", "the", "config", "root", "from", "the", "environment" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/cmdenv/env.go#L65-L72
127,448
ipfs/go-ipfs
core/commands/pin.go
Format
func (r PinVerifyRes) Format(out io.Writer) { if r.Ok { fmt.Fprintf(out, "%s ok\n", r.Cid) } else { fmt.Fprintf(out, "%s broken\n", r.Cid) for _, e := range r.BadNodes { fmt.Fprintf(out, " %s: %s\n", e.Cid, e.Err) } } }
go
func (r PinVerifyRes) Format(out io.Writer) { if r.Ok { fmt.Fprintf(out, "%s ok\n", r.Cid) } else { fmt.Fprintf(out, "%s broken\n", r.Cid) for _, e := range r.BadNodes { fmt.Fprintf(out, " %s: %s\n", e.Cid, e.Err) } } }
[ "func", "(", "r", "PinVerifyRes", ")", "Format", "(", "out", "io", ".", "Writer", ")", "{", "if", "r", ".", "Ok", "{", "fmt", ".", "Fprintf", "(", "out", ",", "\"", "\\n", "\"", ",", "r", ".", "Cid", ")", "\n", "}", "else", "{", "fmt", ".", ...
// Format formats PinVerifyRes
[ "Format", "formats", "PinVerifyRes" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/pin.go#L661-L670
127,449
ipfs/go-ipfs
cmd/seccat/seccat.go
Listen
func Listen(localAddr string) (net.Conn, error) { l, err := net.Listen("tcp", localAddr) if err != nil { return nil, err } out("listening at %s", l.Addr()) c, err := l.Accept() if err != nil { return nil, err } out("accepted connection from %s", c.RemoteAddr()) // done with listener l.Close() return c...
go
func Listen(localAddr string) (net.Conn, error) { l, err := net.Listen("tcp", localAddr) if err != nil { return nil, err } out("listening at %s", l.Addr()) c, err := l.Accept() if err != nil { return nil, err } out("accepted connection from %s", c.RemoteAddr()) // done with listener l.Close() return c...
[ "func", "Listen", "(", "localAddr", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "l", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "localAddr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// Listen listens and accepts one incoming UDT connection on a given port, // and pipes all incoming data to os.Stdout.
[ "Listen", "listens", "and", "accepts", "one", "incoming", "UDT", "connection", "on", "a", "given", "port", "and", "pipes", "all", "incoming", "data", "to", "os", ".", "Stdout", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/seccat/seccat.go#L181-L198
127,450
ipfs/go-ipfs
namesys/dns.go
resolveOnceAsync
func (r *DNSResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult { var fqdn string out := make(chan onceResult, 1) segments := strings.SplitN(name, "/", 2) domain := segments[0] if !isd.IsDomain(domain) { out <- onceResult{err: errors.New("not a valid domain n...
go
func (r *DNSResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult { var fqdn string out := make(chan onceResult, 1) segments := strings.SplitN(name, "/", 2) domain := segments[0] if !isd.IsDomain(domain) { out <- onceResult{err: errors.New("not a valid domain n...
[ "func", "(", "r", "*", "DNSResolver", ")", "resolveOnceAsync", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "options", "opts", ".", "ResolveOpts", ")", "<-", "chan", "onceResult", "{", "var", "fqdn", "string", "\n", "out", ":=", "ma...
// resolveOnce implements resolver. // TXT records for a given domain name should contain a b58 // encoded multihash.
[ "resolveOnce", "implements", "resolver", ".", "TXT", "records", "for", "a", "given", "domain", "name", "should", "contain", "a", "b58", "encoded", "multihash", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/dns.go#L46-L111
127,451
ipfs/go-ipfs
commands/context.go
GetConfig
func (c *Context) GetConfig() (*config.Config, error) { var err error if c.config == nil { if c.LoadConfig == nil { return nil, errors.New("nil LoadConfig function") } c.config, err = c.LoadConfig(c.ConfigRoot) } return c.config, err }
go
func (c *Context) GetConfig() (*config.Config, error) { var err error if c.config == nil { if c.LoadConfig == nil { return nil, errors.New("nil LoadConfig function") } c.config, err = c.LoadConfig(c.ConfigRoot) } return c.config, err }
[ "func", "(", "c", "*", "Context", ")", "GetConfig", "(", ")", "(", "*", "config", ".", "Config", ",", "error", ")", "{", "var", "err", "error", "\n", "if", "c", ".", "config", "==", "nil", "{", "if", "c", ".", "LoadConfig", "==", "nil", "{", "r...
// GetConfig returns the config of the current Command execution // context. It may load it with the provided function.
[ "GetConfig", "returns", "the", "config", "of", "the", "current", "Command", "execution", "context", ".", "It", "may", "load", "it", "with", "the", "provided", "function", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/context.go#L40-L49
127,452
ipfs/go-ipfs
commands/context.go
GetNode
func (c *Context) GetNode() (*core.IpfsNode, error) { var err error if c.node == nil { if c.ConstructNode == nil { return nil, errors.New("nil ConstructNode function") } c.node, err = c.ConstructNode() } return c.node, err }
go
func (c *Context) GetNode() (*core.IpfsNode, error) { var err error if c.node == nil { if c.ConstructNode == nil { return nil, errors.New("nil ConstructNode function") } c.node, err = c.ConstructNode() } return c.node, err }
[ "func", "(", "c", "*", "Context", ")", "GetNode", "(", ")", "(", "*", "core", ".", "IpfsNode", ",", "error", ")", "{", "var", "err", "error", "\n", "if", "c", ".", "node", "==", "nil", "{", "if", "c", ".", "ConstructNode", "==", "nil", "{", "re...
// GetNode returns the node of the current Command execution // context. It may construct it with the provided function.
[ "GetNode", "returns", "the", "node", "of", "the", "current", "Command", "execution", "context", ".", "It", "may", "construct", "it", "with", "the", "provided", "function", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/context.go#L53-L62
127,453
ipfs/go-ipfs
commands/context.go
GetAPI
func (c *Context) GetAPI() (coreiface.CoreAPI, error) { if c.api == nil { n, err := c.GetNode() if err != nil { return nil, err } fetchBlocks := true if c.Gateway { cfg, err := c.GetConfig() if err != nil { return nil, err } fetchBlocks = !cfg.Gateway.NoFetch } c.api, err = coreapi.Ne...
go
func (c *Context) GetAPI() (coreiface.CoreAPI, error) { if c.api == nil { n, err := c.GetNode() if err != nil { return nil, err } fetchBlocks := true if c.Gateway { cfg, err := c.GetConfig() if err != nil { return nil, err } fetchBlocks = !cfg.Gateway.NoFetch } c.api, err = coreapi.Ne...
[ "func", "(", "c", "*", "Context", ")", "GetAPI", "(", ")", "(", "coreiface", ".", "CoreAPI", ",", "error", ")", "{", "if", "c", ".", "api", "==", "nil", "{", "n", ",", "err", ":=", "c", ".", "GetNode", "(", ")", "\n", "if", "err", "!=", "nil"...
// GetAPI returns CoreAPI instance backed by ipfs node. // It may construct the node with the provided function
[ "GetAPI", "returns", "CoreAPI", "instance", "backed", "by", "ipfs", "node", ".", "It", "may", "construct", "the", "node", "with", "the", "provided", "function" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/context.go#L66-L87
127,454
ipfs/go-ipfs
commands/context.go
Context
func (c *Context) Context() context.Context { n, err := c.GetNode() if err != nil { log.Debug("error getting node: ", err) return context.Background() } return n.Context() }
go
func (c *Context) Context() context.Context { n, err := c.GetNode() if err != nil { log.Debug("error getting node: ", err) return context.Background() } return n.Context() }
[ "func", "(", "c", "*", "Context", ")", "Context", "(", ")", "context", ".", "Context", "{", "n", ",", "err", ":=", "c", ".", "GetNode", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Debug", "(", "\"", "\"", ",", "err", ")", "\n"...
// Context returns the node's context.
[ "Context", "returns", "the", "node", "s", "context", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/context.go#L90-L98
127,455
ipfs/go-ipfs
commands/context.go
LogRequest
func (c *Context) LogRequest(req *cmds.Request) func() { rle := &ReqLogEntry{ StartTime: time.Now(), Active: true, Command: strings.Join(req.Path, "/"), Options: req.Options, Args: req.Arguments, ID: c.ReqLog.nextID, log: c.ReqLog, } c.ReqLog.AddEntry(rle) return func() { c...
go
func (c *Context) LogRequest(req *cmds.Request) func() { rle := &ReqLogEntry{ StartTime: time.Now(), Active: true, Command: strings.Join(req.Path, "/"), Options: req.Options, Args: req.Arguments, ID: c.ReqLog.nextID, log: c.ReqLog, } c.ReqLog.AddEntry(rle) return func() { c...
[ "func", "(", "c", "*", "Context", ")", "LogRequest", "(", "req", "*", "cmds", ".", "Request", ")", "func", "(", ")", "{", "rle", ":=", "&", "ReqLogEntry", "{", "StartTime", ":", "time", ".", "Now", "(", ")", ",", "Active", ":", "true", ",", "Comm...
// LogRequest adds the passed request to the request log and // returns a function that should be called when the request // lifetime is over.
[ "LogRequest", "adds", "the", "passed", "request", "to", "the", "request", "log", "and", "returns", "a", "function", "that", "should", "be", "called", "when", "the", "request", "lifetime", "is", "over", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/context.go#L103-L118
127,456
ipfs/go-ipfs
commands/context.go
Close
func (c *Context) Close() { // let's not forget teardown. If a node was initialized, we must close it. // Note that this means the underlying req.Context().Node variable is exposed. // this is gross, and should be changed when we extract out the exec Context. if c.node != nil { log.Info("Shutting down node...") ...
go
func (c *Context) Close() { // let's not forget teardown. If a node was initialized, we must close it. // Note that this means the underlying req.Context().Node variable is exposed. // this is gross, and should be changed when we extract out the exec Context. if c.node != nil { log.Info("Shutting down node...") ...
[ "func", "(", "c", "*", "Context", ")", "Close", "(", ")", "{", "// let's not forget teardown. If a node was initialized, we must close it.", "// Note that this means the underlying req.Context().Node variable is exposed.", "// this is gross, and should be changed when we extract out the exec...
// Close cleans up the application state.
[ "Close", "cleans", "up", "the", "application", "state", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/context.go#L121-L129
127,457
ipfs/go-ipfs
core/node/helpers/helpers.go
LifecycleCtx
func LifecycleCtx(mctx MetricsCtx, lc fx.Lifecycle) context.Context { ctx, cancel := context.WithCancel(mctx) lc.Append(fx.Hook{ OnStop: func(_ context.Context) error { cancel() return nil }, }) return ctx }
go
func LifecycleCtx(mctx MetricsCtx, lc fx.Lifecycle) context.Context { ctx, cancel := context.WithCancel(mctx) lc.Append(fx.Hook{ OnStop: func(_ context.Context) error { cancel() return nil }, }) return ctx }
[ "func", "LifecycleCtx", "(", "mctx", "MetricsCtx", ",", "lc", "fx", ".", "Lifecycle", ")", "context", ".", "Context", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "mctx", ")", "\n", "lc", ".", "Append", "(", "fx", ".", "Hook", ...
// LifecycleCtx creates a context which will be cancelled when lifecycle stops // // This is a hack which we need because most of our services use contexts in a // wrong way
[ "LifecycleCtx", "creates", "a", "context", "which", "will", "be", "cancelled", "when", "lifecycle", "stops", "This", "is", "a", "hack", "which", "we", "need", "because", "most", "of", "our", "services", "use", "contexts", "in", "a", "wrong", "way" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/helpers/helpers.go#L14-L23
127,458
ipfs/go-ipfs
cmd/ipfs/util/ulimit.go
setMaxFds
func setMaxFds() { // check if the IPFS_FD_MAX is set up and if it does // not have a valid fds number notify the user if val := os.Getenv("IPFS_FD_MAX"); val != "" { fds, err := strconv.ParseUint(val, 10, 64) if err != nil { log.Errorf("bad value for IPFS_FD_MAX: %s", err) return } maxFds = fds } }
go
func setMaxFds() { // check if the IPFS_FD_MAX is set up and if it does // not have a valid fds number notify the user if val := os.Getenv("IPFS_FD_MAX"); val != "" { fds, err := strconv.ParseUint(val, 10, 64) if err != nil { log.Errorf("bad value for IPFS_FD_MAX: %s", err) return } maxFds = fds } }
[ "func", "setMaxFds", "(", ")", "{", "// check if the IPFS_FD_MAX is set up and if it does", "// not have a valid fds number notify the user", "if", "val", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", ";", "val", "!=", "\"", "\"", "{", "fds", ",", "err", ":=", ...
// setMaxFds sets the maxFds value from IPFS_FD_MAX // env variable if it's present on the system
[ "setMaxFds", "sets", "the", "maxFds", "value", "from", "IPFS_FD_MAX", "env", "variable", "if", "it", "s", "present", "on", "the", "system" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/ipfs/util/ulimit.go#L31-L44
127,459
ipfs/go-ipfs
cmd/ipfs/util/ulimit.go
ManageFdLimit
func ManageFdLimit() (changed bool, newLimit uint64, err error) { if !supportsFDManagement { return false, 0, nil } setMaxFds() soft, hard, err := getLimit() if err != nil { return false, 0, err } if maxFds <= soft { return false, 0, nil } // the soft limit is the value that the kernel enforces for th...
go
func ManageFdLimit() (changed bool, newLimit uint64, err error) { if !supportsFDManagement { return false, 0, nil } setMaxFds() soft, hard, err := getLimit() if err != nil { return false, 0, err } if maxFds <= soft { return false, 0, nil } // the soft limit is the value that the kernel enforces for th...
[ "func", "ManageFdLimit", "(", ")", "(", "changed", "bool", ",", "newLimit", "uint64", ",", "err", "error", ")", "{", "if", "!", "supportsFDManagement", "{", "return", "false", ",", "0", ",", "nil", "\n", "}", "\n\n", "setMaxFds", "(", ")", "\n", "soft"...
// ManageFdLimit raise the current max file descriptor count // of the process based on the IPFS_FD_MAX value
[ "ManageFdLimit", "raise", "the", "current", "max", "file", "descriptor", "count", "of", "the", "process", "based", "on", "the", "IPFS_FD_MAX", "value" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/ipfs/util/ulimit.go#L48-L87
127,460
ipfs/go-ipfs
fuse/ipns/common.go
InitializeKeyspace
func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error { ctx, cancel := context.WithCancel(n.Context()) defer cancel() emptyDir := ft.EmptyDirNode() err := n.Pinning.Pin(ctx, emptyDir, false) if err != nil { return err } err = n.Pinning.Flush() if err != nil { return err } pub := nsys.NewIpns...
go
func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error { ctx, cancel := context.WithCancel(n.Context()) defer cancel() emptyDir := ft.EmptyDirNode() err := n.Pinning.Pin(ctx, emptyDir, false) if err != nil { return err } err = n.Pinning.Flush() if err != nil { return err } pub := nsys.NewIpns...
[ "func", "InitializeKeyspace", "(", "n", "*", "core", ".", "IpfsNode", ",", "key", "ci", ".", "PrivKey", ")", "error", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "n", ".", "Context", "(", ")", ")", "\n", "defer", "cancel", "("...
// InitializeKeyspace sets the ipns record for the given key to // point to an empty directory.
[ "InitializeKeyspace", "sets", "the", "ipns", "record", "for", "the", "given", "key", "to", "point", "to", "an", "empty", "directory", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/ipns/common.go#L15-L34
127,461
ipfs/go-ipfs
p2p/remote.go
ForwardRemote
func (p2p *P2P) ForwardRemote(ctx context.Context, proto protocol.ID, addr ma.Multiaddr, reportRemote bool) (Listener, error) { listener := &remoteListener{ p2p: p2p, proto: proto, addr: addr, reportRemote: reportRemote, } if err := p2p.ListenersP2P.Register(listener); err != nil { return nil, err } ...
go
func (p2p *P2P) ForwardRemote(ctx context.Context, proto protocol.ID, addr ma.Multiaddr, reportRemote bool) (Listener, error) { listener := &remoteListener{ p2p: p2p, proto: proto, addr: addr, reportRemote: reportRemote, } if err := p2p.ListenersP2P.Register(listener); err != nil { return nil, err } ...
[ "func", "(", "p2p", "*", "P2P", ")", "ForwardRemote", "(", "ctx", "context", ".", "Context", ",", "proto", "protocol", ".", "ID", ",", "addr", "ma", ".", "Multiaddr", ",", "reportRemote", "bool", ")", "(", "Listener", ",", "error", ")", "{", "listener"...
// ForwardRemote creates new p2p listener
[ "ForwardRemote", "creates", "new", "p2p", "listener" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/p2p/remote.go#L31-L46
127,462
ipfs/go-ipfs
commands/reqlog.go
Copy
func (r *ReqLogEntry) Copy() *ReqLogEntry { out := *r out.log = nil return &out }
go
func (r *ReqLogEntry) Copy() *ReqLogEntry { out := *r out.log = nil return &out }
[ "func", "(", "r", "*", "ReqLogEntry", ")", "Copy", "(", ")", "*", "ReqLogEntry", "{", "out", ":=", "*", "r", "\n", "out", ".", "log", "=", "nil", "\n", "return", "&", "out", "\n", "}" ]
// Copy returns a copy of the ReqLogEntry
[ "Copy", "returns", "a", "copy", "of", "the", "ReqLogEntry" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/reqlog.go#L22-L26
127,463
ipfs/go-ipfs
commands/reqlog.go
AddEntry
func (rl *ReqLog) AddEntry(rle *ReqLogEntry) { rl.lock.Lock() defer rl.lock.Unlock() rl.nextID++ rl.Requests = append(rl.Requests, rle) if rle == nil || !rle.Active { rl.maybeCleanup() } }
go
func (rl *ReqLog) AddEntry(rle *ReqLogEntry) { rl.lock.Lock() defer rl.lock.Unlock() rl.nextID++ rl.Requests = append(rl.Requests, rle) if rle == nil || !rle.Active { rl.maybeCleanup() } }
[ "func", "(", "rl", "*", "ReqLog", ")", "AddEntry", "(", "rle", "*", "ReqLogEntry", ")", "{", "rl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rl", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "rl", ".", "nextID", "++", "\n", "rl", "."...
// AddEntry adds an entry to the log
[ "AddEntry", "adds", "an", "entry", "to", "the", "log" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/reqlog.go#L37-L47
127,464
ipfs/go-ipfs
commands/reqlog.go
ClearInactive
func (rl *ReqLog) ClearInactive() { rl.lock.Lock() defer rl.lock.Unlock() k := rl.keep rl.keep = 0 rl.cleanup() rl.keep = k }
go
func (rl *ReqLog) ClearInactive() { rl.lock.Lock() defer rl.lock.Unlock() k := rl.keep rl.keep = 0 rl.cleanup() rl.keep = k }
[ "func", "(", "rl", "*", "ReqLog", ")", "ClearInactive", "(", ")", "{", "rl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rl", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "k", ":=", "rl", ".", "keep", "\n", "rl", ".", "keep", "=", "0...
// ClearInactive removes stale entries
[ "ClearInactive", "removes", "stale", "entries" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/reqlog.go#L50-L58
127,465
ipfs/go-ipfs
commands/reqlog.go
SetKeepTime
func (rl *ReqLog) SetKeepTime(t time.Duration) { rl.lock.Lock() defer rl.lock.Unlock() rl.keep = t }
go
func (rl *ReqLog) SetKeepTime(t time.Duration) { rl.lock.Lock() defer rl.lock.Unlock() rl.keep = t }
[ "func", "(", "rl", "*", "ReqLog", ")", "SetKeepTime", "(", "t", "time", ".", "Duration", ")", "{", "rl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rl", ".", "lock", ".", "Unlock", "(", ")", "\n", "rl", ".", "keep", "=", "t", "\n", "...
// SetKeepTime sets a duration after which an entry will be considered inactive
[ "SetKeepTime", "sets", "a", "duration", "after", "which", "an", "entry", "will", "be", "considered", "inactive" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/reqlog.go#L82-L86
127,466
ipfs/go-ipfs
commands/reqlog.go
Report
func (rl *ReqLog) Report() []*ReqLogEntry { rl.lock.Lock() defer rl.lock.Unlock() out := make([]*ReqLogEntry, len(rl.Requests)) for i, e := range rl.Requests { out[i] = e.Copy() } return out }
go
func (rl *ReqLog) Report() []*ReqLogEntry { rl.lock.Lock() defer rl.lock.Unlock() out := make([]*ReqLogEntry, len(rl.Requests)) for i, e := range rl.Requests { out[i] = e.Copy() } return out }
[ "func", "(", "rl", "*", "ReqLog", ")", "Report", "(", ")", "[", "]", "*", "ReqLogEntry", "{", "rl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rl", ".", "lock", ".", "Unlock", "(", ")", "\n", "out", ":=", "make", "(", "[", "]", "*", ...
// Report generates a copy of all the entries in the requestlog
[ "Report", "generates", "a", "copy", "of", "all", "the", "entries", "in", "the", "requestlog" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/reqlog.go#L89-L99
127,467
ipfs/go-ipfs
commands/reqlog.go
Finish
func (rl *ReqLog) Finish(rle *ReqLogEntry) { rl.lock.Lock() defer rl.lock.Unlock() rle.Active = false rle.EndTime = time.Now() rl.maybeCleanup() }
go
func (rl *ReqLog) Finish(rle *ReqLogEntry) { rl.lock.Lock() defer rl.lock.Unlock() rle.Active = false rle.EndTime = time.Now() rl.maybeCleanup() }
[ "func", "(", "rl", "*", "ReqLog", ")", "Finish", "(", "rle", "*", "ReqLogEntry", ")", "{", "rl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "rl", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "rle", ".", "Active", "=", "false", "\n", "r...
// Finish marks an entry in the log as finished
[ "Finish", "marks", "an", "entry", "in", "the", "log", "as", "finished" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/commands/reqlog.go#L102-L110
127,468
ipfs/go-ipfs
core/commands/e/error.go
Error
func (err HandlerError) Error() string { return fmt.Sprintf("%s in:\n%s", err.Err.Error(), err.Stack) }
go
func (err HandlerError) Error() string { return fmt.Sprintf("%s in:\n%s", err.Err.Error(), err.Stack) }
[ "func", "(", "err", "HandlerError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "err", ".", "Err", ".", "Error", "(", ")", ",", "err", ".", "Stack", ")", "\n", "}" ]
// Error makes HandlerError implement error
[ "Error", "makes", "HandlerError", "implement", "error" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/e/error.go#L23-L25
127,469
ipfs/go-ipfs
core/commands/e/error.go
New
func New(err error) HandlerError { return HandlerError{Err: err, Stack: debug.Stack()} }
go
func New(err error) HandlerError { return HandlerError{Err: err, Stack: debug.Stack()} }
[ "func", "New", "(", "err", "error", ")", "HandlerError", "{", "return", "HandlerError", "{", "Err", ":", "err", ",", "Stack", ":", "debug", ".", "Stack", "(", ")", "}", "\n", "}" ]
// New returns a new HandlerError
[ "New", "returns", "a", "new", "HandlerError" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/e/error.go#L28-L30
127,470
ipfs/go-ipfs
core/commands/object/object.go
deserializeNode
func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error) { dagnode := new(dag.ProtoNode) switch dataFieldEncoding { case "text": dagnode.SetData([]byte(nd.Data)) case "base64": data, err := base64.StdEncoding.DecodeString(nd.Data) if err != nil { return nil, err } dagnode.SetDat...
go
func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error) { dagnode := new(dag.ProtoNode) switch dataFieldEncoding { case "text": dagnode.SetData([]byte(nd.Data)) case "base64": data, err := base64.StdEncoding.DecodeString(nd.Data) if err != nil { return nil, err } dagnode.SetDat...
[ "func", "deserializeNode", "(", "nd", "*", "Node", ",", "dataFieldEncoding", "string", ")", "(", "*", "dag", ".", "ProtoNode", ",", "error", ")", "{", "dagnode", ":=", "new", "(", "dag", ".", "ProtoNode", ")", "\n", "switch", "dataFieldEncoding", "{", "c...
// converts the Node object into a real dag.ProtoNode
[ "converts", "the", "Node", "object", "into", "a", "real", "dag", ".", "ProtoNode" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/object/object.go#L521-L551
127,471
ipfs/go-ipfs
dagutils/utils.go
NewMemoryDagService
func NewMemoryDagService() ipld.DAGService { // build mem-datastore for editor's intermediary nodes bs := bstore.NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore())) bsrv := bserv.New(bs, offline.Exchange(bs)) return dag.NewDAGService(bsrv) }
go
func NewMemoryDagService() ipld.DAGService { // build mem-datastore for editor's intermediary nodes bs := bstore.NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore())) bsrv := bserv.New(bs, offline.Exchange(bs)) return dag.NewDAGService(bsrv) }
[ "func", "NewMemoryDagService", "(", ")", "ipld", ".", "DAGService", "{", "// build mem-datastore for editor's intermediary nodes", "bs", ":=", "bstore", ".", "NewBlockstore", "(", "syncds", ".", "MutexWrap", "(", "ds", ".", "NewMapDatastore", "(", ")", ")", ")", "...
// NewMemoryDagService returns a new, thread-safe in-memory DAGService.
[ "NewMemoryDagService", "returns", "a", "new", "thread", "-", "safe", "in", "-", "memory", "DAGService", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/utils.go#L33-L38
127,472
ipfs/go-ipfs
dagutils/utils.go
GetNode
func (e *Editor) GetNode() *dag.ProtoNode { return e.root.Copy().(*dag.ProtoNode) }
go
func (e *Editor) GetNode() *dag.ProtoNode { return e.root.Copy().(*dag.ProtoNode) }
[ "func", "(", "e", "*", "Editor", ")", "GetNode", "(", ")", "*", "dag", ".", "ProtoNode", "{", "return", "e", ".", "root", ".", "Copy", "(", ")", ".", "(", "*", "dag", ".", "ProtoNode", ")", "\n", "}" ]
// GetNode returns the a copy of the root node being edited.
[ "GetNode", "returns", "the", "a", "copy", "of", "the", "root", "node", "being", "edited", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/utils.go#L53-L55
127,473
ipfs/go-ipfs
dagutils/utils.go
InsertNodeAtPath
func (e *Editor) InsertNodeAtPath(ctx context.Context, pth string, toinsert ipld.Node, create func() *dag.ProtoNode) error { splpath := path.SplitList(pth) nd, err := e.insertNodeAtPath(ctx, e.root, splpath, toinsert, create) if err != nil { return err } e.root = nd return nil }
go
func (e *Editor) InsertNodeAtPath(ctx context.Context, pth string, toinsert ipld.Node, create func() *dag.ProtoNode) error { splpath := path.SplitList(pth) nd, err := e.insertNodeAtPath(ctx, e.root, splpath, toinsert, create) if err != nil { return err } e.root = nd return nil }
[ "func", "(", "e", "*", "Editor", ")", "InsertNodeAtPath", "(", "ctx", "context", ".", "Context", ",", "pth", "string", ",", "toinsert", "ipld", ".", "Node", ",", "create", "func", "(", ")", "*", "dag", ".", "ProtoNode", ")", "error", "{", "splpath", ...
// InsertNodeAtPath inserts a new node in the tree and replaces the current root with the new one.
[ "InsertNodeAtPath", "inserts", "a", "new", "node", "in", "the", "tree", "and", "replaces", "the", "current", "root", "with", "the", "new", "one", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/utils.go#L89-L97
127,474
ipfs/go-ipfs
dagutils/utils.go
RmLink
func (e *Editor) RmLink(ctx context.Context, pth string) error { splpath := path.SplitList(pth) nd, err := e.rmLink(ctx, e.root, splpath) if err != nil { return err } e.root = nd return nil }
go
func (e *Editor) RmLink(ctx context.Context, pth string) error { splpath := path.SplitList(pth) nd, err := e.rmLink(ctx, e.root, splpath) if err != nil { return err } e.root = nd return nil }
[ "func", "(", "e", "*", "Editor", ")", "RmLink", "(", "ctx", "context", ".", "Context", ",", "pth", "string", ")", "error", "{", "splpath", ":=", "path", ".", "SplitList", "(", "pth", ")", "\n", "nd", ",", "err", ":=", "e", ".", "rmLink", "(", "ct...
// RmLink removes the link with the given name and updates the root node of // the editor.
[ "RmLink", "removes", "the", "link", "with", "the", "given", "name", "and", "updates", "the", "root", "node", "of", "the", "editor", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/utils.go#L145-L153
127,475
ipfs/go-ipfs
dagutils/utils.go
Finalize
func (e *Editor) Finalize(ctx context.Context, ds ipld.DAGService) (*dag.ProtoNode, error) { nd := e.GetNode() err := copyDag(ctx, nd, e.tmp, ds) return nd, err }
go
func (e *Editor) Finalize(ctx context.Context, ds ipld.DAGService) (*dag.ProtoNode, error) { nd := e.GetNode() err := copyDag(ctx, nd, e.tmp, ds) return nd, err }
[ "func", "(", "e", "*", "Editor", ")", "Finalize", "(", "ctx", "context", ".", "Context", ",", "ds", "ipld", ".", "DAGService", ")", "(", "*", "dag", ".", "ProtoNode", ",", "error", ")", "{", "nd", ":=", "e", ".", "GetNode", "(", ")", "\n", "err",...
// Finalize writes the new DAG to the given DAGService and returns the modified // root node.
[ "Finalize", "writes", "the", "new", "DAG", "to", "the", "given", "DAGService", "and", "returns", "the", "modified", "root", "node", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/utils.go#L204-L208
127,476
ipfs/go-ipfs
core/node/core.go
BlockService
func BlockService(lc fx.Lifecycle, bs blockstore.Blockstore, rem exchange.Interface) blockservice.BlockService { bsvc := blockservice.New(bs, rem) lc.Append(fx.Hook{ OnStop: func(ctx context.Context) error { return bsvc.Close() }, }) return bsvc }
go
func BlockService(lc fx.Lifecycle, bs blockstore.Blockstore, rem exchange.Interface) blockservice.BlockService { bsvc := blockservice.New(bs, rem) lc.Append(fx.Hook{ OnStop: func(ctx context.Context) error { return bsvc.Close() }, }) return bsvc }
[ "func", "BlockService", "(", "lc", "fx", ".", "Lifecycle", ",", "bs", "blockstore", ".", "Blockstore", ",", "rem", "exchange", ".", "Interface", ")", "blockservice", ".", "BlockService", "{", "bsvc", ":=", "blockservice", ".", "New", "(", "bs", ",", "rem",...
// BlockService creates new blockservice which provides an interface to fetch content-addressable blocks
[ "BlockService", "creates", "new", "blockservice", "which", "provides", "an", "interface", "to", "fetch", "content", "-", "addressable", "blocks" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/core.go#L29-L39
127,477
ipfs/go-ipfs
core/node/core.go
Pinning
func Pinning(bstore blockstore.Blockstore, ds format.DAGService, repo repo.Repo) (pin.Pinner, error) { internalDag := merkledag.NewDAGService(blockservice.New(bstore, offline.Exchange(bstore))) pinning, err := pin.LoadPinner(repo.Datastore(), ds, internalDag) if err != nil { // TODO: we should move towards only ru...
go
func Pinning(bstore blockstore.Blockstore, ds format.DAGService, repo repo.Repo) (pin.Pinner, error) { internalDag := merkledag.NewDAGService(blockservice.New(bstore, offline.Exchange(bstore))) pinning, err := pin.LoadPinner(repo.Datastore(), ds, internalDag) if err != nil { // TODO: we should move towards only ru...
[ "func", "Pinning", "(", "bstore", "blockstore", ".", "Blockstore", ",", "ds", "format", ".", "DAGService", ",", "repo", "repo", ".", "Repo", ")", "(", "pin", ".", "Pinner", ",", "error", ")", "{", "internalDag", ":=", "merkledag", ".", "NewDAGService", "...
// Pinning creates new pinner which tells GC which blocks should be kept
[ "Pinning", "creates", "new", "pinner", "which", "tells", "GC", "which", "blocks", "should", "be", "kept" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/core.go#L42-L54
127,478
ipfs/go-ipfs
core/node/core.go
Files
func Files(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGService) (*mfs.Root, error) { dsk := datastore.NewKey("/local/filesroot") pf := func(ctx context.Context, c cid.Cid) error { return repo.Datastore().Put(dsk, c.Bytes()) } var nd *merkledag.ProtoNode val, err := repo.Datastore().G...
go
func Files(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGService) (*mfs.Root, error) { dsk := datastore.NewKey("/local/filesroot") pf := func(ctx context.Context, c cid.Cid) error { return repo.Datastore().Put(dsk, c.Bytes()) } var nd *merkledag.ProtoNode val, err := repo.Datastore().G...
[ "func", "Files", "(", "mctx", "helpers", ".", "MetricsCtx", ",", "lc", "fx", ".", "Lifecycle", ",", "repo", "repo", ".", "Repo", ",", "dag", "format", ".", "DAGService", ")", "(", "*", "mfs", ".", "Root", ",", "error", ")", "{", "dsk", ":=", "datas...
// Files loads persisted MFS root
[ "Files", "loads", "persisted", "MFS", "root" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/core.go#L74-L121
127,479
ipfs/go-ipfs
core/node/storage.go
BaseBlockstoreCtor
func BaseBlockstoreCtor(cacheOpts blockstore.CacheOpts, nilRepo bool, hashOnRead bool) func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) { return func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) { rds := &retrystore.Datastore{ Batchi...
go
func BaseBlockstoreCtor(cacheOpts blockstore.CacheOpts, nilRepo bool, hashOnRead bool) func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) { return func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) { rds := &retrystore.Datastore{ Batchi...
[ "func", "BaseBlockstoreCtor", "(", "cacheOpts", "blockstore", ".", "CacheOpts", ",", "nilRepo", "bool", ",", "hashOnRead", "bool", ")", "func", "(", "mctx", "helpers", ".", "MetricsCtx", ",", "repo", "repo", ".", "Repo", ",", "lc", "fx", ".", "Lifecycle", ...
// BaseBlockstoreCtor creates cached blockstore backed by the provided datastore
[ "BaseBlockstoreCtor", "creates", "cached", "blockstore", "backed", "by", "the", "provided", "datastore" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/storage.go#L45-L81
127,480
ipfs/go-ipfs
core/node/storage.go
GcBlockstoreCtor
func GcBlockstoreCtor(bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, bs blockstore.Blockstore) { gclocker = blockstore.NewGCLocker() gcbs = blockstore.NewGCBlockstore(bb, gclocker) bs = gcbs return }
go
func GcBlockstoreCtor(bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, bs blockstore.Blockstore) { gclocker = blockstore.NewGCLocker() gcbs = blockstore.NewGCBlockstore(bb, gclocker) bs = gcbs return }
[ "func", "GcBlockstoreCtor", "(", "bb", "BaseBlocks", ")", "(", "gclocker", "blockstore", ".", "GCLocker", ",", "gcbs", "blockstore", ".", "GCBlockstore", ",", "bs", "blockstore", ".", "Blockstore", ")", "{", "gclocker", "=", "blockstore", ".", "NewGCLocker", "...
// GcBlockstoreCtor wraps the base blockstore with GC and Filestore layers
[ "GcBlockstoreCtor", "wraps", "the", "base", "blockstore", "with", "GC", "and", "Filestore", "layers" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/storage.go#L84-L90
127,481
ipfs/go-ipfs
core/node/storage.go
FilestoreBlockstoreCtor
func FilestoreBlockstoreCtor(repo repo.Repo, bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, bs blockstore.Blockstore, fstore *filestore.Filestore) { gclocker, gcbs, bs = GcBlockstoreCtor(bb) // hash security fstore = filestore.NewFilestore(bb, repo.FileManager()) gcbs = blockstore.NewG...
go
func FilestoreBlockstoreCtor(repo repo.Repo, bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, bs blockstore.Blockstore, fstore *filestore.Filestore) { gclocker, gcbs, bs = GcBlockstoreCtor(bb) // hash security fstore = filestore.NewFilestore(bb, repo.FileManager()) gcbs = blockstore.NewG...
[ "func", "FilestoreBlockstoreCtor", "(", "repo", "repo", ".", "Repo", ",", "bb", "BaseBlocks", ")", "(", "gclocker", "blockstore", ".", "GCLocker", ",", "gcbs", "blockstore", ".", "GCBlockstore", ",", "bs", "blockstore", ".", "Blockstore", ",", "fstore", "*", ...
// GcBlockstoreCtor wraps GcBlockstore and adds Filestore support
[ "GcBlockstoreCtor", "wraps", "GcBlockstore", "and", "adds", "Filestore", "support" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/storage.go#L93-L103
127,482
ipfs/go-ipfs
core/commands/commands.go
CommandsCmd
func CommandsCmd(root *cmds.Command) *cmds.Command { return &cmds.Command{ Helptext: cmdkit.HelpText{ Tagline: "List all available commands.", ShortDescription: `Lists all available commands (and subcommands) and exits.`, }, Options: []cmdkit.Option{ cmdkit.BoolOption(flagsOptionName, "f", "Sho...
go
func CommandsCmd(root *cmds.Command) *cmds.Command { return &cmds.Command{ Helptext: cmdkit.HelpText{ Tagline: "List all available commands.", ShortDescription: `Lists all available commands (and subcommands) and exits.`, }, Options: []cmdkit.Option{ cmdkit.BoolOption(flagsOptionName, "f", "Sho...
[ "func", "CommandsCmd", "(", "root", "*", "cmds", ".", "Command", ")", "*", "cmds", ".", "Command", "{", "return", "&", "cmds", ".", "Command", "{", "Helptext", ":", "cmdkit", ".", "HelpText", "{", "Tagline", ":", "\"", "\"", ",", "ShortDescription", ":...
// CommandsCmd takes in a root command, // and returns a command that lists the subcommands in that root
[ "CommandsCmd", "takes", "in", "a", "root", "command", "and", "returns", "a", "command", "that", "lists", "the", "subcommands", "in", "that", "root" ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/commands.go#L61-L82
127,483
ipfs/go-ipfs
core/commands/commands.go
streamResult
func streamResult(procVal func(interface{}, io.Writer) nonFatalError) func(cmds.Response, cmds.ResponseEmitter) error { return func(res cmds.Response, re cmds.ResponseEmitter) (err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf("internal error: %v", r) } re.Close() }() var e...
go
func streamResult(procVal func(interface{}, io.Writer) nonFatalError) func(cmds.Response, cmds.ResponseEmitter) error { return func(res cmds.Response, re cmds.ResponseEmitter) (err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf("internal error: %v", r) } re.Close() }() var e...
[ "func", "streamResult", "(", "procVal", "func", "(", "interface", "{", "}", ",", "io", ".", "Writer", ")", "nonFatalError", ")", "func", "(", "cmds", ".", "Response", ",", "cmds", ".", "ResponseEmitter", ")", "error", "{", "return", "func", "(", "res", ...
// streamResult is a helper function to stream results that possibly // contain non-fatal errors. The helper function is allowed to panic // on internal errors.
[ "streamResult", "is", "a", "helper", "function", "to", "stream", "results", "that", "possibly", "contain", "non", "-", "fatal", "errors", ".", "The", "helper", "function", "is", "allowed", "to", "panic", "on", "internal", "errors", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/commands.go#L139-L171
127,484
ipfs/go-ipfs
core/corerepo/gc.go
CollectResult
func CollectResult(ctx context.Context, gcOut <-chan gc.Result, cb func(cid.Cid)) error { var errors []error loop: for { select { case res, ok := <-gcOut: if !ok { break loop } if res.Error != nil { errors = append(errors, res.Error) } else if res.KeyRemoved.Defined() && cb != nil { cb(res...
go
func CollectResult(ctx context.Context, gcOut <-chan gc.Result, cb func(cid.Cid)) error { var errors []error loop: for { select { case res, ok := <-gcOut: if !ok { break loop } if res.Error != nil { errors = append(errors, res.Error) } else if res.KeyRemoved.Defined() && cb != nil { cb(res...
[ "func", "CollectResult", "(", "ctx", "context", ".", "Context", ",", "gcOut", "<-", "chan", "gc", ".", "Result", ",", "cb", "func", "(", "cid", ".", "Cid", ")", ")", "error", "{", "var", "errors", "[", "]", "error", "\n", "loop", ":", "for", "{", ...
// CollectResult collects the output of a garbage collection run and calls the // given callback for each object removed. It also collects all errors into a // MultiError which is returned after the gc is completed.
[ "CollectResult", "collects", "the", "output", "of", "a", "garbage", "collection", "run", "and", "calls", "the", "given", "callback", "for", "each", "object", "removed", ".", "It", "also", "collects", "all", "errors", "into", "a", "MultiError", "which", "is", ...
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/corerepo/gc.go#L99-L127
127,485
ipfs/go-ipfs
core/corerepo/gc.go
NewMultiError
func NewMultiError(errs ...error) *MultiError { return &MultiError{errs[:len(errs)-1], errs[len(errs)-1]} }
go
func NewMultiError(errs ...error) *MultiError { return &MultiError{errs[:len(errs)-1], errs[len(errs)-1]} }
[ "func", "NewMultiError", "(", "errs", "...", "error", ")", "*", "MultiError", "{", "return", "&", "MultiError", "{", "errs", "[", ":", "len", "(", "errs", ")", "-", "1", "]", ",", "errs", "[", "len", "(", "errs", ")", "-", "1", "]", "}", "\n", ...
// NewMultiError creates a new MultiError object from a given slice of errors.
[ "NewMultiError", "creates", "a", "new", "MultiError", "object", "from", "a", "given", "slice", "of", "errors", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/corerepo/gc.go#L130-L132
127,486
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
Open
func Open(repoPath string) (repo.Repo, error) { fn := func() (repo.Repo, error) { return open(repoPath) } return onlyOne.Open(repoPath, fn) }
go
func Open(repoPath string) (repo.Repo, error) { fn := func() (repo.Repo, error) { return open(repoPath) } return onlyOne.Open(repoPath, fn) }
[ "func", "Open", "(", "repoPath", "string", ")", "(", "repo", ".", "Repo", ",", "error", ")", "{", "fn", ":=", "func", "(", ")", "(", "repo", ".", "Repo", ",", "error", ")", "{", "return", "open", "(", "repoPath", ")", "\n", "}", "\n", "return", ...
// Open the FSRepo at path. Returns an error if the repo is not // initialized.
[ "Open", "the", "FSRepo", "at", "path", ".", "Returns", "an", "error", "if", "the", "repo", "is", "not", "initialized", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L112-L117
127,487
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
ConfigAt
func ConfigAt(repoPath string) (*config.Config, error) { // packageLock must be held to ensure that the Read is atomic. packageLock.Lock() defer packageLock.Unlock() configFilename, err := config.Filename(repoPath) if err != nil { return nil, err } return serialize.Load(configFilename) }
go
func ConfigAt(repoPath string) (*config.Config, error) { // packageLock must be held to ensure that the Read is atomic. packageLock.Lock() defer packageLock.Unlock() configFilename, err := config.Filename(repoPath) if err != nil { return nil, err } return serialize.Load(configFilename) }
[ "func", "ConfigAt", "(", "repoPath", "string", ")", "(", "*", "config", ".", "Config", ",", "error", ")", "{", "// packageLock must be held to ensure that the Read is atomic.", "packageLock", ".", "Lock", "(", ")", "\n", "defer", "packageLock", ".", "Unlock", "(",...
// ConfigAt returns an error if the FSRepo at the given path is not // initialized. This function allows callers to read the config file even when // another process is running and holding the lock.
[ "ConfigAt", "returns", "an", "error", "if", "the", "FSRepo", "at", "the", "given", "path", "is", "not", "initialized", ".", "This", "function", "allows", "callers", "to", "read", "the", "config", "file", "even", "when", "another", "process", "is", "running",...
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L211-L222
127,488
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
configIsInitialized
func configIsInitialized(path string) bool { configFilename, err := config.Filename(path) if err != nil { return false } if !util.FileExists(configFilename) { return false } return true }
go
func configIsInitialized(path string) bool { configFilename, err := config.Filename(path) if err != nil { return false } if !util.FileExists(configFilename) { return false } return true }
[ "func", "configIsInitialized", "(", "path", "string", ")", "bool", "{", "configFilename", ",", "err", ":=", "config", ".", "Filename", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "if", "!", "util", ".", ...
// configIsInitialized returns true if the repo is initialized at // provided |path|.
[ "configIsInitialized", "returns", "true", "if", "the", "repo", "is", "initialized", "at", "provided", "|path|", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L226-L235
127,489
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
LockedByOtherProcess
func LockedByOtherProcess(repoPath string) (bool, error) { repoPath = filepath.Clean(repoPath) locked, err := lockfile.Locked(repoPath, LockFile) if locked { log.Debugf("(%t)<->Lock is held at %s", locked, repoPath) } return locked, err }
go
func LockedByOtherProcess(repoPath string) (bool, error) { repoPath = filepath.Clean(repoPath) locked, err := lockfile.Locked(repoPath, LockFile) if locked { log.Debugf("(%t)<->Lock is held at %s", locked, repoPath) } return locked, err }
[ "func", "LockedByOtherProcess", "(", "repoPath", "string", ")", "(", "bool", ",", "error", ")", "{", "repoPath", "=", "filepath", ".", "Clean", "(", "repoPath", ")", "\n", "locked", ",", "err", ":=", "lockfile", ".", "Locked", "(", "repoPath", ",", "Lock...
// LockedByOtherProcess returns true if the FSRepo is locked by another // process. If true, then the repo cannot be opened by this process.
[ "LockedByOtherProcess", "returns", "true", "if", "the", "FSRepo", "is", "locked", "by", "another", "process", ".", "If", "true", "then", "the", "repo", "cannot", "be", "opened", "by", "this", "process", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L304-L311
127,490
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
openConfig
func (r *FSRepo) openConfig() error { configFilename, err := config.Filename(r.path) if err != nil { return err } conf, err := serialize.Load(configFilename) if err != nil { return err } r.config = conf return nil }
go
func (r *FSRepo) openConfig() error { configFilename, err := config.Filename(r.path) if err != nil { return err } conf, err := serialize.Load(configFilename) if err != nil { return err } r.config = conf return nil }
[ "func", "(", "r", "*", "FSRepo", ")", "openConfig", "(", ")", "error", "{", "configFilename", ",", "err", ":=", "config", ".", "Filename", "(", "r", ".", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "conf", ...
// openConfig returns an error if the config file is not present.
[ "openConfig", "returns", "an", "error", "if", "the", "config", "file", "is", "not", "present", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L373-L384
127,491
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
openDatastore
func (r *FSRepo) openDatastore() error { if r.config.Datastore.Type != "" || r.config.Datastore.Path != "" { return fmt.Errorf("old style datatstore config detected") } else if r.config.Datastore.Spec == nil { return fmt.Errorf("required Datastore.Spec entry missing from config file") } if r.config.Datastore.No...
go
func (r *FSRepo) openDatastore() error { if r.config.Datastore.Type != "" || r.config.Datastore.Path != "" { return fmt.Errorf("old style datatstore config detected") } else if r.config.Datastore.Spec == nil { return fmt.Errorf("required Datastore.Spec entry missing from config file") } if r.config.Datastore.No...
[ "func", "(", "r", "*", "FSRepo", ")", "openDatastore", "(", ")", "error", "{", "if", "r", ".", "config", ".", "Datastore", ".", "Type", "!=", "\"", "\"", "||", "r", ".", "config", ".", "Datastore", ".", "Path", "!=", "\"", "\"", "{", "return", "f...
// openDatastore returns an error if the config file is not present.
[ "openDatastore", "returns", "an", "error", "if", "the", "config", "file", "is", "not", "present", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L399-L435
127,492
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
Close
func (r *FSRepo) Close() error { packageLock.Lock() defer packageLock.Unlock() if r.closed { return errors.New("repo is closed") } err := os.Remove(filepath.Join(r.path, apiFile)) if err != nil && !os.IsNotExist(err) { log.Warning("error removing api file: ", err) } if err := r.ds.Close(); err != nil { ...
go
func (r *FSRepo) Close() error { packageLock.Lock() defer packageLock.Unlock() if r.closed { return errors.New("repo is closed") } err := os.Remove(filepath.Join(r.path, apiFile)) if err != nil && !os.IsNotExist(err) { log.Warning("error removing api file: ", err) } if err := r.ds.Close(); err != nil { ...
[ "func", "(", "r", "*", "FSRepo", ")", "Close", "(", ")", "error", "{", "packageLock", ".", "Lock", "(", ")", "\n", "defer", "packageLock", ".", "Unlock", "(", ")", "\n\n", "if", "r", ".", "closed", "{", "return", "errors", ".", "New", "(", "\"", ...
// Close closes the FSRepo, releasing held resources.
[ "Close", "closes", "the", "FSRepo", "releasing", "held", "resources", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L450-L477
127,493
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
Config
func (r *FSRepo) Config() (*config.Config, error) { // It is not necessary to hold the package lock since the repo is in an // opened state. The package lock is _not_ meant to ensure that the repo is // thread-safe. The package lock is only meant to guard against removal and // coordinate the lockfile. However, we ...
go
func (r *FSRepo) Config() (*config.Config, error) { // It is not necessary to hold the package lock since the repo is in an // opened state. The package lock is _not_ meant to ensure that the repo is // thread-safe. The package lock is only meant to guard against removal and // coordinate the lockfile. However, we ...
[ "func", "(", "r", "*", "FSRepo", ")", "Config", "(", ")", "(", "*", "config", ".", "Config", ",", "error", ")", "{", "// It is not necessary to hold the package lock since the repo is in an", "// opened state. The package lock is _not_ meant to ensure that the repo is", "// t...
// Config the current config. This function DOES NOT copy the config. The caller // MUST NOT modify it without first calling `Clone`. // // Result when not Open is undefined. The method may panic if it pleases.
[ "Config", "the", "current", "config", ".", "This", "function", "DOES", "NOT", "copy", "the", "config", ".", "The", "caller", "MUST", "NOT", "modify", "it", "without", "first", "calling", "Clone", ".", "Result", "when", "not", "Open", "is", "undefined", "."...
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L483-L496
127,494
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
setConfigUnsynced
func (r *FSRepo) setConfigUnsynced(updated *config.Config) error { configFilename, err := config.Filename(r.path) if err != nil { return err } // to avoid clobbering user-provided keys, must read the config from disk // as a map, write the updated struct values to the map and write the map // to disk. var mapc...
go
func (r *FSRepo) setConfigUnsynced(updated *config.Config) error { configFilename, err := config.Filename(r.path) if err != nil { return err } // to avoid clobbering user-provided keys, must read the config from disk // as a map, write the updated struct values to the map and write the map // to disk. var mapc...
[ "func", "(", "r", "*", "FSRepo", ")", "setConfigUnsynced", "(", "updated", "*", "config", ".", "Config", ")", "error", "{", "configFilename", ",", "err", ":=", "config", ".", "Filename", "(", "r", ".", "path", ")", "\n", "if", "err", "!=", "nil", "{"...
// setConfigUnsynced is for private use.
[ "setConfigUnsynced", "is", "for", "private", "use", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L529-L555
127,495
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
SetConfig
func (r *FSRepo) SetConfig(updated *config.Config) error { // packageLock is held to provide thread-safety. packageLock.Lock() defer packageLock.Unlock() return r.setConfigUnsynced(updated) }
go
func (r *FSRepo) SetConfig(updated *config.Config) error { // packageLock is held to provide thread-safety. packageLock.Lock() defer packageLock.Unlock() return r.setConfigUnsynced(updated) }
[ "func", "(", "r", "*", "FSRepo", ")", "SetConfig", "(", "updated", "*", "config", ".", "Config", ")", "error", "{", "// packageLock is held to provide thread-safety.", "packageLock", ".", "Lock", "(", ")", "\n", "defer", "packageLock", ".", "Unlock", "(", ")",...
// SetConfig updates the FSRepo's config. The user must not modify the config // object after calling this method.
[ "SetConfig", "updates", "the", "FSRepo", "s", "config", ".", "The", "user", "must", "not", "modify", "the", "config", "object", "after", "calling", "this", "method", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L559-L566
127,496
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
GetConfigKey
func (r *FSRepo) GetConfigKey(key string) (interface{}, error) { packageLock.Lock() defer packageLock.Unlock() if r.closed { return nil, errors.New("repo is closed") } filename, err := config.Filename(r.path) if err != nil { return nil, err } var cfg map[string]interface{} if err := serialize.ReadConfigF...
go
func (r *FSRepo) GetConfigKey(key string) (interface{}, error) { packageLock.Lock() defer packageLock.Unlock() if r.closed { return nil, errors.New("repo is closed") } filename, err := config.Filename(r.path) if err != nil { return nil, err } var cfg map[string]interface{} if err := serialize.ReadConfigF...
[ "func", "(", "r", "*", "FSRepo", ")", "GetConfigKey", "(", "key", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "packageLock", ".", "Lock", "(", ")", "\n", "defer", "packageLock", ".", "Unlock", "(", ")", "\n\n", "if", "r", "."...
// GetConfigKey retrieves only the value of a particular key.
[ "GetConfigKey", "retrieves", "only", "the", "value", "of", "a", "particular", "key", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L569-L586
127,497
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
SetConfigKey
func (r *FSRepo) SetConfigKey(key string, value interface{}) error { packageLock.Lock() defer packageLock.Unlock() if r.closed { return errors.New("repo is closed") } filename, err := config.Filename(r.path) if err != nil { return err } var mapconf map[string]interface{} if err := serialize.ReadConfigFil...
go
func (r *FSRepo) SetConfigKey(key string, value interface{}) error { packageLock.Lock() defer packageLock.Unlock() if r.closed { return errors.New("repo is closed") } filename, err := config.Filename(r.path) if err != nil { return err } var mapconf map[string]interface{} if err := serialize.ReadConfigFil...
[ "func", "(", "r", "*", "FSRepo", ")", "SetConfigKey", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "packageLock", ".", "Lock", "(", ")", "\n", "defer", "packageLock", ".", "Unlock", "(", ")", "\n\n", "if", "r", ".", ...
// SetConfigKey writes the value of a particular key.
[ "SetConfigKey", "writes", "the", "value", "of", "a", "particular", "key", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L589-L669
127,498
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
Datastore
func (r *FSRepo) Datastore() repo.Datastore { packageLock.Lock() d := r.ds packageLock.Unlock() return d }
go
func (r *FSRepo) Datastore() repo.Datastore { packageLock.Lock() d := r.ds packageLock.Unlock() return d }
[ "func", "(", "r", "*", "FSRepo", ")", "Datastore", "(", ")", "repo", ".", "Datastore", "{", "packageLock", ".", "Lock", "(", ")", "\n", "d", ":=", "r", ".", "ds", "\n", "packageLock", ".", "Unlock", "(", ")", "\n", "return", "d", "\n", "}" ]
// Datastore returns a repo-owned datastore. If FSRepo is Closed, return value // is undefined.
[ "Datastore", "returns", "a", "repo", "-", "owned", "datastore", ".", "If", "FSRepo", "is", "Closed", "return", "value", "is", "undefined", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L673-L678
127,499
ipfs/go-ipfs
repo/fsrepo/fsrepo.go
IsInitialized
func IsInitialized(path string) bool { // packageLock is held to ensure that another caller doesn't attempt to // Init or Remove the repo while this call is in progress. packageLock.Lock() defer packageLock.Unlock() return isInitializedUnsynced(path) }
go
func IsInitialized(path string) bool { // packageLock is held to ensure that another caller doesn't attempt to // Init or Remove the repo while this call is in progress. packageLock.Lock() defer packageLock.Unlock() return isInitializedUnsynced(path) }
[ "func", "IsInitialized", "(", "path", "string", ")", "bool", "{", "// packageLock is held to ensure that another caller doesn't attempt to", "// Init or Remove the repo while this call is in progress.", "packageLock", ".", "Lock", "(", ")", "\n", "defer", "packageLock", ".", "U...
// IsInitialized returns true if the repo is initialized at provided |path|.
[ "IsInitialized", "returns", "true", "if", "the", "repo", "is", "initialized", "at", "provided", "|path|", "." ]
5fd5d444796d4936166f3a38dc066fda7183399c
https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/fsrepo.go#L705-L712