κρμγ 8 年之前
父节点
当前提交
aeb5fe4188
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      ipfs_api/api.go

+ 3 - 1
ipfs_api/api.go

@@ -20,7 +20,7 @@ type MyShell struct {
 }
 
 func reset() {
-	if sh == nil {
+	if sh == nil || !sh.IsUp(){
 		sh = &MyShell{
 			Url:    Addr,
 			Client: http.DefaultClient,
@@ -30,6 +30,8 @@ func reset() {
 		if id, err := sh.ID(); err == nil {
 			v0, _, _ := sh.Version()
 			log.Println("ipfs version", v0, "node", id.ID, "online")
+		} else {
+			sh = nil
 		}
 	}
 }