aboutsummaryrefslogtreecommitdiff
path: root/examples/payments
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-10-21 16:34:25 -0400
committerDeterminant <[email protected]>2019-10-21 16:34:25 -0400
commit190b04fcbcadf4807c5c2bb0ef9e528bbff62e32 (patch)
treed9302f7a9b877c3f6d7b5903d91a84a116337c53 /examples/payments
parent7212dbd90f4cb8fe907617f804c8940db1ce657e (diff)
add NewTxPoolHeadEvent
Diffstat (limited to 'examples/payments')
-rw-r--r--examples/payments/main.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/payments/main.go b/examples/payments/main.go
index 1eab70b..5076737 100644
--- a/examples/payments/main.go
+++ b/examples/payments/main.go
@@ -4,10 +4,10 @@ import (
"crypto/rand"
"fmt"
"github.com/ava-labs/coreth"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/eth"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/common/hexutil"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/types"
"github.com/ava-labs/go-ethereum/log"
"github.com/ava-labs/go-ethereum/params"
@@ -83,11 +83,13 @@ func main() {
header.Extra = append(header.Extra, hid...)
})
newBlockChan := make(chan *types.Block)
+ newTxPoolHeadChan := make(chan core.NewTxPoolHeadEvent, 1)
chain.SetOnSealFinish(func(block *types.Block) error {
newBlockChan <- block
return nil
})
+ chain.GetTxPool().SubscribeNewHeadEvent(newTxPoolHeadChan)
// start the chain
chain.Start()
for i := 0; i < 42; i++ {
@@ -98,7 +100,7 @@ func main() {
nonce++
chain.GenBlock()
block := <-newBlockChan
- chain.SetTail(block.Hash())
+ <-newTxPoolHeadChan
log.Info("finished generating block, starting the next iteration", "height", block.Number())
}
showBalance()