Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
7849b7e9
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,发现更多精彩内容 >>
提交
7849b7e9
编写于
10月 28, 2014
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refund SSTORE properly
上级
5920aa7b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
2 deletion
+27
-2
ethstate/state.go
ethstate/state.go
+25
-1
vm/vm_debug.go
vm/vm_debug.go
+2
-1
未找到文件。
ethstate/state.go
浏览文件 @
7849b7e9
...
...
@@ -22,11 +22,13 @@ type State struct {
stateObjects
map
[
string
]
*
StateObject
manifest
*
Manifest
refund
map
[
string
]
*
big
.
Int
}
// Create a new state from a given trie
func
New
(
trie
*
ethtrie
.
Trie
)
*
State
{
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
()}
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
()
,
refund
:
make
(
map
[
string
]
*
big
.
Int
)
}
}
// Retrieve the balance from the given address or 0 if object not found
...
...
@@ -39,6 +41,16 @@ func (self *State) GetBalance(addr []byte) *big.Int {
return
ethutil
.
Big0
}
func
(
self
*
State
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
amount
:=
new
(
big
.
Int
)
.
Mul
(
gas
,
price
)
if
self
.
refund
[
string
(
addr
)]
==
nil
{
self
.
refund
[
string
(
addr
)]
=
new
(
big
.
Int
)
}
self
.
refund
[
string
(
addr
)]
=
new
(
big
.
Int
)
.
Add
(
self
.
refund
[
string
(
addr
)],
amount
)
}
func
(
self
*
State
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
...
...
@@ -186,6 +198,10 @@ func (self *State) Copy() *State {
state
.
stateObjects
[
k
]
=
stateObject
.
Copy
()
}
for
addr
,
refund
:=
range
self
.
refund
{
state
.
refund
[
addr
]
=
refund
}
return
state
}
...
...
@@ -199,6 +215,7 @@ func (self *State) Set(state *State) {
self
.
Trie
=
state
.
Trie
self
.
stateObjects
=
state
.
stateObjects
self
.
refund
=
state
.
refund
}
func
(
s
*
State
)
Root
()
interface
{}
{
...
...
@@ -240,10 +257,17 @@ func (s *State) Sync() {
func
(
self
*
State
)
Empty
()
{
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
refund
=
make
(
map
[
string
]
*
big
.
Int
)
}
func
(
self
*
State
)
Update
()
{
var
deleted
bool
// Refund any gas that's left
for
addr
,
amount
:=
range
self
.
refund
{
self
.
GetStateObject
([]
byte
(
addr
))
.
AddBalance
(
amount
)
}
for
_
,
stateObject
:=
range
self
.
stateObjects
{
if
stateObject
.
remove
{
self
.
DeleteStateObject
(
stateObject
)
...
...
vm/vm_debug.go
浏览文件 @
7849b7e9
...
...
@@ -179,7 +179,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
// 0 => non 0
mult
=
ethutil
.
Big3
}
else
if
val
.
BigInt
()
.
Cmp
(
ethutil
.
Big0
)
!=
0
&&
len
(
y
.
Bytes
())
==
0
{
//state.AddBalance(closure.caller.Address(), new(big.Int).Mul(big.NewInt(100), closure.Price))
state
.
Refund
(
closure
.
caller
.
Address
(),
big
.
NewInt
(
100
),
closure
.
Price
)
mult
=
ethutil
.
Big0
}
else
{
// non 0 => non 0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录