mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
Merge branch 'bzz' of https://github.com/ethersphere/go-ethereum into bzz
This commit is contained in:
commit
0e07d1921e
3 changed files with 23 additions and 13 deletions
|
|
@ -284,7 +284,6 @@ func (s *dbStore) Put(chunk *Chunk) {
|
|||
batch.Put(ikey, idata)
|
||||
|
||||
s.db.Write(batch)
|
||||
|
||||
}
|
||||
|
||||
// try to find index; if found, update access cnt and return true
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package bzz
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/bzz/test"
|
||||
"os"
|
||||
"testing"
|
||||
|
|
@ -16,25 +15,23 @@ func TestDPA(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("DB error: %v", err)
|
||||
}
|
||||
// memStore := newMemStore(dbStore)
|
||||
// localStore := &localStore{
|
||||
// memStore,
|
||||
// dbStore,
|
||||
// }
|
||||
memStore := newMemStore(dbStore)
|
||||
localStore := &localStore{
|
||||
memStore,
|
||||
dbStore,
|
||||
}
|
||||
chunker := &TreeChunker{}
|
||||
chunker.Init()
|
||||
dpa := &DPA{
|
||||
Chunker: chunker,
|
||||
ChunkStore: dbStore,
|
||||
ChunkStore: localStore,
|
||||
}
|
||||
dpa.Start()
|
||||
reader, slice := testDataReader(0x100)
|
||||
fmt.Printf("Chunk size: %d.", len(slice))
|
||||
reader, slice := testDataReader(0x1000000)
|
||||
key, err := dpa.Store(reader)
|
||||
if err != nil {
|
||||
t.Errorf("Store error: %v", err)
|
||||
}
|
||||
// time.Sleep(2 * time.Second)
|
||||
resultReader := dpa.Retrieve(key)
|
||||
resultSlice := make([]byte, len(slice))
|
||||
n, err := resultReader.ReadAt(resultSlice, 0)
|
||||
|
|
@ -47,5 +44,19 @@ func TestDPA(t *testing.T) {
|
|||
if !bytes.Equal(slice, resultSlice) {
|
||||
t.Errorf("Comparison error.")
|
||||
}
|
||||
// time.Sleep(time.Second)
|
||||
localStore.memStore = newMemStore(dbStore)
|
||||
resultReader = dpa.Retrieve(key)
|
||||
for i, _ := range resultSlice {
|
||||
resultSlice[i] = 0
|
||||
}
|
||||
n, err = resultReader.ReadAt(resultSlice, 0)
|
||||
if err != nil {
|
||||
t.Errorf("Retrieve error after removing memStore: %v", err)
|
||||
}
|
||||
if n != len(slice) {
|
||||
t.Errorf("Slice size error after removing memStore got %d, expected %d.", n, len(slice))
|
||||
}
|
||||
if !bytes.Equal(slice, resultSlice) {
|
||||
t.Errorf("Comparison error after removing memStore.")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ type localStore struct {
|
|||
// its integrity is checked ?
|
||||
func (self *localStore) Put(chunk *Chunk) {
|
||||
self.memStore.Put(chunk)
|
||||
self.dbStore.Put(chunk)
|
||||
go self.dbStore.Put(chunk)
|
||||
}
|
||||
|
||||
// Get(chunk *Chunk) looks up a chunk in the local stores
|
||||
|
|
|
|||
Loading…
Reference in a new issue