good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
8f91d47b
Commit
8f91d47b
authored
10 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into develop
parents
93261b98
5d2669db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ethchain/block.go
+28
-5
28 additions, 5 deletions
ethchain/block.go
ethchain/state_manager.go
+6
-11
6 additions, 11 deletions
ethchain/state_manager.go
ethminer/miner.go
+1
-0
1 addition, 0 deletions
ethminer/miner.go
with
35 additions
and
16 deletions
ethchain/block.go
+
28
−
5
View file @
8f91d47b
...
...
@@ -7,7 +7,7 @@ import (
"github.com/ethereum/eth-go/ethtrie"
"github.com/ethereum/eth-go/ethutil"
"math/big"
"strconv"
_
"strconv"
"time"
)
...
...
@@ -252,20 +252,43 @@ func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) {
func
(
block
*
Block
)
setTransactions
(
txs
[]
*
Transaction
)
{
block
.
transactions
=
txs
/*
trie := ethtrie.NewTrie(ethutil.Config.Db, "")
for i, tx := range txs {
trie.Update(strconv.Itoa(i), string(tx.RlpEncode()))
}
switch trie.Root.(type) {
case string:
block.TxSha = []byte(trie.Root.(string))
case []byte:
block.TxSha = trie.Root.([]byte)
default:
panic(fmt.Sprintf("invalid root type %T", trie.Root))
}
*/
}
func
CreateTxSha
(
receipts
Receipts
)
(
sha
[]
byte
)
{
trie
:=
ethtrie
.
NewTrie
(
ethutil
.
Config
.
Db
,
""
)
for
i
,
t
x
:=
range
t
x
s
{
trie
.
Update
(
str
conv
.
Itoa
(
i
),
string
(
tx
.
Rlp
Encode
()))
for
i
,
receip
t
:=
range
receip
ts
{
trie
.
Update
(
str
ing
(
ethutil
.
NewValue
(
i
)
.
Encode
()),
string
(
ethutil
.
NewValue
(
receipt
.
RlpData
())
.
Encode
()))
}
switch
trie
.
Root
.
(
type
)
{
case
string
:
block
.
TxS
ha
=
[]
byte
(
trie
.
Root
.
(
string
))
s
ha
=
[]
byte
(
trie
.
Root
.
(
string
))
case
[]
byte
:
block
.
TxS
ha
=
trie
.
Root
.
([]
byte
)
s
ha
=
trie
.
Root
.
([]
byte
)
default
:
panic
(
fmt
.
Sprintf
(
"invalid root type %T"
,
trie
.
Root
))
}
return
sha
}
func
(
self
*
Block
)
SetTxHash
(
receipts
Receipts
)
{
self
.
TxSha
=
CreateTxSha
(
receipts
)
}
func
(
block
*
Block
)
Value
()
*
ethutil
.
Value
{
...
...
This diff is collapsed.
Click to expand it.
ethchain/state_manager.go
+
6
−
11
View file @
8f91d47b
...
...
@@ -201,11 +201,16 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
fmt
.
Printf
(
"## %x %x ##
\n
"
,
block
.
Hash
(),
block
.
Number
)
}
_
,
err
=
sm
.
ApplyDiff
(
state
,
parent
,
block
)
receipts
,
err
:
=
sm
.
ApplyDiff
(
state
,
parent
,
block
)
if
err
!=
nil
{
return
err
}
txSha
:=
CreateTxSha
(
receipts
)
if
bytes
.
Compare
(
txSha
,
block
.
TxSha
)
!=
0
{
return
fmt
.
Errorf
(
"Error validating tx sha. Received %x, got %x"
,
block
.
TxSha
,
txSha
)
}
// Block validation
if
err
=
sm
.
ValidateBlock
(
block
);
err
!=
nil
{
statelogger
.
Errorln
(
"Error validating block:"
,
err
)
...
...
@@ -219,17 +224,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
return
err
}
/*
if ethutil.Config.Paranoia {
valid, _ := ethtrie.ParanoiaCheck(state.trie)
if !valid {
err = fmt.Errorf("PARANOIA: World state trie corruption")
}
}
*/
if
!
block
.
State
()
.
Cmp
(
state
)
{
err
=
fmt
.
Errorf
(
"Invalid merkle root.
\n
rec: %x
\n
is: %x"
,
block
.
State
()
.
trie
.
Root
,
state
.
trie
.
Root
)
return
}
...
...
This diff is collapsed.
Click to expand it.
ethminer/miner.go
+
1
−
0
View file @
8f91d47b
...
...
@@ -165,6 +165,7 @@ func (self *Miner) mineNewBlock() {
logger
.
Debugln
(
err
)
}
self
.
txs
=
append
(
txs
,
unhandledTxs
...
)
self
.
block
.
SetTxHash
(
receipts
)
// Set the transactions to the block so the new SHA3 can be calculated
self
.
block
.
SetReceipts
(
receipts
,
txs
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment