aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-08-14 23:55:12 -0400
committerDeterminant <ted.sybil@gmail.com>2019-08-14 23:55:12 -0400
commit03513e267d25b5086b3f905b6d1bc5635fcda845 (patch)
treed2c800a6d04f7def64b4061ceb97f5faa13cf8ea /examples
parent63fc17f85121f84d597742a49b99ab3d022aa6bd (diff)
...
Diffstat (limited to 'examples')
-rw-r--r--examples/payments/main.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/examples/payments/main.go b/examples/payments/main.go
index 46e4e58..8a1dca8 100644
--- a/examples/payments/main.go
+++ b/examples/payments/main.go
@@ -9,7 +9,6 @@ import (
"math/big"
//"encoding/hex"
"github.com/ethereum/go-ethereum/core/types"
- //"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core"
"github.com/Determinant/coreth/eth"
@@ -42,7 +41,7 @@ func main() {
Ethash: nil,
}
- genBalance := big.NewInt(1000000000000000000)
+ genBalance := big.NewInt(100000000000000000)
genKey, _ := coreth.NewKey(rand.Reader)
config.Genesis = &core.Genesis{
@@ -56,24 +55,32 @@ func main() {
}
config.Miner.ManualMining = true
+ config.Miner.ManualUncle = true
chainID := chainConfig.ChainID
nonce := uint64(0)
value := big.NewInt(1000000000000)
gasLimit := 21000
- gasPrice := big.NewInt(1000)
+ gasPrice := big.NewInt(1000000000)
bob, err := coreth.NewKey(rand.Reader); checkError(err)
chain := coreth.NewETHChain(&config, nil)
+ chain.SetOnSeal(func(block *types.Block) {
+ go func() {
+ time.Sleep(1000 * time.Millisecond)
+ chain.GenBlock()
+ }()
+ })
chain.Start()
+ chain.GenBlock()
for i := 0; i < 10; i++ {
tx := types.NewTransaction(nonce, bob.Address, value, uint64(gasLimit), gasPrice, nil)
signedTx, err := types.SignTx(tx, types.NewEIP155Signer(chainID), genKey.PrivateKey); checkError(err)
- chain.AddLocalTxs([]*types.Transaction{signedTx})
- time.Sleep(2000 * time.Millisecond)
+ _ = signedTx
+ chain.AddRemoteTxs([]*types.Transaction{signedTx})
+ time.Sleep(1000 * time.Millisecond)
nonce++
- chain.GenBlock()
}
c := make(chan os.Signal, 1)