1

I'm trying to start a full ethereum node in go using my existing chaindb, but can't get the configuration right and was hoping someone could point me in the right direction.

Attempted something similar to what is described here (In-process Full Node section: https://twurst.com/articles/geth-1.5-api.html). However, the code below only returns the genesis block (and fails if I try any other block), so I assume something is wrong with my setup.

func main() {
    stackConf := &node.Config{
        DataDir: "/Users/me/Library/Ethereum",
    }
    ethConf := &eth.DefaultConfig

    stack, err := node.New(stackConf)
    if err != nil {
        log.Fatalf("protocol stack: %v", err)
    }
    if err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { return eth.New(ctx, ethConf) }); err != nil {
        log.Fatalf("failed to register Ethereum protocol: %v", err)
    }
    if err = stack.Start(); err != nil {
        log.Fatalf("failed to start test stack: %v", err)
    }
    var ethereum *eth.Ethereum
    stack.Service(&ethereum)
    stack.Start()
    latestBlock, err := ethereum.ApiBackend.BlockByNumber(context.Background(), -1)
    if err != nil {
        log.Fatal(err)
    }
    log.Println(latestBlock)
    log.Println("latest block:", latestBlock.Number())
}

I'm not using the RPC, since the method I'm interested in using is GetReceipts, which gets all of the receipts for a given block, whereas the RPC only allows for grabbing the receipt for a single transaction (i.e. have to call for every transaction in the block).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.