mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
swarm/storage: tracing for chunk
This commit is contained in:
parent
b72cd7eb70
commit
4ffd38efb7
3 changed files with 11 additions and 3 deletions
|
|
@ -546,6 +546,7 @@ func (s *LDBStore) CurrentStorageIndex() uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LDBStore) Put(chunk *Chunk) {
|
func (s *LDBStore) Put(chunk *Chunk) {
|
||||||
|
log.Trace("ldbstore.put", "key", chunk.Key)
|
||||||
ikey := getIndexKey(chunk.Key)
|
ikey := getIndexKey(chunk.Key)
|
||||||
var index dpaDBIndex
|
var index dpaDBIndex
|
||||||
|
|
||||||
|
|
@ -553,6 +554,7 @@ func (s *LDBStore) Put(chunk *Chunk) {
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
|
||||||
|
log.Trace("ldbstore.put: s.db.Get", "key", chunk.Key)
|
||||||
idata, err := s.db.Get(ikey)
|
idata, err := s.db.Get(ikey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.doPut(chunk, ikey, &index, po)
|
s.doPut(chunk, ikey, &index, po)
|
||||||
|
|
@ -562,7 +564,7 @@ func (s *LDBStore) Put(chunk *Chunk) {
|
||||||
close(chunk.dbStored)
|
close(chunk.dbStored)
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
log.Trace(fmt.Sprintf("DbStore: chunk already exists, only update access"))
|
log.Trace("ldbstore.put: chunk already exists, only update access", "key", chunk.Key)
|
||||||
decodeIndex(idata, &index)
|
decodeIndex(idata, &index)
|
||||||
close(chunk.dbStored)
|
close(chunk.dbStored)
|
||||||
}
|
}
|
||||||
|
|
@ -578,6 +580,7 @@ func (s *LDBStore) Put(chunk *Chunk) {
|
||||||
|
|
||||||
// force putting into db, does not check access index
|
// force putting into db, does not check access index
|
||||||
func (s *LDBStore) doPut(chunk *Chunk, ikey []byte, index *dpaDBIndex, po uint8) {
|
func (s *LDBStore) doPut(chunk *Chunk, ikey []byte, index *dpaDBIndex, po uint8) {
|
||||||
|
log.Trace("ldbstore.doPut", "key", chunk.Key)
|
||||||
data := s.encodeDataFunc(chunk)
|
data := s.encodeDataFunc(chunk)
|
||||||
s.batch.Put(getDataKey(s.dataIdx, po), data)
|
s.batch.Put(getDataKey(s.dataIdx, po), data)
|
||||||
index.Idx = s.dataIdx
|
index.Idx = s.dataIdx
|
||||||
|
|
@ -659,6 +662,7 @@ func (s *LDBStore) tryAccessIdx(ikey []byte, index *dpaDBIndex) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LDBStore) Get(key Key) (chunk *Chunk, err error) {
|
func (s *LDBStore) Get(key Key) (chunk *Chunk, err error) {
|
||||||
|
//log.Trace("ldbstore.get", "key", chunk.Key) - seems like chunk is nil sometimes
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
return s.get(key)
|
return s.get(key)
|
||||||
|
|
@ -671,6 +675,7 @@ func (s *LDBStore) get(key Key) (chunk *Chunk, err error) {
|
||||||
var data []byte
|
var data []byte
|
||||||
if s.getDataFunc != nil {
|
if s.getDataFunc != nil {
|
||||||
// if getDataFunc is defined, use it to retrieve the chunk data
|
// if getDataFunc is defined, use it to retrieve the chunk data
|
||||||
|
log.Trace("ldbstore.get retrieve with getDataFunc", "key", key)
|
||||||
data, err = s.getDataFunc(key)
|
data, err = s.getDataFunc(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
@ -680,9 +685,9 @@ func (s *LDBStore) get(key Key) (chunk *Chunk, err error) {
|
||||||
proximity := s.po(key)
|
proximity := s.po(key)
|
||||||
datakey := getDataKey(indx.Idx, proximity)
|
datakey := getDataKey(indx.Idx, proximity)
|
||||||
data, err = s.db.Get(datakey)
|
data, err = s.db.Get(datakey)
|
||||||
log.Trace(fmt.Sprintf("DBStore: Chunk %v indexkey %v datakey %x proximity %d", key.Log(), indx.Idx, datakey, proximity))
|
log.Trace("ldbstore.get retrieve", "key", key, "indexkey", indx.Idx, "datakey", datakey, "proximity", proximity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Trace(fmt.Sprintf("DBStore: Chunk %v found but could not be accessed: %v", key.Log(), err))
|
log.Trace("ldbstore.get chunk found but could not be accessed", "key", key, "err", err)
|
||||||
s.delete(indx.Idx, getIndexKey(key), s.po(key))
|
s.delete(indx.Idx, getIndexKey(key), s.po(key))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ func (self *LocalStore) CacheCounter() uint64 {
|
||||||
// LocalStore is itself a chunk store
|
// LocalStore is itself a chunk store
|
||||||
// unsafe, in that the data is not integrity checked
|
// unsafe, in that the data is not integrity checked
|
||||||
func (self *LocalStore) Put(chunk *Chunk) {
|
func (self *LocalStore) Put(chunk *Chunk) {
|
||||||
|
log.Trace("localstore.put", "key", chunk.Key)
|
||||||
self.mu.Lock()
|
self.mu.Lock()
|
||||||
defer self.mu.Unlock()
|
defer self.mu.Unlock()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ func (s *MemStore) Counter() uint {
|
||||||
|
|
||||||
// entry (not its copy) is going to be in MemStore
|
// entry (not its copy) is going to be in MemStore
|
||||||
func (s *MemStore) Put(entry *Chunk) {
|
func (s *MemStore) Put(entry *Chunk) {
|
||||||
|
log.Trace("memstore.put", "key", entry.Key)
|
||||||
if s.capacity == 0 {
|
if s.capacity == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -219,6 +220,7 @@ func (s *MemStore) Put(entry *Chunk) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MemStore) Get(hash Key) (chunk *Chunk, err error) {
|
func (s *MemStore) Get(hash Key) (chunk *Chunk, err error) {
|
||||||
|
log.Trace("memstore.get", "key", hash)
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue