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
56aa2400
Commit
56aa2400
authored
Nov 14, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up
parent
711be700
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
21 deletions
+20
-21
block_pool.go
block_pool.go
+4
-1
block.go
chain/block.go
+1
-1
block_manager.go
chain/block_manager.go
+10
-10
bloom9.go
chain/bloom9.go
+4
-4
receipt.go
chain/receipt.go
+1
-5
No files found.
block_pool.go
View file @
56aa2400
...
...
@@ -323,7 +323,10 @@ out:
self
.
Reset
()
poollogger
.
Debugf
(
"Punishing peer for supplying bad chain (%v)
\n
"
,
self
.
peer
.
conn
.
RemoteAddr
())
if
self
.
peer
!=
nil
&&
self
.
peer
.
conn
!=
nil
{
poollogger
.
Debugf
(
"Punishing peer for supplying bad chain (%v)
\n
"
,
self
.
peer
.
conn
.
RemoteAddr
())
}
// This peer gave us bad hashes and made us fetch a bad chain, therefor he shall be punished.
self
.
eth
.
BlacklistPeer
(
self
.
peer
)
self
.
peer
.
StopWithReason
(
DiscBadPeer
)
...
...
chain/block.go
View file @
56aa2400
...
...
@@ -238,7 +238,7 @@ func (block *Block) SetUncles(uncles []*Block) {
func
(
self
*
Block
)
SetReceipts
(
receipts
Receipts
)
{
self
.
receipts
=
receipts
self
.
ReceiptSha
=
DeriveSha
(
receipts
)
self
.
LogsBloom
=
CreateBloom
(
self
)
self
.
LogsBloom
=
CreateBloom
(
receipts
)
}
func
(
self
*
Block
)
SetTransactions
(
txs
Transactions
)
{
...
...
chain/block_manager.go
View file @
56aa2400
...
...
@@ -159,8 +159,8 @@ done:
txGas
.
Sub
(
txGas
,
st
.
gas
)
cumulative
:=
new
(
big
.
Int
)
.
Set
(
totalUsedGas
.
Add
(
totalUsedGas
,
txGas
))
bloom
:=
ethutil
.
LeftPadBytes
(
LogsBloom
(
state
.
Logs
())
.
Bytes
(),
64
)
receipt
:=
&
Receipt
{
ethutil
.
CopyBytes
(
state
.
Root
()),
cumulative
,
bloom
,
state
.
Logs
()}
receipt
:=
&
Receipt
{
ethutil
.
CopyBytes
(
state
.
Root
()),
cumulative
,
nil
/*bloom*/
,
state
.
Logs
()}
receipt
.
Bloom
=
CreateBloom
(
Receipts
{
receipt
})
// Notify all subscribers
go
self
.
eth
.
EventMux
()
.
Post
(
TxPostEvent
{
tx
})
...
...
@@ -217,38 +217,38 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
txSha
:=
DeriveSha
(
block
.
transactions
)
if
bytes
.
Compare
(
txSha
,
block
.
TxSha
)
!=
0
{
err
=
fmt
.
Errorf
(
"
Error validating transaction root. Received %x, got
%x"
,
block
.
TxSha
,
txSha
)
err
=
fmt
.
Errorf
(
"
validating transaction root. received=%x got=
%x"
,
block
.
TxSha
,
txSha
)
return
}
receiptSha
:=
DeriveSha
(
receipts
)
if
bytes
.
Compare
(
receiptSha
,
block
.
ReceiptSha
)
!=
0
{
err
=
fmt
.
Errorf
(
"
Error validating receipt root. Received %x, got
%x"
,
block
.
ReceiptSha
,
receiptSha
)
err
=
fmt
.
Errorf
(
"
validating receipt root. received=%x got=
%x"
,
block
.
ReceiptSha
,
receiptSha
)
return
}
// Block validation
if
err
=
sm
.
ValidateBlock
(
block
,
parent
);
err
!=
nil
{
statelogger
.
Errorln
(
"
Error
validating block:"
,
err
)
statelogger
.
Errorln
(
"validating block:"
,
err
)
return
}
if
err
=
sm
.
AccumelateRewards
(
state
,
block
,
parent
);
err
!=
nil
{
statelogger
.
Errorln
(
"
Error
accumulating reward"
,
err
)
statelogger
.
Errorln
(
"accumulating reward"
,
err
)
return
}
block
.
receipts
=
receipts
rbloom
:=
CreateBloom
(
block
)
block
.
receipts
=
receipts
// although this isn't necessary it be in the future
rbloom
:=
CreateBloom
(
receipts
)
if
bytes
.
Compare
(
rbloom
,
block
.
LogsBloom
)
!=
0
{
err
=
fmt
.
Errorf
(
"unable to replicate block's bloom
:
%x"
,
rbloom
)
err
=
fmt
.
Errorf
(
"unable to replicate block's bloom
=
%x"
,
rbloom
)
return
}
state
.
Update
()
if
!
block
.
State
()
.
Cmp
(
state
)
{
err
=
fmt
.
Errorf
(
"
Invalid merkle root.
\n
rec: %x
\n
is: %x"
,
block
.
State
()
.
Root
(),
state
.
Root
())
err
=
fmt
.
Errorf
(
"
invalid merkle root. received=%x got=%x"
,
block
.
Root
(),
state
.
Root
())
return
}
...
...
chain/bloom9.go
View file @
56aa2400
...
...
@@ -8,16 +8,16 @@ import (
"github.com/ethereum/go-ethereum/state"
)
func
CreateBloom
(
block
*
Block
)
[]
byte
{
func
CreateBloom
(
receipts
Receipts
)
[]
byte
{
bin
:=
new
(
big
.
Int
)
for
_
,
receipt
:=
range
block
.
Receipts
()
{
bin
.
Or
(
bin
,
L
ogsBloom
(
receipt
.
logs
))
for
_
,
receipt
:=
range
receipts
{
bin
.
Or
(
bin
,
l
ogsBloom
(
receipt
.
logs
))
}
return
ethutil
.
LeftPadBytes
(
bin
.
Bytes
(),
64
)
}
func
L
ogsBloom
(
logs
state
.
Logs
)
*
big
.
Int
{
func
l
ogsBloom
(
logs
state
.
Logs
)
*
big
.
Int
{
bin
:=
new
(
big
.
Int
)
for
_
,
log
:=
range
logs
{
data
:=
[][]
byte
{
log
.
Address
}
...
...
chain/receipt.go
View file @
56aa2400
...
...
@@ -51,11 +51,7 @@ func (self *Receipt) Cmp(other *Receipt) bool {
}
func
(
self
*
Receipt
)
String
()
string
{
return
fmt
.
Sprintf
(
`Receipt: %x
cumulative gas: %v
bloom: %x
logs: %v
rlp: %x`
,
self
.
PostState
,
self
.
CumulativeGasUsed
,
self
.
Bloom
,
self
.
logs
,
self
.
RlpEncode
())
return
fmt
.
Sprintf
(
"receipt{med=%x cgas=%v bloom=%x logs=%v}"
,
self
.
PostState
,
self
.
CumulativeGasUsed
,
self
.
Bloom
,
self
.
logs
)
}
type
Receipts
[]
*
Receipt
...
...
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