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
a30f5730
Commit
a30f5730
authored
Mar 24, 2014
by
Maran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reimplement new miner creation
parent
6724d27c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
29 deletions
+15
-29
ethereum.go
ethereum/ethereum.go
+15
-29
No files found.
ethereum/ethereum.go
View file @
a30f5730
...
@@ -4,8 +4,8 @@ import (
...
@@ -4,8 +4,8 @@ import (
"fmt"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethminer"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/go-ethereum/utils"
"github.com/ethereum/go-ethereum/utils"
"log"
"log"
"os"
"os"
...
@@ -121,36 +121,22 @@ func main() {
...
@@ -121,36 +121,22 @@ func main() {
// 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
()
{
pow
:=
&
ethchain
.
EasyPow
{}
if
StartMining
{
log
.
Printf
(
"Miner started
\n
"
)
go
func
()
{
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
keyRing
:=
ethutil
.
NewValueFromBytes
(
data
)
keyRing
:=
ethutil
.
NewValueFromBytes
(
data
)
addr
:=
keyRing
.
Get
(
1
)
.
Bytes
()
addr
:=
keyRing
.
Get
(
1
)
.
Bytes
()
for
{
miner
:=
ethminer
.
NewDefaultMiner
(
addr
,
ethereum
)
txs
:=
ethereum
.
TxPool
()
.
Flush
()
miner
.
Start
()
// Create a new block which we're going to mine
block
:=
ethereum
.
BlockChain
()
.
NewBlock
(
addr
,
txs
)
log
.
Println
(
"Mining on new block. Includes"
,
len
(
block
.
Transactions
()),
"transactions"
)
// Apply all transactions to the block
ethereum
.
StateManager
()
.
ApplyTransactions
(
block
,
block
.
Transactions
())
ethereum
.
StateManager
()
.
Prepare
(
block
.
State
(),
block
.
State
())
ethereum
.
StateManager
()
.
AccumelateRewards
(
block
)
// Search the nonce
}()
block
.
Nonce
=
pow
.
Search
(
block
)
ethereum
.
Broadcast
(
ethwire
.
MsgBlockTy
,
[]
interface
{}{
block
.
Value
()
.
Val
})
ethereum
.
StateManager
()
.
PrepareDefault
(
block
)
err
:=
ethereum
.
StateManager
()
.
ProcessBlock
(
block
)
if
err
!=
nil
{
log
.
Println
(
err
)
}
else
{
log
.
Println
(
"
\n
+++++++ MINED BLK +++++++
\n
"
,
ethereum
.
BlockChain
()
.
CurrentBlock
)
log
.
Printf
(
"🔨 Mined block %x
\n
"
,
block
.
Hash
())
}
}
}
}()
}()
}
}
// Wait for shutdown
// Wait for shutdown
...
...
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