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
5ad473d7
Commit
5ad473d7
authored
Dec 18, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved methods to messages
parent
db494170
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
37 deletions
+14
-37
gui.go
cmd/mist/gui.go
+2
-2
state_transition.go
core/state_transition.go
+6
-4
transaction_pool.go
core/transaction_pool.go
+0
-6
transaction.go
core/types/transaction.go
+2
-21
hexface.go
xeth/hexface.go
+1
-1
js_types.go
xeth/js_types.go
+3
-3
No files found.
cmd/mist/gui.go
View file @
5ad473d7
...
...
@@ -310,7 +310,7 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
s
,
r
string
)
if
tx
.
CreatesContract
(
)
{
if
core
.
MessageCreatesContract
(
tx
)
{
rec
=
nameReg
.
Storage
(
core
.
AddressFromMessage
(
tx
))
}
...
...
@@ -322,7 +322,7 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
if
rec
.
Len
()
!=
0
{
r
=
strings
.
Trim
(
rec
.
Str
(),
"
\x00
"
)
}
else
{
if
tx
.
CreatesContract
(
)
{
if
core
.
MessageCreatesContract
(
tx
)
{
r
=
ethutil
.
Bytes2Hex
(
core
.
AddressFromMessage
(
tx
))
}
else
{
r
=
ethutil
.
Bytes2Hex
(
tx
.
To
())
...
...
core/state_transition.go
View file @
5ad473d7
...
...
@@ -44,8 +44,6 @@ type StateTransition struct {
type
Message
interface
{
Hash
()
[]
byte
CreatesContract
()
bool
From
()
[]
byte
To
()
[]
byte
...
...
@@ -63,6 +61,10 @@ func AddressFromMessage(msg Message) []byte {
return
crypto
.
Sha3
(
ethutil
.
NewValue
([]
interface
{}{
msg
.
From
(),
msg
.
Nonce
()})
.
Encode
())[
12
:
]
}
func
MessageCreatesContract
(
msg
Message
)
bool
{
return
len
(
msg
.
To
())
==
0
}
func
NewStateTransition
(
coinbase
*
state
.
StateObject
,
msg
Message
,
state
*
state
.
StateDB
,
block
*
types
.
Block
)
*
StateTransition
{
return
&
StateTransition
{
coinbase
.
Address
(),
msg
.
To
(),
msg
,
new
(
big
.
Int
),
new
(
big
.
Int
)
.
Set
(
msg
.
GasPrice
()),
msg
.
Value
(),
msg
.
Data
(),
state
,
block
,
coinbase
,
nil
,
nil
,
nil
}
}
...
...
@@ -93,7 +95,7 @@ func (self *StateTransition) From() *state.StateObject {
return
self
.
sen
}
func
(
self
*
StateTransition
)
To
()
*
state
.
StateObject
{
if
self
.
msg
!=
nil
&&
self
.
msg
.
CreatesContract
(
)
{
if
self
.
msg
!=
nil
&&
MessageCreatesContract
(
self
.
msg
)
{
return
nil
}
...
...
@@ -205,7 +207,7 @@ func (self *StateTransition) TransitionState() (err error) {
var
ret
[]
byte
vmenv
:=
self
.
VmEnv
()
var
ref
vm
.
ClosureRef
if
msg
.
CreatesContract
(
)
{
if
MessageCreatesContract
(
msg
)
{
self
.
rec
=
MakeContract
(
msg
,
self
.
state
)
ret
,
err
,
ref
=
vmenv
.
Create
(
sender
,
self
.
rec
.
Address
(),
self
.
msg
.
Data
(),
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
...
...
core/transaction_pool.go
View file @
5ad473d7
...
...
@@ -131,12 +131,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
return
fmt
.
Errorf
(
"Insufficient amount in sender's (%x) account"
,
tx
.
From
())
}
if
tx
.
IsContract
()
{
if
tx
.
GasPrice
()
.
Cmp
(
big
.
NewInt
(
minGasPrice
))
<
0
{
return
fmt
.
Errorf
(
"Gasprice too low, %s given should be at least %d."
,
tx
.
GasPrice
,
minGasPrice
)
}
}
// Increment the nonce making each tx valid only once to prevent replay
// attacks
...
...
core/types/transaction.go
View file @
5ad473d7
...
...
@@ -9,11 +9,8 @@ import (
"github.com/obscuren/secp256k1-go"
)
var
ContractAddr
=
[]
byte
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
func
IsContractAddr
(
addr
[]
byte
)
bool
{
return
len
(
addr
)
==
0
//return bytes.Compare(addr, ContractAddr) == 0
}
type
Transaction
struct
{
...
...
@@ -25,17 +22,14 @@ type Transaction struct {
data
[]
byte
v
byte
r
,
s
[]
byte
// Indicates whether this tx is a contract creation transaction
contractCreation
bool
}
func
NewContractCreationTx
(
value
,
gas
,
gasPrice
*
big
.
Int
,
script
[]
byte
)
*
Transaction
{
return
&
Transaction
{
recipient
:
nil
,
value
:
value
,
gas
:
gas
,
gasPrice
:
gasPrice
,
data
:
script
,
contractCreation
:
true
}
return
&
Transaction
{
recipient
:
nil
,
value
:
value
,
gas
:
gas
,
gasPrice
:
gasPrice
,
data
:
script
}
}
func
NewTransactionMessage
(
to
[]
byte
,
value
,
gas
,
gasPrice
*
big
.
Int
,
data
[]
byte
)
*
Transaction
{
return
&
Transaction
{
recipient
:
to
,
value
:
value
,
gasPrice
:
gasPrice
,
gas
:
gas
,
data
:
data
,
contractCreation
:
IsContractAddr
(
to
)
}
return
&
Transaction
{
recipient
:
to
,
value
:
value
,
gasPrice
:
gasPrice
,
gas
:
gas
,
data
:
data
}
}
func
NewTransactionFromBytes
(
data
[]
byte
)
*
Transaction
{
...
...
@@ -99,15 +93,6 @@ func (self *Transaction) To() []byte {
return
self
.
recipient
}
func
(
tx
*
Transaction
)
CreatesContract
()
bool
{
return
tx
.
contractCreation
}
/* Deprecated */
func
(
tx
*
Transaction
)
IsContract
()
bool
{
return
tx
.
CreatesContract
()
}
func
(
tx
*
Transaction
)
Curve
()
(
v
byte
,
r
[]
byte
,
s
[]
byte
)
{
v
=
tx
.
v
r
=
ethutil
.
LeftPadBytes
(
tx
.
r
,
32
)
...
...
@@ -192,10 +177,6 @@ func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
tx
.
r
=
decoder
.
Get
(
7
)
.
Bytes
()
tx
.
s
=
decoder
.
Get
(
8
)
.
Bytes
()
if
IsContractAddr
(
tx
.
recipient
)
{
tx
.
contractCreation
=
true
}
}
func
(
tx
*
Transaction
)
String
()
string
{
...
...
xeth/hexface.go
View file @
5ad473d7
...
...
@@ -229,7 +229,7 @@ func (self *JSXEth) PushTx(txStr string) (*JSReceipt, error) {
return
nil
,
err
}
return
NewJSReciept
(
tx
.
CreatesContract
(
),
core
.
AddressFromMessage
(
tx
),
tx
.
Hash
(),
tx
.
From
()),
nil
return
NewJSReciept
(
core
.
MessageCreatesContract
(
tx
),
core
.
AddressFromMessage
(
tx
),
tx
.
Hash
(),
tx
.
From
()),
nil
}
func
(
self
*
JSXEth
)
CompileMutan
(
code
string
)
string
{
...
...
xeth/js_types.go
View file @
5ad473d7
...
...
@@ -102,16 +102,16 @@ func NewJSTx(tx *types.Transaction, state *state.StateDB) *JSTransaction {
receiver
=
ethutil
.
Bytes2Hex
(
core
.
AddressFromMessage
(
tx
))
}
sender
:=
ethutil
.
Bytes2Hex
(
tx
.
Sender
())
createsContract
:=
tx
.
CreatesContract
(
)
createsContract
:=
core
.
MessageCreatesContract
(
tx
)
var
data
string
if
tx
.
CreatesContract
()
{
if
createsContract
{
data
=
strings
.
Join
(
core
.
Disassemble
(
tx
.
Data
()),
"
\n
"
)
}
else
{
data
=
ethutil
.
Bytes2Hex
(
tx
.
Data
())
}
return
&
JSTransaction
{
ref
:
tx
,
Hash
:
hash
,
Value
:
ethutil
.
CurrencyToString
(
tx
.
Value
()),
Address
:
receiver
,
Contract
:
tx
.
CreatesContract
()
,
Gas
:
tx
.
Gas
()
.
String
(),
GasPrice
:
tx
.
GasPrice
()
.
String
(),
Data
:
data
,
Sender
:
sender
,
CreatesContract
:
createsContract
,
RawData
:
ethutil
.
Bytes2Hex
(
tx
.
Data
())}
return
&
JSTransaction
{
ref
:
tx
,
Hash
:
hash
,
Value
:
ethutil
.
CurrencyToString
(
tx
.
Value
()),
Address
:
receiver
,
Contract
:
createsContract
,
Gas
:
tx
.
Gas
()
.
String
(),
GasPrice
:
tx
.
GasPrice
()
.
String
(),
Data
:
data
,
Sender
:
sender
,
CreatesContract
:
createsContract
,
RawData
:
ethutil
.
Bytes2Hex
(
tx
.
Data
())}
}
func
(
self
*
JSTransaction
)
ToString
()
string
{
...
...
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