mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
localStore implementing ChunkStore interface
This commit is contained in:
parent
558fe2aaf8
commit
630a0b6748
1 changed files with 29 additions and 0 deletions
29
bzz/localstore.go
Normal file
29
bzz/localstore.go
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// localstore.go
|
||||||
|
package bzz
|
||||||
|
|
||||||
|
type localStore struct {
|
||||||
|
memStore *memStore
|
||||||
|
dbStore *dbStore
|
||||||
|
}
|
||||||
|
|
||||||
|
// localStore is itself a chunk store , to stores a chunk only
|
||||||
|
// its integrity is checked ?
|
||||||
|
func (self *localStore) Put(chunk *Chunk) {
|
||||||
|
self.memStore.Put(chunk)
|
||||||
|
self.dbStore.Put(chunk)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get(chunk *Chunk) looks up a chunk in the local stores
|
||||||
|
// This method is blocking until the chunk is retrieved so additional timeout is needed to wrap this call
|
||||||
|
func (self *localStore) Get(key Key) (chunk *Chunk, err error) {
|
||||||
|
chunk, err = self.memStore.Get(key)
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
chunk, err = self.dbStore.Get(key)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.memStore.Put(chunk)
|
||||||
|
return
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue