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

eth,core: add api debug_getTrieFlushInterval #27303

Merged
merged 3 commits into from Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/blockchain.go
Expand Up @@ -2492,3 +2492,8 @@ func (bc *BlockChain) SetBlockValidatorAndProcessorForTesting(v Validator, p Pro
func (bc *BlockChain) SetTrieFlushInterval(interval time.Duration) {
bc.flushInterval.Store(int64(interval))
}

// GetTrieFlushInterval gets the in-memroy tries flush interval
func (bc *BlockChain) GetTrieFlushInterval() time.Duration {
return time.Duration(bc.flushInterval.Load())
}
8 changes: 8 additions & 0 deletions eth/api_debug.go
Expand Up @@ -395,6 +395,9 @@ func (api *DebugAPI) GetAccessibleState(from, to rpc.BlockNumber) (uint64, error

// SetTrieFlushInterval configures how often in-memory tries are persisted
// to disk. The value is in terms of block processing time, not wall clock.
// If the value is shorter than the block generation time, or even 0 or negative,
// the node will flush trie after processing each block.
// Its behavior is the same as that of an archive node, so please use it with caution.
holiman marked this conversation as resolved.
Show resolved Hide resolved
func (api *DebugAPI) SetTrieFlushInterval(interval string) error {
t, err := time.ParseDuration(interval)
if err != nil {
Expand All @@ -403,3 +406,8 @@ func (api *DebugAPI) SetTrieFlushInterval(interval string) error {
api.eth.blockchain.SetTrieFlushInterval(t)
return nil
}

// GetTrieFlushInterval gets the current value of in-memroy tries flush interval
holiman marked this conversation as resolved.
Show resolved Hide resolved
func (api *DebugAPI) GetTrieFlushInterval() string {
return api.eth.blockchain.GetTrieFlushInterval().String()
}
5 changes: 5 additions & 0 deletions internal/web3ext/web3ext.go
Expand Up @@ -495,6 +495,11 @@ web3._extend({
call: 'debug_setTrieFlushInterval',
params: 1
}),
new web3._extend.Method({
name: 'getTrieFlushInterval',
call: 'debug_getTrieFlushInterval',
params: 0
}),
],
properties: []
});
Expand Down