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
1275e5bd
Commit
1275e5bd
authored
May 21, 2014
by
Maran
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:ethereum/eth-go into develop
parents
d658a7f4
86cf6964
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
11 deletions
+23
-11
state_manager.go
ethchain/state_manager.go
+7
-5
miner.go
ethminer/miner.go
+16
-5
peer.go
peer.go
+0
-1
No files found.
ethchain/state_manager.go
View file @
1275e5bd
...
@@ -104,7 +104,7 @@ func (sm *StateManager) ApplyTransactions(state *State, block *Block, txs []*Tra
...
@@ -104,7 +104,7 @@ func (sm *StateManager) ApplyTransactions(state *State, block *Block, txs []*Tra
}
}
}
}
func
(
sm
*
StateManager
)
ApplyTransaction
(
state
*
State
,
block
*
Block
,
tx
*
Transaction
)
{
func
(
sm
*
StateManager
)
ApplyTransaction
(
state
*
State
,
block
*
Block
,
tx
*
Transaction
)
error
{
// If there's no recipient, it's a contract
// If there's no recipient, it's a contract
// Check if this is a contract creation traction and if so
// Check if this is a contract creation traction and if so
// create a contract of this tx.
// create a contract of this tx.
...
@@ -115,10 +115,10 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
...
@@ -115,10 +115,10 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
if
contract
!=
nil
{
if
contract
!=
nil
{
sm
.
EvalScript
(
state
,
contract
.
Init
(),
contract
,
tx
,
block
)
sm
.
EvalScript
(
state
,
contract
.
Init
(),
contract
,
tx
,
block
)
}
else
{
}
else
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE] Unable to create contract"
)
return
fmt
.
Errorf
(
"[STATE] Unable to create contract"
)
}
}
}
else
{
}
else
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE] contract create:"
,
err
)
return
fmt
.
Errorf
(
"[STATE] contract create:"
,
err
)
}
}
}
else
{
}
else
{
err
:=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
,
false
)
err
:=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
,
false
)
...
@@ -126,9 +126,11 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
...
@@ -126,9 +126,11 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
if
err
==
nil
&&
contract
!=
nil
&&
len
(
contract
.
Script
())
>
0
{
if
err
==
nil
&&
contract
!=
nil
&&
len
(
contract
.
Script
())
>
0
{
sm
.
EvalScript
(
state
,
contract
.
Script
(),
contract
,
tx
,
block
)
sm
.
EvalScript
(
state
,
contract
.
Script
(),
contract
,
tx
,
block
)
}
else
if
err
!=
nil
{
}
else
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE] process:"
,
err
)
return
fmt
.
Errorf
(
"[STATE] process:"
,
err
)
}
}
}
}
return
nil
}
}
func
(
sm
*
StateManager
)
Process
(
block
*
Block
,
dontReact
bool
)
error
{
func
(
sm
*
StateManager
)
Process
(
block
*
Block
,
dontReact
bool
)
error
{
...
@@ -184,7 +186,7 @@ func (sm *StateManager) ProcessBlock(state *State, parent, block *Block, dontRea
...
@@ -184,7 +186,7 @@ func (sm *StateManager) ProcessBlock(state *State, parent, block *Block, dontRea
//if !sm.compState.Cmp(state) {
//if !sm.compState.Cmp(state) {
if
!
block
.
State
()
.
Cmp
(
state
)
{
if
!
block
.
State
()
.
Cmp
(
state
)
{
return
fmt
.
Errorf
(
"Invalid merkle root.
Expected %x, got
%x"
,
block
.
State
()
.
trie
.
Root
,
state
.
trie
.
Root
)
return
fmt
.
Errorf
(
"Invalid merkle root.
\n
rec: %x
\n
is:
%x"
,
block
.
State
()
.
trie
.
Root
,
state
.
trie
.
Root
)
}
}
// Calculate the new total difficulty and sync back to the db
// Calculate the new total difficulty and sync back to the db
...
...
ethminer/miner.go
View file @
1275e5bd
...
@@ -105,14 +105,14 @@ func (miner *Miner) listener() {
...
@@ -105,14 +105,14 @@ func (miner *Miner) listener() {
miner
.
block
.
Undo
()
miner
.
block
.
Undo
()
//log.Infoln("[MINER] We did not know about this transaction, adding")
//log.Infoln("[MINER] We did not know about this transaction, adding")
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
miner
.
block
.
SetTransactions
(
miner
.
txs
)
}
else
{
}
else
{
//log.Infoln("[MINER] We already had this transaction, ignoring")
//log.Infoln("[MINER] We already had this transaction, ignoring")
}
}
}
}
default
:
default
:
ethutil
.
Config
.
Log
.
Infoln
(
"[MINER] Mining on block. Includes"
,
len
(
miner
.
txs
),
"transactions"
)
stateManager
:=
miner
.
ethereum
.
StateManager
()
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
// Apply uncles
// Apply uncles
if
len
(
miner
.
uncles
)
>
0
{
if
len
(
miner
.
uncles
)
>
0
{
...
@@ -120,8 +120,19 @@ func (miner *Miner) listener() {
...
@@ -120,8 +120,19 @@ func (miner *Miner) listener() {
}
}
// Apply all transactions to the block
// Apply all transactions to the block
miner
.
ethereum
.
StateManager
()
.
ApplyTransactions
(
miner
.
block
.
State
(),
miner
.
block
,
miner
.
block
.
Transactions
())
txs
:=
miner
.
txs
miner
.
ethereum
.
StateManager
()
.
AccumelateRewards
(
miner
.
block
.
State
(),
miner
.
block
)
miner
.
txs
=
nil
for
_
,
tx
:=
range
txs
{
if
err
:=
stateManager
.
ApplyTransaction
(
miner
.
block
.
State
(),
miner
.
block
,
tx
);
err
==
nil
{
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
}
}
miner
.
block
.
SetTransactions
(
miner
.
txs
)
stateManager
.
AccumelateRewards
(
miner
.
block
.
State
(),
miner
.
block
)
ethutil
.
Config
.
Log
.
Infoln
(
"[MINER] Mining on block. Includes"
,
len
(
miner
.
txs
),
"transactions"
)
//miner.ethereum.StateManager().ApplyTransactions(miner.block.State(), miner.block, miner.block.Transactions())
// Search the nonce
// Search the nonce
miner
.
block
.
Nonce
=
miner
.
pow
.
Search
(
miner
.
block
,
miner
.
quitChan
)
miner
.
block
.
Nonce
=
miner
.
pow
.
Search
(
miner
.
block
,
miner
.
quitChan
)
...
...
peer.go
View file @
1275e5bd
...
@@ -381,7 +381,6 @@ func (p *Peer) HandleInbound() {
...
@@ -381,7 +381,6 @@ func (p *Peer) HandleInbound() {
}
}
case
ethwire
.
MsgTxTy
:
case
ethwire
.
MsgTxTy
:
fmt
.
Println
(
"received tx"
)
// If the message was a transaction queue the transaction
// If the message was a transaction queue the transaction
// in the TxPool where it will undergo validation and
// in the TxPool where it will undergo validation and
// processing when a new block is found
// processing when a new block is found
...
...
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