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
770a0e78
Commit
770a0e78
authored
Jun 03, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
b26f5e0b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
10 deletions
+69
-10
admin.go
cmd/geth/admin.go
+66
-2
block_processor.go
core/block_processor.go
+0
-6
chain_manager.go
core/chain_manager.go
+3
-2
No files found.
cmd/geth/admin.go
View file @
770a0e78
...
...
@@ -78,6 +78,12 @@ func (js *jsre) adminBindings() {
miner
.
Set
(
"stopAutoDAG"
,
js
.
stopAutoDAG
)
miner
.
Set
(
"makeDAG"
,
js
.
makeDAG
)
admin
.
Set
(
"txPool"
,
struct
{}{})
t
,
_
=
admin
.
Get
(
"txPool"
)
txPool
:=
t
.
Object
()
txPool
.
Set
(
"pending"
,
js
.
allPendingTransactions
)
txPool
.
Set
(
"queued"
,
js
.
allQueuedTransactions
)
admin
.
Set
(
"debug"
,
struct
{}{})
t
,
_
=
admin
.
Get
(
"debug"
)
debug
:=
t
.
Object
()
...
...
@@ -89,6 +95,7 @@ func (js *jsre) adminBindings() {
debug
.
Set
(
"setHead"
,
js
.
setHead
)
debug
.
Set
(
"processBlock"
,
js
.
debugBlock
)
debug
.
Set
(
"seedhash"
,
js
.
seedHash
)
debug
.
Set
(
"insertBlock"
,
js
.
insertBlockRlp
)
// undocumented temporary
debug
.
Set
(
"waitForBlocks"
,
js
.
waitForBlocks
)
}
...
...
@@ -140,6 +147,32 @@ func (js *jsre) seedHash(call otto.FunctionCall) otto.Value {
return
otto
.
UndefinedValue
()
}
func
(
js
*
jsre
)
allPendingTransactions
(
call
otto
.
FunctionCall
)
otto
.
Value
{
txs
:=
js
.
ethereum
.
TxPool
()
.
GetTransactions
()
ltxs
:=
make
([]
*
tx
,
len
(
txs
))
for
i
,
tx
:=
range
txs
{
// no need to check err
ltxs
[
i
]
=
newTx
(
tx
)
}
v
,
_
:=
call
.
Otto
.
ToValue
(
ltxs
)
return
v
}
func
(
js
*
jsre
)
allQueuedTransactions
(
call
otto
.
FunctionCall
)
otto
.
Value
{
txs
:=
js
.
ethereum
.
TxPool
()
.
GetQueuedTransactions
()
ltxs
:=
make
([]
*
tx
,
len
(
txs
))
for
i
,
tx
:=
range
txs
{
// no need to check err
ltxs
[
i
]
=
newTx
(
tx
)
}
v
,
_
:=
call
.
Otto
.
ToValue
(
ltxs
)
return
v
}
func
(
js
*
jsre
)
pendingTransactions
(
call
otto
.
FunctionCall
)
otto
.
Value
{
txs
:=
js
.
ethereum
.
TxPool
()
.
GetTransactions
()
...
...
@@ -237,16 +270,47 @@ func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
return
otto
.
UndefinedValue
()
}
tstart
:=
time
.
Now
()
old
:=
vm
.
Debug
vm
.
Debug
=
true
_
,
err
=
js
.
ethereum
.
BlockProcessor
()
.
RetryProcess
(
block
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
r
,
_
:=
call
.
Otto
.
ToValue
(
map
[
string
]
interface
{}{
"success"
:
false
,
"time"
:
time
.
Since
(
tstart
)
.
Seconds
()})
return
r
}
vm
.
Debug
=
old
fmt
.
Println
(
"ok"
)
return
otto
.
UndefinedValue
()
r
,
_
:=
call
.
Otto
.
ToValue
(
map
[
string
]
interface
{}{
"success"
:
true
,
"time"
:
time
.
Since
(
tstart
)
.
Seconds
()})
return
r
}
func
(
js
*
jsre
)
insertBlockRlp
(
call
otto
.
FunctionCall
)
otto
.
Value
{
tstart
:=
time
.
Now
()
var
block
types
.
Block
if
call
.
Argument
(
0
)
.
IsString
()
{
blockRlp
,
_
:=
call
.
Argument
(
0
)
.
ToString
()
err
:=
rlp
.
DecodeBytes
(
common
.
Hex2Bytes
(
blockRlp
),
&
block
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
otto
.
UndefinedValue
()
}
}
old
:=
vm
.
Debug
vm
.
Debug
=
true
_
,
err
:=
js
.
ethereum
.
BlockProcessor
()
.
RetryProcess
(
&
block
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
r
,
_
:=
call
.
Otto
.
ToValue
(
map
[
string
]
interface
{}{
"success"
:
false
,
"time"
:
time
.
Since
(
tstart
)
.
Seconds
()})
return
r
}
vm
.
Debug
=
old
r
,
_
:=
call
.
Otto
.
ToValue
(
map
[
string
]
interface
{}{
"success"
:
true
,
"time"
:
time
.
Since
(
tstart
)
.
Seconds
()})
return
r
}
func
(
js
*
jsre
)
setHead
(
call
otto
.
FunctionCall
)
otto
.
Value
{
...
...
core/block_processor.go
View file @
770a0e78
...
...
@@ -178,7 +178,6 @@ func (sm *BlockProcessor) Process(block *types.Block) (logs state.Logs, err erro
return
nil
,
ParentError
(
header
.
ParentHash
)
}
parent
:=
sm
.
bc
.
GetBlock
(
header
.
ParentHash
)
return
sm
.
processWithParent
(
block
,
parent
)
}
...
...
@@ -254,14 +253,9 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st
return
nil
,
err
}
// Calculate the td for this block
//td = CalculateTD(block, parent)
// Sync the current block's state to the database
state
.
Sync
()
// Remove transactions from the pool
sm
.
txpool
.
RemoveTransactions
(
block
.
Transactions
())
// This puts transactions in a extra db for rpc
for
i
,
tx
:=
range
block
.
Transactions
()
{
putTx
(
sm
.
extraDb
,
tx
,
block
,
uint64
(
i
))
...
...
core/chain_manager.go
View file @
770a0e78
...
...
@@ -560,6 +560,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
defer
close
(
nonceQuit
)
for
i
,
block
:=
range
chain
{
bstart
:=
time
.
Now
()
// Wait for block i's nonce to be verified before processing
// its state transition.
for
nonceChecked
[
i
]
{
...
...
@@ -642,11 +643,11 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
queueEvent
.
canonicalCount
++
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"[%v] inserted block #%d (%d TXs %d UNCs) (%x...)
\n
"
,
time
.
Now
()
.
UnixNano
(),
block
.
Number
(),
len
(
block
.
Transactions
()),
len
(
block
.
Uncles
()),
block
.
Hash
()
.
Bytes
()[
0
:
4
]
)
glog
.
Infof
(
"[%v] inserted block #%d (%d TXs %d UNCs) (%x...)
. Took %v
\n
"
,
time
.
Now
()
.
UnixNano
(),
block
.
Number
(),
len
(
block
.
Transactions
()),
len
(
block
.
Uncles
()),
block
.
Hash
()
.
Bytes
()[
0
:
4
],
time
.
Since
(
bstart
)
)
}
}
else
{
if
glog
.
V
(
logger
.
Detail
)
{
glog
.
Infof
(
"inserted forked block #%d (TD=%v) (%d TXs %d UNCs) (%x...)
\n
"
,
block
.
Number
(),
block
.
Difficulty
(),
len
(
block
.
Transactions
()),
len
(
block
.
Uncles
()),
block
.
Hash
()
.
Bytes
()[
0
:
4
]
)
glog
.
Infof
(
"inserted forked block #%d (TD=%v) (%d TXs %d UNCs) (%x...)
. Took %v
\n
"
,
block
.
Number
(),
block
.
Difficulty
(),
len
(
block
.
Transactions
()),
len
(
block
.
Uncles
()),
block
.
Hash
()
.
Bytes
()[
0
:
4
],
time
.
Since
(
bstart
)
)
}
queue
[
i
]
=
ChainSideEvent
{
block
,
logs
}
...
...
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