mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
30 lines
574 B
Go
30 lines
574 B
Go
package chains
|
|
|
|
import (
|
|
"embed"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
)
|
|
|
|
//go:embed allocs
|
|
var allocs embed.FS
|
|
|
|
func readPrealloc(filename string) types.GenesisAlloc {
|
|
f, err := allocs.Open(filename)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("Could not open genesis preallocation for %s: %v", filename, err))
|
|
}
|
|
|
|
defer f.Close()
|
|
decoder := json.NewDecoder(f)
|
|
ga := make(types.GenesisAlloc)
|
|
|
|
err = decoder.Decode(&ga)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("Could not parse genesis preallocation for %s: %v", filename, err))
|
|
}
|
|
|
|
return ga
|
|
}
|