erigon-pulse/cmd/hack/tool/fromdb/tool.go
Alex Sharov ad72b7178e
prune speedup. stage_senders: don't re-calc existing senders (#7643)
- stage_senders: don't re-calc existing senders
- stage_tx_lookup: prune less blocks per iteration - because
random-deletes are expensive. pruning must not slow-down sync.
- prune data even if --snap.stop is set
- "prune as-much-as-possible at startup" is not very good idea: at
initialCycle machine can be cold and prune will cause big downtime, no
reason to produce much freelist in 1 tx. People may also restart erigon
- because of some bug - and it will cause unexpected downtime (usually
Erigon startup very fast). So, I just remove all `initialSync`-related
logic in pruning.
- fix lost metrics about disk write byte/sec
2023-06-03 12:30:53 +07:00

64 lines
1.2 KiB
Go

package fromdb
import (
"context"
"github.com/ledgerwatch/erigon-lib/chain"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/kvcfg"
"github.com/ledgerwatch/erigon/cmd/hack/tool"
"github.com/ledgerwatch/erigon/ethdb/prune"
)
func ChainConfig(db kv.RoDB) (cc *chain.Config) {
err := db.View(context.Background(), func(tx kv.Tx) error {
cc = tool.ChainConfig(tx)
return nil
})
tool.Check(err)
if cc == nil {
panic("database is not initalized")
}
return cc
}
func PruneMode(db kv.RoDB) (pm prune.Mode) {
if err := db.View(context.Background(), func(tx kv.Tx) error {
var err error
pm, err = prune.Get(tx)
if err != nil {
return err
}
return nil
}); err != nil {
panic(err)
}
return
}
func TxsV3(db kv.RoDB) (enabled bool) {
if err := db.View(context.Background(), func(tx kv.Tx) error {
var err error
enabled, err = kvcfg.TransactionsV3.Enabled(tx)
if err != nil {
return err
}
return nil
}); err != nil {
panic(err)
}
return
}
func HistV3(db kv.RoDB) (enabled bool) {
if err := db.View(context.Background(), func(tx kv.Tx) error {
var err error
enabled, err = kvcfg.HistoryV3.Enabled(tx)
if err != nil {
return err
}
return nil
}); err != nil {
panic(err)
}
return
}