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
45afbe5d
Commit
45afbe5d
authored
Mar 05, 2015
by
zelig
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/poc-9' into blockpool3
parents
73159628
c47866d2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
44 additions
and
30 deletions
+44
-30
gui.go
cmd/mist/gui.go
+0
-2
ui_lib.go
cmd/mist/ui_lib.go
+2
-1
block_processor.go
core/block_processor.go
+2
-5
chain_manager.go
core/chain_manager.go
+19
-9
genesis.go
core/genesis.go
+3
-2
block.go
core/types/block.go
+8
-6
protocol.go
eth/protocol.go
+1
-1
big.go
ethutil/big.go
+2
-1
worker.go
miner/worker.go
+7
-3
No files found.
cmd/mist/gui.go
View file @
45afbe5d
...
@@ -159,8 +159,6 @@ func (gui *Gui) Stop() {
...
@@ -159,8 +159,6 @@ func (gui *Gui) Stop() {
gui
.
win
.
Hide
()
gui
.
win
.
Hide
()
}
}
gui
.
uiLib
.
jsEngine
.
Stop
()
guilogger
.
Infoln
(
"Stopped"
)
guilogger
.
Infoln
(
"Stopped"
)
}
}
...
...
cmd/mist/ui_lib.go
View file @
45afbe5d
...
@@ -58,7 +58,8 @@ type UiLib struct {
...
@@ -58,7 +58,8 @@ type UiLib struct {
}
}
func
NewUiLib
(
engine
*
qml
.
Engine
,
eth
*
eth
.
Ethereum
,
assetPath
string
)
*
UiLib
{
func
NewUiLib
(
engine
*
qml
.
Engine
,
eth
*
eth
.
Ethereum
,
assetPath
string
)
*
UiLib
{
lib
:=
&
UiLib
{
XEth
:
xeth
.
New
(
eth
),
engine
:
engine
,
eth
:
eth
,
assetPath
:
assetPath
,
jsEngine
:
javascript
.
NewJSRE
(
eth
),
filterCallbacks
:
make
(
map
[
int
][]
int
)}
//, filters: make(map[int]*xeth.JSFilter)}
x
:=
xeth
.
New
(
eth
)
lib
:=
&
UiLib
{
XEth
:
x
,
engine
:
engine
,
eth
:
eth
,
assetPath
:
assetPath
,
jsEngine
:
javascript
.
NewJSRE
(
x
),
filterCallbacks
:
make
(
map
[
int
][]
int
)}
//, filters: make(map[int]*xeth.JSFilter)}
lib
.
filterManager
=
filter
.
NewFilterManager
(
eth
.
EventMux
())
lib
.
filterManager
=
filter
.
NewFilterManager
(
eth
.
EventMux
())
go
lib
.
filterManager
.
Start
()
go
lib
.
filterManager
.
Start
()
...
...
core/block_processor.go
View file @
45afbe5d
...
@@ -253,9 +253,6 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
...
@@ -253,9 +253,6 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
return
fmt
.
Errorf
(
"Difficulty check failed for block %v, %v"
,
block
.
Difficulty
,
expd
)
return
fmt
.
Errorf
(
"Difficulty check failed for block %v, %v"
,
block
.
Difficulty
,
expd
)
}
}
//expl := CalcGasLimit(parent, block)
//if expl.Cmp(block.Header().GasLimit) != 0 {
// block.gasLimit - parent.gasLimit <= parent.gasLimit / 1024
// block.gasLimit - parent.gasLimit <= parent.gasLimit / 1024
a
:=
new
(
big
.
Int
)
.
Sub
(
block
.
GasLimit
,
parent
.
GasLimit
)
a
:=
new
(
big
.
Int
)
.
Sub
(
block
.
GasLimit
,
parent
.
GasLimit
)
b
:=
new
(
big
.
Int
)
.
Div
(
parent
.
GasLimit
,
big
.
NewInt
(
1024
))
b
:=
new
(
big
.
Int
)
.
Div
(
parent
.
GasLimit
,
big
.
NewInt
(
1024
))
...
@@ -263,8 +260,8 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
...
@@ -263,8 +260,8 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
return
fmt
.
Errorf
(
"GasLimit check failed for block %v (%v > %v)"
,
block
.
GasLimit
,
a
,
b
)
return
fmt
.
Errorf
(
"GasLimit check failed for block %v (%v > %v)"
,
block
.
GasLimit
,
a
,
b
)
}
}
if
block
.
Time
<
parent
.
Time
{
if
block
.
Time
<
=
parent
.
Time
{
return
ValidationError
(
"Block timestamp not after prev block (%v - %v)"
,
block
.
Time
,
parent
.
Time
)
return
ValidationError
(
"Block timestamp not after
or equal to
prev block (%v - %v)"
,
block
.
Time
,
parent
.
Time
)
}
}
if
int64
(
block
.
Time
)
>
time
.
Now
()
.
Unix
()
{
if
int64
(
block
.
Time
)
>
time
.
Now
()
.
Unix
()
{
...
...
core/chain_manager.go
View file @
45afbe5d
...
@@ -31,15 +31,18 @@ type StateQuery interface {
...
@@ -31,15 +31,18 @@ type StateQuery interface {
func
CalcDifficulty
(
block
,
parent
*
types
.
Header
)
*
big
.
Int
{
func
CalcDifficulty
(
block
,
parent
*
types
.
Header
)
*
big
.
Int
{
diff
:=
new
(
big
.
Int
)
diff
:=
new
(
big
.
Int
)
//adjust := new(big.Int).Rsh(parent.Difficulty(), 10)
min
:=
big
.
NewInt
(
2048
)
//if block.Time() >= parent.Time()+8 {
adjust
:=
new
(
big
.
Int
)
.
Div
(
parent
.
Difficulty
,
min
)
adjust
:=
new
(
big
.
Int
)
.
Div
(
parent
.
Difficulty
,
big
.
NewInt
(
2048
))
if
(
block
.
Time
-
parent
.
Time
)
<
8
{
if
(
block
.
Time
-
parent
.
Time
)
<
8
{
diff
.
Add
(
parent
.
Difficulty
,
adjust
)
diff
.
Add
(
parent
.
Difficulty
,
adjust
)
}
else
{
}
else
{
diff
.
Sub
(
parent
.
Difficulty
,
adjust
)
diff
.
Sub
(
parent
.
Difficulty
,
adjust
)
}
}
if
diff
.
Cmp
(
GenesisDiff
)
<
0
{
return
GenesisDiff
}
return
diff
return
diff
}
}
...
@@ -378,9 +381,12 @@ func (bc *ChainManager) Stop() {
...
@@ -378,9 +381,12 @@ func (bc *ChainManager) Stop() {
}
}
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
println
(
"insert chain start"
)
self
.
tsmu
.
Lock
()
self
.
tsmu
.
Lock
()
defer
self
.
tsmu
.
Unlock
()
defer
self
.
tsmu
.
Unlock
()
defer
println
(
"insert chain end"
)
for
_
,
block
:=
range
chain
{
for
_
,
block
:=
range
chain
{
// Call in to the block processor and check for errors. It's likely that if one block fails
// Call in to the block processor and check for errors. It's likely that if one block fails
// all others will fail too (unless a known block is returned).
// all others will fail too (unless a known block is returned).
...
@@ -422,14 +428,18 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -422,14 +428,18 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
self
.
mu
.
Unlock
()
self
.
mu
.
Unlock
()
if
canonical
{
if
canonical
{
jsonlogger
.
LogJson
(
&
logger
.
EthChainNewHead
{
/*
BlockHash
:
ethutil
.
Bytes2Hex
(
block
.
Hash
()),
jsonlogger.LogJson(&logger.EthChainNewHead{
BlockNumber
:
block
.
Number
(),
BlockHash: ethutil.Bytes2Hex(block.Hash()),
ChainHeadHash
:
ethutil
.
Bytes2Hex
(
cblock
.
Hash
()),
BlockNumber: block.Number(),
BlockPrevHash
:
ethutil
.
Bytes2Hex
(
block
.
ParentHash
()),
ChainHeadHash: ethutil.Bytes2Hex(cblock.Hash()),
})
BlockPrevHash: ethutil.Bytes2Hex(block.ParentHash()),
})
*/
self
.
setTransState
(
state
.
New
(
block
.
Root
(),
self
.
db
))
self
.
setTransState
(
state
.
New
(
block
.
Root
(),
self
.
db
))
self
.
eventMux
.
Post
(
ChainEvent
{
block
,
td
})
self
.
eventMux
.
Post
(
ChainEvent
{
block
,
td
})
}
else
{
//self.eventMux.
}
}
if
split
{
if
split
{
...
...
core/genesis.go
View file @
45afbe5d
...
@@ -22,8 +22,10 @@ var ZeroHash512 = make([]byte, 64)
...
@@ -22,8 +22,10 @@ var ZeroHash512 = make([]byte, 64)
var
EmptyShaList
=
crypto
.
Sha3
(
ethutil
.
Encode
([]
interface
{}{}))
var
EmptyShaList
=
crypto
.
Sha3
(
ethutil
.
Encode
([]
interface
{}{}))
var
EmptyListRoot
=
crypto
.
Sha3
(
ethutil
.
Encode
(
""
))
var
EmptyListRoot
=
crypto
.
Sha3
(
ethutil
.
Encode
(
""
))
var
GenesisDiff
=
big
.
NewInt
(
131072
)
func
GenesisBlock
(
db
ethutil
.
Database
)
*
types
.
Block
{
func
GenesisBlock
(
db
ethutil
.
Database
)
*
types
.
Block
{
genesis
:=
types
.
NewBlock
(
ZeroHash256
,
ZeroHash160
,
nil
,
big
.
NewInt
(
2048
)
,
42
,
""
)
genesis
:=
types
.
NewBlock
(
ZeroHash256
,
ZeroHash160
,
nil
,
GenesisDiff
,
42
,
""
)
genesis
.
Header
()
.
Number
=
ethutil
.
Big0
genesis
.
Header
()
.
Number
=
ethutil
.
Big0
genesis
.
Header
()
.
GasLimit
=
big
.
NewInt
(
1000000
)
genesis
.
Header
()
.
GasLimit
=
big
.
NewInt
(
1000000
)
genesis
.
Header
()
.
GasUsed
=
ethutil
.
Big0
genesis
.
Header
()
.
GasUsed
=
ethutil
.
Big0
...
@@ -53,7 +55,6 @@ func GenesisBlock(db ethutil.Database) *types.Block {
...
@@ -53,7 +55,6 @@ func GenesisBlock(db ethutil.Database) *types.Block {
}
}
statedb
.
Sync
()
statedb
.
Sync
()
genesis
.
Header
()
.
Root
=
statedb
.
Root
()
genesis
.
Header
()
.
Root
=
statedb
.
Root
()
fmt
.
Println
(
genesis
)
return
genesis
return
genesis
}
}
...
...
core/types/block.go
View file @
45afbe5d
...
@@ -40,12 +40,12 @@ type Header struct {
...
@@ -40,12 +40,12 @@ type Header struct {
Time
uint64
Time
uint64
// Extra data
// Extra data
Extra
string
Extra
string
// Nonce
Nonce
[]
byte
// Mix digest for quick checking to prevent DOS
MixDigest
ethutil
.
Bytes
// SeedHash used for light client verification
// SeedHash used for light client verification
SeedHash
ethutil
.
Bytes
SeedHash
ethutil
.
Bytes
// Mix digest for quick checking to prevent DOS
MixDigest
ethutil
.
Bytes
// Nonce
Nonce
[]
byte
}
}
func
(
self
*
Header
)
rlpData
(
withNonce
bool
)
[]
interface
{}
{
func
(
self
*
Header
)
rlpData
(
withNonce
bool
)
[]
interface
{}
{
...
@@ -62,9 +62,11 @@ func (self *Header) rlpData(withNonce bool) []interface{} {
...
@@ -62,9 +62,11 @@ func (self *Header) rlpData(withNonce bool) []interface{} {
self
.
GasLimit
,
self
.
GasLimit
,
self
.
GasUsed
,
self
.
GasUsed
,
self
.
Time
,
self
.
Time
,
self
.
Extra
}
self
.
Extra
,
self
.
SeedHash
,
}
if
withNonce
{
if
withNonce
{
fields
=
append
(
fields
,
self
.
SeedHash
,
self
.
MixDigest
,
self
.
Nonce
)
fields
=
append
(
fields
,
self
.
MixDigest
,
self
.
Nonce
)
}
}
return
fields
return
fields
...
...
eth/protocol.go
View file @
45afbe5d
...
@@ -250,7 +250,7 @@ func (self *ethProtocol) handle() error {
...
@@ -250,7 +250,7 @@ func (self *ethProtocol) handle() error {
return
self
.
protoError
(
ErrDecode
,
"msg %v: %v"
,
msg
,
err
)
return
self
.
protoError
(
ErrDecode
,
"msg %v: %v"
,
msg
,
err
)
}
}
hash
:=
request
.
Block
.
Hash
()
hash
:=
request
.
Block
.
Hash
()
fmt
.
Print
ln
(
"received block: %x
"
,
hash
)
fmt
.
Print
f
(
"received block: %x
\n
"
,
hash
)
_
,
chainHead
,
_
:=
self
.
chainManager
.
Status
()
_
,
chainHead
,
_
:=
self
.
chainManager
.
Status
()
jsonlogger
.
LogJson
(
&
logger
.
EthChainReceivedNewBlock
{
jsonlogger
.
LogJson
(
&
logger
.
EthChainReceivedNewBlock
{
...
...
ethutil/big.go
View file @
45afbe5d
...
@@ -25,12 +25,13 @@ func Big(num string) *big.Int {
...
@@ -25,12 +25,13 @@ func Big(num string) *big.Int {
// BigD
// BigD
//
//
// Shortcut for new(big.Int).SetBytes(...)
// Shortcut for new(big.Int).SetBytes(...)
func
B
igD
(
data
[]
byte
)
*
big
.
Int
{
func
B
ytes2Big
(
data
[]
byte
)
*
big
.
Int
{
n
:=
new
(
big
.
Int
)
n
:=
new
(
big
.
Int
)
n
.
SetBytes
(
data
)
n
.
SetBytes
(
data
)
return
n
return
n
}
}
func
BigD
(
data
[]
byte
)
*
big
.
Int
{
return
Bytes2Big
(
data
)
}
func
BitTest
(
num
*
big
.
Int
,
i
int
)
bool
{
func
BitTest
(
num
*
big
.
Int
,
i
int
)
bool
{
return
num
.
Bit
(
i
)
>
0
return
num
.
Bit
(
i
)
>
0
...
...
miner/worker.go
View file @
45afbe5d
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"sync"
"sync"
"time"
"time"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
...
@@ -138,7 +139,7 @@ out:
...
@@ -138,7 +139,7 @@ out:
}
}
break
out
break
out
case
<-
timer
.
C
:
case
<-
timer
.
C
:
minerlogger
.
Debug
ln
(
"Hash rate:"
,
self
.
HashRate
(),
"Khash"
)
minerlogger
.
Info
ln
(
"Hash rate:"
,
self
.
HashRate
(),
"Khash"
)
}
}
}
}
...
@@ -164,7 +165,6 @@ func (self *worker) wait() {
...
@@ -164,7 +165,6 @@ func (self *worker) wait() {
if
err
:=
self
.
chain
.
InsertChain
(
types
.
Blocks
{
self
.
current
.
block
});
err
==
nil
{
if
err
:=
self
.
chain
.
InsertChain
(
types
.
Blocks
{
self
.
current
.
block
});
err
==
nil
{
self
.
mux
.
Post
(
core
.
NewMinedBlockEvent
{
self
.
current
.
block
})
self
.
mux
.
Post
(
core
.
NewMinedBlockEvent
{
self
.
current
.
block
})
fmt
.
Println
(
"GOOD BLOCK"
,
self
.
current
.
block
)
}
else
{
}
else
{
self
.
commitNewWork
()
self
.
commitNewWork
()
}
}
...
@@ -190,7 +190,11 @@ func (self *worker) commitNewWork() {
...
@@ -190,7 +190,11 @@ func (self *worker) commitNewWork() {
self
.
mu
.
Lock
()
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
defer
self
.
mu
.
Unlock
()
self
.
current
=
env
(
self
.
chain
.
NewBlock
(
self
.
coinbase
),
self
.
eth
)
block
:=
self
.
chain
.
NewBlock
(
self
.
coinbase
)
seednum
:=
ethash
.
GetSeedBlockNum
(
block
.
NumberU64
())
block
.
Header
()
.
SeedHash
=
self
.
chain
.
GetBlockByNumber
(
seednum
)
.
SeedHash
()
self
.
current
=
env
(
block
,
self
.
eth
)
parent
:=
self
.
chain
.
GetBlock
(
self
.
current
.
block
.
ParentHash
())
parent
:=
self
.
chain
.
GetBlock
(
self
.
current
.
block
.
ParentHash
())
self
.
current
.
coinbase
.
SetGasPool
(
core
.
CalcGasLimit
(
parent
,
self
.
current
.
block
))
self
.
current
.
coinbase
.
SetGasPool
(
core
.
CalcGasLimit
(
parent
,
self
.
current
.
block
))
...
...
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