mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
Merge d4fd6a6101 into f6367548e4
This commit is contained in:
commit
b830d95678
4 changed files with 16 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ package common
|
||||||
type Database interface {
|
type Database interface {
|
||||||
Put(key []byte, value []byte) error
|
Put(key []byte, value []byte) error
|
||||||
Get(key []byte) ([]byte, error)
|
Get(key []byte) ([]byte, error)
|
||||||
|
Has(key []byte) bool
|
||||||
Delete(key []byte) error
|
Delete(key []byte) error
|
||||||
Close()
|
Close()
|
||||||
Flush() error
|
Flush() error
|
||||||
|
|
|
||||||
|
|
@ -364,9 +364,7 @@ func (bc *ChainManager) HasBlock(hash common.Hash) bool {
|
||||||
if bc.cache.Contains(hash) {
|
if bc.cache.Contains(hash) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
return bc.chainDb.Has(append(blockHashPre, hash[:]...))
|
||||||
data, _ := bc.chainDb.Get(append(blockHashPre, hash[:]...))
|
|
||||||
return len(data) != 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ChainManager) GetBlockHashesFromHash(hash common.Hash, max uint64) (chain []common.Hash) {
|
func (self *ChainManager) GetBlockHashesFromHash(hash common.Hash, max uint64) (chain []common.Hash) {
|
||||||
|
|
@ -560,6 +558,10 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
|
||||||
glog.V(logger.Debug).Infoln("Premature abort during chain processing")
|
glog.V(logger.Debug).Infoln("Premature abort during chain processing")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if self.HasBlock(block.Hash()) {
|
||||||
|
stats.ignored++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
bstart := time.Now()
|
bstart := time.Now()
|
||||||
// Wait for block i's nonce to be verified before processing
|
// Wait for block i's nonce to be verified before processing
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,11 @@ func (self *LDBDatabase) Delete(key []byte) error {
|
||||||
return self.db.Delete(key, nil)
|
return self.db.Delete(key, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *LDBDatabase) Has(key []byte) bool {
|
||||||
|
b, _ := self.db.Has(key, nil)
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
func (self *LDBDatabase) NewIterator() iterator.Iterator {
|
func (self *LDBDatabase) NewIterator() iterator.Iterator {
|
||||||
return self.db.NewIterator(nil, nil)
|
return self.db.NewIterator(nil, nil)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,11 @@ func (db *MemDatabase) GetKeys() []*common.Key {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
func (db *MemDatabase) Has(key []byte) bool {
|
||||||
|
_, ok := db.db[string(key)]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
func (db *MemDatabase) Delete(key []byte) error {
|
func (db *MemDatabase) Delete(key []byte) error {
|
||||||
delete(db.db, string(key))
|
delete(db.db, string(key))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue