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: upgrade dependency of btfs #446

Merged
merged 4 commits into from
Aug 23, 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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.22
MAINTAINER TRON-US <support@tron.network>

# Install deps
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.testing
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.22
MAINTAINER TRON-US <support@tron.network>

# Install deps
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.unit_testing
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.22
MAINTAINER TRON-US <support@tron.network>

# Dockerfile.unit_testing will build an image to run the go unit tests.
Expand Down
14 changes: 12 additions & 2 deletions cmd/btfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (
loader "github.com/bittorrent/go-btfs/plugin/loader"
repo "github.com/bittorrent/go-btfs/repo"
fsrepo "github.com/bittorrent/go-btfs/repo/fsrepo"
"github.com/google/uuid"

cmds "github.com/bittorrent/go-btfs-cmds"
"github.com/bittorrent/go-btfs-cmds/cli"
cmdhttp "github.com/bittorrent/go-btfs-cmds/http"
config "github.com/bittorrent/go-btfs-config"
u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log"
loggables "github.com/libp2p/go-libp2p-loggables"
ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns"
manet "github.com/multiformats/go-multiaddr/net"
Expand Down Expand Up @@ -73,7 +73,7 @@ func main() {

func mainRet() int {
rand.Seed(time.Now().UnixNano())
ctx := logging.ContextWithLoggable(context.Background(), loggables.Uuid("session"))
ctx := logging.ContextWithLoggable(context.Background(), newUUID("session"))
var err error

// we'll call this local helper to output errors.
Expand Down Expand Up @@ -382,3 +382,13 @@ func resolveAddr(ctx context.Context, addr ma.Multiaddr) (ma.Multiaddr, error) {

return addrs[0], nil
}

func newUUID(key string) logging.Metadata {
ids := "#UUID-ERROR#"
if id, err := uuid.NewRandom(); err == nil {
ids = id.String()
}
return logging.Metadata{
key: ids,
}
}
4 changes: 2 additions & 2 deletions core/commands/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

cmds "github.com/bittorrent/go-btfs-cmds"
humanize "github.com/dustin/go-humanize"
bitswap "github.com/ipfs/go-bitswap"
decision "github.com/ipfs/go-bitswap/decision"
bitswap "github.com/ipfs/boxo/bitswap"
decision "github.com/ipfs/boxo/bitswap/decision"
cidutil "github.com/ipfs/go-cidutil"
peer "github.com/libp2p/go-libp2p/core/peer"
)
Expand Down
5 changes: 3 additions & 2 deletions core/commands/dag/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
files "github.com/bittorrent/go-btfs-files"
"github.com/bittorrent/interface-go-btfs-core/options"
path "github.com/bittorrent/interface-go-btfs-core/path"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
cidenc "github.com/ipfs/go-cidutil/cidenc"
ipld "github.com/ipfs/go-ipld-format"
Expand Down Expand Up @@ -386,7 +387,7 @@ Maximum supported CAR version: 1

if block, err := node.Blockstore.Get(ctx, c); err != nil {
ret.PinErrorMsg = err.Error()
} else if nd, err := ipld.Decode(block); err != nil {
} else if nd, err := ipld.Decode(block, func(block blocks.Block) (ipld.Node, error) { return nil, nil }); err != nil {
ret.PinErrorMsg = err.Error()
} else if err := node.Pinning.Pin(req.Context, nd, true); err != nil {
ret.PinErrorMsg = err.Error()
Expand Down Expand Up @@ -494,7 +495,7 @@ func importWorker(req *cmds.Request, re cmds.ResponseEmitter, api iface.CoreAPI,
}

// the double-decode is suboptimal, but we need it for batching
nd, err := ipld.Decode(block)
nd, err := ipld.Decode(block, func(block blocks.Block) (ipld.Node, error) { return nil, nil })
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions core/commands/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ var findProvidersDhtCmd = &cmds.Command{
if verbose {
fmt.Fprintf(out, "provider: ")
}
fmt.Fprintf(out, "%s\n", prov.ID.Pretty())
fmt.Fprintf(out, "%s\n", prov.ID.String())
if verbose {
for _, a := range prov.Addrs {
fmt.Fprintf(out, "\t%s\n", a)
Expand Down Expand Up @@ -612,7 +612,7 @@ identified by QmFoo.
return nil
},
routing.Value: func(obj *routing.QueryEvent, out io.Writer, verbose bool) error {
fmt.Fprintf(out, "%s\n", obj.ID.Pretty())
fmt.Fprintf(out, "%s\n", obj.ID.String())
return nil
},
}
Expand Down
4 changes: 2 additions & 2 deletions core/commands/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ func TestKeyTranslation(t *testing.T) {
pkname := namesys.PkKeyForID(pid)
ipnsname := ipns.RecordKey(pid)

pkk, err := escapeDhtKey("/pk/" + pid.Pretty())
pkk, err := escapeDhtKey("/pk/" + pid.String())
if err != nil {
t.Fatal(err)
}

ipnsk, err := escapeDhtKey("/btns/" + pid.Pretty())
ipnsk, err := escapeDhtKey("/btns/" + pid.String())
if err != nil {
t.Fatal(err)
}
Expand Down
118 changes: 0 additions & 118 deletions core/commands/encryption_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion core/commands/guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ to the guard service.`,
return err
}
questions, err := guard.PrepCustomFileChallengeQuestions(rss, rootHash, shardHashes, hostIDs, qCount, false,
n.Identity.Pretty())
n.Identity.String())
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion core/commands/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
pstore "github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p/core/protocol"
)

const offlineIdErrorMessage = `'btfs id' currently cannot query information on remote
Expand Down Expand Up @@ -254,7 +255,7 @@ func printSelf(keyEnc ke.KeyEncoder, node *core.IpfsNode, env cmds.Environment)
info.Addresses = append(info.Addresses, a.String())
}
sort.Strings(info.Addresses)
info.Protocols = node.PeerHost.Mux().Protocols()
info.Protocols = protocol.ConvertToStrings(node.PeerHost.Mux().Protocols())
sort.Strings(info.Protocols)
}
info.ProtocolVersion = "btfs/0.1.0" //identify.LibP2PVersion
Expand Down
3 changes: 1 addition & 2 deletions core/commands/keyencode/keyencode.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func KeyEncoderFromString(formatLabel string) (KeyEncoder, error) {

func (enc KeyEncoder) FormatID(id peer.ID) string {
if enc.baseEnc == nil {
//nolint deprecated
return peer.Encode(id)
return id.String()
}
if s, err := peer.ToCid(id).StringOfBase(enc.baseEnc.Encoding()); err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion core/commands/name/ipns.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Resolve the value of a dnslink:
if err != nil {
return err
}
name = self.ID().Pretty()
name = self.ID().String()
} else {
name = req.Arguments[0]
}
Expand Down
4 changes: 2 additions & 2 deletions core/commands/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ trip latency information.
if len(n.Peerstore.Addrs(pid)) == 0 {
// Make sure we can find the node in question
if err := res.Emit(&PingResult{
Text: fmt.Sprintf("Looking up peer %s", pid.Pretty()),
Text: fmt.Sprintf("Looking up peer %s", pid.String()),
Success: true,
}); err != nil {
return err
Expand All @@ -95,7 +95,7 @@ trip latency information.
}

if err := res.Emit(&PingResult{
Text: fmt.Sprintf("PING %s.", pid.Pretty()),
Text: fmt.Sprintf("PING %s.", pid.String()),
Success: true,
}); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion core/commands/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
list := &stringList{make([]string, 0, len(peers))}

for _, peer := range peers {
list.Strings = append(list.Strings, peer.Pretty())
list.Strings = append(list.Strings, peer.String())
}
sort.Strings(list.Strings)
return cmds.EmitOnce(res, list)
Expand Down
9 changes: 5 additions & 4 deletions core/commands/statuscontract.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"encoding/json"
"errors"
"fmt"
onlinePb "github.com/bittorrent/go-btfs-common/protos/online"
"github.com/bittorrent/go-btfs/utils"
"io"
"math/big"
"strconv"
"time"

onlinePb "github.com/bittorrent/go-btfs-common/protos/online"
"github.com/bittorrent/go-btfs/utils"

cmds "github.com/bittorrent/go-btfs-cmds"
"github.com/bittorrent/go-btfs/chain"
"github.com/bittorrent/go-btfs/core/commands/cmdenv"
Expand Down Expand Up @@ -62,7 +63,7 @@ var TotalCmd = &cmds.Command{
if err != nil {
return err
}
peerId := n.Identity.Pretty()
peerId := n.Identity.String()

list, err := chain.GetReportStatusListOK()
if err != nil {
Expand Down Expand Up @@ -135,7 +136,7 @@ var ReportListCmd = &cmds.Command{
if err != nil {
return err
}
peerId := n.Identity.Pretty()
peerId := n.Identity.String()

from, err := strconv.Atoi(req.Arguments[0])
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions core/commands/statusonline.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var ReportListDailyCmd = &cmds.Command{
if err != nil {
return err
}
peerId := n.Identity.Pretty()
peerId := n.Identity.String()

cfg, err := cmdenv.GetConfig(env)
if err != nil {
Expand Down Expand Up @@ -181,7 +181,7 @@ var TotalDailyCmd = &cmds.Command{
if err != nil {
return err
}
peerId := n.Identity.Pretty()
peerId := n.Identity.String()

list, err := chain.GetReportOnlineListDailyOK()
if err != nil {
Expand Down
Loading
Loading