mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
parent
76e244f24f
commit
71ef201c17
@ -2093,6 +2093,42 @@ func indexKeySizes(chaindata string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func extractBodies(chaindata string, block uint64) error {
|
||||
db := ethdb.MustOpen(chaindata)
|
||||
defer db.Close()
|
||||
tx, err := db.Begin(context.Background(), ethdb.RO)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
c := tx.(ethdb.HasTx).Tx().Cursor(dbutils.BlockBodyPrefix)
|
||||
defer c.Close()
|
||||
blockEncoded := dbutils.EncodeBlockNumber(block)
|
||||
for k, _, err := c.Seek(blockEncoded); k != nil; k, _, err = c.Next() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
blockNumber := binary.BigEndian.Uint64(k[:8])
|
||||
blockHash := common.BytesToHash(k[8:])
|
||||
body := rawdb.ReadBody(db, blockHash, blockNumber)
|
||||
b, err := rlp.EncodeToBytes(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Body %d %x: %x\n", blockNumber, blockHash, b)
|
||||
header := rawdb.ReadHeader(db, blockHash, blockNumber)
|
||||
b, err = rlp.EncodeToBytes(header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Header %d %x: %x\n", blockNumber, blockHash, b)
|
||||
if blockNumber > block+5 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
@ -2277,4 +2313,9 @@ func main() {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
}
|
||||
}
|
||||
if *action == "extractBodies" {
|
||||
if err := extractBodies(*chaindata, uint64(*block)); err != nil {
|
||||
fmt.Printf("Error:%v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user