Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
e32b1a1d
Commit
e32b1a1d
authored
Jan 25, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fake block mining
parent
97882a65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
ethereum.go
ethereum.go
+13
-8
No files found.
ethereum.go
View file @
e32b1a1d
...
@@ -6,7 +6,7 @@ import (
...
@@ -6,7 +6,7 @@ import (
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go"
"github.com/ethereum/ethchain-go"
"github.com/ethereum/ethchain-go"
"github.com/ethereum/ethutil-go"
"github.com/ethereum/ethutil-go"
"github.com/ethereum/ethwire-go"
_
"github.com/ethereum/ethwire-go"
"log"
"log"
"math/big"
"math/big"
"os"
"os"
...
@@ -84,12 +84,15 @@ func main() {
...
@@ -84,12 +84,15 @@ func main() {
ethereum
.
Start
()
ethereum
.
Start
()
if
StartMining
{
if
StartMining
{
log
.
Println
(
"Dev Test Mining started"
)
blockTime
:=
time
.
Duration
(
15
)
log
.
Printf
(
"Dev Test Mining started. Blocks found each %d seconds
\n
"
,
blockTime
)
// Fake block mining. It broadcasts a new block every 5 seconds
// Fake block mining. It broadcasts a new block every 5 seconds
go
func
()
{
go
func
()
{
for
{
for
{
time
.
Sleep
(
5
*
time
.
Second
)
txs
:=
ethereum
.
TxPool
.
Flush
()
time
.
Sleep
(
blockTime
*
time
.
Second
)
block
:=
ethchain
.
CreateBlock
(
block
:=
ethchain
.
CreateBlock
(
ethereum
.
BlockManager
.
BlockChain
()
.
LastBlock
.
State
()
.
Root
,
ethereum
.
BlockManager
.
BlockChain
()
.
LastBlock
.
State
()
.
Root
,
...
@@ -98,11 +101,13 @@ func main() {
...
@@ -98,11 +101,13 @@ func main() {
big
.
NewInt
(
1
),
big
.
NewInt
(
1
),
big
.
NewInt
(
1
),
big
.
NewInt
(
1
),
""
,
""
,
ethereum
.
TxPool
.
Flush
())
txs
)
err
:=
ethereum
.
BlockManager
.
ProcessBlockWithState
(
block
,
block
.
State
())
ethereum
.
BlockManager
.
ProcessBlockWithState
(
block
,
block
.
State
())
if
err
!=
nil
{
ethereum
.
Broadcast
(
ethwire
.
MsgBlockTy
,
block
.
RlpData
())
log
.
Println
(
err
)
log
.
Println
(
"
\n
"
,
block
.
String
())
}
else
{
log
.
Println
(
"
\n
+++++++ MINED BLK +++++++
\n
"
,
block
.
String
())
}
}
}
}()
}()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment