Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
b0e8337b
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b0e8337b
编写于
5月 06, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
start work on b1 vesting and network activation
上级
62fa1bfc
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
32 addition
and
5 deletion
+32
-5
contracts/eosio.system/delegate_bandwidth.cpp
contracts/eosio.system/delegate_bandwidth.cpp
+14
-1
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+2
-1
contracts/eosio.system/voting.cpp
contracts/eosio.system/voting.cpp
+12
-2
unittests/bootseq_tests.cpp
unittests/bootseq_tests.cpp
+4
-1
未找到文件。
contracts/eosio.system/delegate_bandwidth.cpp
浏览文件 @
b0e8337b
...
...
@@ -291,6 +291,17 @@ namespace eosiosystem {
}
}
// delegatebw
void
validate_b1_vesting
(
uint64_t
stake
)
{
const
int64_t
seconds_per_year
=
60
*
60
*
24
*
365
;
const
int64_t
base_time
=
1527811200
;
/// 2018-06-01
const
int64_t
end_time
=
seconds_per_year
*
10
+
1527811200
;
/// 2018-06-01
const
int64_t
max_claimable
=
100'000'000'0000ll
;
const
int64_t
claimable
=
int64_t
(
max_claimable
*
double
(
now
()
-
base_time
)
/
seconds_per_year
);
eosio_assert
(
max_claimable
-
claimable
<=
stake
,
"b1 can only claim their tokens over 10 years"
);
}
void
system_contract
::
undelegatebw
(
account_name
from
,
account_name
receiver
,
asset
unstake_net_quantity
,
asset
unstake_cpu_quantity
)
{
...
...
@@ -308,7 +319,9 @@ namespace eosiosystem {
_voters
.
modify
(
_voters
.
get
(
from
),
0
,
[
&
](
auto
&
v
)
{
v
.
staked
-=
uint64_t
(
total_refund
);
print
(
" vote weight: "
,
v
.
last_vote_weight
,
"
\n
"
);
if
(
from
==
N
(
b1
)
)
{
validate_b1_vesting
(
v
.
staked
);
}
});
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
b0e8337b
...
...
@@ -34,10 +34,11 @@ namespace eosiosystem {
block_timestamp
last_producer_schedule_update
=
0
;
eosio
::
asset
eos_bucket
;
eosio
::
asset
savings
;
int64_t
total_activiated_stake
=
0
;
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE_DERIVED
(
eosio_global_state
,
eosio_parameters
,
(
total_ram_bytes_reserved
)(
total_ram_stake
)
(
last_producer_schedule_update
)(
eos_bucket
)(
savings
)
)
(
last_producer_schedule_update
)(
eos_bucket
)(
savings
)
(
total_activiated_stake
)
)
};
struct
producer_info
{
...
...
contracts/eosio.system/voting.cpp
浏览文件 @
b0e8337b
...
...
@@ -71,7 +71,7 @@ namespace eosiosystem {
eosio
::
producer_schedule
schedule
;
schedule
.
producers
.
reserve
(
21
);
size_t
n
=
0
;
for
(
auto
it
=
idx
.
c
rbegin
();
it
!=
idx
.
cr
end
()
&&
n
<
21
&&
0
<
it
->
total_votes
;
++
it
)
{
for
(
auto
it
=
idx
.
c
begin
();
it
!=
idx
.
c
end
()
&&
n
<
21
&&
0
<
it
->
total_votes
;
++
it
)
{
if
(
it
->
active
()
&&
it
->
time_became_active
==
0
)
{
...
...
@@ -104,13 +104,14 @@ namespace eosiosystem {
}
// should use producer_schedule_type from libraries/chain/include/eosio/chain/producer_schedule.hpp
bytes
packed_schedule
=
pack
(
schedule
);
bytes
packed_schedule
=
pack
(
schedule
.
producers
);
set_active_producers
(
packed_schedule
.
data
(),
packed_schedule
.
size
()
);
// not voted on
_gstate
.
last_producer_schedule_update
=
block_time
;
}
/**
* @pre producers must be sorted from lowest to highest and must be registered and active
* @pre if proxy is set then no producers can be voted for
...
...
@@ -145,6 +146,15 @@ namespace eosiosystem {
auto
voter
=
_voters
.
find
(
voter_name
);
eosio_assert
(
voter
!=
_voters
.
end
(),
"user must stake before they can vote"
);
/// staking creates voter object
/**
* The first time someone votes we calculate and set last_vote_weight, since they cannot unstake until
* after total_activiated_stake hits threshold, we can use last_vote_weight to determine that this is
* their first vote and should consider their stake activated.
*/
if
(
voter
->
last_vote_weight
<=
0.0
)
{
_gstate
.
total_activiated_stake
+=
voter
->
staked
;
}
auto
weight
=
int64_t
(
now
()
/
(
seconds_per_day
*
7
))
/
double
(
52
);
double
new_vote_weight
=
double
(
voter
->
staked
)
*
std
::
pow
(
2
,
weight
);
...
...
unittests/bootseq_tests.cpp
浏览文件 @
b0e8337b
...
...
@@ -284,10 +284,13 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
produce_blocks
(
100
);
votepro
(
N
(
b1
),
{
N
(
p1
),
N
(
p2
)}
);
votepro
(
N
(
whale2
),
{
N
(
p2
),
N
(
p3
)}
);
votepro
(
N
(
whale3
),
{
N
(
p2
),
N
(
p4
),
N
(
p5
)}
);
wlog
(
"pb"
);
produce_block
(
fc
::
days
(
1
)
);
produce_block
s
(
10
);
wdump
((
control
->
head_block_state
()
->
active_schedule
));
return
;
produce_blocks
(
7000
);
/// produce blocks until virutal bandwidth can acomadate a small user
wlog
(
"minow"
);
votepro
(
N
(
minow1
),
{
N
(
p1
),
N
(
p2
)}
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录