Browse Source

state: fix GetStorage on blockcache with unknown account

pull/43/merge
Ethan Buchman 10 years ago
parent
commit
a976721a97
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      state/block_cache.go

+ 7
- 1
state/block_cache.go View File

@ -95,9 +95,11 @@ func (cache *BlockCache) GetStorage(addr Word256, key Word256) (value Word256) {
if removed {
panic("GetStorage() on removed account")
}
if storage == nil {
if acc != nil && storage == nil {
storage = makeStorage(cache.db, acc.StorageRoot)
cache.accounts[string(addr.Prefix(20))] = accountInfo{acc, storage, false, dirty}
} else if acc == nil {
return Zero256
}
// Load and set cache
@ -145,6 +147,9 @@ func (cache *BlockCache) Sync() {
addr, key := Tuple256Split(storageKey)
if addr != curAddr || curAcc == nil {
acc, storage, removed, _ := cache.accounts[string(addr.Prefix(20))].unpack()
if storage == nil {
storage = makeStorage(cache.db, acc.StorageRoot)
}
curAddr = addr
curAcc = acc
curAccRemoved = removed
@ -161,6 +166,7 @@ func (cache *BlockCache) Sync() {
curStorage.Remove(key.Bytes())
} else {
curStorage.Set(key.Bytes(), value.Bytes())
cache.accounts[string(addr.Prefix(20))] = accountInfo{curAcc, curStorage, false, true}
}
}


Loading…
Cancel
Save