aboutsummaryrefslogtreecommitdiff
path: root/coreth.go
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-08-15 14:50:39 -0400
committerDeterminant <ted.sybil@gmail.com>2019-08-15 14:50:39 -0400
commit669168d32a534c1054f9df659b3199f7b6da0d21 (patch)
tree5cc6fc7fa2174473d298cababb5d573640ebe977 /coreth.go
parent49b07487092947a8b54d39ce4fbdc94e33537993 (diff)
show wallet state in the example
Diffstat (limited to 'coreth.go')
-rw-r--r--coreth.go36
1 files changed, 35 insertions, 1 deletions
diff --git a/coreth.go b/coreth.go
index f761347..84a6b59 100644
--- a/coreth.go
+++ b/coreth.go
@@ -9,6 +9,7 @@ import (
"github.com/ava-labs/coreth/eth"
"github.com/ava-labs/coreth/node"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
@@ -68,10 +69,43 @@ func (self *ETHChain) AddLocalTxs(txs []*types.Transaction) []error {
return self.backend.TxPool().AddLocals(txs)
}
-func (self *ETHChain) SetOnSeal(cb func(*types.Block)) {
+func (self *ETHChain) SetOnSeal(cb func(*types.Block) error) {
self.cb.OnSeal = cb
}
+func (self *ETHChain) SetOnAPIs(cb dummy.OnAPIsCallbackType) {
+ self.cb.OnAPIs = cb
+}
+
+func (self *ETHChain) SetOnFinalize(cb dummy.OnFinalizeCallbackType) {
+ self.cb.OnFinalize = cb
+}
+
+func (self *ETHChain) SetOnFinalizeAndAssemble(cb dummy.OnFinalizeAndAssembleCallbackType) {
+ self.cb.OnFinalizeAndAssemble = cb
+}
+
+// Returns a new mutable state based on the current HEAD block.
+func (self *ETHChain) CurrentState() (*state.StateDB, error) {
+ return self.backend.BlockChain().State()
+}
+
+// Returns a new mutable state based on the given block.
+func (self *ETHChain) BlockState(block *types.Block) (*state.StateDB, error) {
+ return self.backend.BlockChain().StateAt(block.Root())
+}
+
+// Retrives a block from the database by hash.
+func (self *ETHChain) GetBlockByHash(hash common.Hash) *types.Block {
+ return self.backend.BlockChain().GetBlockByHash(hash)
+}
+
+// SetHead sets the current head block to the one defined by the hash
+// irrelevant what the chain contents were prior.
+func (self *ETHChain) SetHead(hash common.Hash) error {
+ return self.backend.BlockChain().FastSyncCommitHead(hash)
+}
+
type Key struct {
Address common.Address
PrivateKey *ecdsa.PrivateKey