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

Commit c4660c1

Browse files
committed
Cleanup comments
1 parent 8a931fb commit c4660c1

36 files changed

+210
-214
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ This repository contains the OpenBazaar server daemon which handles the heavy li
2525

2626
## Install
2727

28-
A typical install of OpenBazaar contains a bundle of the server deamon and user interface. If this is what you are looking for you can find an installer at https://openbazaar.org/download.html. If you're looking to run the server daemon by itself or to contribute to developement see below for instructions.
28+
A typical install of OpenBazaar contains a bundle of the server deamon and user interface. If this is what you are looking for you can find an installer at https://openbazaar.org/download.html. If you are looking to run the server daemon by itself or to contribute to developement see below for instructions.
2929

3030
### Install prebuilt packages
3131

3232
The easiest way to run the server is to download a pre-built binary. You can find binaries of our latest release for each operating system [here](https://github.com/OpenBazaar/openbazaar-go/releases/).
3333

3434
### Build from Source
3535

36-
To build from source you will need to have Go installed and properly configured. Detailed instructs for installing Go and openbazaar-go on each operating system can be found in the [docs package](https://github.com/OpenBazaar/openbazaar-go/tree/master/docs).
36+
To build from source you will need to have Go installed and properly configured. Detailed instructs for installing Go and openbazaar-go on each operating system can be found in the [docs package](https://github.com/OpenBazaar/openbazaar-go/tree/master/docs).
3737

3838
## Dependency Management
3939

api/gateway.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func Serve(cb chan<- bool, node *core.OpenBazaarNode, ctx commands.Context, auth
5656
return err
5757
}
5858

59-
// if the server exits beforehand
59+
// If the server exits beforehand
6060
var serverError error
6161
serverExited := make(chan struct{})
6262

@@ -69,11 +69,11 @@ func Serve(cb chan<- bool, node *core.OpenBazaarNode, ctx commands.Context, auth
6969
close(serverExited)
7070
})
7171

72-
// wait for server to exit.
72+
// Wait for server to exit
7373
select {
7474
case <-serverExited:
7575

76-
// if node being closed before server exits, close server
76+
// If node being closed before server exits, close server
7777
case <-node.IpfsNode.Process().Closing():
7878
log.Infof("server at %s terminating...", addr)
7979
if config.SSL {
@@ -84,10 +84,10 @@ func Serve(cb chan<- bool, node *core.OpenBazaarNode, ctx commands.Context, auth
8484

8585
outer:
8686
for {
87-
// wait until server exits
87+
// Wait until server exits
8888
select {
8989
case <-serverExited:
90-
// if the server exited as we are closing, we really dont care about errors
90+
// If the server exited as we are closing, we really do not care about errors
9191
serverError = nil
9292
break outer
9393
case <-time.After(5 * time.Second):

api/hub.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package api
22

33
type hub struct {
4-
// Registered connections.
4+
// Registered connections
55
connections map[*connection]bool
66

7-
// Inbound messages from the connections.
7+
// Inbound messages from the connections
88
Broadcast chan []byte
99

10-
// Register requests from the connections.
10+
// Register requests from the connections
1111
register chan *connection
1212

13-
// Unregister requests from connections.
13+
// Unregister requests from connections
1414
unregister chan *connection
1515
}
1616

api/jsonapi.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (i *jsonAPIHandler) POSTProfile(w http.ResponseWriter, r *http.Request) {
192192
return
193193
}
194194

195-
// Write profile back out as json
195+
// Write profile back out as JSON
196196
m := jsonpb.Marshaler{
197197
EnumsAsInts: false,
198198
EmitDefaults: true,
@@ -210,7 +210,7 @@ func (i *jsonAPIHandler) POSTProfile(w http.ResponseWriter, r *http.Request) {
210210

211211
func (i *jsonAPIHandler) PUTProfile(w http.ResponseWriter, r *http.Request) {
212212

213-
// If profile isn't set tell them to use POST
213+
// If profile is not set tell them to use POST
214214
profilePath := path.Join(i.node.RepoPath, "root", "profile")
215215
_, ferr := os.Stat(profilePath)
216216
if os.IsNotExist(ferr) {
@@ -246,7 +246,7 @@ func (i *jsonAPIHandler) PUTProfile(w http.ResponseWriter, r *http.Request) {
246246
return
247247
}
248248

249-
// Return the profile in json format
249+
// Return the profile in JSON format
250250
m := jsonpb.Marshaler{
251251
EnumsAsInts: false,
252252
EmitDefaults: true,

api/ws.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import (
99
)
1010

1111
type connection struct {
12-
// The websocket connection.
12+
// The websocket connection
1313
ws *websocket.Conn
1414

15-
// Buffered channel of outbound messages.
15+
// Buffered channel of outbound messages
1616
send chan []byte
1717

18-
// The hub.
18+
// The hub
1919
h *hub
2020
}
2121

@@ -27,7 +27,7 @@ func (c *connection) reader() {
2727
}
2828
log.Debugf("Incoming websocket message: %s", string(message))
2929

30-
// Just echo for now until we set up the api
30+
// Just echo for now until we set up the API
3131
c.h.Broadcast <- message
3232
}
3333
c.ws.Close()

bitcoin/exchange/bitcoinprices_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestDecodeBitcoinAverage(t *testing.T) {
122122
"volume_percent": 0.0
123123
}}`
124124

125-
// Test missing json element
125+
// Test missing JSON element
126126
r = &req{bytes.NewReader([]byte(resp))}
127127
err = b.decode(r)
128128
if err == nil {
@@ -137,7 +137,7 @@ func TestDecodeBitcoinAverage(t *testing.T) {
137137
"volume_percent": 0.0
138138
}`
139139

140-
// Test invalid json
140+
// Test invalid JSON
141141
r = &req{bytes.NewReader([]byte(resp))}
142142
err = b.decode(r)
143143
if err == nil {
@@ -169,14 +169,14 @@ func TestDecodeBitPay(t *testing.T) {
169169
}
170170

171171
resp := `[{"code":"BTC","name":"Bitcoin"},{"code":"USD","name":"US Dollar","rate":611.02},{"code":"EUR","name":"Eurozone Euro","rate":546.740696},{"code":"GBP","name":"Pound Sterling","rate":462.982074},{"code":"JPY","name":"Japanese Yen","rate":62479.23908}]`
172-
// Test missing json element
172+
// Test missing JSON element
173173
r = &req{bytes.NewReader([]byte(resp))}
174174
err = b.decode(r)
175175
if err == nil {
176176
t.Error(err)
177177
}
178178
resp = `[{"name":"Bitcoin","rate":611.02},{"code":"USD","name":"US Dollar","rate":611.02},{"code":"EUR","name":"Eurozone Euro","rate":546.740696},{"code":"GBP","name":"Pound Sterling","rate":462.982074},{"code":"JPY","name":"Japanese Yen","rate":62479.23908}]`
179-
// Test missing json element
179+
// Test missing JSON element
180180
r = &req{bytes.NewReader([]byte(resp))}
181181
err = b.decode(r)
182182
if err == nil {
@@ -212,7 +212,7 @@ func TestDecodeBlockChainInfo(t *testing.T) {
212212
resp := `{"USD" : [{"15m" : 612.73, "last" : 612.73, "buy" : 611.1, "sell" : 612.72, "symbol" : "$"}],
213213
"ISK" : {"15m" : 74706.49, "last" : 74706.49, "buy" : 74507.76, "sell" : 74705.27, "symbol" : "kr"},
214214
"HKD" : {"15m" : 4752.76, "last" : 4752.76, "buy" : 4740.11, "sell" : 4752.68, "symbol" : "$"}}`
215-
// Test missing json element
215+
// Test missing JSON element
216216
r = &req{bytes.NewReader([]byte(resp))}
217217
err = b.decode(r)
218218
if err == nil {
@@ -221,7 +221,7 @@ func TestDecodeBlockChainInfo(t *testing.T) {
221221
resp = `{"USD" : {"15m" : 612.73, "buy" : 611.1, "sell" : 612.72, "symbol" : "$"},
222222
"ISK" : {"15m" : 74706.49, "last" : 74706.49, "buy" : 74507.76, "sell" : 74705.27, "symbol" : "kr"},
223223
"HKD" : {"15m" : 4752.76, "last" : 4752.76, "buy" : 4740.11, "sell" : 4752.68, "symbol" : "$"}}`
224-
// Test missing json element
224+
// Test missing JSON element
225225
r = &req{bytes.NewReader([]byte(resp))}
226226
err = b.decode(r)
227227
if err == nil {
@@ -253,30 +253,30 @@ func TestDecodeBitcoinCharts(t *testing.T) {
253253
}
254254

255255
resp := `{"USD": {"7d": "642.47", "30d": "656.26"}, "IDR": {"7d": "8473454.17", "30d": "8611783.41", "24h": "8118676.19"}, "ILS": {"7d": "2486.06", "30d": "2595.67", "24h": "2351.95"}, "GBP": {"7d": "499.01", "30d": "508.06", "24h": "479.65"}}`
256-
// Test missing json element
256+
// Test missing JSON element
257257
r = &req{bytes.NewReader([]byte(resp))}
258258
err = b.decode(r)
259259
if err != nil {
260260
t.Error(err)
261261
}
262262
resp = `{"USD": {"7d": "642.47", "30d": "656.26", "24h": 618.68}, "IDR": {"7d": "8473454.17", "30d": "8611783.41", "24h": "8118676.19"}, "ILS": {"7d": "2486.06", "30d": "2595.67", "24h": "2351.95"}, "GBP": {"7d": "499.01", "30d": "508.06", "24h": "479.65"}}`
263-
// Test malformatted json
263+
// Test malformatted JSON
264264
r = &req{bytes.NewReader([]byte(resp))}
265265
err = b.decode(r)
266266
if err == nil {
267267
t.Error(err)
268268
}
269269

270270
resp = `{"USD": {"7d": "642.47", "30d": "656.26", "24h": "asdf"}, "IDR": {"7d": "8473454.17", "30d": "8611783.41", "24h": "8118676.19"}, "ILS": {"7d": "2486.06", "30d": "2595.67", "24h": "2351.95"}, "GBP": {"7d": "499.01", "30d": "508.06", "24h": "479.65"}}`
271-
// Test malformatted json
271+
// Test malformatted JSON
272272
r = &req{bytes.NewReader([]byte(resp))}
273273
err = b.decode(r)
274274
if err == nil {
275275
t.Error(err)
276276
}
277277

278278
resp = `{"USD": [{"7d": "642.47", "30d": "656.26", "24h": "615.00"}], "IDR": {"7d": "8473454.17", "30d": "8611783.41", "24h": "8118676.19"}, "ILS": {"7d": "2486.06", "30d": "2595.67", "24h": "2351.95"}, "GBP": {"7d": "499.01", "30d": "508.06", "24h": "479.65"}}`
279-
// Test malformatted json
279+
// Test malformatted JSON
280280
r = &req{bytes.NewReader([]byte(resp))}
281281
err = b.decode(r)
282282
if err == nil {

bitcoin/exchangerates.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package bitcoin
22

33
type ExchangeRates interface {
44

5-
// Fetch the exchange rate for the given currency
6-
// It's OK if this returns from a cache.
5+
/* Fetch the exchange rate for the given currency
6+
It is OK if this returns from a cache. */
77
GetExchangeRate(currencyCode string) (float64, error)
88

9-
// Update the prices with the current exchange rate before returning.
9+
// Update the prices with the current exchange rate before returning
1010
GetLatestRate(currencyCode string) (float64, error)
1111

12-
// Return the number of currency units per coin. For example, in bitcoin
13-
// this is 100m satoshi per BTC. This is used when converting from fiat
14-
// to the smaller currency unit.
12+
/* Return the number of currency units per coin. For example, in bitcoin
13+
this is 100m satoshi per BTC. This is used when converting from fiat
14+
to the smaller currency unit. */
1515
UnitsPerCoin() int
1616
}

bitcoin/listeners/transaction_listener.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (l *TransactionListener) processSalePayment(txid []byte, output spvwallet.T
111111
funding := output.Value
112112
for _, r := range records {
113113
funding += r.Value
114-
// If we've already seen this transaction for some reason, just return
114+
// If we have already seen this transaction for some reason, just return
115115
if r.Txid == chainHash.String() {
116116
return
117117
}
@@ -161,7 +161,7 @@ func (l *TransactionListener) processPurchasePayment(txid []byte, output spvwall
161161
funding := output.Value
162162
for _, r := range records {
163163
funding += r.Value
164-
// If we've already seen this transaction for some reason, just return
164+
// If we have already seen this transaction for some reason, just return
165165
if r.Txid == chainHash.String() {
166166
return
167167
}

core/core.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ type OpenBazaarNode struct {
3232
// IPFS node object
3333
IpfsNode *core.IpfsNode
3434

35-
// The roothash of the node directory inside the openbazaar repo.
36-
// This directory hash is published on IPNS at our peer ID making
37-
// the directory publicly viewable on the network.
35+
/* The roothash of the node directory inside the openbazaar repo.
36+
This directory hash is published on IPNS at our peer ID making
37+
the directory publicly viewable on the network. */
3838
RootHash string
3939

40-
// The path to the openbazaar repo in the file system.
40+
// The path to the openbazaar repo in the file system
4141
RepoPath string
4242

4343
// The OpenBazaar network service for direct communication between peers
@@ -46,7 +46,7 @@ type OpenBazaarNode struct {
4646
// Database for storing node specific data
4747
Datastore repo.Datastore
4848

49-
// Websocket channel used for pushing data to the UI.
49+
// Websocket channel used for pushing data to the UI
5050
Broadcast chan []byte
5151

5252
// Bitcoin wallet implementation
@@ -71,7 +71,7 @@ type OpenBazaarNode struct {
7171
CrosspostGateways []*url.URL
7272
}
7373

74-
// Unpin the current node repo, re-add it, then publish to ipns
74+
// Unpin the current node repo, re-add it, then publish to IPNS
7575
func (n *OpenBazaarNode) SeedNode() error {
7676
hash, aerr := ipfs.AddDirectory(n.Context, path.Join(n.RepoPath, "root"))
7777
if aerr != nil {
@@ -103,8 +103,8 @@ func (n *OpenBazaarNode) publish(hash string) {
103103
}
104104
}
105105

106-
// This is a placeholder until the libsignal is operational
107-
// For now we will just encrypt outgoing offline messages with the long lived identity key.
106+
/* This is a placeholder until the libsignal is operational.
107+
For now we will just encrypt outgoing offline messages with the long lived identity key. */
108108
func (n *OpenBazaarNode) EncryptMessage(peerId peer.ID, message []byte) (ct []byte, rerr error) {
109109
ctx, cancel := context.WithCancel(context.Background())
110110
defer cancel()

core/follow.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"path"
1010
)
1111

12-
// This function updates the follow and following lists in the node's root directory
13-
// as well as adds the current follow, following, and listing counts to the profile.
14-
// We only do this when a user updates his node to avoid needing to make network calls
15-
// each time a new follower or unfollow request comes in.
12+
/* This function updates the follow and following lists in the node's root directory
13+
as well as adds the current follow, following, and listing counts to the profile.
14+
We only do this when a user updates his node to avoid needing to make network calls
15+
each time a new follower or unfollow request comes in. */
1616
func (n *OpenBazaarNode) UpdateFollow() error {
1717
followPath := path.Join(n.RepoPath, "root", "followers")
1818
followingPath := path.Join(n.RepoPath, "root", "following")
@@ -69,7 +69,7 @@ func (n *OpenBazaarNode) UpdateFollow() error {
6969

7070
_, ferr := os.Stat(profilePath)
7171
if !os.IsNotExist(ferr) {
72-
// read existing file
72+
// Read existing file
7373
file, err := ioutil.ReadFile(profilePath)
7474
if err != nil {
7575
return err

0 commit comments

Comments
 (0)