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
b0ae61c6
Commit
b0ae61c6
authored
Aug 18, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the "Get" part
parent
793e666f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
21 deletions
+83
-21
state_transition.go
ethchain/state_transition.go
+1
-0
js_pipe.go
ethpipe/js_pipe.go
+38
-11
js_types.go
ethpipe/js_types.go
+31
-0
packages.go
ethrpc/packages.go
+9
-9
manifest.go
ethstate/manifest.go
+2
-1
vm.go
ethvm/vm.go
+2
-0
No files found.
ethchain/state_transition.go
View file @
b0ae61c6
...
...
@@ -216,6 +216,7 @@ func (self *StateTransition) TransitionState() (err error) {
Input
:
self
.
tx
.
Data
,
Origin
:
sender
.
Address
(),
Block
:
self
.
block
.
Hash
(),
Timestamp
:
self
.
block
.
Time
,
Coinbase
:
self
.
block
.
Coinbase
,
Number
:
self
.
block
.
Number
,
Value
:
self
.
value
,
})
// Process the init code and create 'valid' contract
...
...
ethpipe/js_pipe.go
View file @
b0ae61c6
...
...
@@ -17,28 +17,28 @@ func NewJSPipe(eth ethchain.EthManager) *JSPipe {
return
&
JSPipe
{
New
(
eth
)}
}
func
(
self
*
JSPipe
)
Get
BlockByHash
(
strHash
string
)
*
JSBlock
{
func
(
self
*
JSPipe
)
BlockByHash
(
strHash
string
)
*
JSBlock
{
hash
:=
ethutil
.
Hex2Bytes
(
strHash
)
block
:=
self
.
obj
.
BlockChain
()
.
GetBlock
(
hash
)
return
NewJSBlock
(
block
)
}
func
(
self
*
JSPipe
)
Get
Key
()
*
JSKey
{
func
(
self
*
JSPipe
)
Key
()
*
JSKey
{
return
NewJSKey
(
self
.
obj
.
KeyManager
()
.
KeyPair
())
}
func
(
self
*
JSPipe
)
Get
StateObject
(
addr
string
)
*
JSObject
{
func
(
self
*
JSPipe
)
StateObject
(
addr
string
)
*
JSObject
{
object
:=
&
Object
{
self
.
World
()
.
safeGet
(
ethutil
.
Hex2Bytes
(
addr
))}
return
NewJSObject
(
object
)
}
func
(
self
*
JSPipe
)
Get
PeerCount
()
int
{
func
(
self
*
JSPipe
)
PeerCount
()
int
{
return
self
.
obj
.
PeerCount
()
}
func
(
self
*
JSPipe
)
Get
Peers
()
[]
JSPeer
{
func
(
self
*
JSPipe
)
Peers
()
[]
JSPeer
{
var
peers
[]
JSPeer
for
peer
:=
self
.
obj
.
Peers
()
.
Front
();
peer
!=
nil
;
peer
=
peer
.
Next
()
{
p
:=
peer
.
Value
.
(
ethchain
.
Peer
)
...
...
@@ -51,23 +51,33 @@ func (self *JSPipe) GetPeers() []JSPeer {
return
peers
}
func
(
self
*
JSPipe
)
Get
IsMining
()
bool
{
func
(
self
*
JSPipe
)
IsMining
()
bool
{
return
self
.
obj
.
IsMining
()
}
func
(
self
*
JSPipe
)
Get
IsListening
()
bool
{
func
(
self
*
JSPipe
)
IsListening
()
bool
{
return
self
.
obj
.
IsListening
()
}
func
(
self
*
JSPipe
)
Get
CoinBase
()
string
{
func
(
self
*
JSPipe
)
CoinBase
()
string
{
return
ethutil
.
Bytes2Hex
(
self
.
obj
.
KeyManager
()
.
Address
())
}
func
(
self
*
JSPipe
)
GetStorage
(
addr
,
storageAddr
string
)
string
{
func
(
self
*
JSPipe
)
BalanceAt
(
addr
string
)
string
{
return
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Balance
.
String
()
}
func
(
self
*
JSPipe
)
NumberToHuman
(
balance
string
)
string
{
b
:=
ethutil
.
Big
(
balance
)
return
ethutil
.
CurrencyToString
(
b
)
}
func
(
self
*
JSPipe
)
StorageAt
(
addr
,
storageAddr
string
)
string
{
return
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Storage
(
ethutil
.
Hex2Bytes
(
storageAddr
))
.
Str
()
}
func
(
self
*
JSPipe
)
Get
TxCountAt
(
address
string
)
int
{
func
(
self
*
JSPipe
)
TxCountAt
(
address
string
)
int
{
return
int
(
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
address
))
.
Nonce
)
}
...
...
@@ -89,7 +99,7 @@ type KeyVal struct {
Value
string
`json:"value"`
}
func
(
self
*
JSPipe
)
Get
EachStorage
(
addr
string
)
string
{
func
(
self
*
JSPipe
)
EachStorage
(
addr
string
)
string
{
var
values
[]
KeyVal
object
:=
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
object
.
EachStorage
(
func
(
name
string
,
value
*
ethutil
.
Value
)
{
...
...
@@ -175,3 +185,20 @@ func (self *JSPipe) CompileMutan(code string) string {
return
ethutil
.
Bytes2Hex
(
data
)
}
func
(
self
*
JSPipe
)
Messages
(
object
map
[
string
]
interface
{})
string
{
filter
:=
ethchain
.
NewFilterFromMap
(
object
,
self
.
obj
)
messages
:=
filter
.
Find
()
var
msgs
[]
JSMessage
for
_
,
m
:=
range
messages
{
msgs
=
append
(
msgs
,
NewJSMessage
(
m
))
}
b
,
err
:=
json
.
Marshal
(
msgs
)
if
err
!=
nil
{
return
"{
\"
error
\"
:"
+
err
.
Error
()
+
"}"
}
return
string
(
b
)
}
ethpipe/js_types.go
View file @
b0ae61c6
...
...
@@ -7,6 +7,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
)
...
...
@@ -175,3 +176,33 @@ func NewJSReciept(contractCreation bool, creationAddress, hash, address []byte)
ethutil
.
Bytes2Hex
(
address
),
}
}
type
JSMessage
struct
{
To
string
`json:"to"`
From
string
`json:"from"`
Input
string
`json:"input"`
Output
string
`json:"output"`
Path
int32
`json:"path"`
Origin
string
`json:"origin"`
Timestamp
int32
`json:"timestamp"`
Coinbase
string
`json:"coinbase"`
Block
string
`json:"block"`
Number
int32
`json:"number"`
Value
string
`json:"value"`
}
func
NewJSMessage
(
message
*
ethstate
.
Message
)
JSMessage
{
return
JSMessage
{
To
:
ethutil
.
Bytes2Hex
(
message
.
To
),
From
:
ethutil
.
Bytes2Hex
(
message
.
From
),
Input
:
ethutil
.
Bytes2Hex
(
message
.
Input
),
Output
:
ethutil
.
Bytes2Hex
(
message
.
Output
),
Path
:
int32
(
message
.
Path
),
Origin
:
ethutil
.
Bytes2Hex
(
message
.
Origin
),
Timestamp
:
int32
(
message
.
Timestamp
),
Coinbase
:
ethutil
.
Bytes2Hex
(
message
.
Origin
),
Block
:
ethutil
.
Bytes2Hex
(
message
.
Block
),
Number
:
int32
(
message
.
Number
.
Int64
()),
Value
:
message
.
Value
.
String
(),
}
}
ethrpc/packages.go
View file @
b0ae61c6
...
...
@@ -74,7 +74,7 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *string) error {
return
err
}
block
:=
p
.
pipe
.
Get
BlockByHash
(
args
.
Hash
)
block
:=
p
.
pipe
.
BlockByHash
(
args
.
Hash
)
*
reply
=
NewSuccessRes
(
block
)
return
nil
}
...
...
@@ -129,7 +129,7 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *string) error {
if
err
!=
nil
{
return
err
}
result
,
_
:=
p
.
pipe
.
Transact
(
p
.
pipe
.
Get
Key
()
.
PrivateKey
,
args
.
Recipient
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Body
)
result
,
_
:=
p
.
pipe
.
Transact
(
p
.
pipe
.
Key
()
.
PrivateKey
,
args
.
Recipient
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Body
)
*
reply
=
NewSuccessRes
(
result
)
return
nil
}
...
...
@@ -140,13 +140,13 @@ func (p *EthereumApi) Create(args *NewTxArgs, reply *string) error {
return
err
}
result
,
_
:=
p
.
pipe
.
Transact
(
p
.
pipe
.
Get
Key
()
.
PrivateKey
,
""
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Body
)
result
,
_
:=
p
.
pipe
.
Transact
(
p
.
pipe
.
Key
()
.
PrivateKey
,
""
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Body
)
*
reply
=
NewSuccessRes
(
result
)
return
nil
}
func
(
p
*
EthereumApi
)
GetKey
(
args
interface
{},
reply
*
string
)
error
{
*
reply
=
NewSuccessRes
(
p
.
pipe
.
Get
Key
())
*
reply
=
NewSuccessRes
(
p
.
pipe
.
Key
())
return
nil
}
...
...
@@ -212,7 +212,7 @@ type GetPeerCountRes struct {
}
func
(
p
*
EthereumApi
)
GetPeerCount
(
args
*
interface
{},
reply
*
string
)
error
{
*
reply
=
NewSuccessRes
(
GetPeerCountRes
{
PeerCount
:
p
.
pipe
.
Get
PeerCount
()})
*
reply
=
NewSuccessRes
(
GetPeerCountRes
{
PeerCount
:
p
.
pipe
.
PeerCount
()})
return
nil
}
...
...
@@ -221,7 +221,7 @@ type GetListeningRes struct {
}
func
(
p
*
EthereumApi
)
GetIsListening
(
args
*
interface
{},
reply
*
string
)
error
{
*
reply
=
NewSuccessRes
(
GetListeningRes
{
IsListening
:
p
.
pipe
.
Get
IsListening
()})
*
reply
=
NewSuccessRes
(
GetListeningRes
{
IsListening
:
p
.
pipe
.
IsListening
()})
return
nil
}
...
...
@@ -230,7 +230,7 @@ type GetCoinbaseRes struct {
}
func
(
p
*
EthereumApi
)
GetCoinbase
(
args
*
interface
{},
reply
*
string
)
error
{
*
reply
=
NewSuccessRes
(
GetCoinbaseRes
{
Coinbase
:
p
.
pipe
.
Get
CoinBase
()})
*
reply
=
NewSuccessRes
(
GetCoinbaseRes
{
Coinbase
:
p
.
pipe
.
CoinBase
()})
return
nil
}
...
...
@@ -239,7 +239,7 @@ type GetMiningRes struct {
}
func
(
p
*
EthereumApi
)
GetIsMining
(
args
*
interface
{},
reply
*
string
)
error
{
*
reply
=
NewSuccessRes
(
GetMiningRes
{
IsMining
:
p
.
pipe
.
Get
IsMining
()})
*
reply
=
NewSuccessRes
(
GetMiningRes
{
IsMining
:
p
.
pipe
.
IsMining
()})
return
nil
}
...
...
@@ -248,7 +248,7 @@ func (p *EthereumApi) GetTxCountAt(args *GetTxCountArgs, reply *string) error {
if
err
!=
nil
{
return
err
}
state
:=
p
.
pipe
.
Get
TxCountAt
(
args
.
Address
)
state
:=
p
.
pipe
.
TxCountAt
(
args
.
Address
)
*
reply
=
NewSuccessRes
(
GetTxCountRes
{
Nonce
:
state
})
return
nil
}
...
...
ethstate/manifest.go
View file @
b0ae61c6
...
...
@@ -41,6 +41,7 @@ type Message struct {
Coinbase
[]
byte
Block
[]
byte
Number
*
big
.
Int
Value
*
big
.
Int
ChangedAddresses
[][]
byte
}
...
...
@@ -50,5 +51,5 @@ func (self *Message) AddStorageChange(addr []byte) {
}
func
(
self
*
Message
)
String
()
string
{
return
fmt
.
Sprintf
(
"Message{to: %x from: %x input: %x output: %x origin: %x coinbase: %x block: %x number: %v timestamp: %d path: %d
"
,
self
.
To
,
self
.
From
,
self
.
Input
,
self
.
Output
,
self
.
Origin
,
self
.
Coinbase
,
self
.
Block
,
self
.
Number
,
self
.
Timestamp
,
self
.
Path
)
return
fmt
.
Sprintf
(
"Message{to: %x from: %x input: %x output: %x origin: %x coinbase: %x block: %x number: %v timestamp: %d path: %d
value: %v"
,
self
.
To
,
self
.
From
,
self
.
Input
,
self
.
Output
,
self
.
Origin
,
self
.
Coinbase
,
self
.
Block
,
self
.
Number
,
self
.
Timestamp
,
self
.
Path
,
self
.
Value
)
}
ethvm/vm.go
View file @
b0ae61c6
...
...
@@ -700,6 +700,7 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
To
:
addr
,
From
:
closure
.
Address
(),
Origin
:
self
.
env
.
Origin
(),
Block
:
self
.
env
.
BlockHash
(),
Timestamp
:
self
.
env
.
Time
(),
Coinbase
:
self
.
env
.
Coinbase
(),
Number
:
self
.
env
.
BlockNumber
(),
Value
:
value
,
})
// Create a new contract
...
...
@@ -765,6 +766,7 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
Input
:
args
,
Origin
:
self
.
env
.
Origin
(),
Block
:
self
.
env
.
BlockHash
(),
Timestamp
:
self
.
env
.
Time
(),
Coinbase
:
self
.
env
.
Coinbase
(),
Number
:
self
.
env
.
BlockNumber
(),
Value
:
value
,
})
if
closure
.
object
.
Balance
.
Cmp
(
value
)
<
0
{
...
...
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