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
335dc9e6
Commit
335dc9e6
authored
Apr 09, 2014
by
Maran
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feature/mnemonic
parents
35a82f8f
6d28bf53
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
13 deletions
+31
-13
block_chain.go
ethchain/block_chain.go
+2
-0
state_manager.go
ethchain/state_manager.go
+14
-6
transaction_pool.go
ethchain/transaction_pool.go
+4
-2
vm_test.go
ethchain/vm_test.go
+10
-5
miner.go
ethminer/miner.go
+1
-0
No files found.
ethchain/block_chain.go
View file @
335dc9e6
...
...
@@ -169,6 +169,8 @@ func (bc *BlockChain) ResetTillBlockHash(hash []byte) error {
bc
.
LastBlockHash
=
bc
.
genesisBlock
.
Hash
()
bc
.
LastBlockNumber
=
1
}
else
{
// TODO: Somehow this doesn't really give the right numbers, double check.
// TODO: Change logs into debug lines
returnTo
=
bc
.
GetBlock
(
hash
)
bc
.
CurrentBlock
=
returnTo
bc
.
LastBlockHash
=
returnTo
.
Hash
()
...
...
ethchain/state_manager.go
View file @
335dc9e6
...
...
@@ -112,16 +112,21 @@ 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
{
err
=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
,
true
)
if
err
==
nil
{
sm
.
ProcessContract
(
contract
,
tx
,
block
)
}
}
else
{
err
:=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
)
err
=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
,
false
)
}
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE]"
,
err
)
}
}
}
}
}
// The prepare function, prepares the state manager for the next
...
...
@@ -283,7 +288,7 @@ func (sm *StateManager) AccumelateRewards(block *Block) error {
// Reward amount of ether to the coinbase address
addr
.
AddFee
(
CalculateBlockReward
(
block
,
len
(
block
.
Uncles
)))
var
acc
[]
byte
acc
:=
make
([]
byte
,
len
(
block
.
Coinbase
))
copy
(
acc
,
block
.
Coinbase
)
sm
.
procState
.
UpdateAccount
(
acc
,
addr
)
...
...
@@ -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 @
335dc9e6
...
...
@@ -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
,
block
*
Block
,
toContract
bool
)
(
err
error
)
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
log
.
Println
(
r
)
...
...
@@ -108,7 +108,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
}
if
sender
.
Nonce
!=
tx
.
Nonce
{
return
fmt
.
Errorf
(
"[TXPL] Invalid account nonce, state nonce is %d transact
oi
n nonce is %d instead"
,
sender
.
Nonce
,
tx
.
Nonce
)
return
fmt
.
Errorf
(
"[TXPL] Invalid account nonce, state nonce is %d transact
io
n nonce is %d instead"
,
sender
.
Nonce
,
tx
.
Nonce
)
}
// Get the receiver
...
...
@@ -119,6 +119,8 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
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
)
...
...
ethchain/vm_test.go
View file @
335dc9e6
...
...
@@ -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
)
...
...
ethminer/miner.go
View file @
335dc9e6
...
...
@@ -105,6 +105,7 @@ func (miner *Miner) listener() {
if
found
==
false
{
log
.
Println
(
"[MINER] We did not know about this transaction, adding"
)
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
miner
.
block
.
SetTransactions
(
miner
.
txs
)
}
else
{
log
.
Println
(
"[MINER] We already had this transaction, ignoring"
)
...
...
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