Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
31b4ff8c
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,发现更多精彩内容 >>
提交
31b4ff8c
编写于
3月 08, 2016
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2310 from karalabe/ethash-future-cache
Godeps: pull in ethash future cache generator
上级
848e50d6
119b7243
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
25 addition
and
9 deletion
+25
-9
Godeps/Godeps.json
Godeps/Godeps.json
+2
-2
Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
+23
-7
未找到文件。
Godeps/Godeps.json
浏览文件 @
31b4ff8c
...
...
@@ -20,8 +20,8 @@
},
{
"ImportPath"
:
"github.com/ethereum/ethash"
,
"Comment"
:
"v23.1-24
0-ga524c9f
"
,
"Rev"
:
"
a524c9f7d55cb8925567dc201b44ba555862056d
"
"Comment"
:
"v23.1-24
2-gbc9ba4d
"
,
"Rev"
:
"
bc9ba4d6a83a0fe308fefd8c6001b8ed1607137f
"
},
{
"ImportPath"
:
"github.com/fatih/color"
,
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
浏览文件 @
31b4ff8c
...
...
@@ -108,10 +108,13 @@ func freeCache(cache *cache) {
// Light implements the Verify half of the proof of work. It uses a few small
// in-memory caches to verify the nonces found by Full.
type
Light
struct
{
test
bool
// if set use a smaller cache size
mu
sync
.
Mutex
// protects the per-epoch map of DAGs
caches
map
[
uint64
]
*
cache
// currently cached verification DAGs
NumCaches
int
// Maximum number of DAGs to cache before eviction (only init, don't modify)
test
bool
// If set, use a smaller cache size
mu
sync
.
Mutex
// Protects the per-epoch map of verification caches
caches
map
[
uint64
]
*
cache
// Currently maintained verification caches
future
*
cache
// Pre-generated cache for the estimated future DAG
NumCaches
int
// Maximum number of caches to keep before eviction (only init, don't modify)
}
// Verify checks whether the block's nonce is valid.
...
...
@@ -192,12 +195,25 @@ func (l *Light) getCache(blockNum uint64) *cache {
evict
=
cache
}
}
glog
.
V
(
logger
.
Info
)
.
Infof
(
"Evicting DAG for epoch %d in favour of epoch %d"
,
evict
.
epoch
,
epoch
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Evicting DAG for epoch %d in favour of epoch %d"
,
evict
.
epoch
,
epoch
)
delete
(
l
.
caches
,
evict
.
epoch
)
}
// Create and return a new DAG for the epoch
// If we have the new DAG pre-generated, use that, otherwise create a new one
if
l
.
future
!=
nil
&&
l
.
future
.
epoch
==
epoch
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Using pre-generated DAG for epoch %d"
,
epoch
)
c
,
l
.
future
=
l
.
future
,
nil
}
else
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"No pre-generated DAG available, creating new for epoch %d"
,
epoch
)
c
=
&
cache
{
epoch
:
epoch
,
test
:
l
.
test
}
}
l
.
caches
[
epoch
]
=
c
// If we just used up the future cache, or need a refresh, regenerate
if
l
.
future
==
nil
||
l
.
future
.
epoch
<=
epoch
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Pre-generating DAG for epoch %d"
,
epoch
+
1
)
l
.
future
=
&
cache
{
epoch
:
epoch
+
1
,
test
:
l
.
test
}
go
l
.
future
.
generate
()
}
}
c
.
used
=
time
.
Now
()
l
.
mu
.
Unlock
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录