Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
00d3935a
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,发现更多精彩内容 >>
提交
00d3935a
编写于
7月 01, 2014
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed old method
上级
bb2433ca
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
39 addition
and
46 deletion
+39
-46
ethchain/closure.go
ethchain/closure.go
+3
-3
ethchain/state.go
ethchain/state.go
+5
-1
ethchain/state_object.go
ethchain/state_object.go
+28
-39
ethpub/pub.go
ethpub/pub.go
+2
-2
ethpub/types.go
ethpub/types.go
+1
-1
未找到文件。
ethchain/closure.go
浏览文件 @
00d3935a
...
...
@@ -10,7 +10,7 @@ import (
type
ClosureRef
interface
{
ReturnGas
(
*
big
.
Int
,
*
big
.
Int
,
*
State
)
Address
()
[]
byte
Get
Mem
(
*
big
.
Int
)
*
ethutil
.
Value
Get
Storage
(
*
big
.
Int
)
*
ethutil
.
Value
SetStorage
(
*
big
.
Int
,
*
ethutil
.
Value
)
N
()
*
big
.
Int
}
...
...
@@ -43,8 +43,8 @@ func NewClosure(caller ClosureRef, object *StateObject, script []byte, state *St
}
// Retuns the x element in data slice
func
(
c
*
Closure
)
Get
Mem
(
x
*
big
.
Int
)
*
ethutil
.
Value
{
m
:=
c
.
object
.
Get
Mem
(
x
)
func
(
c
*
Closure
)
Get
Storage
(
x
*
big
.
Int
)
*
ethutil
.
Value
{
m
:=
c
.
object
.
Get
Storage
(
x
)
if
m
==
nil
{
return
ethutil
.
EmptyValue
()
}
...
...
ethchain/state.go
浏览文件 @
00d3935a
...
...
@@ -66,7 +66,11 @@ func (self *State) Empty() {
func
(
self
*
State
)
Update
()
{
for
_
,
stateObject
:=
range
self
.
stateObjects
{
self
.
UpdateStateObject
(
stateObject
)
if
stateObject
.
remove
{
self
.
trie
.
Delete
(
string
(
stateObject
.
Address
()))
}
else
{
self
.
UpdateStateObject
(
stateObject
)
}
}
}
...
...
ethchain/state_object.go
浏览文件 @
00d3935a
...
...
@@ -31,6 +31,11 @@ type StateObject struct {
// left if this object is the coinbase. Gas is directly
// purchased of the coinbase.
gasPool
*
big
.
Int
// Mark for deletion
// When an object is marked for deletion it will be delete from the trie
// during the "update" phase of the state transition
remove
bool
}
// Converts an transaction in to a state object
...
...
@@ -77,15 +82,11 @@ func NewStateObjectFromBytes(address, data []byte) *StateObject {
return
object
}
func
(
c
*
StateObject
)
State
()
*
State
{
return
c
.
state
}
func
(
c
*
StateObject
)
N
()
*
big
.
Int
{
return
big
.
NewInt
(
int64
(
c
.
Nonce
))
func
(
self
*
StateObject
)
MarkForDeletion
()
{
self
.
remove
=
true
}
func
(
c
*
StateObject
)
Addr
(
addr
[]
byte
)
*
ethutil
.
Value
{
func
(
c
*
StateObject
)
Get
Addr
(
addr
[]
byte
)
*
ethutil
.
Value
{
return
ethutil
.
NewValueFromBytes
([]
byte
(
c
.
state
.
trie
.
Get
(
string
(
addr
))))
}
...
...
@@ -108,12 +109,7 @@ func (c *StateObject) SetStorage(num *big.Int, val *ethutil.Value) {
func
(
c
*
StateObject
)
GetStorage
(
num
*
big
.
Int
)
*
ethutil
.
Value
{
nb
:=
ethutil
.
BigToBytes
(
num
,
256
)
return
c
.
Addr
(
nb
)
}
/* DEPRECATED */
func
(
c
*
StateObject
)
GetMem
(
num
*
big
.
Int
)
*
ethutil
.
Value
{
return
c
.
GetStorage
(
num
)
return
c
.
GetAddr
(
nb
)
}
func
(
c
*
StateObject
)
GetInstr
(
pc
*
big
.
Int
)
*
ethutil
.
Value
{
...
...
@@ -124,14 +120,6 @@ func (c *StateObject) GetInstr(pc *big.Int) *ethutil.Value {
return
ethutil
.
NewValueFromBytes
([]
byte
{
c
.
script
[
pc
.
Int64
()]})
}
// Return the gas back to the origin. Used by the Virtual machine or Closures
func
(
c
*
StateObject
)
ReturnGas
(
gas
,
price
*
big
.
Int
,
state
*
State
)
{
/*
remainder := new(big.Int).Mul(gas, price)
c.AddAmount(remainder)
*/
}
func
(
c
*
StateObject
)
AddAmount
(
amount
*
big
.
Int
)
{
c
.
SetAmount
(
new
(
big
.
Int
)
.
Add
(
c
.
Amount
,
amount
))
...
...
@@ -148,6 +136,12 @@ func (c *StateObject) SetAmount(amount *big.Int) {
c
.
Amount
=
amount
}
//
// Gas setters and getters
//
// Return the gas back to the origin. Used by the Virtual machine or Closures
func
(
c
*
StateObject
)
ReturnGas
(
gas
,
price
*
big
.
Int
,
state
*
State
)
{}
func
(
c
*
StateObject
)
ConvertGas
(
gas
,
price
*
big
.
Int
)
error
{
total
:=
new
(
big
.
Int
)
.
Mul
(
gas
,
price
)
if
total
.
Cmp
(
c
.
Amount
)
>
0
{
...
...
@@ -206,26 +200,17 @@ func (self *StateObject) Set(stateObject *StateObject) {
self
=
stateObject
}
/*
func (self *StateObject) Copy() *StateObject {
stCopy := &StateObject{}
stCopy.address = make([]byte, len(self.address))
copy(stCopy.address, self.address)
stCopy.Amount = new(big.Int).Set(self.Amount)
stCopy.ScriptHash = make([]byte, len(self.ScriptHash))
copy(stCopy.ScriptHash, self.ScriptHash)
stCopy.Nonce = self.Nonce
if self.state != nil {
stCopy.state = self.state.Copy()
}
stCopy.script = make([]byte, len(self.script))
copy(stCopy.script, self.script)
stCopy.initScript = make([]byte, len(self.initScript))
copy(stCopy.initScript, self.initScript)
//
// Attribute accessors
//
func
(
c
*
StateObject
)
State
()
*
State
{
return
c
.
state
}
return stCopy
func
(
c
*
StateObject
)
N
()
*
big
.
Int
{
return
big
.
NewInt
(
int64
(
c
.
Nonce
))
}
*/
// Returns the address of the contract/account
func
(
c
*
StateObject
)
Address
()
[]
byte
{
...
...
@@ -242,6 +227,10 @@ func (c *StateObject) Init() Code {
return
c
.
initScript
}
//
// Encoding
//
// State object encoding methods
func
(
c
*
StateObject
)
RlpEncode
()
[]
byte
{
var
root
interface
{}
...
...
ethpub/pub.go
浏览文件 @
00d3935a
...
...
@@ -166,7 +166,7 @@ func (lib *PEthereum) Create(key, valueStr, gasStr, gasPriceStr, script string)
return
lib
.
createTx
(
key
,
""
,
valueStr
,
gasStr
,
gasPriceStr
,
script
)
}
func
GetAddressFrom
NameReg
(
stateManager
*
ethchain
.
StateManager
,
name
string
)
[]
byte
{
func
FindAddressIn
NameReg
(
stateManager
*
ethchain
.
StateManager
,
name
string
)
[]
byte
{
nameReg
:=
EthereumConfig
(
stateManager
)
.
NameReg
()
if
nameReg
!=
nil
{
addr
:=
ethutil
.
RightPadBytes
([]
byte
(
name
),
32
)
...
...
@@ -186,7 +186,7 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, sc
contractCreation
=
true
}
else
{
// Check if an address is stored by this address
addr
:=
GetAddressFrom
NameReg
(
lib
.
stateManager
,
recipient
)
addr
:=
FindAddressIn
NameReg
(
lib
.
stateManager
,
recipient
)
if
len
(
addr
)
>
0
{
hash
=
addr
}
else
{
...
...
ethpub/types.go
浏览文件 @
00d3935a
...
...
@@ -164,7 +164,7 @@ func (c *PStateObject) GetStorage(address string) string {
// still has some magical object so we can't rely on
// undefined or null at the QML side
if
c
.
object
!=
nil
{
val
:=
c
.
object
.
Get
Mem
(
ethutil
.
Big
(
"0x"
+
address
))
val
:=
c
.
object
.
Get
Storage
(
ethutil
.
Big
(
"0x"
+
address
))
return
val
.
BigInt
()
.
String
()
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录