mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-18 16:44:12 +00:00
c68f00045a
* Revert "remove tombstones (#426)"
This reverts commit aa6bab40e8
.
* tombstones don't hide storage or account anymore
* auto-format code by prettier (similar to gofmt)
* wow, it works.....
* small simplification, but need make it more clear
* rebase to master
* rebase to master
* rebase to master
* re-run ci
* clean test files
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package debug
|
|
|
|
import (
|
|
"os"
|
|
"sync"
|
|
"sync/atomic"
|
|
)
|
|
|
|
var gerEnv sync.Once
|
|
var ThinHistory bool
|
|
|
|
var itcEnv sync.Once
|
|
|
|
// atomic: bit 0 is the value, bit 1 is the initialized flag
|
|
var getNodeData uint32
|
|
|
|
const (
|
|
gndValueFlag = 1 << iota
|
|
gndInitializedFlag
|
|
)
|
|
|
|
func IsThinHistory() bool {
|
|
gerEnv.Do(func() {
|
|
_, ThinHistory = os.LookupEnv("THIN_HISTORY")
|
|
})
|
|
return ThinHistory
|
|
}
|
|
|
|
// IsGetNodeData indicates whether the GetNodeData functionality should be enabled.
|
|
// By default that's driven by the presence or absence of DISABLE_GET_NODE_DATA environment variable.
|
|
func IsGetNodeData() bool {
|
|
x := atomic.LoadUint32(&getNodeData)
|
|
if x&gndInitializedFlag != 0 { // already initialized
|
|
return x&gndValueFlag != 0
|
|
}
|
|
|
|
RestoreGetNodeData()
|
|
return IsGetNodeData()
|
|
}
|
|
|
|
// RestoreGetNodeData enables or disables the GetNodeData functionality
|
|
// according to the presence or absence of DISABLE_GET_NODE_DATA environment variable.
|
|
func RestoreGetNodeData() {
|
|
_, envVarSet := os.LookupEnv("DISABLE_GET_NODE_DATA")
|
|
OverrideGetNodeData(!envVarSet)
|
|
}
|
|
|
|
// OverrideGetNodeData allows to explicitly enable or disable the GetNodeData functionality.
|
|
func OverrideGetNodeData(val bool) {
|
|
if val {
|
|
atomic.StoreUint32(&getNodeData, gndInitializedFlag|gndValueFlag)
|
|
} else {
|
|
atomic.StoreUint32(&getNodeData, gndInitializedFlag)
|
|
}
|
|
}
|