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
82be3054
Commit
82be3054
authored
Oct 02, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed inconsistencies
parent
a34a971b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
25 deletions
+37
-25
state_manager.go
ethchain/state_manager.go
+10
-7
state_transition.go
ethchain/state_transition.go
+2
-2
transaction.go
ethchain/transaction.go
+9
-2
js_pipe.go
ethpipe/js_pipe.go
+3
-3
js_types.go
ethpipe/js_types.go
+4
-4
pipe.go
ethpipe/pipe.go
+6
-4
vm.go
ethvm/vm.go
+3
-3
No files found.
ethchain/state_manager.go
View file @
82be3054
...
@@ -104,18 +104,21 @@ func (self *StateManager) Stop() {
...
@@ -104,18 +104,21 @@ func (self *StateManager) Stop() {
}
}
func
(
self
*
StateManager
)
updateThread
()
{
func
(
self
*
StateManager
)
updateThread
()
{
blockChan
:=
self
.
eth
.
Eventer
()
.
Register
(
"block"
)
blockChan
:=
self
.
eth
.
Eventer
()
.
Register
(
"block
s
"
)
out
:
out
:
for
{
for
{
select
{
select
{
case
event
:=
<-
blockChan
:
case
event
:=
<-
blockChan
:
block
:=
event
.
Data
.
(
*
Block
)
blocks
:=
event
.
Data
.
(
Blocks
)
err
:=
self
.
Process
(
block
,
false
)
for
_
,
block
:=
range
blocks
{
if
err
!=
nil
{
err
:=
self
.
Process
(
block
,
false
)
statelogger
.
Infoln
(
err
)
if
err
!=
nil
{
statelogger
.
Debugf
(
"Block #%v failed (%x...)
\n
"
,
block
.
Number
,
block
.
Hash
()[
0
:
4
])
statelogger
.
Infoln
(
err
)
statelogger
.
Debugln
(
block
)
statelogger
.
Debugf
(
"Block #%v failed (%x...)
\n
"
,
block
.
Number
,
block
.
Hash
()[
0
:
4
])
statelogger
.
Debugln
(
block
)
break
}
}
}
case
<-
self
.
quit
:
case
<-
self
.
quit
:
...
...
ethchain/state_transition.go
View file @
82be3054
...
@@ -292,9 +292,9 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context
...
@@ -292,9 +292,9 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context
func
MakeContract
(
tx
*
Transaction
,
state
*
ethstate
.
State
)
*
ethstate
.
StateObject
{
func
MakeContract
(
tx
*
Transaction
,
state
*
ethstate
.
State
)
*
ethstate
.
StateObject
{
// Create contract if there's no recipient
// Create contract if there's no recipient
if
tx
.
IsContract
()
{
if
tx
.
IsContract
()
{
addr
:=
tx
.
CreationAddress
()
addr
:=
tx
.
CreationAddress
(
state
)
contract
:=
state
.
NewStateObject
(
addr
)
contract
:=
state
.
GetOr
NewStateObject
(
addr
)
contract
.
InitCode
=
tx
.
Data
contract
.
InitCode
=
tx
.
Data
contract
.
State
=
ethstate
.
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
""
))
contract
.
State
=
ethstate
.
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
""
))
...
...
ethchain/transaction.go
View file @
82be3054
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"math/big"
"math/big"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/secp256k1-go"
"github.com/obscuren/secp256k1-go"
)
)
...
@@ -77,8 +78,14 @@ func (tx *Transaction) IsContract() bool {
...
@@ -77,8 +78,14 @@ func (tx *Transaction) IsContract() bool {
return
tx
.
CreatesContract
()
return
tx
.
CreatesContract
()
}
}
func
(
tx
*
Transaction
)
CreationAddress
()
[]
byte
{
func
(
tx
*
Transaction
)
CreationAddress
(
state
*
ethstate
.
State
)
[]
byte
{
return
ethcrypto
.
Sha3Bin
(
ethutil
.
NewValue
([]
interface
{}{
tx
.
Sender
(),
tx
.
Nonce
})
.
Encode
())[
12
:
]
// Generate a new address
addr
:=
ethcrypto
.
Sha3Bin
(
ethutil
.
NewValue
([]
interface
{}{
tx
.
Sender
(),
tx
.
Nonce
})
.
Encode
())[
12
:
]
//for i := uint64(0); state.GetStateObject(addr) != nil; i++ {
// addr = ethcrypto.Sha3Bin(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce + i}).Encode())[12:]
//}
return
addr
}
}
func
(
tx
*
Transaction
)
Signature
(
key
[]
byte
)
[]
byte
{
func
(
tx
*
Transaction
)
Signature
(
key
[]
byte
)
[]
byte
{
...
...
ethpipe/js_pipe.go
View file @
82be3054
...
@@ -233,16 +233,16 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
...
@@ -233,16 +233,16 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
if
contractCreation
{
if
contractCreation
{
logger
.
Infof
(
"Contract addr %x"
,
tx
.
CreationAddress
())
logger
.
Infof
(
"Contract addr %x"
,
tx
.
CreationAddress
(
self
.
World
()
.
State
()
))
}
}
return
NewJSReciept
(
contractCreation
,
tx
.
CreationAddress
(),
tx
.
Hash
(),
keyPair
.
Address
()),
nil
return
NewJSReciept
(
contractCreation
,
tx
.
CreationAddress
(
self
.
World
()
.
State
()
),
tx
.
Hash
(),
keyPair
.
Address
()),
nil
}
}
func
(
self
*
JSPipe
)
PushTx
(
txStr
string
)
(
*
JSReceipt
,
error
)
{
func
(
self
*
JSPipe
)
PushTx
(
txStr
string
)
(
*
JSReceipt
,
error
)
{
tx
:=
ethchain
.
NewTransactionFromBytes
(
ethutil
.
Hex2Bytes
(
txStr
))
tx
:=
ethchain
.
NewTransactionFromBytes
(
ethutil
.
Hex2Bytes
(
txStr
))
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
return
NewJSReciept
(
tx
.
CreatesContract
(),
tx
.
CreationAddress
(),
tx
.
Hash
(),
tx
.
Sender
()),
nil
return
NewJSReciept
(
tx
.
CreatesContract
(),
tx
.
CreationAddress
(
self
.
World
()
.
State
()
),
tx
.
Hash
(),
tx
.
Sender
()),
nil
}
}
func
(
self
*
JSPipe
)
CompileMutan
(
code
string
)
string
{
func
(
self
*
JSPipe
)
CompileMutan
(
code
string
)
string
{
...
...
ethpipe/js_types.go
View file @
82be3054
...
@@ -35,7 +35,7 @@ func NewJSBlock(block *ethchain.Block) *JSBlock {
...
@@ -35,7 +35,7 @@ func NewJSBlock(block *ethchain.Block) *JSBlock {
var
ptxs
[]
JSTransaction
var
ptxs
[]
JSTransaction
for
_
,
tx
:=
range
block
.
Transactions
()
{
for
_
,
tx
:=
range
block
.
Transactions
()
{
ptxs
=
append
(
ptxs
,
*
NewJSTx
(
tx
))
ptxs
=
append
(
ptxs
,
*
NewJSTx
(
tx
,
block
.
State
()
))
}
}
list
:=
ethutil
.
NewList
(
ptxs
)
list
:=
ethutil
.
NewList
(
ptxs
)
...
@@ -64,7 +64,7 @@ func (self *JSBlock) GetTransaction(hash string) *JSTransaction {
...
@@ -64,7 +64,7 @@ func (self *JSBlock) GetTransaction(hash string) *JSTransaction {
return
nil
return
nil
}
}
return
NewJSTx
(
tx
)
return
NewJSTx
(
tx
,
self
.
ref
.
State
()
)
}
}
type
JSTransaction
struct
{
type
JSTransaction
struct
{
...
@@ -83,11 +83,11 @@ type JSTransaction struct {
...
@@ -83,11 +83,11 @@ type JSTransaction struct {
Confirmations
int
`json:"confirmations"`
Confirmations
int
`json:"confirmations"`
}
}
func
NewJSTx
(
tx
*
ethchain
.
Transaction
)
*
JSTransaction
{
func
NewJSTx
(
tx
*
ethchain
.
Transaction
,
state
*
ethstate
.
State
)
*
JSTransaction
{
hash
:=
ethutil
.
Bytes2Hex
(
tx
.
Hash
())
hash
:=
ethutil
.
Bytes2Hex
(
tx
.
Hash
())
receiver
:=
ethutil
.
Bytes2Hex
(
tx
.
Recipient
)
receiver
:=
ethutil
.
Bytes2Hex
(
tx
.
Recipient
)
if
receiver
==
"0000000000000000000000000000000000000000"
{
if
receiver
==
"0000000000000000000000000000000000000000"
{
receiver
=
ethutil
.
Bytes2Hex
(
tx
.
CreationAddress
())
receiver
=
ethutil
.
Bytes2Hex
(
tx
.
CreationAddress
(
state
))
}
}
sender
:=
ethutil
.
Bytes2Hex
(
tx
.
Sender
())
sender
:=
ethutil
.
Bytes2Hex
(
tx
.
Sender
())
createsContract
:=
tx
.
CreatesContract
()
createsContract
:=
tx
.
CreatesContract
()
...
...
ethpipe/pipe.go
View file @
82be3054
...
@@ -143,9 +143,10 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
...
@@ -143,9 +143,10 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
if
contractCreation
{
if
contractCreation
{
logger
.
Infof
(
"Contract addr %x"
,
tx
.
CreationAddress
())
addr
:=
tx
.
CreationAddress
(
self
.
World
()
.
State
())
logger
.
Infof
(
"Contract addr %x
\n
"
,
addr
)
return
tx
.
CreationAddress
()
,
nil
return
addr
,
nil
}
}
return
tx
.
Hash
(),
nil
return
tx
.
Hash
(),
nil
...
@@ -154,8 +155,9 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
...
@@ -154,8 +155,9 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
func
(
self
*
Pipe
)
PushTx
(
tx
*
ethchain
.
Transaction
)
([]
byte
,
error
)
{
func
(
self
*
Pipe
)
PushTx
(
tx
*
ethchain
.
Transaction
)
([]
byte
,
error
)
{
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
if
tx
.
Recipient
==
nil
{
if
tx
.
Recipient
==
nil
{
logger
.
Infof
(
"Contract addr %x"
,
tx
.
CreationAddress
())
addr
:=
tx
.
CreationAddress
(
self
.
World
()
.
State
())
return
tx
.
CreationAddress
(),
nil
logger
.
Infof
(
"Contract addr %x
\n
"
,
addr
)
return
addr
,
nil
}
}
return
tx
.
Hash
(),
nil
return
tx
.
Hash
(),
nil
}
}
...
...
ethvm/vm.go
View file @
82be3054
...
@@ -763,9 +763,9 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
...
@@ -763,9 +763,9 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
// Generate a new address
// Generate a new address
addr
:=
ethcrypto
.
CreateAddress
(
closure
.
Address
(),
closure
.
object
.
Nonce
)
addr
:=
ethcrypto
.
CreateAddress
(
closure
.
Address
(),
closure
.
object
.
Nonce
)
for
i
:=
uint64
(
0
);
self
.
env
.
State
()
.
GetStateObject
(
addr
)
!=
nil
;
i
++
{
//
for i := uint64(0); self.env.State().GetStateObject(addr) != nil; i++ {
ethcrypto
.
CreateAddress
(
closure
.
Address
(),
closure
.
object
.
Nonce
+
i
)
//
ethcrypto.CreateAddress(closure.Address(), closure.object.Nonce+i)
}
//
}
closure
.
object
.
Nonce
++
closure
.
object
.
Nonce
++
self
.
Printf
(
" (*) %x"
,
addr
)
.
Endl
()
self
.
Printf
(
" (*) %x"
,
addr
)
.
Endl
()
...
...
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