Created
May 14, 2022 18:04
-
-
Save enriquefynn/7db8fed4fac13f087210226318cc9d99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"strconv" | |
"github.com/ethereum/go-ethereum/common" | |
"github.com/ethereum/go-ethereum/consensus/ethash" | |
"github.com/ethereum/go-ethereum/core" | |
"github.com/ethereum/go-ethereum/core/state" | |
"github.com/ethereum/go-ethereum/core/types" | |
"github.com/ethereum/go-ethereum/core/vm" | |
"github.com/ethereum/go-ethereum/ethdb" | |
"github.com/ethereum/go-ethereum/params" | |
) | |
var ( | |
cache, _ = strconv.Atoi(os.Args[1]) | |
ethDb, _ = ethdb.NewLDBDatabase(os.Args[1], cache, 256) | |
// executeDb, _ = ethdb.NewMemDatabase() | |
engine = ethash.NewFullFaker() | |
config = params.MainnetChainConfig | |
vmConfig = vm.Config{} | |
) | |
func main() { | |
blockchain, err := core.NewBlockChain(ethDb, nil, config, engine, vmConfig, func(block *types.Block) bool { return false }) | |
st, err := blockchain.State() | |
if err != nil { | |
log.Fatalf("State bad: %v", err) | |
} | |
it := state.NewNodeIterator(st) | |
for it.Next() { | |
addr := common.BytesToAddress(it.Parent.Bytes()) | |
code := st.GetCode(addr) | |
fmt.Printf("CODE[%x]: %v\n", addr, code) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment