mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-04 01:54:28 +00:00
f0bc2b2146
* lmdb tests * trigger ci * fix tests * disable parallelism * disable parallelism * cleanup resources * cleanup resources * reduce concurency * try run tests on bolt * try run tests on bolt * fix downloader test * run bolt tests * rely on interface instead of exact instance * Rename AbstractKV to KV * don't use separator for badger * don't initialize badger cursor - because it not used here * fix linter * try reduce badger compactors * compat with master * try lmdb * try lmdb * try lmdb * reduce badger's MaxTableSize, reduce badger's minGoMaxProc for inMem option * allow to close closed db * release * release * ideal batch size for badger * ideal batch size for badger
83 lines
1.7 KiB
Go
83 lines
1.7 KiB
Go
package debug
|
|
|
|
import (
|
|
"os"
|
|
"sync"
|
|
"sync/atomic"
|
|
)
|
|
|
|
var (
|
|
compressBlocks bool
|
|
getCompressBlocks sync.Once
|
|
)
|
|
|
|
// atomic: bit 0 is the value, bit 1 is the initialized flag
|
|
var getNodeData uint32
|
|
|
|
const (
|
|
gndValueFlag = 1 << iota
|
|
gndInitializedFlag
|
|
)
|
|
|
|
// 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 GET_NODE_DATA environment variable.
|
|
func RestoreGetNodeData() {
|
|
_, envVarSet := os.LookupEnv("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)
|
|
}
|
|
}
|
|
|
|
func IsBlockCompressionEnabled() bool {
|
|
getCompressBlocks.Do(func() {
|
|
_, compressBlocks = os.LookupEnv("COMPRESS_BLOCKS")
|
|
})
|
|
return compressBlocks
|
|
}
|
|
|
|
var (
|
|
trackWitnessSize bool
|
|
getTrackWitnessSizeLen sync.Once
|
|
)
|
|
|
|
func IsTrackWitnessSizeEnabled() bool {
|
|
getTrackWitnessSizeLen.Do(func() {
|
|
_, trackWitnessSize = os.LookupEnv("TRACK_WITNESS_SIZE")
|
|
})
|
|
return trackWitnessSize
|
|
}
|
|
|
|
var (
|
|
testDB string
|
|
getTestDB sync.Once
|
|
)
|
|
|
|
func TestDB() string {
|
|
getTestDB.Do(func() {
|
|
testDB, _ = os.LookupEnv("TEST_DB")
|
|
if testDB == "" {
|
|
testDB = "bolt"
|
|
}
|
|
})
|
|
return testDB
|
|
}
|