swarm: remove unused/dead code (#18351)
This commit is contained in:
committed by
GitHub
parent
335760bf06
commit
9e9fc87e70
@@ -60,7 +60,3 @@ func (bv *BitVector) Set(i int, v bool) {
|
||||
func (bv *BitVector) Bytes() []byte {
|
||||
return bv.b
|
||||
}
|
||||
|
||||
func (bv *BitVector) Length() int {
|
||||
return bv.len
|
||||
}
|
||||
|
@@ -35,8 +35,6 @@ import (
|
||||
|
||||
const (
|
||||
DefaultNetworkID = 3
|
||||
// ProtocolMaxMsgSize maximum allowed message size
|
||||
ProtocolMaxMsgSize = 10 * 1024 * 1024
|
||||
// timeout for waiting
|
||||
bzzHandshakeTimeout = 3000 * time.Millisecond
|
||||
)
|
||||
@@ -250,11 +248,6 @@ func NewBzzPeer(p *protocols.Peer) *BzzPeer {
|
||||
return &BzzPeer{Peer: p, BzzAddr: NewAddr(p.Node())}
|
||||
}
|
||||
|
||||
// LastActive returns the time the peer was last active
|
||||
func (p *BzzPeer) LastActive() time.Time {
|
||||
return p.lastActive
|
||||
}
|
||||
|
||||
// ID returns the peer's underlay node identifier.
|
||||
func (p *BzzPeer) ID() enode.ID {
|
||||
// This is here to resolve a method tie: both protocols.Peer and BzzAddr are embedded
|
||||
|
@@ -20,7 +20,6 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
@@ -44,31 +43,7 @@ func init() {
|
||||
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
|
||||
}
|
||||
|
||||
type testStore struct {
|
||||
sync.Mutex
|
||||
|
||||
values map[string][]byte
|
||||
}
|
||||
|
||||
func (t *testStore) Load(key string) ([]byte, error) {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
v, ok := t.values[key]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("key not found: %s", key)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func (t *testStore) Save(key string, v []byte) error {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
t.values[key] = v
|
||||
return nil
|
||||
}
|
||||
|
||||
func HandshakeMsgExchange(lhs, rhs *HandshakeMsg, id enode.ID) []p2ptest.Exchange {
|
||||
|
||||
return []p2ptest.Exchange{
|
||||
{
|
||||
Expects: []p2ptest.Expect{
|
||||
|
@@ -17,14 +17,11 @@
|
||||
package intervals
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/state"
|
||||
)
|
||||
|
||||
var ErrNotFound = errors.New("not found")
|
||||
|
||||
// TestInmemoryStore tests basic functionality of InmemoryStore.
|
||||
func TestInmemoryStore(t *testing.T) {
|
||||
testStore(t, state.NewInmemoryStore())
|
||||
|
@@ -388,14 +388,6 @@ func (r *Registry) Quit(peerId enode.ID, s Stream) error {
|
||||
return peer.Send(context.TODO(), msg)
|
||||
}
|
||||
|
||||
func (r *Registry) NodeInfo() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Registry) PeerInfo(id enode.ID) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Registry) Close() error {
|
||||
return r.intervalsStore.Close()
|
||||
}
|
||||
|
@@ -127,19 +127,9 @@ func (s *SwarmSyncerServer) SetNextBatch(from, to uint64) ([]byte, uint64, uint6
|
||||
|
||||
// SwarmSyncerClient
|
||||
type SwarmSyncerClient struct {
|
||||
sessionAt uint64
|
||||
nextC chan struct{}
|
||||
sessionRoot storage.Address
|
||||
sessionReader storage.LazySectionReader
|
||||
retrieveC chan *storage.Chunk
|
||||
storeC chan *storage.Chunk
|
||||
store storage.SyncChunkStore
|
||||
// chunker storage.Chunker
|
||||
currentRoot storage.Address
|
||||
requestFunc func(chunk *storage.Chunk)
|
||||
end, start uint64
|
||||
peer *Peer
|
||||
stream Stream
|
||||
store storage.SyncChunkStore
|
||||
peer *Peer
|
||||
stream Stream
|
||||
}
|
||||
|
||||
// NewSwarmSyncerClient is a contructor for provable data exchange syncer
|
||||
@@ -209,46 +199,6 @@ func (s *SwarmSyncerClient) BatchDone(stream Stream, from uint64, hashes []byte,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SwarmSyncerClient) TakeoverProof(stream Stream, from uint64, hashes []byte, root storage.Address) (*TakeoverProof, error) {
|
||||
// for provable syncer currentRoot is non-zero length
|
||||
// TODO: reenable this with putter/getter
|
||||
// if s.chunker != nil {
|
||||
// if from > s.sessionAt { // for live syncing currentRoot is always updated
|
||||
// //expRoot, err := s.chunker.Append(s.currentRoot, bytes.NewReader(hashes), s.retrieveC, s.storeC)
|
||||
// expRoot, _, err := s.chunker.Append(s.currentRoot, bytes.NewReader(hashes), s.retrieveC)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// if !bytes.Equal(root, expRoot) {
|
||||
// return nil, fmt.Errorf("HandoverProof mismatch")
|
||||
// }
|
||||
// s.currentRoot = root
|
||||
// } else {
|
||||
// expHashes := make([]byte, len(hashes))
|
||||
// _, err := s.sessionReader.ReadAt(expHashes, int64(s.end*HashSize))
|
||||
// if err != nil && err != io.EOF {
|
||||
// return nil, err
|
||||
// }
|
||||
// if !bytes.Equal(expHashes, hashes) {
|
||||
// return nil, errors.New("invalid proof")
|
||||
// }
|
||||
// }
|
||||
// return nil, nil
|
||||
// }
|
||||
s.end += uint64(len(hashes)) / HashSize
|
||||
takeover := &Takeover{
|
||||
Stream: stream,
|
||||
Start: s.start,
|
||||
End: s.end,
|
||||
Root: root,
|
||||
}
|
||||
// serialise and sign
|
||||
return &TakeoverProof{
|
||||
Takeover: takeover,
|
||||
Sig: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *SwarmSyncerClient) Close() {}
|
||||
|
||||
// base for parsing and formating sync bin key
|
||||
|
Reference in New Issue
Block a user