Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(project):update #3

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions example/leveldb_kv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"

iflog "github.com/IceFireDB/icefiredb-ipfs-log"
"github.com/IceFireDB/icefiredb-ipfs-log/stores/levelkv"
"github.com/abiosoft/ishell/v2"
Expand Down Expand Up @@ -54,7 +55,7 @@ func main() {
Name: "get",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(errors.New("参数错误"))
c.Err(errors.New("Parameter error"))
return
}
val, err := kvdb.Get([]byte(c.Args[0]))
Expand All @@ -73,7 +74,7 @@ func main() {
Name: "set",
Func: func(c *ishell.Context) {
if len(c.Args) != 2 {
c.Err(errors.New("参数错误"))
c.Err(errors.New("Parameter error"))
return
}
err := kvdb.Put(ctx, []byte(c.Args[0]), []byte(c.Args[1]))
Expand All @@ -89,7 +90,7 @@ func main() {
Name: "delete",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(errors.New("参数错误"))
c.Err(errors.New("Parameter error"))
return
}
err := kvdb.Delete(ctx, []byte(c.Args[0]))
Expand All @@ -115,7 +116,7 @@ func main() {
Name: "connect",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(fmt.Errorf("参数错误"))
c.Err(fmt.Errorf("Parameter error"))
return
}
bstr, err := ma.NewMultiaddr(c.Args[0])
Expand All @@ -133,7 +134,7 @@ func main() {
return
}
node.PeerHost.ConnManager().TagPeer(inf.ID, "keep", 100)
c.Println("连接成功!")
c.Println("connection succeeded!")
},
})
shell.AddCmd(&ishell.Cmd{
Expand Down
19 changes: 7 additions & 12 deletions example/loger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package main
import (
"context"
"fmt"
"log"
"os"

iflog "github.com/IceFireDB/icefiredb-ipfs-log"
ishell "github.com/abiosoft/ishell/v2"
"github.com/ipfs/go-cid"
"github.com/ipfs/kubo/core"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
ma "github.com/multiformats/go-multiaddr"
"log"
"os"
)

var logger *log.Logger
Expand Down Expand Up @@ -67,7 +68,7 @@ func addCmd(ctx context.Context, shell *ishell.Shell, node *core.IpfsNode, ev *i
Name: "append",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(fmt.Errorf("参数错误"))
c.Err(fmt.Errorf("Parameter error"))
return
}
field := c.Args[0]
Expand All @@ -84,7 +85,7 @@ func addCmd(ctx context.Context, shell *ishell.Shell, node *core.IpfsNode, ev *i
Name: "get",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(fmt.Errorf("参数错误"))
c.Err(fmt.Errorf("Parameter error"))
return
}
hash := c.Args[0]
Expand All @@ -110,7 +111,7 @@ func addCmd(ctx context.Context, shell *ishell.Shell, node *core.IpfsNode, ev *i
Name: "connect",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(fmt.Errorf("参数错误"))
c.Err(fmt.Errorf("Parameter error"))
return
}
bstr, err := ma.NewMultiaddr(c.Args[0])
Expand All @@ -128,15 +129,9 @@ func addCmd(ctx context.Context, shell *ishell.Shell, node *core.IpfsNode, ev *i
return
}
node.PeerHost.ConnManager().TagPeer(inf.ID, "keep", 100)
c.Println("连接成功!")
c.Println("connection succeeded!")
},
})
//shell.AddCmd(&ishell.Cmd{
// Name: "dagadd",
// Func: func(c *ishell.Context) {
// node.DAG.Add(ctx)
// },
//})
}

func PrintHostAddress(ha host.Host) {
Expand Down
11 changes: 6 additions & 5 deletions example/memory_kv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"

iflog "github.com/IceFireDB/icefiredb-ipfs-log"
"github.com/IceFireDB/icefiredb-ipfs-log/stores/kv"
"github.com/abiosoft/ishell/v2"
Expand Down Expand Up @@ -53,7 +54,7 @@ func main() {
Name: "get",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(errors.New("参数错误"))
c.Err(errors.New("Parameter error"))
return
}
val := kvdb.Get(c.Args[0])
Expand All @@ -68,7 +69,7 @@ func main() {
Name: "set",
Func: func(c *ishell.Context) {
if len(c.Args) != 2 {
c.Err(errors.New("参数错误"))
c.Err(errors.New("Parameter error"))
return
}
err := kvdb.Put(ctx, c.Args[0], c.Args[1])
Expand All @@ -84,7 +85,7 @@ func main() {
Name: "delete",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(errors.New("参数错误"))
c.Err(errors.New("Parameter error"))
return
}
err := kvdb.Delete(ctx, c.Args[0])
Expand Down Expand Up @@ -121,7 +122,7 @@ func main() {
Name: "connect",
Func: func(c *ishell.Context) {
if len(c.Args) != 1 {
c.Err(fmt.Errorf("参数错误"))
c.Err(fmt.Errorf("Parameter error"))
return
}
bstr, err := ma.NewMultiaddr(c.Args[0])
Expand All @@ -139,7 +140,7 @@ func main() {
return
}
node.PeerHost.ConnManager().TagPeer(inf.ID, "keep", 100)
c.Println("连接成功!")
c.Println("connection succeeded!")
},
})
shell.AddCmd(&ishell.Cmd{
Expand Down