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
60a2704b
Commit
60a2704b
authored
Mar 01, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement eth.miner.new_block event
parent
ad3a21f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
types.go
logger/types.go
+5
-4
worker.go
miner/worker.go
+9
-1
No files found.
logger/types.go
View file @
60a2704b
package
logger
import
(
"math/big"
"time"
)
...
...
@@ -53,10 +54,10 @@ func (l *P2PDisconnected) EventName() string {
}
type
EthMinerNewBlock
struct
{
BlockHash
string
`json:"block_hash"`
BlockNumber
int
`json:"block_number"`
ChainHeadHash
string
`json:"chain_head_hash"`
BlockPrevHash
string
`json:"block_prev_hash"`
BlockHash
string
`json:"block_hash"`
BlockNumber
*
big
.
Int
`json:"block_number"`
ChainHeadHash
string
`json:"chain_head_hash"`
BlockPrevHash
string
`json:"block_prev_hash"`
LogEvent
}
...
...
miner/worker.go
View file @
60a2704b
...
...
@@ -10,11 +10,14 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/state"
"gopkg.in/fatih/set.v0"
)
var
jsonlogger
=
logger
.
NewJsonLogger
()
type
environment
struct
{
totalUsedGas
*
big
.
Int
state
*
state
.
StateDB
...
...
@@ -141,7 +144,12 @@ func (self *worker) wait() {
block
:=
self
.
current
.
block
if
block
.
Number
()
.
Uint64
()
==
work
.
Number
&&
block
.
Nonce
()
==
nil
{
self
.
current
.
block
.
Header
()
.
Nonce
=
work
.
Nonce
jsonlogger
.
LogJson
(
&
logger
.
EthMinerNewBlock
{
BlockHash
:
ethutil
.
Bytes2Hex
(
block
.
Hash
()),
BlockNumber
:
block
.
Number
(),
ChainHeadHash
:
ethutil
.
Bytes2Hex
(
block
.
ParentHeaderHash
),
BlockPrevHash
:
ethutil
.
Bytes2Hex
(
block
.
ParentHeaderHash
),
})
if
err
:=
self
.
chain
.
InsertChain
(
types
.
Blocks
{
self
.
current
.
block
});
err
==
nil
{
self
.
mux
.
Post
(
core
.
NewMinedBlockEvent
{
self
.
current
.
block
})
}
else
{
...
...
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