aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/evm')
-rw-r--r--plugin/evm/vm.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index 2b78d43..73a97e8 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -24,6 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
@@ -160,7 +161,7 @@ type VM struct {
chaindb Database
newBlockChan chan *Block
networkChan chan<- commonEng.Message
- newTxPoolHeadChan chan core.NewTxPoolHeadEvent
+ newTxPoolHeadChan *event.TypeMuxSubscription
acceptedDB database.Database
@@ -244,6 +245,10 @@ func (vm *VM) Initialize(
config := eth.DefaultConfig
config.ManualCanonical = true
config.Genesis = g
+ // disable the experimental snapshot feature from geth
+ config.TrieCleanCache += config.SnapshotCache
+ config.SnapshotCache = 0
+
config.Miner.ManualMining = true
config.Miner.DisableUncle = true
@@ -340,23 +345,28 @@ func (vm *VM) Initialize(
vm.bdTimerState = bdTimerStateLong
vm.bdGenWaitFlag = true
- vm.newTxPoolHeadChan = make(chan core.NewTxPoolHeadEvent, 1)
+ //vm.newTxPoolHeadChan = make(chan core.NewTxPoolHeadEvent, 1)
vm.txPoolStabilizedOk = make(chan struct{}, 1)
// TODO: read size from options
vm.pendingAtomicTxs = make(chan *Tx, 1024)
vm.atomicTxSubmitChan = make(chan struct{}, 1)
- chain.GetTxPool().SubscribeNewHeadEvent(vm.newTxPoolHeadChan)
+ //chain.GetTxPool().SubscribeNewHeadEvent(vm.newTxPoolHeadChan)
+ vm.newTxPoolHeadChan = vm.chain.SubscribeNewMinedBlockEvent()
// TODO: shutdown this go routine
go ctx.Log.RecoverAndPanic(func() {
for {
select {
- case h := <-vm.newTxPoolHeadChan:
- vm.txPoolStabilizedLock.Lock()
- if vm.txPoolStabilizedHead == h.Block.Hash() {
- vm.txPoolStabilizedOk <- struct{}{}
- vm.txPoolStabilizedHead = common.Hash{}
+ case e := <-vm.newTxPoolHeadChan.Chan():
+ switch h := e.Data.(type) {
+ case core.NewMinedBlockEvent:
+ vm.txPoolStabilizedLock.Lock()
+ if vm.txPoolStabilizedHead == h.Block.Hash() {
+ vm.txPoolStabilizedOk <- struct{}{}
+ vm.txPoolStabilizedHead = common.Hash{}
+ }
+ vm.txPoolStabilizedLock.Unlock()
+ default:
}
- vm.txPoolStabilizedLock.Unlock()
}
}
})