mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 04:57:17 +00:00
Junk db util (#3284)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
This commit is contained in:
parent
4622287834
commit
3655916eb9
@ -2331,6 +2331,45 @@ func mainnetGenesis() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func junkdb() error {
|
||||
dir, err := ioutil.TempDir(".", "junk")
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating temp dir for db size test: %w", err)
|
||||
}
|
||||
//defer os.RemoveAll(dir)
|
||||
oneBucketCfg := make(kv.TableCfg)
|
||||
oneBucketCfg["t"] = kv.TableCfgItem{}
|
||||
var db kv.RwDB
|
||||
db, err = mdbx.NewMDBX(log.New()).Path(dir).WithTablessCfg(func(kv.TableCfg) kv.TableCfg {
|
||||
return oneBucketCfg
|
||||
}).Open()
|
||||
if err != nil {
|
||||
return fmt.Errorf("opening database: %w", err)
|
||||
}
|
||||
defer db.Close()
|
||||
for i := 0; i < 1_000_000; i++ {
|
||||
if err = db.Update(context.Background(), func(tx kv.RwTx) error {
|
||||
c, e := tx.RwCursor("t")
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
defer c.Close()
|
||||
for j := 0; j < 1_000_000_000; j++ {
|
||||
var b [8]byte
|
||||
binary.BigEndian.PutUint64(b[:], uint64(i*1_000_000_000+j))
|
||||
if e = c.Append(b[:], b[:]); e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Info("Appended records", "bln", i+1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
debug.RaiseFdLimit()
|
||||
flag.Parse()
|
||||
@ -2502,6 +2541,8 @@ func main() {
|
||||
err = genstate()
|
||||
case "mainnetGenesis":
|
||||
err = mainnetGenesis()
|
||||
case "junkdb":
|
||||
err = junkdb()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user