Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
4141cc39
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4141cc39
编写于
6月 25, 2014
作者:
Z
zelig
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/develop' into feature/logging
上级
f58c7ac5
d8c675af
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
6 deletion
+48
-6
ethchain/vm.go
ethchain/vm.go
+3
-1
ethpub/pub.go
ethpub/pub.go
+33
-2
ethpub/types.go
ethpub/types.go
+1
-0
ethrpc/packages.go
ethrpc/packages.go
+11
-3
未找到文件。
ethchain/vm.go
浏览文件 @
4141cc39
...
...
@@ -597,7 +597,9 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
// Generate a new address
addr
:=
ethutil
.
CreateAddress
(
closure
.
caller
.
Address
(),
closure
.
caller
.
N
())
// Create a new contract
contract
:=
NewContract
(
addr
,
value
,
[]
byte
(
""
))
contract
:=
vm
.
state
.
NewStateObject
(
addr
)
contract
.
Amount
=
value
// Set the init script
contract
.
initScript
=
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
())
// Transfer all remaining gas to the new
...
...
ethpub/pub.go
浏览文件 @
4141cc39
package
ethpub
import
(
"bytes"
"encoding/hex"
"encoding/json"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethlog"
...
...
@@ -84,6 +86,36 @@ func (lib *PEthereum) GetCoinBase() string {
return
lib
.
SecretToAddress
(
hex
.
EncodeToString
(
key
))
}
func
(
lib
*
PEthereum
)
GetTransactionsFor
(
address
string
,
asJson
bool
)
interface
{}
{
sBlk
:=
lib
.
manager
.
BlockChain
()
.
LastBlockHash
blk
:=
lib
.
manager
.
BlockChain
()
.
GetBlock
(
sBlk
)
addr
:=
[]
byte
(
ethutil
.
FromHex
(
address
))
var
txs
[]
*
PTx
for
;
blk
!=
nil
;
blk
=
lib
.
manager
.
BlockChain
()
.
GetBlock
(
sBlk
)
{
sBlk
=
blk
.
PrevHash
// Loop through all transactions to see if we missed any while being offline
for
_
,
tx
:=
range
blk
.
Transactions
()
{
if
bytes
.
Compare
(
tx
.
Sender
(),
addr
)
==
0
||
bytes
.
Compare
(
tx
.
Recipient
,
addr
)
==
0
{
ptx
:=
NewPTx
(
tx
)
//TODO: somehow move this to NewPTx
ptx
.
Confirmations
=
int
(
lib
.
manager
.
BlockChain
()
.
LastBlockNumber
-
blk
.
BlockInfo
()
.
Number
)
txs
=
append
(
txs
,
ptx
)
}
}
}
if
asJson
{
txJson
,
err
:=
json
.
Marshal
(
txs
)
if
err
!=
nil
{
return
nil
}
return
string
(
txJson
)
}
return
txs
}
func
(
lib
*
PEthereum
)
GetStorage
(
address
,
storageAddress
string
)
string
{
return
lib
.
GetStateObject
(
address
)
.
GetStorage
(
storageAddress
)
}
...
...
@@ -126,7 +158,6 @@ func GetAddressFromNameReg(stateManager *ethchain.StateManager, name string) []b
return
nil
}
func
(
lib
*
PEthereum
)
createTx
(
key
,
recipient
,
valueStr
,
gasStr
,
gasPriceStr
,
scriptStr
string
)
(
*
PReceipt
,
error
)
{
var
hash
[]
byte
var
contractCreation
bool
...
...
@@ -145,7 +176,7 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, sc
var
keyPair
*
ethutil
.
KeyPair
var
err
error
if
key
[
0
:
2
]
==
"0x"
{
keyPair
,
err
=
ethutil
.
NewKeyPairFromSec
([]
byte
(
ethutil
.
FromHex
(
key
[
0
:
2
])))
keyPair
,
err
=
ethutil
.
NewKeyPairFromSec
([]
byte
(
ethutil
.
FromHex
(
key
[
2
:
])))
}
else
{
keyPair
,
err
=
ethutil
.
NewKeyPairFromSec
([]
byte
(
ethutil
.
FromHex
(
key
)))
}
...
...
ethpub/types.go
浏览文件 @
4141cc39
...
...
@@ -99,6 +99,7 @@ type PTx struct {
Data
string
`json:"data"`
Contract
bool
`json:"isContract"`
CreatesContract
bool
`json:"createsContract"`
Confirmations
int
`json:"confirmations"`
}
func
NewPTx
(
tx
*
ethchain
.
Transaction
)
*
PTx
{
...
...
ethrpc/packages.go
浏览文件 @
4141cc39
...
...
@@ -6,6 +6,7 @@ import (
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"math/big"
"strings"
)
type
EthereumApi
struct
{
...
...
@@ -174,9 +175,16 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *string) error {
return
err
}
state
:=
p
.
ethp
.
GetStateObject
(
args
.
Address
)
// Convert the incoming string (which is a bigint) into hex
i
,
_
:=
new
(
big
.
Int
)
.
SetString
(
args
.
Key
,
10
)
hx
:=
ethutil
.
Hex
(
i
.
Bytes
())
var
hx
string
if
strings
.
Index
(
args
.
Key
,
"0x"
)
==
0
{
hx
=
string
([]
byte
(
args
.
Key
)[
2
:
])
}
else
{
// Convert the incoming string (which is a bigint) into hex
i
,
_
:=
new
(
big
.
Int
)
.
SetString
(
args
.
Key
,
10
)
hx
=
ethutil
.
Hex
(
i
.
Bytes
())
}
ethutil
.
Config
.
Log
.
Debugf
(
"[JSON] GetStorageAt(%s, %s)
\n
"
,
args
.
Address
,
hx
)
value
:=
state
.
GetStorage
(
hx
)
*
reply
=
NewSuccessRes
(
GetStorageAtRes
{
Address
:
args
.
Address
,
Key
:
args
.
Key
,
Value
:
value
})
return
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录