【发布时间】:2021-05-28 13:44:01
【问题描述】:
我是 ipfs 的新手,尝试使用 go-ipfs-api 获取 ipfs 信息。以下是我的代码:
package main
import (
"fmt"
"context"
"os"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/ipfs/go-ipfs-api"
)
var sh *shell.Shell
func main() {
sh := shell.NewShell("localhost:5001")
cid, err := sh.SwarmPeers()
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s", err)
os.Exit(1)
}
fmt.Printf("added %s", cid)
}
这个sh.SwarmPeers 需要一些上下文作为参数。我没有得到我需要传递什么参数来获取对等列表。另外,我应该使用哪些 API 函数来获取 ipfs 上存在的文件总数和文件的总大小?请帮忙。如果有教程,请分享。它将帮助我理解使用其他功能。任何帮助将不胜感激。
【问题讨论】: