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
27c42ea9
Commit
27c42ea9
authored
Mar 06, 2015
by
Gustav Simonsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add empty total difficulty to test blocks and clean up stopping the node
parent
676a0de5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
main.go
cmd/blocktest/main.go
+11
-3
cmd.go
cmd/utils/cmd.go
+9
-0
backend.go
eth/backend.go
+11
-0
No files found.
cmd/blocktest/main.go
View file @
27c42ea9
...
@@ -168,7 +168,7 @@ func main() {
...
@@ -168,7 +168,7 @@ func main() {
logger
.
Flush
()
logger
.
Flush
()
}()
}()
utils
.
HandleInterrupt
()
//
utils.HandleInterrupt()
utils
.
InitConfig
(
VmType
,
ConfigFile
,
Datadir
,
"ethblocktest"
)
utils
.
InitConfig
(
VmType
,
ConfigFile
,
Datadir
,
"ethblocktest"
)
...
@@ -190,12 +190,17 @@ func main() {
...
@@ -190,12 +190,17 @@ func main() {
MinerThreads
:
MinerThreads
,
MinerThreads
:
MinerThreads
,
})
})
utils
.
StartEthereumForTest
(
ethereum
)
utils
.
StartRpc
(
ethereum
,
RpcListenAddress
,
RpcPort
)
utils
.
StartRpc
(
ethereum
,
RpcListenAddress
,
RpcPort
)
utils
.
StartEthereum
(
ethereum
)
ethereum
.
ChainManager
()
.
ResetWithGenesisBlock
(
blocks
[
0
])
ethereum
.
ChainManager
()
.
ResetWithGenesisBlock
(
blocks
[
0
])
// bph := ethereum.ChainManager().GetBlock(blocks[1].Header().ParentHash)
// fmt.Println("bph: ", bph)
// fmt.Println("HURR: ", hex.EncodeToString(ethutil.Encode(blocks[0].RlpData())))
//fmt.Println("b0: ", hex.EncodeToString(ethutil.Encode(blocks[0].RlpData())))
//fmt.Println("b0: ", hex.EncodeToString(blocks[0].Hash()))
//fmt.Println("b1: ", hex.EncodeToString(ethutil.Encode(blocks[1].RlpData())))
//fmt.Println("b1: ", hex.EncodeToString(blocks[1].Hash()))
go
ethereum
.
ChainManager
()
.
InsertChain
(
types
.
Blocks
{
blocks
[
1
]})
go
ethereum
.
ChainManager
()
.
InsertChain
(
types
.
Blocks
{
blocks
[
1
]})
fmt
.
Println
(
"OK! "
)
fmt
.
Println
(
"OK! "
)
...
@@ -254,6 +259,9 @@ func loadBlocksFromTestFile(filePath string) (blocks types.Blocks, err error) {
...
@@ -254,6 +259,9 @@ func loadBlocksFromTestFile(filePath string) (blocks types.Blocks, err error) {
}
}
gb
:=
types
.
NewBlockWithHeader
(
gbh
)
gb
:=
types
.
NewBlockWithHeader
(
gbh
)
//gb.uncles = *new([]*types.Header)
//gb.transactions = *new(types.Transactions)
gb
.
Td
=
new
(
big
.
Int
)
gb
.
Reward
=
new
(
big
.
Int
)
gb
.
Reward
=
new
(
big
.
Int
)
testBlock
:=
new
(
types
.
Block
)
testBlock
:=
new
(
types
.
Block
)
...
...
cmd/utils/cmd.go
View file @
27c42ea9
...
@@ -134,6 +134,15 @@ func StartEthereum(ethereum *eth.Ethereum) {
...
@@ -134,6 +134,15 @@ func StartEthereum(ethereum *eth.Ethereum) {
})
})
}
}
func
StartEthereumForTest
(
ethereum
*
eth
.
Ethereum
)
{
clilogger
.
Infoln
(
"Starting "
,
ethereum
.
Name
())
ethereum
.
StartForTest
()
RegisterInterrupt
(
func
(
sig
os
.
Signal
)
{
ethereum
.
Stop
()
logger
.
Flush
()
})
}
func
KeyTasks
(
keyManager
*
crypto
.
KeyManager
,
KeyRing
string
,
GenAddr
bool
,
SecretFile
string
,
ExportDir
string
,
NonInteractive
bool
)
{
func
KeyTasks
(
keyManager
*
crypto
.
KeyManager
,
KeyRing
string
,
GenAddr
bool
,
SecretFile
string
,
ExportDir
string
,
NonInteractive
bool
)
{
var
err
error
var
err
error
switch
{
switch
{
...
...
eth/backend.go
View file @
27c42ea9
...
@@ -275,6 +275,17 @@ func (s *Ethereum) Start() error {
...
@@ -275,6 +275,17 @@ func (s *Ethereum) Start() error {
return
nil
return
nil
}
}
func
(
s
*
Ethereum
)
StartForTest
()
{
jsonlogger
.
LogJson
(
&
logger
.
LogStarting
{
ClientString
:
s
.
net
.
Name
,
ProtocolVersion
:
ProtocolVersion
,
})
// Start services
s
.
txPool
.
Start
()
s
.
blockPool
.
Start
()
}
func
(
self
*
Ethereum
)
SuggestPeer
(
nodeURL
string
)
error
{
func
(
self
*
Ethereum
)
SuggestPeer
(
nodeURL
string
)
error
{
n
,
err
:=
discover
.
ParseNode
(
nodeURL
)
n
,
err
:=
discover
.
ParseNode
(
nodeURL
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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