Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
26c6e3b2
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,体验更适合开发者的 AI 搜索 >>
提交
26c6e3b2
编写于
8月 03, 2015
作者:
G
Gustav Simonsson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
miner: gas limit strategy, target 3141592 & def gas price 50 Shannon
上级
ff66e8fa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
8 deletion
+22
-8
cmd/utils/flags.go
cmd/utils/flags.go
+3
-3
core/chain_util.go
core/chain_util.go
+15
-2
eth/fetcher/fetcher_test.go
eth/fetcher/fetcher_test.go
+2
-1
params/protocol_params.go
params/protocol_params.go
+2
-2
未找到文件。
cmd/utils/flags.go
浏览文件 @
26c6e3b2
...
...
@@ -158,7 +158,7 @@ var (
GasPriceFlag
=
cli
.
StringFlag
{
Name
:
"gasprice"
,
Usage
:
"Sets the minimal gasprice when mining transactions"
,
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
0
),
common
.
Shannon
)
.
String
(),
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
),
common
.
Shannon
)
.
String
(),
}
UnlockedAccountFlag
=
cli
.
StringFlag
{
...
...
@@ -318,12 +318,12 @@ var (
GpoMinGasPriceFlag
=
cli
.
StringFlag
{
Name
:
"gpomin"
,
Usage
:
"Minimum suggested gas price"
,
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
1
),
common
.
Szabo
)
.
String
(),
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
),
common
.
Shannon
)
.
String
(),
}
GpoMaxGasPriceFlag
=
cli
.
StringFlag
{
Name
:
"gpomax"
,
Usage
:
"Maximum suggested gas price"
,
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
100
),
common
.
Szabo
)
.
String
(),
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
500
),
common
.
Shannon
)
.
String
(),
}
GpoFullBlockRatioFlag
=
cli
.
IntFlag
{
Name
:
"gpofull"
,
...
...
core/chain_util.go
浏览文件 @
26c6e3b2
...
...
@@ -69,17 +69,30 @@ func CalcTD(block, parent *types.Block) *big.Int {
// CalcGasLimit computes the gas limit of the next block after parent.
// The result may be modified by the caller.
// This is miner strategy, not consensus protocol.
func
CalcGasLimit
(
parent
*
types
.
Block
)
*
big
.
Int
{
decay
:=
new
(
big
.
Int
)
.
Div
(
parent
.
GasLimit
(),
params
.
GasLimitBoundDivisor
)
// contrib = (parentGasUsed * 3 / 2) / 1024
contrib
:=
new
(
big
.
Int
)
.
Mul
(
parent
.
GasUsed
(),
big
.
NewInt
(
3
))
contrib
=
contrib
.
Div
(
contrib
,
big
.
NewInt
(
2
))
contrib
=
contrib
.
Div
(
contrib
,
params
.
GasLimitBoundDivisor
)
// decay = parentGasLimit / 1024 -1
decay
:=
new
(
big
.
Int
)
.
Div
(
parent
.
GasLimit
(),
params
.
GasLimitBoundDivisor
)
decay
.
Sub
(
decay
,
big
.
NewInt
(
1
))
/*
strategy: gasLimit of block-to-mine is set based on parent's
gasUsed value. if parentGasUsed > parentGasLimit * (2/3) then we
increase it, otherwise lower it (or leave it unchanged if it's right
at that usage) the amount increased/decreased depends on how far away
from parentGasLimit * (2/3) parentGasUsed is.
*/
gl
:=
new
(
big
.
Int
)
.
Sub
(
parent
.
GasLimit
(),
decay
)
gl
=
gl
.
Add
(
gl
,
contrib
)
gl
=
gl
.
Add
(
gl
,
big
.
NewInt
(
1
))
gl
.
Set
(
common
.
BigMax
(
gl
,
params
.
MinGasLimit
))
// however, if we're now below the target (GenesisGasLimit) we increase the
// limit as much as we can (parentGasLimit / 1024 -1)
if
gl
.
Cmp
(
params
.
GenesisGasLimit
)
<
0
{
gl
.
Add
(
parent
.
GasLimit
(),
decay
)
gl
.
Set
(
common
.
BigMin
(
gl
,
params
.
GenesisGasLimit
))
...
...
eth/fetcher/fetcher_test.go
浏览文件 @
26c6e3b2
...
...
@@ -28,12 +28,13 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
)
var
(
testdb
,
_
=
ethdb
.
NewMemDatabase
()
genesis
=
core
.
GenesisBlockForTesting
(
testdb
,
common
.
Address
{},
big
.
NewInt
(
0
))
unknownBlock
=
types
.
NewBlock
(
&
types
.
Header
{},
nil
,
nil
,
nil
)
unknownBlock
=
types
.
NewBlock
(
&
types
.
Header
{
GasLimit
:
params
.
GenesisGasLimit
},
nil
,
nil
,
nil
)
)
// makeChain creates a chain of n blocks starting at and including parent.
...
...
params/protocol_params.go
浏览文件 @
26c6e3b2
...
...
@@ -39,8 +39,8 @@ var (
EcrecoverGas
=
big
.
NewInt
(
3000
)
//
Sha256WordGas
=
big
.
NewInt
(
12
)
//
MinGasLimit
=
big
.
NewInt
(
5000
)
// Minimum the gas limit may ever be.
GenesisGasLimit
=
big
.
NewInt
(
5000
)
// Gas limit of the Genesis block.
MinGasLimit
=
big
.
NewInt
(
5000
)
// Minimum the gas limit may ever be.
GenesisGasLimit
=
big
.
NewInt
(
3141592
)
// Gas limit of the Genesis block.
Sha3Gas
=
big
.
NewInt
(
30
)
// Once per SHA3 operation.
Sha256Gas
=
big
.
NewInt
(
60
)
//
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录