Skip to content

Commit

Permalink
disable archive gcmode as default
Browse files Browse the repository at this point in the history
  • Loading branch information
zongyuan committed Jun 17, 2019
1 parent 3f8690d commit 77d391a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type BlockChain struct {
func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(block *types.Block) bool) (*BlockChain, error) {
if cacheConfig == nil {
cacheConfig = &CacheConfig{
TrieNodeLimit: 256 * 1024 * 1024,
TrieNodeLimit: 256,
TrieTimeLimit: 5 * time.Minute,
}
}
Expand Down Expand Up @@ -205,6 +205,10 @@ func (bc *BlockChain) getProcInterrupt() bool {
return atomic.LoadInt32(&bc.procInterrupt) == 1
}

func (bc *BlockChain) CacheDisabled() bool {
return bc.cacheConfig.Disabled
}

// loadLastState loads the last known chain state from the database. This method
// assumes that the chain manager mutex is held.
func (bc *BlockChain) loadLastState() error {
Expand Down Expand Up @@ -944,7 +948,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.
chosen := header.Number.Uint64()

// If we exceeded out time allowance, flush an entire trie to disk
if bc.gcproc > bc.cacheConfig.TrieTimeLimit {
if bc.gcproc > bc.cacheConfig.TrieTimeLimit || (chosen%3000 == 0) {
// If we're exceeding limits but haven't reached a large enough memory gap,
// warn the user that the system is becoming unstable.
if chosen < lastWrite+triesInMemory && bc.gcproc >= 2*bc.cacheConfig.TrieTimeLimit {
Expand Down
2 changes: 1 addition & 1 deletion eth/downloader/modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func DefaultSyncMode() SyncMode {
}

func FullGcModeSupported() bool {
return false
return true
}

func DefaultGcMode() string {
Expand Down
9 changes: 9 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ func (w *worker) taskLoop() {
// resultLoop is a standalone goroutine to handle sealing result submitting
// and flush relative data to the database.
func (w *worker) resultLoop() {
fastBlockNumber := w.chain.CurrentFastBlock().NumberU64()
for {
select {
case block := <-w.resultCh:
Expand All @@ -505,6 +506,14 @@ func (w *worker) resultLoop() {
if w.chain.HasBlock(block.Hash(), block.NumberU64()) {
continue
}
if !w.chain.CacheDisabled() && block.NumberU64() < fastBlockNumber {
if common.DebugMode {
log.Info("full block is lower than fast block",
"full", block.NumberU64(), "fast", fastBlockNumber)
}
continue
}

var (
sealhash = w.engine.SealHash(block.Header())
hash = block.Hash()
Expand Down

0 comments on commit 77d391a

Please sign in to comment.