diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-19 23:56:01 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-19 23:56:01 +0800 |
commit | b05e63c34d335e65c8c76ed9a9401b74170db617 (patch) | |
tree | 2c8a8fe2710592c6ded4b226d8930c2c11c0db9e /ptrie/cache.go | |
parent | cab7e6000e20413d697d07a1a6b2abcc85dfc2e1 (diff) | |
download | go-tangerine-b05e63c34d335e65c8c76ed9a9401b74170db617.tar go-tangerine-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.gz go-tangerine-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.bz2 go-tangerine-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.lz go-tangerine-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.xz go-tangerine-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.zst go-tangerine-b05e63c34d335e65c8c76ed9a9401b74170db617.zip |
Added paranoia check for tries
Diffstat (limited to 'ptrie/cache.go')
-rw-r--r-- | ptrie/cache.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ptrie/cache.go b/ptrie/cache.go index 8efdb047b..721dc4cf6 100644 --- a/ptrie/cache.go +++ b/ptrie/cache.go @@ -1,8 +1,8 @@ package ptrie type Backend interface { - Get([]byte) []byte - Set([]byte, []byte) + Get([]byte) ([]byte, error) + Put([]byte, []byte) } type Cache struct { @@ -17,19 +17,19 @@ func NewCache(backend Backend) *Cache { func (self *Cache) Get(key []byte) []byte { data := self.store[string(key)] if data == nil { - data = self.backend.Get(key) + data, _ = self.backend.Get(key) } return data } -func (self *Cache) Set(key []byte, data []byte) { +func (self *Cache) Put(key []byte, data []byte) { self.store[string(key)] = data } func (self *Cache) Flush() { for k, v := range self.store { - self.backend.Set([]byte(k), v) + self.backend.Put([]byte(k), v) } // This will eventually grow too large. We'd could |