Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
204ac811
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,发现更多精彩内容 >>
提交
204ac811
编写于
4月 08, 2015
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved handling of nonces to the managed state
上级
6e2f78eb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
6 deletion
+9
-6
core/state/managed_state.go
core/state/managed_state.go
+2
-2
core/state/managed_state_test.go
core/state/managed_state_test.go
+6
-3
eth/backend.go
eth/backend.go
+1
-1
未找到文件。
core/state/managed_state.go
浏览文件 @
204ac811
...
...
@@ -62,7 +62,7 @@ func (ms *ManagedState) NewNonce(addr common.Address) uint64 {
}
}
account
.
nonces
=
append
(
account
.
nonces
,
true
)
return
uint64
(
len
(
account
.
nonces
))
+
account
.
nstart
return
uint64
(
len
(
account
.
nonces
)
-
1
)
+
account
.
nstart
}
// GetNonce returns the canonical nonce for the managed or unmanged account
...
...
@@ -109,5 +109,5 @@ func (ms *ManagedState) getAccount(addr common.Address) *account {
}
func
newAccount
(
so
*
StateObject
)
*
account
{
return
&
account
{
so
,
so
.
nonce
-
1
,
nil
}
return
&
account
{
so
,
so
.
nonce
,
nil
}
}
core/state/managed_state_test.go
浏览文件 @
204ac811
...
...
@@ -4,12 +4,15 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
)
var
addr
=
common
.
BytesToAddress
([]
byte
(
"test"
))
func
create
()
(
*
ManagedState
,
*
account
)
{
ms
:=
ManageState
(
&
StateDB
{
stateObjects
:
make
(
map
[
string
]
*
StateObject
)})
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
New
(
common
.
Hash
{},
db
)
ms
:=
ManageState
(
statedb
)
so
:=
&
StateObject
{
address
:
addr
,
nonce
:
100
}
ms
.
StateDB
.
stateObjects
[
addr
.
Str
()]
=
so
ms
.
accounts
[
addr
.
Str
()]
=
newAccount
(
so
)
...
...
@@ -95,13 +98,13 @@ func TestSetNonce(t *testing.T) {
ms
.
SetNonce
(
addr
,
10
)
if
ms
.
GetNonce
(
addr
)
!=
10
{
t
.
Error
f
(
"Expected nonce of 10, got"
,
ms
.
GetNonce
(
addr
))
t
.
Error
(
"Expected nonce of 10, got"
,
ms
.
GetNonce
(
addr
))
}
addr
[
0
]
=
1
ms
.
StateDB
.
SetNonce
(
addr
,
1
)
if
ms
.
GetNonce
(
addr
)
!=
1
{
t
.
Error
f
(
"Expected nonce of 1, got"
,
ms
.
GetNonce
(
addr
))
t
.
Error
(
"Expected nonce of 1, got"
,
ms
.
GetNonce
(
addr
))
}
}
eth/backend.go
浏览文件 @
204ac811
...
...
@@ -449,7 +449,7 @@ func (self *Ethereum) syncAccounts(tx *types.Transaction) {
if
self
.
accountManager
.
HasAccount
(
from
.
Bytes
())
{
if
self
.
chainManager
.
TxState
()
.
GetNonce
(
from
)
<
tx
.
Nonce
()
{
self
.
chainManager
.
TxState
()
.
SetNonce
(
from
,
tx
.
Nonce
()
+
1
)
self
.
chainManager
.
TxState
()
.
SetNonce
(
from
,
tx
.
Nonce
())
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录