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

Commit

Permalink
Merge pull request #1433 from OpenBazaar/revert-1306-minor-cleanups
Browse files Browse the repository at this point in the history
Revert "Minor cleanups"
  • Loading branch information
placer14 authored Feb 5, 2019
2 parents 6ffe3c7 + be84e7a commit f50b53e
Show file tree
Hide file tree
Showing 77 changed files with 533 additions and 533 deletions.
12 changes: 6 additions & 6 deletions api/jsonapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"encoding/json"
"fmt"
routing "gx/ipfs/QmRaVcGchmC1stHHK7YhcgEuTk5k1JiGS568pfYWMgT91H/go-libp2p-kad-dht"
"gx/ipfs/QmTmqJGRQfuH8eKWD1FjThwPRipt1QhqJQNZ8MpzmfAAxo/go-ipfs-ds-help"
dshelp "gx/ipfs/QmTmqJGRQfuH8eKWD1FjThwPRipt1QhqJQNZ8MpzmfAAxo/go-ipfs-ds-help"
ps "gx/ipfs/QmXauCuJzmzapetmC6W4TuDJLL1yFFrVzSHoWv8YdbmnxH/go-libp2p-peerstore"
"gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
"gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
"io/ioutil"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -42,7 +42,7 @@ import (
"github.com/ipfs/go-ipfs/core/coreunix"
ipnspb "github.com/ipfs/go-ipfs/namesys/pb"
ipnspath "github.com/ipfs/go-ipfs/path"
"github.com/ipfs/go-ipfs/repo/fsrepo"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
)

type JSONAPIConfig struct {
Expand Down Expand Up @@ -1165,7 +1165,7 @@ func (i *jsonAPIHandler) GETInventory(w http.ResponseWriter, r *http.Request) {
}

// If we want our own inventory get it from the local database and return
getPersonalInventory := peerIDString == "" || peerIDString == i.node.IPFSIdentityString()
getPersonalInventory := (peerIDString == "" || peerIDString == i.node.IPFSIdentityString())
if getPersonalInventory {
var (
err error
Expand Down Expand Up @@ -3271,7 +3271,7 @@ func (i *jsonAPIHandler) GETEstimateFee(w http.ResponseWriter, r *http.Request)
return
}
}
fmt.Fprintf(w, `{"estimatedFee": %d}`, fee)
fmt.Fprintf(w, `{"estimatedFee": %d}`, (fee))
}

func (i *jsonAPIHandler) GETFees(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 3 additions & 3 deletions api/jsonapi_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net"
manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net"
ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -202,9 +202,9 @@ func httpGet(endpoint string) ([]byte, error) {
func jsonFor(t *testing.T, fixture proto.Message) string {
m := jsonpb.Marshaler{}

jsonStr, err := m.MarshalToString(fixture)
json, err := m.MarshalToString(fixture)
if err != nil {
t.Fatal(err)
}
return jsonStr
return json
}
4 changes: 2 additions & 2 deletions api/jsonapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ func TestListingsAcceptedCurrencies(t *testing.T) {
}
resp.Body.Close()

var respObj []struct {
respObj := []struct {
AcceptedCurrencies []string `json:"acceptedCurrencies"`
}
}{}
err = json.Unmarshal(respBody, &respObj)
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion api/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (m *notificationManager) sendNotification(n repo.Notifier) {
// TODO: should be extended to include new notifiers in the list
func (m *notificationManager) getNotifiers() []notifier {
settings, err := m.node.Datastore.Settings().Get()
var notifiers []notifier
notifiers := []notifier{}
if err != nil {
return notifiers
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ func (x *Convert) Execute(args []string) error {
json.Unmarshal(cf, &cfgIface)
cfgObj, ok := cfgIface.(map[string]interface{})
if !ok {
return errors.New("invalid config file")
return errors.New("Invalid config file")
}

walletIface, ok := cfgObj["Wallet"]
if !ok {
return errors.New("config file missing wallet field")
return errors.New("Config file missing wallet field")
}
walletCfg, ok := walletIface.(map[string]interface{})
if !ok {
return errors.New("invalid config file")
return errors.New("Invalid config file")
}
walletCfg["Type"] = cfgtype
if strings.ToLower(args[0]) == "zcash" {
Expand Down Expand Up @@ -305,7 +305,7 @@ func (x *Convert) Execute(args []string) error {
for i, l := range index {
h, ok := hashes[l.Slug]
if !ok {
return errors.New("malformatted index file")
return errors.New("Malformatted index file")
}
l.Hash = h
index[i] = l
Expand Down
4 changes: 2 additions & 2 deletions cmd/gencerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func (x *GenerateCertificates) Execute(args []string) error {
}

// Check if host ip or dns name and count their quantity
var ipAddresses []net.IP
var dnsNames []string
ipAddresses := []net.IP{}
dnsNames := []string{}
hosts := strings.Split(x.Host, ",")
for _, h := range hosts {
if ip := net.ParseIP(h); ip != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (x *Init) Execute(args []string) error {
if x.WalletCreationDate != "" {
creationDate, err = time.Parse(time.RFC3339, x.WalletCreationDate)
if err != nil {
return errors.New("wallet creation date timestamp must be in RFC3339 format")
return errors.New("Wallet creation date timestamp must be in RFC3339 format")
}
}

Expand Down
14 changes: 7 additions & 7 deletions cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (
"context"
"errors"
"fmt"
"gx/ipfs/QmNSWW3Sb4eju4o2djPQ1L1c2Zj9XN9sMYJL8r1cbxdc6b/go-addr-util"
addrutil "gx/ipfs/QmNSWW3Sb4eju4o2djPQ1L1c2Zj9XN9sMYJL8r1cbxdc6b/go-addr-util"
p2pbhost "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/host/basic"
p2phost "gx/ipfs/QmNmJZL7FQySMtE2BQuLMuZg2EB2CLEunJJUSVSc9YnnbV/go-libp2p-host"
"gx/ipfs/QmRaVcGchmC1stHHK7YhcgEuTk5k1JiGS568pfYWMgT91H/go-libp2p-kad-dht"
dht "gx/ipfs/QmRaVcGchmC1stHHK7YhcgEuTk5k1JiGS568pfYWMgT91H/go-libp2p-kad-dht"
dhtutil "gx/ipfs/QmRaVcGchmC1stHHK7YhcgEuTk5k1JiGS568pfYWMgT91H/go-libp2p-kad-dht/util"
"gx/ipfs/QmSwZMWwFZSUpe5muU2xgTUwppH24KfMwdPXiwbEp2c6G5/go-libp2p-swarm"
swarm "gx/ipfs/QmSwZMWwFZSUpe5muU2xgTUwppH24KfMwdPXiwbEp2c6G5/go-libp2p-swarm"
ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr"
pstore "gx/ipfs/QmXauCuJzmzapetmC6W4TuDJLL1yFFrVzSHoWv8YdbmnxH/go-libp2p-peerstore"
smux "gx/ipfs/QmY9JXR3FupnYAYJWK9aMr9bCpqWKcToQ1tz8DVGTrHpHw/go-stream-muxer"
"gx/ipfs/QmZPrWxuM8GHr4cGKbyF5CCT11sFUP9hgqpeUHALvx2nUr/go-libp2p-interface-pnet"
"gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
"gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
"gx/ipfs/QmdeBtQGXjSt7cb97nx9JyLHHv5va2LyEAue7Q5tDFzpLy/go-libp2p-metrics"
metrics "gx/ipfs/QmdeBtQGXjSt7cb97nx9JyLHHv5va2LyEAue7Q5tDFzpLy/go-libp2p-metrics"
oniontp "gx/ipfs/Qmdh86HZtNap3ktHvjyiVhBnp4uRpQWMCRAASieh8fDH8J/go-onion-transport"
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
"io/ioutil"
Expand Down Expand Up @@ -83,7 +83,7 @@ func (x *Restore) Execute(args []string) error {
if x.WalletCreationDate != "" {
creationDate, err = time.Parse(time.RFC3339, x.WalletCreationDate)
if err != nil {
return errors.New("wallet creation date timestamp must be in RFC3339 format")
return errors.New("Wallet creation date timestamp must be in RFC3339 format")
}
}
os.RemoveAll(repoPath)
Expand Down Expand Up @@ -216,7 +216,7 @@ func (x *Restore) Execute(args []string) error {
if x.TorPassword != "" {
torPw = x.TorPassword
}
onionTransport, err = oniontp.NewOnionTransport("tcp4", torControl, torPw, nil, repoPath, usingTor && usingClearnet)
onionTransport, err = oniontp.NewOnionTransport("tcp4", torControl, torPw, nil, repoPath, (usingTor && usingClearnet))
if err != nil {
PrintError(err.Error())
return err
Expand Down
40 changes: 20 additions & 20 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ import (
"crypto/rand"
"errors"
"fmt"
"gx/ipfs/QmNSWW3Sb4eju4o2djPQ1L1c2Zj9XN9sMYJL8r1cbxdc6b/go-addr-util"
addrutil "gx/ipfs/QmNSWW3Sb4eju4o2djPQ1L1c2Zj9XN9sMYJL8r1cbxdc6b/go-addr-util"
p2pbhost "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/host/basic"
p2phost "gx/ipfs/QmNmJZL7FQySMtE2BQuLMuZg2EB2CLEunJJUSVSc9YnnbV/go-libp2p-host"
"gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net"
"gx/ipfs/QmRaVcGchmC1stHHK7YhcgEuTk5k1JiGS568pfYWMgT91H/go-libp2p-kad-dht"
manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net"
dht "gx/ipfs/QmRaVcGchmC1stHHK7YhcgEuTk5k1JiGS568pfYWMgT91H/go-libp2p-kad-dht"
dhtutil "gx/ipfs/QmRaVcGchmC1stHHK7YhcgEuTk5k1JiGS568pfYWMgT91H/go-libp2p-kad-dht/util"
ipfslogging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
"gx/ipfs/QmSwZMWwFZSUpe5muU2xgTUwppH24KfMwdPXiwbEp2c6G5/go-libp2p-swarm"
"gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing"
"gx/ipfs/QmTmqJGRQfuH8eKWD1FjThwPRipt1QhqJQNZ8MpzmfAAxo/go-ipfs-ds-help"
swarm "gx/ipfs/QmSwZMWwFZSUpe5muU2xgTUwppH24KfMwdPXiwbEp2c6G5/go-libp2p-swarm"
routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing"
dshelp "gx/ipfs/QmTmqJGRQfuH8eKWD1FjThwPRipt1QhqJQNZ8MpzmfAAxo/go-ipfs-ds-help"
recpb "gx/ipfs/QmUpttFinNDmNPgFwKN8sZK6BUtBmA68Y4KdSBDXa8t9sJ/go-libp2p-record/pb"
ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr"
ds "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore"
pstore "gx/ipfs/QmXauCuJzmzapetmC6W4TuDJLL1yFFrVzSHoWv8YdbmnxH/go-libp2p-peerstore"
smux "gx/ipfs/QmY9JXR3FupnYAYJWK9aMr9bCpqWKcToQ1tz8DVGTrHpHw/go-stream-muxer"
"gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
"gx/ipfs/QmZPrWxuM8GHr4cGKbyF5CCT11sFUP9hgqpeUHALvx2nUr/go-libp2p-interface-pnet"
"gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
"gx/ipfs/QmdeBtQGXjSt7cb97nx9JyLHHv5va2LyEAue7Q5tDFzpLy/go-libp2p-metrics"
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
ipnet "gx/ipfs/QmZPrWxuM8GHr4cGKbyF5CCT11sFUP9hgqpeUHALvx2nUr/go-libp2p-interface-pnet"
peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
metrics "gx/ipfs/QmdeBtQGXjSt7cb97nx9JyLHHv5va2LyEAue7Q5tDFzpLy/go-libp2p-metrics"
oniontp "gx/ipfs/Qmdh86HZtNap3ktHvjyiVhBnp4uRpQWMCRAASieh8fDH8J/go-onion-transport"
"io"
"io/ioutil"
Expand Down Expand Up @@ -85,7 +85,7 @@ var fileLogFormat = logging.MustStringFormatter(
)

var (
ErrNoGateways = errors.New("no gateway addresses configured")
ErrNoGateways = errors.New("No gateway addresses configured")
)

type Start struct {
Expand Down Expand Up @@ -114,19 +114,19 @@ func (x *Start) Execute(args []string) error {
printSplashScreen(x.Verbose)

if x.Testnet && x.Regtest {
return errors.New("invalid combination of testnet and regtest modes")
return errors.New("Invalid combination of testnet and regtest modes")
}

if x.Tor && x.DualStack {
return errors.New("invalid combination of tor and dual stack modes")
return errors.New("Invalid combination of tor and dual stack modes")
}

isTestnet := false
if x.Testnet || x.Regtest {
isTestnet = true
}
if x.BitcoinCash && x.ZCash != "" {
return errors.New("bitcoin cash and zcash cannot be used at the same time")
return errors.New("Bitcoin Cash and ZCash cannot be used at the same time")
}

// Set repo path
Expand Down Expand Up @@ -400,7 +400,7 @@ func (x *Start) Execute(args []string) error {
if x.TorPassword != "" {
torPw = x.TorPassword
}
onionTransport, err = oniontp.NewOnionTransport("tcp4", torControl, torPw, nil, repoPath, usingTor && usingClearnet)
onionTransport, err = oniontp.NewOnionTransport("tcp4", torControl, torPw, nil, repoPath, (usingTor && usingClearnet))
if err != nil {
log.Error("setup tor transport:", err)
return err
Expand Down Expand Up @@ -628,7 +628,7 @@ func (x *Start) Execute(args []string) error {
f.Close()
} else {
if string(cookie)[:len(cookiePrefix)] != cookiePrefix {
return errors.New("invalid authentication cookie. Delete it to generate a new one")
return errors.New("Invalid authentication cookie. Delete it to generate a new one")
}
split := strings.SplitAfter(string(cookie), cookiePrefix)
authCookie.Value = split[1]
Expand Down Expand Up @@ -703,12 +703,12 @@ func (x *Start) Execute(args []string) error {
storage = selfhosted.NewSelfHostedStorage(repoPath, core.Node.IpfsNode, pushNodes, core.Node.SendStore)
} else if x.Storage == "dropbox" {
if usingTor && !usingClearnet {
log.Error("dropbox can not be used with tor")
return errors.New("dropbox can not be used with tor")
log.Error("Dropbox can not be used with Tor")
return errors.New("Dropbox can not be used with Tor")
}

if dropboxToken == "" {
err = errors.New("dropbox token not set in config file")
err = errors.New("Dropbox token not set in config file")
log.Error(err)
return err
}
Expand All @@ -718,7 +718,7 @@ func (x *Start) Execute(args []string) error {
return err
}
} else {
err = errors.New("invalid storage option")
err = errors.New("Invalid storage option")
log.Error(err)
return err
}
Expand Down
12 changes: 6 additions & 6 deletions core/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (n *OpenBazaarNode) CompleteOrder(orderRatings *OrderRatings, contract *pb.
var rk []byte
if contract.DisputeResolution != nil {
if contract.VendorOrderConfirmation == nil {
return errors.New("cannot leave review because the vendor never accepted this order")
return errors.New("Cannot leave review because the vendor never accepted this order")
}
for _, sig := range contract.VendorOrderConfirmation.RatingSignatures {
if sig.Metadata.ListingSlug == r.Slug {
Expand All @@ -92,7 +92,7 @@ func (n *OpenBazaarNode) CompleteOrder(orderRatings *OrderRatings, contract *pb.
}
}
if len(contract.BuyerOrder.RatingKeys) < len(orderRatings.Ratings) {
return errors.New("invalid number of rating keys in buyer order")
return errors.New("Invalid number of rating keys in buyer order")
}
rk = contract.BuyerOrder.RatingKeys[z]

Expand Down Expand Up @@ -331,7 +331,7 @@ func (n *OpenBazaarNode) ReleaseFundsAfterTimeout(contract *pb.RicardianContract
}

if confirms < minConfirms {
EscrowTimeLockedError = fmt.Errorf("tx %s needs %d more confirmations before it can be spent", r.Txid, int(minConfirms-confirms))
EscrowTimeLockedError = fmt.Errorf("Tx %s needs %d more confirmations before it can be spent", r.Txid, int(minConfirms-confirms))
return EscrowTimeLockedError
}

Expand Down Expand Up @@ -577,11 +577,11 @@ func verifySignaturesOnOrderCompletion(contract *pb.RicardianContract) error {
); err != nil {
switch err.(type) {
case noSigError:
return errors.New("contract does not contain a signature for the order completion")
return errors.New("Contract does not contain a signature for the order completion")
case invalidSigError:
return errors.New("buyer's guid signature on contact failed to verify")
return errors.New("Buyer's guid signature on contact failed to verify")
case matchKeyError:
return errors.New("public key in order does not match reported buyer ID")
return errors.New("Public key in order does not match reported buyer ID")
default:
return err
}
Expand Down
Loading

0 comments on commit f50b53e

Please sign in to comment.