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
f5852b47
Commit
f5852b47
authored
May 21, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed some logging and refactored a bit
parent
86cf6964
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
44 deletions
+42
-44
dagger.go
ethchain/dagger.go
+1
-1
miner.go
ethminer/miner.go
+41
-43
No files found.
ethchain/dagger.go
View file @
f5852b47
...
@@ -29,7 +29,7 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
...
@@ -29,7 +29,7 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
for
{
for
{
select
{
select
{
case
<-
reactChan
:
case
<-
reactChan
:
ethutil
.
Config
.
Log
.
Infoln
(
"[POW] Received reactor event; breaking out."
)
//
ethutil.Config.Log.Infoln("[POW] Received reactor event; breaking out.")
return
nil
return
nil
default
:
default
:
i
++
i
++
...
...
ethminer/miner.go
View file @
f5852b47
...
@@ -60,10 +60,10 @@ func (miner *Miner) listener() {
...
@@ -60,10 +60,10 @@ func (miner *Miner) listener() {
select
{
select
{
case
chanMessage
:=
<-
miner
.
reactChan
:
case
chanMessage
:=
<-
miner
.
reactChan
:
if
block
,
ok
:=
chanMessage
.
Resource
.
(
*
ethchain
.
Block
);
ok
{
if
block
,
ok
:=
chanMessage
.
Resource
.
(
*
ethchain
.
Block
);
ok
{
ethutil
.
Config
.
Log
.
Infoln
(
"[MINER] Got new block via Reactor"
)
//
ethutil.Config.Log.Infoln("[MINER] Got new block via Reactor")
if
bytes
.
Compare
(
miner
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
block
.
Hash
())
==
0
{
if
bytes
.
Compare
(
miner
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
block
.
Hash
())
==
0
{
// TODO: Perhaps continue mining to get some uncle rewards
// TODO: Perhaps continue mining to get some uncle rewards
ethutil
.
Config
.
Log
.
Infoln
(
"[MINER] New top block found resetting state"
)
//
ethutil.Config.Log.Infoln("[MINER] New top block found resetting state")
// Filter out which Transactions we have that were not in this block
// Filter out which Transactions we have that were not in this block
var
newtxs
[]
*
ethchain
.
Transaction
var
newtxs
[]
*
ethchain
.
Transaction
...
@@ -87,13 +87,11 @@ func (miner *Miner) listener() {
...
@@ -87,13 +87,11 @@ func (miner *Miner) listener() {
if
bytes
.
Compare
(
block
.
PrevHash
,
miner
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
PrevHash
)
==
0
{
if
bytes
.
Compare
(
block
.
PrevHash
,
miner
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
PrevHash
)
==
0
{
ethutil
.
Config
.
Log
.
Infoln
(
"[MINER] Adding uncle block"
)
ethutil
.
Config
.
Log
.
Infoln
(
"[MINER] Adding uncle block"
)
miner
.
uncles
=
append
(
miner
.
uncles
,
block
)
miner
.
uncles
=
append
(
miner
.
uncles
,
block
)
//miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
}
}
}
}
}
}
if
tx
,
ok
:=
chanMessage
.
Resource
.
(
*
ethchain
.
Transaction
);
ok
{
if
tx
,
ok
:=
chanMessage
.
Resource
.
(
*
ethchain
.
Transaction
);
ok
{
//log.Infoln("[MINER] Got new transaction from Reactor", tx)
found
:=
false
found
:=
false
for
_
,
ctx
:=
range
miner
.
txs
{
for
_
,
ctx
:=
range
miner
.
txs
{
if
found
=
bytes
.
Compare
(
ctx
.
Hash
(),
tx
.
Hash
())
==
0
;
found
{
if
found
=
bytes
.
Compare
(
ctx
.
Hash
(),
tx
.
Hash
())
==
0
;
found
{
...
@@ -102,54 +100,54 @@ func (miner *Miner) listener() {
...
@@ -102,54 +100,54 @@ func (miner *Miner) listener() {
}
}
if
found
==
false
{
if
found
==
false
{
// Undo all previous commits
miner
.
block
.
Undo
()
miner
.
block
.
Undo
()
//
log.Infoln("[MINER] We did not know about this transaction, adding")
//
Apply new transactions
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
}
else
{
//log.Infoln("[MINER] We already had this transaction, ignoring")
}
}
}
}
default
:
default
:
stateManager
:=
miner
.
ethereum
.
StateManager
()
miner
.
mineNewBlock
()
}
}
}
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
func
(
self
*
Miner
)
mineNewBlock
()
{
stateManager
:=
self
.
ethereum
.
StateManager
()
self
.
block
=
self
.
ethereum
.
BlockChain
()
.
NewBlock
(
self
.
coinbase
,
self
.
txs
)
// Apply uncles
// Apply uncles
if
len
(
miner
.
uncles
)
>
0
{
if
len
(
self
.
uncles
)
>
0
{
miner
.
block
.
SetUncles
(
miner
.
uncles
)
self
.
block
.
SetUncles
(
self
.
uncles
)
}
}
// Apply all transactions to the block
// Accumulate all valid transaction and apply them to the new state
txs
:=
miner
.
txs
var
txs
[]
*
ethchain
.
Transaction
miner
.
txs
=
nil
for
_
,
tx
:=
range
self
.
txs
{
for
_
,
tx
:=
range
txs
{
if
err
:=
stateManager
.
ApplyTransaction
(
self
.
block
.
State
(),
self
.
block
,
tx
);
err
==
nil
{
if
err
:=
stateManager
.
ApplyTransaction
(
miner
.
block
.
State
(),
miner
.
block
,
tx
);
err
==
nil
{
txs
=
append
(
txs
,
tx
)
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
}
}
}
}
miner
.
block
.
SetTransactions
(
miner
.
txs
)
self
.
txs
=
txs
stateManager
.
AccumelateRewards
(
miner
.
block
.
State
(),
miner
.
block
)
// Set the transactions to the block so the new SHA3 can be calculated
self
.
block
.
SetTransactions
(
self
.
txs
)
ethutil
.
Config
.
Log
.
Infoln
(
"[MINER] Mining on block. Includes"
,
len
(
miner
.
txs
),
"transactions"
)
// Accumulate the rewards included for this block
stateManager
.
AccumelateRewards
(
self
.
block
.
State
(),
self
.
block
)
//miner.ethereum.StateManager().ApplyTransactions(miner.block.State(), miner.block, miner.block.Transactions()
)
ethutil
.
Config
.
Log
.
Infoln
(
"[MINER] Mining on block. Includes"
,
len
(
self
.
txs
),
"transactions"
)
// Search the
nonce
// Find a valid
nonce
miner
.
block
.
Nonce
=
miner
.
pow
.
Search
(
miner
.
block
,
miner
.
quitChan
)
self
.
block
.
Nonce
=
self
.
pow
.
Search
(
self
.
block
,
self
.
quitChan
)
if
miner
.
block
.
Nonce
!=
nil
{
if
self
.
block
.
Nonce
!=
nil
{
err
:=
miner
.
ethereum
.
StateManager
()
.
Process
(
miner
.
block
,
true
)
err
:=
self
.
ethereum
.
StateManager
()
.
Process
(
self
.
block
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Infoln
(
err
)
ethutil
.
Config
.
Log
.
Infoln
(
err
)
miner
.
txs
=
[]
*
ethchain
.
Transaction
{}
// Move this somewhere neat
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
}
else
{
}
else
{
miner
.
ethereum
.
Broadcast
(
ethwire
.
MsgBlockTy
,
[]
interface
{}{
miner
.
block
.
Value
()
.
Val
})
self
.
ethereum
.
Broadcast
(
ethwire
.
MsgBlockTy
,
[]
interface
{}{
self
.
block
.
Value
()
.
Val
})
ethutil
.
Config
.
Log
.
Infof
(
"[MINER] 🔨 Mined block %x
\n
"
,
miner
.
block
.
Hash
())
ethutil
.
Config
.
Log
.
Infof
(
"[MINER] 🔨 Mined block %x
\n
"
,
self
.
block
.
Hash
())
// Gather the new batch of transactions currently in the tx pool
miner
.
txs
=
[]
*
ethchain
.
Transaction
{}
// Move this somewhere neat
self
.
txs
=
self
.
ethereum
.
TxPool
()
.
CurrentTransactions
()
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
}
}
}
}
}
}
}
}
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