Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update big cache to fastcache #1392

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
return nil, err
}

bc.loadStateCache()
// Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
//for hash := range BadHashes {
// if header := bc.GetHeaderByHash(hash); header != nil {
Expand Down Expand Up @@ -294,31 +293,6 @@ func (bc *BlockChain) loadLastState() error {
return nil
}

func (bc *BlockChain) loadStateCache() {
go func() {
log.Debug("Start load state cache")
t := time.Now()
tr, err := bc.stateCache.OpenTrie(bc.CurrentBlock().Root())
if err != nil {
log.Error("Failed to open trie", "err", err)
return
}

limit := (uint64(bc.cacheConfig.TrieDBCache*1024*1024) / 8) - 1024
c := 0
it := tr.NodeIterator(nil)
for it.Next(true) {
c++

if bc.stateCache.TrieDB().CacheCapacity() >= limit || time.Since(t) >= 30*time.Second {
break
}
}
bc.stateCache.TrieDB().ResetCacheStats()
log.Debug("Load state cache", "count", c, "limit", limit, "duration", time.Since(t))
}()
}

// SetHead rewinds the local chain to a new head. In the case of headers, everything
// above the new head will be deleted and the new one set. In the case of blocks
// though, the head may be further rewound if block bodies are missing (non-archive
Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ require (
github.com/Azure/azure-storage-blob-go v0.0.0-20180712005634-eaae161d9d5e
github.com/PlatONnetwork/wagon v0.6.1-0.20200422074910-d2bccc71e673
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/VictoriaMetrics/fastcache v1.5.7
github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847
github.com/btcsuite/btcd v0.20.1-beta
github.com/btcsuite/btcutil v1.0.2
github.com/cespare/cp v0.1.0
github.com/cespare/xxhash v1.1.0
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea
github.com/deckarep/golang-set v1.7.1
github.com/docker/docker v17.12.0-ce-rc1.0.20180625184442-8e610b2b55bf+incompatible
github.com/edsrzf/mmap-go v1.0.1-0.20190108065903-904c4ced31cd // indirect
github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa
Expand All @@ -26,7 +27,7 @@ require (
github.com/golang/protobuf v1.2.1-0.20181128192352-1d3f30b51784
github.com/golang/snappy v0.0.1
github.com/google/go-cmp v0.4.0 // indirect
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad
github.com/hashicorp/golang-lru v0.5.4
github.com/herumi/bls v0.0.0-20200517120024-accfc25c06c0
github.com/huin/goupnp v0.0.0-20161224104101-679507af18f3
github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883
Expand Down Expand Up @@ -57,8 +58,8 @@ require (
github.com/stretchr/testify v1.4.0
github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
golang.org/x/sys v0.0.0-20190412213103-97732733099d
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
golang.org/x/text v0.3.1-0.20171227012246-e19ae1496984 // indirect
golang.org/x/tools v0.0.0-20170215214335-be0fcc31ae23
gopkg.in/check.v1 v1.0.0-20161208181325-20d25e280405
Expand Down
300 changes: 0 additions & 300 deletions trie/bigcache.go

This file was deleted.

Loading