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
053d5552
Commit
053d5552
authored
Apr 04, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated logging
parent
5dc5e669
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
22 deletions
+38
-22
chain_manager.go
core/chain_manager.go
+18
-8
verbosity.go
logger/verbosity.go
+2
-1
agent.go
miner/agent.go
+3
-1
miner.go
miner/miner.go
+0
-3
worker.go
miner/worker.go
+15
-9
No files found.
core/chain_manager.go
View file @
053d5552
...
@@ -291,6 +291,7 @@ func (self *ChainManager) Export(w io.Writer) error {
...
@@ -291,6 +291,7 @@ func (self *ChainManager) Export(w io.Writer) error {
self
.
mu
.
RLock
()
self
.
mu
.
RLock
()
defer
self
.
mu
.
RUnlock
()
defer
self
.
mu
.
RUnlock
()
glog
.
V
(
logger
.
Info
)
.
Infof
(
"exporting %v blocks...
\n
"
,
self
.
currentBlock
.
Header
()
.
Number
)
glog
.
V
(
logger
.
Info
)
.
Infof
(
"exporting %v blocks...
\n
"
,
self
.
currentBlock
.
Header
()
.
Number
)
for
block
:=
self
.
currentBlock
;
block
!=
nil
;
block
=
self
.
GetBlock
(
block
.
Header
()
.
ParentHash
)
{
for
block
:=
self
.
currentBlock
;
block
!=
nil
;
block
=
self
.
GetBlock
(
block
.
Header
()
.
ParentHash
)
{
if
err
:=
block
.
EncodeRLP
(
w
);
err
!=
nil
{
if
err
:=
block
.
EncodeRLP
(
w
);
err
!=
nil
{
return
err
return
err
...
@@ -360,7 +361,7 @@ func (self *ChainManager) GetBlock(hash common.Hash) *types.Block {
...
@@ -360,7 +361,7 @@ func (self *ChainManager) GetBlock(hash common.Hash) *types.Block {
}
}
var
block
types
.
StorageBlock
var
block
types
.
StorageBlock
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
data
),
&
block
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
data
),
&
block
);
err
!=
nil
{
chainlogger
.
Error
f
(
"invalid block RLP for hash %x: %v"
,
hash
,
err
)
glog
.
V
(
logger
.
Error
)
.
Info
f
(
"invalid block RLP for hash %x: %v"
,
hash
,
err
)
return
nil
return
nil
}
}
return
(
*
types
.
Block
)(
&
block
)
return
(
*
types
.
Block
)(
&
block
)
...
@@ -448,8 +449,11 @@ func (self *ChainManager) procFutureBlocks() {
...
@@ -448,8 +449,11 @@ func (self *ChainManager) procFutureBlocks() {
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
var
queue
=
make
([]
interface
{},
len
(
chain
))
var
(
var
queueEvent
=
queueEvent
{
queue
:
queue
}
queue
=
make
([]
interface
{},
len
(
chain
))
queueEvent
=
queueEvent
{
queue
:
queue
}
stats
struct
{
delayed
,
processed
int
}
)
for
i
,
block
:=
range
chain
{
for
i
,
block
:=
range
chain
{
if
block
==
nil
{
if
block
==
nil
{
continue
continue
...
@@ -467,18 +471,22 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -467,18 +471,22 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
// future block for future use
// future block for future use
if
err
==
BlockFutureErr
{
if
err
==
BlockFutureErr
{
self
.
futureBlocks
.
Push
(
block
)
self
.
futureBlocks
.
Push
(
block
)
stats
.
delayed
++
continue
continue
}
}
if
IsParentErr
(
err
)
&&
self
.
futureBlocks
.
Has
(
block
.
ParentHash
())
{
if
IsParentErr
(
err
)
&&
self
.
futureBlocks
.
Has
(
block
.
ParentHash
())
{
self
.
futureBlocks
.
Push
(
block
)
self
.
futureBlocks
.
Push
(
block
)
stats
.
delayed
++
continue
continue
}
}
h
:=
block
.
Header
()
h
:=
block
.
Header
()
chainlogger
.
Errorf
(
"INVALID block #%v (%x)
\n
"
,
h
.
Number
,
h
.
Hash
()
.
Bytes
()[
:
4
])
chainlogger
.
Errorln
(
err
)
glog
.
V
(
logger
.
Error
)
.
Infof
(
"INVALID block #%v (%x)
\n
"
,
h
.
Number
,
h
.
Hash
()
.
Bytes
()[
:
4
])
chainlogger
.
Debugln
(
block
)
glog
.
V
(
logger
.
Error
)
.
Infoln
(
err
)
glog
.
V
(
logger
.
Debug
)
.
Infoln
(
block
)
return
err
return
err
}
}
block
.
Td
=
td
block
.
Td
=
td
...
@@ -530,13 +538,15 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -530,13 +538,15 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
}
}
self
.
mu
.
Unlock
()
self
.
mu
.
Unlock
()
stats
.
processed
++
self
.
futureBlocks
.
Delete
(
block
.
Hash
())
self
.
futureBlocks
.
Delete
(
block
.
Hash
())
}
}
if
len
(
chain
)
>
0
&&
glog
.
V
(
logger
.
Info
)
{
if
(
stats
.
delayed
>
0
||
stats
.
processed
>
0
)
&&
bool
(
glog
.
V
(
logger
.
Info
)
)
{
start
,
end
:=
chain
[
0
],
chain
[
len
(
chain
)
-
1
]
start
,
end
:=
chain
[
0
],
chain
[
len
(
chain
)
-
1
]
glog
.
Infof
(
"imported %d block(s)
#%v [%x / %x]
\n
"
,
len
(
chain
)
,
end
.
Number
(),
start
.
Hash
()
.
Bytes
()[
:
4
],
end
.
Hash
()
.
Bytes
()[
:
4
])
glog
.
Infof
(
"imported %d block(s)
%d delayed. #%v [%x / %x]
\n
"
,
stats
.
processed
,
stats
.
delayed
,
end
.
Number
(),
start
.
Hash
()
.
Bytes
()[
:
4
],
end
.
Hash
()
.
Bytes
()[
:
4
])
}
}
go
self
.
eventMux
.
Post
(
queueEvent
)
go
self
.
eventMux
.
Post
(
queueEvent
)
...
...
logger/verbosity.go
View file @
053d5552
package
logger
package
logger
const
(
const
(
Error
=
iota
+
2
Error
=
iota
+
1
Warn
Info
Info
Core
Core
Debug
Debug
...
...
miner/agent.go
View file @
053d5552
...
@@ -5,6 +5,8 @@ import (
...
@@ -5,6 +5,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/pow"
)
)
...
@@ -75,7 +77,7 @@ done:
...
@@ -75,7 +77,7 @@ done:
}
}
func
(
self
*
CpuMiner
)
mine
(
block
*
types
.
Block
)
{
func
(
self
*
CpuMiner
)
mine
(
block
*
types
.
Block
)
{
minerlogger
.
Debug
f
(
"(re)started agent[%d]. mining...
\n
"
,
self
.
index
)
glog
.
V
(
logger
.
Debug
)
.
Info
f
(
"(re)started agent[%d]. mining...
\n
"
,
self
.
index
)
// Reset the channel
// Reset the channel
self
.
chMu
.
Lock
()
self
.
chMu
.
Lock
()
...
...
miner/miner.go
View file @
053d5552
...
@@ -6,12 +6,9 @@ import (
...
@@ -6,12 +6,9 @@ import (
"github.com/ethereum/ethash"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/pow"
)
)
var
minerlogger
=
logger
.
NewLogger
(
"MINER"
)
type
Miner
struct
{
type
Miner
struct
{
worker
*
worker
worker
*
worker
...
...
miner/worker.go
View file @
053d5552
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/pow"
"gopkg.in/fatih/set.v0"
"gopkg.in/fatih/set.v0"
)
)
...
@@ -144,7 +145,9 @@ out:
...
@@ -144,7 +145,9 @@ out:
}
}
break
out
break
out
case
<-
timer
.
C
:
case
<-
timer
.
C
:
minerlogger
.
Infoln
(
"Hash rate:"
,
self
.
HashRate
(),
"Khash"
)
if
glog
.
V
(
logger
.
Info
)
{
glog
.
Infoln
(
"Hash rate:"
,
self
.
HashRate
(),
"Khash"
)
}
// XXX In case all mined a possible uncle
// XXX In case all mined a possible uncle
if
atomic
.
LoadInt64
(
&
self
.
atWork
)
==
0
{
if
atomic
.
LoadInt64
(
&
self
.
atWork
)
==
0
{
...
@@ -171,7 +174,7 @@ func (self *worker) wait() {
...
@@ -171,7 +174,7 @@ func (self *worker) wait() {
}
}
self
.
mux
.
Post
(
core
.
NewMinedBlockEvent
{
block
})
self
.
mux
.
Post
(
core
.
NewMinedBlockEvent
{
block
})
minerlogger
.
Infof
(
"🔨 Mined block #%v"
,
block
.
Number
())
glog
.
V
(
logger
.
Info
)
.
Infof
(
"🔨 Mined block #%v"
,
block
.
Number
())
jsonlogger
.
LogJson
(
&
logger
.
EthMinerNewBlock
{
jsonlogger
.
LogJson
(
&
logger
.
EthMinerNewBlock
{
BlockHash
:
block
.
Hash
()
.
Hex
(),
BlockHash
:
block
.
Hash
()
.
Hex
(),
...
@@ -238,10 +241,13 @@ gasLimit:
...
@@ -238,10 +241,13 @@ gasLimit:
from
,
_
:=
tx
.
From
()
from
,
_
:=
tx
.
From
()
self
.
chain
.
TxState
()
.
RemoveNonce
(
from
,
tx
.
Nonce
())
self
.
chain
.
TxState
()
.
RemoveNonce
(
from
,
tx
.
Nonce
())
remove
=
append
(
remove
,
tx
)
remove
=
append
(
remove
,
tx
)
minerlogger
.
Infof
(
"TX (%x) failed, will be removed: %v
\n
"
,
tx
.
Hash
()
.
Bytes
()[
:
4
],
err
)
minerlogger
.
Infoln
(
tx
)
if
glog
.
V
(
logger
.
Info
)
{
glog
.
Infof
(
"TX (%x) failed, will be removed: %v
\n
"
,
tx
.
Hash
()
.
Bytes
()[
:
4
],
err
)
}
glog
.
V
(
logger
.
Debug
)
.
Infoln
(
tx
)
case
state
.
IsGasLimitErr
(
err
)
:
case
state
.
IsGasLimitErr
(
err
)
:
minerlogger
.
Infof
(
"Gas limit reached for block. %d TXs included in this block
\n
"
,
i
)
glog
.
V
(
logger
.
Info
)
.
Infof
(
"Gas limit reached for block. %d TXs included in this block
\n
"
,
i
)
// Break on gas limit
// Break on gas limit
break
gasLimit
break
gasLimit
default
:
default
:
...
@@ -260,15 +266,15 @@ gasLimit:
...
@@ -260,15 +266,15 @@ gasLimit:
}
}
if
err
:=
self
.
commitUncle
(
uncle
.
Header
());
err
!=
nil
{
if
err
:=
self
.
commitUncle
(
uncle
.
Header
());
err
!=
nil
{
minerlogger
.
Infof
(
"Bad uncle found and will be removed (%x)
\n
"
,
hash
[
:
4
])
glog
.
V
(
logger
.
Info
)
.
Infof
(
"Bad uncle found and will be removed (%x)
\n
"
,
hash
[
:
4
])
minerlogger
.
Debug
ln
(
uncle
)
glog
.
V
(
logger
.
Debug
)
.
Info
ln
(
uncle
)
badUncles
=
append
(
badUncles
,
hash
)
badUncles
=
append
(
badUncles
,
hash
)
}
else
{
}
else
{
minerlogger
.
Infof
(
"commiting %x as uncle
\n
"
,
hash
[
:
4
])
glog
.
V
(
logger
.
Info
)
.
Infof
(
"commiting %x as uncle
\n
"
,
hash
[
:
4
])
uncles
=
append
(
uncles
,
uncle
.
Header
())
uncles
=
append
(
uncles
,
uncle
.
Header
())
}
}
}
}
minerlogger
.
Infof
(
"commit new work on block %v with %d txs & %d uncles
\n
"
,
self
.
current
.
block
.
Number
(),
tcount
,
len
(
uncles
))
glog
.
V
(
logger
.
Info
)
.
Infof
(
"commit new work on block %v with %d txs & %d uncles
\n
"
,
self
.
current
.
block
.
Number
(),
tcount
,
len
(
uncles
))
for
_
,
hash
:=
range
badUncles
{
for
_
,
hash
:=
range
badUncles
{
delete
(
self
.
possibleUncles
,
hash
)
delete
(
self
.
possibleUncles
,
hash
)
}
}
...
...
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