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
75ee3b3f
Commit
75ee3b3f
authored
Nov 11, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugging code
parent
9509322e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
111 additions
and
66 deletions
+111
-66
block_pool.go
block_pool.go
+4
-4
block_manager.go
chain/block_manager.go
+20
-11
chain_manager.go
chain/chain_manager.go
+1
-0
receipt.go
chain/receipt.go
+65
-0
transaction.go
chain/transaction.go
+0
-47
log.go
state/log.go
+18
-1
state.go
state/state.go
+3
-3
No files found.
block_pool.go
View file @
75ee3b3f
...
...
@@ -316,9 +316,9 @@ out:
if
len
(
blocks
)
>
0
{
chainManager
:=
self
.
eth
.
ChainManager
()
// Test and import
chain
:=
chain
.
NewChain
(
blocks
)
_
,
err
:=
chainManager
.
TestChain
(
chain
)
if
err
!=
nil
{
b
chain
:=
chain
.
NewChain
(
blocks
)
_
,
err
:=
chainManager
.
TestChain
(
b
chain
)
if
err
!=
nil
&&
!
chain
.
IsTDError
(
err
)
{
poollogger
.
Debugln
(
err
)
self
.
Reset
()
...
...
@@ -330,7 +330,7 @@ out:
self
.
td
=
ethutil
.
Big0
self
.
peer
=
nil
}
else
{
chainManager
.
InsertChain
(
chain
)
chainManager
.
InsertChain
(
b
chain
)
for
_
,
block
:=
range
blocks
{
self
.
Remove
(
block
.
Hash
())
}
...
...
chain/block_manager.go
View file @
75ee3b3f
...
...
@@ -159,7 +159,9 @@ done:
txGas
.
Sub
(
txGas
,
st
.
gas
)
cumulative
:=
new
(
big
.
Int
)
.
Set
(
totalUsedGas
.
Add
(
totalUsedGas
,
txGas
))
receipt
:=
&
Receipt
{
ethutil
.
CopyBytes
(
state
.
Root
()
.
([]
byte
)),
cumulative
,
LogsBloom
(
state
.
Logs
())
.
Bytes
(),
state
.
Logs
()}
bloom
:=
ethutil
.
LeftPadBytes
(
LogsBloom
(
state
.
Logs
())
.
Bytes
(),
64
)
receipt
:=
&
Receipt
{
ethutil
.
CopyBytes
(
state
.
Root
()),
cumulative
,
bloom
,
state
.
Logs
()}
//fmt.Println(receipt)
// Notify all subscribers
go
self
.
eth
.
EventMux
()
.
Post
(
TxPostEvent
{
tx
})
...
...
@@ -213,13 +215,15 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
if
err
!=
nil
{
return
}
block
.
SetReceipts
(
receipts
)
//
block.SetReceipts(receipts)
txSha
:=
DeriveSha
(
block
.
transactions
)
if
bytes
.
Compare
(
txSha
,
block
.
TxSha
)
!=
0
{
err
=
fmt
.
Errorf
(
"Error validating transaction sha. Received %x, got %x"
,
block
.
TxSha
,
txSha
)
return
}
/*
txSha := DeriveSha(block.transactions)
if bytes.Compare(txSha, block.TxSha) != 0 {
err = fmt.Errorf("Error validating transaction sha. Received %x, got %x", block.TxSha, txSha)
return
}
*/
receiptSha
:=
DeriveSha
(
receipts
)
if
bytes
.
Compare
(
receiptSha
,
block
.
ReceiptSha
)
!=
0
{
...
...
@@ -255,13 +259,18 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
// Sync the current block's state to the database and cancelling out the deferred Undo
state
.
Sync
()
// TODO at this point we should also insert LOGS in to a database
sm
.
transState
=
state
.
Copy
()
messages
:=
state
.
Manifest
()
.
Messages
state
.
Manifest
()
.
Reset
()
/*
sm.eth.ChainManager().SetTotalDifficulty(td)
sm.eth.ChainManager().add(block)
sm.eth.EventMux().Post(NewBlockEvent{block})
sm.eth.EventMux().Post(messages)
*/
sm
.
transState
=
state
.
Copy
()
sm
.
eth
.
TxPool
()
.
RemoveSet
(
block
.
Transactions
())
return
td
,
messages
,
nil
...
...
chain/chain_manager.go
View file @
75ee3b3f
...
...
@@ -337,6 +337,7 @@ func (self *ChainManager) InsertChain(chain *BlockChain) {
func
(
self
*
ChainManager
)
TestChain
(
chain
*
BlockChain
)
(
td
*
big
.
Int
,
err
error
)
{
self
.
workingChain
=
chain
defer
func
()
{
self
.
workingChain
=
nil
}()
for
e
:=
chain
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
var
(
...
...
chain/receipt.go
0 → 100644
View file @
75ee3b3f
package
chain
import
(
"bytes"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
)
type
Receipt
struct
{
PostState
[]
byte
CumulativeGasUsed
*
big
.
Int
Bloom
[]
byte
logs
state
.
Logs
}
func
NewRecieptFromValue
(
val
*
ethutil
.
Value
)
*
Receipt
{
r
:=
&
Receipt
{}
r
.
RlpValueDecode
(
val
)
return
r
}
func
(
self
*
Receipt
)
RlpValueDecode
(
decoder
*
ethutil
.
Value
)
{
self
.
PostState
=
decoder
.
Get
(
0
)
.
Bytes
()
self
.
CumulativeGasUsed
=
decoder
.
Get
(
1
)
.
BigInt
()
self
.
Bloom
=
decoder
.
Get
(
2
)
.
Bytes
()
it
:=
decoder
.
Get
(
3
)
.
NewIterator
()
for
it
.
Next
()
{
self
.
logs
=
append
(
self
.
logs
,
state
.
NewLogFromValue
(
it
.
Value
()))
}
}
func
(
self
*
Receipt
)
RlpData
()
interface
{}
{
fmt
.
Println
(
self
.
logs
.
RlpData
())
return
[]
interface
{}{
self
.
PostState
,
self
.
CumulativeGasUsed
,
self
.
Bloom
,
self
.
logs
.
RlpData
()}
}
func
(
self
*
Receipt
)
RlpEncode
()
[]
byte
{
return
ethutil
.
Encode
(
self
.
RlpData
())
}
func
(
self
*
Receipt
)
Cmp
(
other
*
Receipt
)
bool
{
if
bytes
.
Compare
(
self
.
PostState
,
other
.
PostState
)
!=
0
{
return
false
}
return
true
}
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
())
}
type
Receipts
[]
*
Receipt
func
(
self
Receipts
)
Len
()
int
{
return
len
(
self
)
}
func
(
self
Receipts
)
GetRlp
(
i
int
)
[]
byte
{
return
ethutil
.
Rlp
(
self
[
i
])
}
chain/transaction.go
View file @
75ee3b3f
package
chain
import
(
"bytes"
"fmt"
"math/big"
...
...
@@ -201,52 +200,6 @@ func (tx *Transaction) String() string {
tx
.
s
)
}
type
Receipt
struct
{
PostState
[]
byte
CumulativeGasUsed
*
big
.
Int
Bloom
[]
byte
logs
state
.
Logs
}
func
NewRecieptFromValue
(
val
*
ethutil
.
Value
)
*
Receipt
{
r
:=
&
Receipt
{}
r
.
RlpValueDecode
(
val
)
return
r
}
func
(
self
*
Receipt
)
RlpValueDecode
(
decoder
*
ethutil
.
Value
)
{
self
.
PostState
=
decoder
.
Get
(
0
)
.
Bytes
()
self
.
CumulativeGasUsed
=
decoder
.
Get
(
1
)
.
BigInt
()
self
.
Bloom
=
decoder
.
Get
(
2
)
.
Bytes
()
it
:=
decoder
.
Get
(
3
)
.
NewIterator
()
for
it
.
Next
()
{
self
.
logs
=
append
(
self
.
logs
,
state
.
NewLogFromValue
(
it
.
Value
()))
}
}
func
(
self
*
Receipt
)
RlpData
()
interface
{}
{
return
[]
interface
{}{
self
.
PostState
,
self
.
CumulativeGasUsed
,
self
.
Bloom
,
self
.
logs
.
RlpData
()}
}
func
(
self
*
Receipt
)
RlpEncode
()
[]
byte
{
return
ethutil
.
Encode
(
self
.
RlpData
())
}
func
(
self
*
Receipt
)
Cmp
(
other
*
Receipt
)
bool
{
if
bytes
.
Compare
(
self
.
PostState
,
other
.
PostState
)
!=
0
{
return
false
}
return
true
}
type
Receipts
[]
*
Receipt
func
(
self
Receipts
)
Len
()
int
{
return
len
(
self
)
}
func
(
self
Receipts
)
GetRlp
(
i
int
)
[]
byte
{
return
ethutil
.
Rlp
(
self
[
i
])
}
// Transaction slice type for basic sorting
type
Transactions
[]
*
Transaction
...
...
state/log.go
View file @
75ee3b3f
package
state
import
"github.com/ethereum/go-ethereum/ethutil"
import
(
"fmt"
"strings"
"github.com/ethereum/go-ethereum/ethutil"
)
type
Log
struct
{
Address
[]
byte
...
...
@@ -26,6 +31,10 @@ func (self Log) RlpData() interface{} {
return
[]
interface
{}{
self
.
Address
,
ethutil
.
ByteSliceToInterface
(
self
.
Topics
),
self
.
Data
}
}
func
(
self
Log
)
String
()
string
{
return
fmt
.
Sprintf
(
`log: %x %x %x`
,
self
.
Address
,
self
.
Topics
,
self
.
Data
)
}
type
Logs
[]
Log
func
(
self
Logs
)
RlpData
()
interface
{}
{
...
...
@@ -36,3 +45,11 @@ func (self Logs) RlpData() interface{} {
return
data
}
func
(
self
Logs
)
String
()
string
{
var
logs
[]
string
for
_
,
log
:=
range
self
{
logs
=
append
(
logs
,
log
.
String
())
}
return
"[ "
+
strings
.
Join
(
logs
,
", "
)
+
" ]"
}
state/state.go
View file @
75ee3b3f
...
...
@@ -62,7 +62,7 @@ func (self *State) Refund(addr []byte, gas, price *big.Int) {
self
.
refund
[
string
(
addr
)]
=
new
(
big
.
Int
)
}
self
.
refund
[
string
(
addr
)]
=
new
(
big
.
Int
)
.
Add
(
self
.
refund
[
string
(
addr
)],
amount
)
self
.
refund
[
string
(
addr
)]
.
Add
(
self
.
refund
[
string
(
addr
)],
amount
)
}
func
(
self
*
State
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
...
...
@@ -237,8 +237,8 @@ func (self *State) Set(state *State) {
self
.
logs
=
state
.
logs
}
func
(
s
*
State
)
Root
()
interface
{}
{
return
s
.
Trie
.
Root
func
(
s
*
State
)
Root
()
[]
byte
{
return
s
.
Trie
.
GetRoot
()
}
// Resets the trie and all siblings
...
...
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