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
12643c7c
Commit
12643c7c
authored
Apr 05, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into miner
parents
782910ea
90bb512f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
15 deletions
+30
-15
state_manager.go
ethchain/state_manager.go
+13
-5
transaction_pool.go
ethchain/transaction_pool.go
+7
-5
vm_test.go
ethchain/vm_test.go
+10
-5
No files found.
ethchain/state_manager.go
View file @
12643c7c
...
...
@@ -112,13 +112,18 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
// Figure out if the address this transaction was sent to is a
// contract or an actual account. In case of a contract, we process that
// contract instead of moving funds between accounts.
var
err
error
if
contract
:=
sm
.
procState
.
GetContract
(
tx
.
Recipient
);
contract
!=
nil
{
sm
.
ProcessContract
(
contract
,
tx
,
block
)
}
else
{
err
:=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
)
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE]"
,
err
)
err
=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
sm
.
procState
,
true
)
if
err
==
nil
{
sm
.
ProcessContract
(
contract
,
tx
,
block
)
}
}
else
{
err
=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
sm
.
procState
,
false
)
}
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE]"
,
err
)
}
}
}
...
...
@@ -323,4 +328,7 @@ func (sm *StateManager) ProcessContract(contract *Contract, tx *Transaction, blo
txData
:
nil
,
})
closure
.
Call
(
vm
,
nil
)
// Update the account (refunds)
sm
.
procState
.
UpdateAccount
(
tx
.
Sender
(),
caller
)
}
ethchain/transaction_pool.go
View file @
12643c7c
...
...
@@ -90,7 +90,7 @@ func (pool *TxPool) addTransaction(tx *Transaction) {
// Process transaction validates the Tx and processes funds from the
// sender to the recipient.
func
(
pool
*
TxPool
)
ProcessTransaction
(
tx
*
Transaction
,
block
*
Block
)
(
err
error
)
{
func
(
pool
*
TxPool
)
ProcessTransaction
(
tx
*
Transaction
,
state
*
State
,
toContract
bool
)
(
err
error
)
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
log
.
Println
(
r
)
...
...
@@ -98,7 +98,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
}
}()
// Get the sender
sender
:=
block
.
state
.
GetAccount
(
tx
.
Sender
())
sender
:=
state
.
GetAccount
(
tx
.
Sender
())
// Make sure there's enough in the sender's account. Having insufficient
// funds won't invalidate this transaction but simple ignores it.
...
...
@@ -112,13 +112,15 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
}
// Get the receiver
receiver
:=
block
.
state
.
GetAccount
(
tx
.
Recipient
)
receiver
:=
state
.
GetAccount
(
tx
.
Recipient
)
sender
.
Nonce
+=
1
// Send Tx to self
if
bytes
.
Compare
(
tx
.
Recipient
,
tx
.
Sender
())
==
0
{
// Subtract the fee
sender
.
Amount
.
Sub
(
sender
.
Amount
,
new
(
big
.
Int
)
.
Mul
(
TxFee
,
TxFeeRat
))
}
else
if
toContract
{
sender
.
Amount
.
Sub
(
sender
.
Amount
,
new
(
big
.
Int
)
.
Mul
(
TxFee
,
TxFeeRat
))
}
else
{
// Subtract the amount from the senders account
sender
.
Amount
.
Sub
(
sender
.
Amount
,
totAmount
)
...
...
@@ -126,10 +128,10 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
// Add the amount to receivers account which should conclude this transaction
receiver
.
Amount
.
Add
(
receiver
.
Amount
,
tx
.
Value
)
block
.
state
.
UpdateAccount
(
tx
.
Recipient
,
receiver
)
state
.
UpdateAccount
(
tx
.
Recipient
,
receiver
)
}
block
.
state
.
UpdateAccount
(
tx
.
Sender
(),
sender
)
state
.
UpdateAccount
(
tx
.
Sender
(),
sender
)
log
.
Printf
(
"[TXPL] Processed Tx %x
\n
"
,
tx
.
Hash
())
...
...
ethchain/vm_test.go
View file @
12643c7c
...
...
@@ -83,18 +83,23 @@ func TestRun4(t *testing.T) {
state
:=
NewState
(
ethutil
.
NewTrie
(
db
,
""
))
asm
,
err
:=
mutan
.
Compile
(
strings
.
NewReader
(
`
a = 10
b = 10
int32
a = 10
int32
b = 10
if a == b {
c = 10
int32
c = 10
if c == 10 {
d = 1000
e = 10
int32
d = 1000
int32
e = 10
}
}
store[0] = 20
store[a] = 20
store[b] = this.caller()
int8[10] ret
int8[10] arg
call(1234, 0, 100000000, arg, ret)
`
),
false
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
...
...
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