Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 296c3a6

Browse files
authored
Merge pull request #1848 from OpenBazaar/eth-master-w-1800-hotfix
Merge v0.13.6 hotfix into ethereum-master
2 parents 7e7def3 + b51b8e2 commit 296c3a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2909
-8723
lines changed

Godeps/Godeps.json

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/jsonapi.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import (
2525
ipnspath "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path"
2626
files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files"
2727
cid "gx/ipfs/QmTbxNB1NwDesLmKTscr4udL2tVP7MaxvXnD1D9yX7g3PN/go-cid"
28-
datastore "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore"
2928
ipns "gx/ipfs/QmUwMnKKjH3JwGKNVZ3TcP37W93xzqNA4ECFFiMo6sXkkc/go-ipns"
3029
iface "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core"
3130
peer "gx/ipfs/QmYVXrKrKHDC9FobgmcmshCDyWwdrfwfanNQN4oxJ9Fk3h/go-libp2p-peer"
3231
routing "gx/ipfs/QmYxUdYY9S6yg5tSPVin5GFTvtfsLauVcr7reHDD3dM8xf/go-libp2p-routing"
3332
ps "gx/ipfs/QmaCTz9RkrU13bm9kMB54f7atgqM4qkjDZpRwRoJiWXEqs/go-libp2p-peerstore"
33+
ggproto "gx/ipfs/QmddjPSGZb3ieihSseFeCfVRpZzcqczPNsD2DvarSwnjJB/gogo-protobuf/proto"
3434
mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash"
3535

3636
"github.com/OpenBazaar/jsonpb"
@@ -47,7 +47,6 @@ import (
4747
"github.com/golang/protobuf/ptypes"
4848
ipfscore "github.com/ipfs/go-ipfs/core"
4949
"github.com/ipfs/go-ipfs/core/coreapi"
50-
"github.com/ipfs/go-ipfs/namesys"
5150
"github.com/ipfs/go-ipfs/repo/fsrepo"
5251
)
5352

@@ -3877,6 +3876,7 @@ func (i *jsonAPIHandler) GETWalletStatus(w http.ResponseWriter, r *http.Request)
38773876
}
38783877

38793878
func (i *jsonAPIHandler) GETIPNS(w http.ResponseWriter, r *http.Request) {
3879+
ipfsStore := i.node.IpfsNode.Repo.Datastore()
38803880
_, peerID := path.Split(r.URL.Path)
38813881

38823882
pid, err := peer.IDB58Decode(peerID)
@@ -3885,7 +3885,7 @@ func (i *jsonAPIHandler) GETIPNS(w http.ResponseWriter, r *http.Request) {
38853885
return
38863886
}
38873887

3888-
val, err := i.node.IpfsNode.Repo.Datastore().Get(namesys.IpnsDsKey(pid))
3888+
peerIPNSRecord, err := ipfs.GetCachedIPNSRecord(ipfsStore, pid)
38893889
if err != nil { // No record in datastore
38903890
ErrorResponse(w, http.StatusNotFound, err.Error())
38913891
return
@@ -3894,7 +3894,7 @@ func (i *jsonAPIHandler) GETIPNS(w http.ResponseWriter, r *http.Request) {
38943894
var keyBytes []byte
38953895
pubkey := i.node.IpfsNode.Peerstore.PubKey(pid)
38963896
if pubkey == nil || !pid.MatchesPublicKey(pubkey) {
3897-
keyval, err := i.node.IpfsNode.Repo.Datastore().Get(datastore.NewKey(core.KeyCachePrefix + peerID))
3897+
keyval, err := ipfs.GetCachedPubkey(ipfsStore, peerID)
38983898
if err != nil {
38993899
ErrorResponse(w, http.StatusNotFound, err.Error())
39003900
return
@@ -3912,8 +3912,13 @@ func (i *jsonAPIHandler) GETIPNS(w http.ResponseWriter, r *http.Request) {
39123912
Pubkey string `json:"pubkey"`
39133913
Record string `json:"record"`
39143914
}
3915+
peerIPNSBytes, err := ggproto.Marshal(peerIPNSRecord)
3916+
if err != nil {
3917+
ErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("marshaling IPNS record: %s", err.Error()))
3918+
return
3919+
}
39153920

3916-
ret := KeyAndRecord{hex.EncodeToString(keyBytes), string(val)}
3921+
ret := KeyAndRecord{hex.EncodeToString(keyBytes), string(peerIPNSBytes)}
39173922
retBytes, err := json.MarshalIndent(ret, "", " ")
39183923
if err != nil {
39193924
ErrorResponse(w, http.StatusInternalServerError, err.Error())
@@ -3943,9 +3948,14 @@ func (i *jsonAPIHandler) GETResolveIPNS(w http.ResponseWriter, r *http.Request)
39433948
var response = respType{PeerID: peerID}
39443949

39453950
if i.node.IpfsNode.Identity.Pretty() == peerID {
3946-
ipnsBytes, err := i.node.IpfsNode.Repo.Datastore().Get(namesys.IpnsDsKey(i.node.IpfsNode.Identity))
3951+
rec, err := ipfs.GetCachedIPNSRecord(i.node.IpfsNode.Repo.Datastore(), i.node.IpfsNode.Identity)
3952+
if err != nil {
3953+
ErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("retrieving self: %s", err))
3954+
return
3955+
}
3956+
ipnsBytes, err := proto.Marshal(rec)
39473957
if err != nil {
3948-
ErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("retrieving self from datastore: %s", err))
3958+
ErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("marshaling self: %s", err))
39493959
return
39503960
}
39513961
response.Record.Hex = hex.EncodeToString(ipnsBytes)

cmd/start.go

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ import (
2323
dht "gx/ipfs/QmSY3nkMNLzh9GdbFKK5tT7YMfLpf52iUZ8ZRkr29MJaa5/go-libp2p-kad-dht"
2424
ma "gx/ipfs/QmTZBfrPJmjWsCvHEtX5FE6KimVJhsJg5sBbqEFYf4UZtL/go-multiaddr"
2525
config "gx/ipfs/QmUAuYuiafnJRZxDDX7MuruMNsicYNuyub5vUeAcupUBNs/go-ipfs-config"
26-
ipnspb "gx/ipfs/QmUwMnKKjH3JwGKNVZ3TcP37W93xzqNA4ECFFiMo6sXkkc/go-ipns/pb"
2726
peer "gx/ipfs/QmYVXrKrKHDC9FobgmcmshCDyWwdrfwfanNQN4oxJ9Fk3h/go-libp2p-peer"
2827
oniontp "gx/ipfs/QmYv2MbwHn7qcvAPFisZ94w85crQVpwUuv8G7TuUeBnfPb/go-onion-transport"
2928
ipfslogging "gx/ipfs/QmbkT7eMTyXfpeyB3ZMxxcxg7XH8t6uXp49jqzz4HB7BGF/go-log/writer"
3029
manet "gx/ipfs/Qmc85NSvmSG4Frn9Vb2cBc1rMyULH6D3TNVEfCzSKoUpip/go-multiaddr-net"
31-
proto "gx/ipfs/QmddjPSGZb3ieihSseFeCfVRpZzcqczPNsD2DvarSwnjJB/gogo-protobuf/proto"
3230

3331
"github.com/OpenBazaar/openbazaar-go/api"
3432
"github.com/OpenBazaar/openbazaar-go/core"
@@ -53,7 +51,6 @@ import (
5351
"github.com/ipfs/go-ipfs/commands"
5452
ipfscore "github.com/ipfs/go-ipfs/core"
5553
"github.com/ipfs/go-ipfs/core/corehttp"
56-
"github.com/ipfs/go-ipfs/namesys"
5754
"github.com/ipfs/go-ipfs/repo/fsrepo"
5855
"github.com/natefinch/lumberjack"
5956
"github.com/op/go-logging"
@@ -407,43 +404,27 @@ func (x *Start) Execute(args []string) error {
407404
}
408405
var dhtRouting *dht.IpfsDHT
409406
for _, router := range tiered.Routers {
410-
if r, ok := router.(*ipfs.CachingRouter); ok {
411-
r.APIRouter().Start(torDialer)
412-
dhtRouting, err = r.DHT()
413-
if err != nil {
414-
return err
415-
}
416-
} else if x.Regtest {
417-
if r, ok := router.(*dht.IpfsDHT); ok {
418-
dhtRouting = r
419-
}
407+
if r, ok := router.(*dht.IpfsDHT); ok {
408+
dhtRouting = r
420409
}
421410
}
422411
if dhtRouting == nil {
423412
return errors.New("IPFS DHT routing is not configured")
424413
}
425414

426415
// Get current directory root hash
427-
ipnskey := namesys.IpnsDsKey(nd.Identity)
428-
ival, hasherr := nd.Repo.Datastore().Get(ipnskey)
416+
cachedIPNSRecord, hasherr := ipfs.GetCachedIPNSRecord(nd.Repo.Datastore(), nd.Identity)
429417
if hasherr != nil {
430-
log.Error("get ipns key:", hasherr)
431-
}
432-
ourIpnsRecord := new(ipnspb.IpnsEntry)
433-
err = proto.Unmarshal(ival, ourIpnsRecord)
434-
if err != nil {
435-
log.Error("unmarshal record value", err)
436-
err = nd.Repo.Datastore().Delete(ipnskey)
437-
if err != nil {
438-
log.Error(err)
418+
log.Warning(err)
419+
if err := ipfs.DeleteCachedIPNSRecord(nd.Repo.Datastore(), nd.Identity); err != nil {
420+
log.Errorf("deleting invalid IPNS record: %s", err.Error())
439421
}
440422
}
441423

442424
if x.ForceKeyCachePurge {
443425
log.Infof("forcing key purge from namesys cache...")
444-
err = nd.Repo.Datastore().Delete(ipnskey)
445-
if err != nil {
446-
log.Error(err)
426+
if err := ipfs.DeleteCachedIPNSRecord(nd.Repo.Datastore(), nd.Identity); err != nil {
427+
log.Errorf("force-purging IPNS record: %s", err.Error())
447428
}
448429
}
449430

@@ -597,6 +578,11 @@ func (x *Start) Execute(args []string) error {
597578
subscriber := ipfs.NewPubsubSubscriber(context.Background(), nd.PeerHost, nd.Routing, nd.Repo.Datastore(), nd.PubSub)
598579
ps := ipfs.Pubsub{Publisher: publisher, Subscriber: subscriber}
599580

581+
var rootHash string
582+
if cachedIPNSRecord != nil {
583+
rootHash = string(cachedIPNSRecord.Value)
584+
}
585+
600586
// OpenBazaar node setup
601587
core.Node = &core.OpenBazaarNode{
602588
AcceptStoreRequests: dataSharing.AcceptStoreRequests,
@@ -611,7 +597,7 @@ func (x *Start) Execute(args []string) error {
611597
PushNodes: pushNodes,
612598
RegressionTestEnable: x.Regtest,
613599
RepoPath: repoPath,
614-
RootHash: string(ourIpnsRecord.Value),
600+
RootHash: rootHash,
615601
TestnetEnable: x.Testnet,
616602
TorDialer: torDialer,
617603
UserAgent: core.USERAGENT,

core/core.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
libp2p "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto"
88
ma "gx/ipfs/QmTZBfrPJmjWsCvHEtX5FE6KimVJhsJg5sBbqEFYf4UZtL/go-multiaddr"
99
cid "gx/ipfs/QmTbxNB1NwDesLmKTscr4udL2tVP7MaxvXnD1D9yX7g3PN/go-cid"
10-
"gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore"
1110
peer "gx/ipfs/QmYVXrKrKHDC9FobgmcmshCDyWwdrfwfanNQN4oxJ9Fk3h/go-libp2p-peer"
1211
routing "gx/ipfs/QmYxUdYY9S6yg5tSPVin5GFTvtfsLauVcr7reHDD3dM8xf/go-libp2p-routing"
1312

@@ -31,7 +30,7 @@ import (
3130

3231
const (
3332
// VERSION - current version
34-
VERSION = "0.13.5"
33+
VERSION = "0.13.6"
3534
// USERAGENT - user-agent header string
3635
USERAGENT = "/openbazaar-go:" + VERSION + "/"
3736
)
@@ -282,8 +281,11 @@ func (n *OpenBazaarNode) EncryptMessage(peerID peer.ID, peerKey *libp2p.PubKey,
282281
ctx, cancel := context.WithTimeout(context.Background(), n.OfflineMessageFailoverTimeout)
283282
defer cancel()
284283
if peerKey == nil {
285-
var pubKey libp2p.PubKey
286-
keyval, err := n.IpfsNode.Repo.Datastore().Get(datastore.NewKey(KeyCachePrefix + peerID.Pretty()))
284+
var (
285+
pubKey libp2p.PubKey
286+
store = n.IpfsNode.Repo.Datastore()
287+
)
288+
keyval, err := ipfs.GetCachedPubkey(store, peerID.Pretty())
287289
if err != nil {
288290
pubKey, err = routing.GetPublicKey(n.IpfsNode.Routing, ctx, peerID)
289291
if err != nil {

core/net.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (n *OpenBazaarNode) SendOfflineMessage(p peer.ID, k *libp2p.PubKey, m *pb.M
122122
go func() {
123123
ctx, cancel := context.WithCancel(context.Background())
124124
defer cancel()
125-
err := n.Pubsub.Publisher.Publish(ctx, ipfs.MessageTopicPrefix+pointer.Cid.String(), ciphertext)
125+
err := n.Pubsub.Publisher.Publish(ctx, pointer.Cid.String(), ciphertext)
126126
if err != nil {
127127
log.Error(err)
128128
}

core/profile.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ import (
2525
"github.com/imdario/mergo"
2626
)
2727

28-
// KeyCachePrefix - cache prefix for public key
29-
const KeyCachePrefix = "/pubkey/"
30-
3128
// ErrorProfileNotFound - profile not found error
3229
var ErrorProfileNotFound = errors.New("profile not found")
3330

docs/install-linux.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ It will use git to checkout the source code into `$GOPATH/src/github.com/OpenBaz
5454

5555
Checkout a release version:
5656
```
57-
git checkout v0.13.5
57+
git checkout v0.13.6
5858
```
5959

6060
Note: `go get` leaves the repo pointing at `master` which is a branch used for active development. Running OpenBazaar from `master` is NOT recommended. Check the [release versions](https://github.com/OpenBazaar/openbazaar-go/releases) for the available versions that you use in checkout.

docs/install-osx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ It will use git to checkout the source code into `$GOPATH/src/github.com/OpenBaz
5656

5757
Checkout a release version:
5858
```
59-
git checkout v0.13.5
59+
git checkout v0.13.6
6060
```
6161

6262
Note: `go get` leaves the repo pointing at `master` which is a branch used for active development. Running OpenBazaar from `master` is NOT recommended. Check the [release versions](https://github.com/OpenBazaar/openbazaar-go/releases) for the available versions that you use in checkout.

docs/install-pi3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ It will use git to checkout the source code into `$GOPATH/src/github.com/OpenBaz
5757

5858
Checkout a release version:
5959
```
60-
git checkout v0.13.5
60+
git checkout v0.13.6
6161
```
6262

6363
Note: `go get` leaves the repo pointing at `master` which is a branch used for active development. Running OpenBazaar from `master` is NOT recommended. Check the [release versions](https://github.com/OpenBazaar/openbazaar-go/releases) for the available versions that you use iin checkout.

docs/install-windows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Create a directory to store all your Go projects (e.g. `C:\goprojects`):
2727
- Install `openbazaar-go`:
2828
+ Open the command prompt and run: `go get github.com/OpenBazaar/openbazaar-go`. This will use git to checkout the source code into `%GOPATH%\src\github.com\OpenBazaar\openbazaar-go`.
2929
- Checkout an OpenBazaar release:
30-
+ Run `git checkout v0.13.5` to checkout a release version.
30+
+ Run `git checkout v0.13.6` to checkout a release version.
3131
+ Note: `go get` leaves the repo pointing at `master` which is a branch used for active development. Running OpenBazaar from `master` is NOT recommended. Check the [release versions](https://github.com/OpenBazaar/openbazaar-go/releases) for the available versions that you use in checkout.
3232
- To compile and run `openbazaar-go`:
3333
+ Open the command prompt and navigate the source directory: `cd %GOPATH%\src\github.com\OpenBazaar\openbazaar-go`

0 commit comments

Comments
 (0)