import "github.com/expanse-project/go-expanse/core/types" // create a new block block := types.Block{} // set the parent hash parentHash := types.NewHash([]byte("previous-block-hash")) block.ParentHash = parentHash
import "github.com/expanse-project/go-expanse/core/types" // given a block hash, retrieve the parent block hash func getParentHash(blockHash types.Hash) (types.Hash, error) { blockHeader, err := getBlockHeader(blockHash) if err != nil { return types.Hash{}, err } return blockHeader.ParentHash, nil }In this example, we define a function that takes a block hash as input and returns its parent block hash. We first retrieve the block header using another function `getBlockHeader` and then return its parent hash field.