aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/storage
diff options
context:
space:
mode:
authorFerenc Szabo <frncmx@gmail.com>2018-10-27 22:18:42 +0800
committerAnton Evangelatov <anton.evangelatov@gmail.com>2018-10-27 22:18:42 +0800
commit54f650a3be2ccf7cd44e9929e3e132ef93f101ad (patch)
tree7e9a4db7c61b5b3009c4b01ad06b0de0a66f941f /swarm/storage
parent8ed4739176f435d09dfa36d8b2e2a3c8c6f407dd (diff)
downloadgo-tangerine-54f650a3be2ccf7cd44e9929e3e132ef93f101ad.tar
go-tangerine-54f650a3be2ccf7cd44e9929e3e132ef93f101ad.tar.gz
go-tangerine-54f650a3be2ccf7cd44e9929e3e132ef93f101ad.tar.bz2
go-tangerine-54f650a3be2ccf7cd44e9929e3e132ef93f101ad.tar.lz
go-tangerine-54f650a3be2ccf7cd44e9929e3e132ef93f101ad.tar.xz
go-tangerine-54f650a3be2ccf7cd44e9929e3e132ef93f101ad.tar.zst
go-tangerine-54f650a3be2ccf7cd44e9929e3e132ef93f101ad.zip
swarm: clean up unused private types and functions (#17989)
* swarm: clean up unused private types and functions Those that were identified by code inspection tool. * swarm/storage: move/add Proximity GoDoc from deleted private function The mentioned proximity() private function was deleted in: 1ca8fc1e6fa0ab4ab1aaca06d6fb32e173cd5f2f
Diffstat (limited to 'swarm/storage')
-rw-r--r--swarm/storage/common_test.go11
-rw-r--r--swarm/storage/feed/handler_test.go13
-rw-r--r--swarm/storage/ldbstore.go20
-rw-r--r--swarm/storage/types.go13
4 files changed, 13 insertions, 44 deletions
diff --git a/swarm/storage/common_test.go b/swarm/storage/common_test.go
index 33133edd7..600be164a 100644
--- a/swarm/storage/common_test.go
+++ b/swarm/storage/common_test.go
@@ -88,17 +88,6 @@ func mputRandomChunks(store ChunkStore, n int, chunksize int64) ([]Chunk, error)
return mput(store, n, GenerateRandomChunk)
}
-func mputChunks(store ChunkStore, chunks ...Chunk) error {
- i := 0
- f := func(n int64) Chunk {
- chunk := chunks[i]
- i++
- return chunk
- }
- _, err := mput(store, len(chunks), f)
- return err
-}
-
func mput(store ChunkStore, n int, f func(i int64) Chunk) (hs []Chunk, err error) {
// put to localstore and wait for stored channel
// does not check delivery error state
diff --git a/swarm/storage/feed/handler_test.go b/swarm/storage/feed/handler_test.go
index cf95bc1f5..fb2ef3a6b 100644
--- a/swarm/storage/feed/handler_test.go
+++ b/swarm/storage/feed/handler_test.go
@@ -27,7 +27,6 @@ import (
"time"
"github.com/ethereum/go-ethereum/crypto"
-
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/chunk"
"github.com/ethereum/go-ethereum/swarm/storage"
@@ -506,15 +505,3 @@ func newCharlieSigner() *GenericSigner {
privKey, _ := crypto.HexToECDSA("facadefacadefacadefacadefacadefacadefacadefacadefacadefacadefaca")
return NewGenericSigner(privKey)
}
-
-func getUpdateDirect(rh *Handler, addr storage.Address) ([]byte, error) {
- chunk, err := rh.chunkStore.Get(context.TODO(), addr)
- if err != nil {
- return nil, err
- }
- var r Request
- if err := r.fromChunk(addr, chunk.Data()); err != nil {
- return nil, err
- }
- return r.data, nil
-}
diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go
index 49508911f..9feb68741 100644
--- a/swarm/storage/ldbstore.go
+++ b/swarm/storage/ldbstore.go
@@ -39,7 +39,6 @@ import (
"github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/storage/mock"
"github.com/syndtr/goleveldb/leveldb"
- "github.com/syndtr/goleveldb/leveldb/opt"
)
const (
@@ -72,13 +71,6 @@ var (
ErrDBClosed = errors.New("LDBStore closed")
)
-type gcItem struct {
- idx *dpaDBIndex
- value uint64
- idxKey []byte
- po uint8
-}
-
type LDBStoreParams struct {
*StoreParams
Path string
@@ -961,15 +953,3 @@ func (s *LDBStore) SyncIterator(since uint64, until uint64, po uint8, f func(Add
}
return it.Error()
}
-
-func databaseExists(path string) bool {
- o := &opt.Options{
- ErrorIfMissing: true,
- }
- tdb, err := leveldb.OpenFile(path, o)
- if err != nil {
- return false
- }
- defer tdb.Close()
- return true
-}
diff --git a/swarm/storage/types.go b/swarm/storage/types.go
index 8c70f4584..ada86831f 100644
--- a/swarm/storage/types.go
+++ b/swarm/storage/types.go
@@ -80,6 +80,19 @@ func (a Address) bits(i, j uint) uint {
return res
}
+// Proximity(x, y) returns the proximity order of the MSB distance between x and y
+//
+// The distance metric MSB(x, y) of two equal length byte sequences x an y is the
+// value of the binary integer cast of the x^y, ie., x and y bitwise xor-ed.
+// the binary cast is big endian: most significant bit first (=MSB).
+//
+// Proximity(x, y) is a discrete logarithmic scaling of the MSB distance.
+// It is defined as the reverse rank of the integer part of the base 2
+// logarithm of the distance.
+// It is calculated by counting the number of common leading zeros in the (MSB)
+// binary representation of the x^y.
+//
+// (0 farthest, 255 closest, 256 self)
func Proximity(one, other []byte) (ret int) {
b := (MaxPO-1)/8 + 1
if b > len(one) {