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
17c5ba2b
Commit
17c5ba2b
authored
Mar 17, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: actually convert transaction pool
parent
ee7202fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
17 deletions
+19
-17
state_transition.go
core/state_transition.go
+9
-10
transaction_pool.go
core/transaction_pool.go
+9
-6
vm_env.go
core/vm_env.go
+1
-1
No files found.
core/state_transition.go
View file @
17c5ba2b
...
...
@@ -5,7 +5,6 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
)
...
...
@@ -57,13 +56,8 @@ type Message interface {
Data
()
[]
byte
}
func
AddressFromMessage
(
msg
Message
)
[]
byte
{
// Generate a new address
return
crypto
.
Sha3
(
common
.
NewValue
([]
interface
{}{
msg
.
From
(),
msg
.
Nonce
()})
.
Encode
())[
12
:
]
}
func
MessageCreatesContract
(
msg
Message
)
bool
{
return
len
(
msg
.
To
())
==
0
return
msg
.
To
()
==
nil
}
func
MessageGasValue
(
msg
Message
)
*
big
.
Int
{
...
...
@@ -93,13 +87,18 @@ func (self *StateTransition) Coinbase() *state.StateObject {
return
self
.
state
.
GetOrNewStateObject
(
self
.
coinbase
)
}
func
(
self
*
StateTransition
)
From
()
*
state
.
StateObject
{
return
self
.
state
.
GetOrNewStateObject
(
self
.
msg
.
From
())
f
,
_
:=
self
.
msg
.
From
()
return
self
.
state
.
GetOrNewStateObject
(
f
)
}
func
(
self
*
StateTransition
)
To
()
*
state
.
StateObject
{
if
self
.
msg
!=
nil
&&
MessageCreatesContract
(
self
.
msg
)
{
if
self
.
msg
==
nil
{
return
nil
}
return
self
.
state
.
GetOrNewStateObject
(
self
.
msg
.
To
())
to
:=
self
.
msg
.
To
()
if
to
==
nil
{
return
nil
// contract creation
}
return
self
.
state
.
GetOrNewStateObject
(
*
to
)
}
func
(
self
*
StateTransition
)
UseGas
(
amount
*
big
.
Int
)
error
{
...
...
core/transaction_pool.go
View file @
17c5ba2b
...
...
@@ -91,8 +91,9 @@ func (self *TxPool) addTx(tx *types.Transaction) {
}
func
(
self
*
TxPool
)
add
(
tx
*
types
.
Transaction
)
error
{
if
self
.
txs
[
tx
.
Hash
()]
!=
nil
{
return
fmt
.
Errorf
(
"Known transaction (%x)"
,
tx
.
Hash
()[
0
:
4
])
hash
:=
tx
.
Hash
()
if
self
.
txs
[
hash
]
!=
nil
{
return
fmt
.
Errorf
(
"Known transaction (%x)"
,
hash
[
0
:
4
])
}
err
:=
self
.
ValidateTransaction
(
tx
)
if
err
!=
nil
{
...
...
@@ -102,7 +103,7 @@ func (self *TxPool) add(tx *types.Transaction) error {
self
.
addTx
(
tx
)
var
toname
string
if
to
,
valid
:=
tx
.
To
();
valid
{
if
to
:=
tx
.
To
();
to
!=
nil
{
toname
=
common
.
Bytes2Hex
(
to
[
:
4
])
}
else
{
toname
=
"[NEW_CONTRACT]"
...
...
@@ -111,7 +112,7 @@ func (self *TxPool) add(tx *types.Transaction) error {
// verified in ValidateTransaction.
f
,
_
:=
tx
.
From
()
from
:=
common
.
Bytes2Hex
(
f
[
:
4
])
txplogger
.
Debugf
(
"(t) %x => %s (%v) %x
\n
"
,
from
,
to
,
tx
.
Value
,
tx
.
Hash
())
txplogger
.
Debugf
(
"(t) %x => %s (%v) %x
\n
"
,
from
,
to
name
,
tx
.
Value
,
tx
.
Hash
())
// Notify the subscribers
go
self
.
eventMux
.
Post
(
TxPreEvent
{
tx
})
...
...
@@ -137,7 +138,8 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) {
if
err
:=
self
.
add
(
tx
);
err
!=
nil
{
txplogger
.
Debugln
(
err
)
}
else
{
txplogger
.
Debugf
(
"tx %x
\n
"
,
tx
.
Hash
()[
0
:
4
])
h
:=
tx
.
Hash
()
txplogger
.
Debugf
(
"tx %x
\n
"
,
h
[
:
4
])
}
}
}
...
...
@@ -161,7 +163,8 @@ func (pool *TxPool) RemoveInvalid(query StateQuery) {
var
removedTxs
types
.
Transactions
for
_
,
tx
:=
range
pool
.
txs
{
sender
:=
query
.
GetAccount
(
tx
.
From
())
from
,
_
:=
tx
.
From
()
sender
:=
query
.
GetAccount
(
from
[
:
])
err
:=
pool
.
ValidateTransaction
(
tx
)
if
err
!=
nil
||
sender
.
Nonce
()
>=
tx
.
Nonce
()
{
removedTxs
=
append
(
removedTxs
,
tx
)
...
...
core/vm_env.go
View file @
17c5ba2b
...
...
@@ -28,7 +28,7 @@ func NewEnv(state *state.StateDB, chain *ChainManager, msg Message, block *types
}
}
func
(
self
*
VMEnv
)
Origin
()
common
.
Address
{
return
self
.
msg
.
From
()
}
func
(
self
*
VMEnv
)
Origin
()
common
.
Address
{
f
,
_
:=
self
.
msg
.
From
();
return
f
}
func
(
self
*
VMEnv
)
BlockNumber
()
*
big
.
Int
{
return
self
.
block
.
Number
()
}
func
(
self
*
VMEnv
)
Coinbase
()
common
.
Address
{
return
self
.
block
.
Coinbase
()
}
func
(
self
*
VMEnv
)
Time
()
int64
{
return
self
.
block
.
Time
()
}
...
...
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