aboutsummaryrefslogtreecommitdiffstats
path: root/swarm
diff options
context:
space:
mode:
authorEmil <mursalimovemeel@gmail.com>2018-09-15 04:07:13 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-09-15 04:07:13 +0800
commit86a03f97d30c11a5321fa2f0fd37cbc4c7f63a32 (patch)
tree92ee61a4d5a2c750b6abc257f30b040485e29842 /swarm
parent7bb95a9a64c9d26bef4f15fdd9301bb0b5cdb668 (diff)
downloadgo-tangerine-86a03f97d30c11a5321fa2f0fd37cbc4c7f63a32.tar
go-tangerine-86a03f97d30c11a5321fa2f0fd37cbc4c7f63a32.tar.gz
go-tangerine-86a03f97d30c11a5321fa2f0fd37cbc4c7f63a32.tar.bz2
go-tangerine-86a03f97d30c11a5321fa2f0fd37cbc4c7f63a32.tar.lz
go-tangerine-86a03f97d30c11a5321fa2f0fd37cbc4c7f63a32.tar.xz
go-tangerine-86a03f97d30c11a5321fa2f0fd37cbc4c7f63a32.tar.zst
go-tangerine-86a03f97d30c11a5321fa2f0fd37cbc4c7f63a32.zip
all: simplify s[:] to s where s is a slice (#17673)
Diffstat (limited to 'swarm')
-rw-r--r--swarm/api/http/server_test.go14
-rw-r--r--swarm/pss/pss.go2
-rw-r--r--swarm/storage/ldbstore.go10
-rw-r--r--swarm/storage/ldbstore_test.go2
-rw-r--r--swarm/storage/types.go2
5 files changed, 15 insertions, 15 deletions
diff --git a/swarm/api/http/server_test.go b/swarm/api/http/server_test.go
index 2acdbd1ad..4a3ca0429 100644
--- a/swarm/api/http/server_test.go
+++ b/swarm/api/http/server_test.go
@@ -501,7 +501,7 @@ func testBzzGetPath(encrypted bool, t *testing.T) {
var respbody []byte
url := srv.URL + "/bzz-raw:/"
- if k[:] != "" {
+ if k != "" {
url += rootRef + "/" + k[1:] + "?content_type=text/plain"
}
resp, err = http.Get(url)
@@ -515,7 +515,7 @@ func testBzzGetPath(encrypted bool, t *testing.T) {
isexpectedfailrequest := false
for _, r := range expectedfailrequests {
- if k[:] == r {
+ if k == r {
isexpectedfailrequest = true
}
}
@@ -530,7 +530,7 @@ func testBzzGetPath(encrypted bool, t *testing.T) {
var respbody []byte
url := srv.URL + "/bzz-hash:/"
- if k[:] != "" {
+ if k != "" {
url += rootRef + "/" + k[1:]
}
resp, err = http.Get(url)
@@ -547,7 +547,7 @@ func testBzzGetPath(encrypted bool, t *testing.T) {
isexpectedfailrequest := false
for _, r := range expectedfailrequests {
- if k[:] == r {
+ if k == r {
isexpectedfailrequest = true
}
}
@@ -599,7 +599,7 @@ func testBzzGetPath(encrypted bool, t *testing.T) {
} {
k := c.path
url := srv.URL + "/bzz-list:/"
- if k[:] != "" {
+ if k != "" {
url += rootRef + "/" + k[1:]
}
t.Run("json list "+c.path, func(t *testing.T) {
@@ -618,7 +618,7 @@ func testBzzGetPath(encrypted bool, t *testing.T) {
isexpectedfailrequest := false
for _, r := range expectedfailrequests {
- if k[:] == r {
+ if k == r {
isexpectedfailrequest = true
}
}
@@ -650,7 +650,7 @@ func testBzzGetPath(encrypted bool, t *testing.T) {
isexpectedfailrequest := false
for _, r := range expectedfailrequests {
- if k[:] == r {
+ if k == r {
isexpectedfailrequest = true
}
}
diff --git a/swarm/pss/pss.go b/swarm/pss/pss.go
index b55c97fdd..b96649fea 100644
--- a/swarm/pss/pss.go
+++ b/swarm/pss/pss.go
@@ -448,7 +448,7 @@ func (p *Pss) isSelfRecipient(msg *PssMsg) bool {
// test match of leftmost bytes in given message to node's Kademlia address
func (p *Pss) isSelfPossibleRecipient(msg *PssMsg) bool {
local := p.Kademlia.BaseAddr()
- return bytes.Equal(msg.To[:], local[:len(msg.To)])
+ return bytes.Equal(msg.To, local[:len(msg.To)])
}
/////////////////////////////////////////////////////////////////////
diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go
index 8ab7e60b3..bde627394 100644
--- a/swarm/storage/ldbstore.go
+++ b/swarm/storage/ldbstore.go
@@ -85,7 +85,7 @@ func NewLDBStoreParams(storeparams *StoreParams, path string) *LDBStoreParams {
return &LDBStoreParams{
StoreParams: storeparams,
Path: path,
- Po: func(k Address) (ret uint8) { return uint8(Proximity(storeparams.BaseKey[:], k[:])) },
+ Po: func(k Address) (ret uint8) { return uint8(Proximity(storeparams.BaseKey, k[:])) },
}
}
@@ -322,7 +322,7 @@ func (s *LDBStore) Export(out io.Writer) (int64, error) {
log.Trace("store.export", "dkey", fmt.Sprintf("%x", datakey), "dataidx", index.Idx, "po", po)
data, err := s.db.Get(datakey)
if err != nil {
- log.Warn(fmt.Sprintf("Chunk %x found but could not be accessed: %v", key[:], err))
+ log.Warn(fmt.Sprintf("Chunk %x found but could not be accessed: %v", key, err))
continue
}
@@ -455,7 +455,7 @@ func (s *LDBStore) Cleanup() {
}
if !found {
- log.Warn(fmt.Sprintf("Chunk %x found but count not be accessed with any po", key[:]))
+ log.Warn(fmt.Sprintf("Chunk %x found but count not be accessed with any po", key))
errorsFound++
continue
}
@@ -469,10 +469,10 @@ func (s *LDBStore) Cleanup() {
}
cs := int64(binary.LittleEndian.Uint64(c.sdata[:8]))
- log.Trace("chunk", "key", fmt.Sprintf("%x", key[:]), "ck", fmt.Sprintf("%x", ck), "dkey", fmt.Sprintf("%x", datakey), "dataidx", index.Idx, "po", po, "len data", len(data), "len sdata", len(c.sdata), "size", cs)
+ log.Trace("chunk", "key", fmt.Sprintf("%x", key), "ck", fmt.Sprintf("%x", ck), "dkey", fmt.Sprintf("%x", datakey), "dataidx", index.Idx, "po", po, "len data", len(data), "len sdata", len(c.sdata), "size", cs)
if len(c.sdata) > ch.DefaultSize+8 {
- log.Warn("chunk for cleanup", "key", fmt.Sprintf("%x", key[:]), "ck", fmt.Sprintf("%x", ck), "dkey", fmt.Sprintf("%x", datakey), "dataidx", index.Idx, "po", po, "len data", len(data), "len sdata", len(c.sdata), "size", cs)
+ log.Warn("chunk for cleanup", "key", fmt.Sprintf("%x", key), "ck", fmt.Sprintf("%x", ck), "dkey", fmt.Sprintf("%x", datakey), "dataidx", index.Idx, "po", po, "len data", len(data), "len sdata", len(c.sdata), "size", cs)
s.delete(index.Idx, getIndexKey(key[1:]), po)
removed++
errorsFound++
diff --git a/swarm/storage/ldbstore_test.go b/swarm/storage/ldbstore_test.go
index ae70ee259..75b5d6aa9 100644
--- a/swarm/storage/ldbstore_test.go
+++ b/swarm/storage/ldbstore_test.go
@@ -74,7 +74,7 @@ func newTestDbStore(mock bool, trusted bool) (*testDbStore, func(), error) {
func testPoFunc(k Address) (ret uint8) {
basekey := make([]byte, 32)
- return uint8(Proximity(basekey[:], k[:]))
+ return uint8(Proximity(basekey, k[:]))
}
func (db *testDbStore) close() {
diff --git a/swarm/storage/types.go b/swarm/storage/types.go
index bc2af2cd7..8c70f4584 100644
--- a/swarm/storage/types.go
+++ b/swarm/storage/types.go
@@ -136,7 +136,7 @@ func (a Address) Log() string {
}
func (a Address) String() string {
- return fmt.Sprintf("%064x", []byte(a)[:])
+ return fmt.Sprintf("%064x", []byte(a))
}
func (a Address) MarshalJSON() (out []byte, err error) {