Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
21e5edaf
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,发现更多精彩内容 >>
提交
21e5edaf
编写于
11月 17, 2017
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
progress toward updating block producers with block header
上级
635abdb6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
74 addition
and
9 deletion
+74
-9
libraries/chain/chain_controller.cpp
libraries/chain/chain_controller.cpp
+60
-4
libraries/chain/include/eosio/chain/contracts/producer_objects.hpp
.../chain/include/eosio/chain/contracts/producer_objects.hpp
+2
-1
libraries/chain/include/eosio/chain/global_property_object.hpp
...ries/chain/include/eosio/chain/global_property_object.hpp
+11
-4
libraries/chain/include/eosio/chain/producer_object.hpp
libraries/chain/include/eosio/chain/producer_object.hpp
+1
-0
未找到文件。
libraries/chain/chain_controller.cpp
浏览文件 @
21e5edaf
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include <eosio/chain/permission_link_object.hpp>
#include <eosio/chain/permission_link_object.hpp>
#include <eosio/chain/authority_checker.hpp>
#include <eosio/chain/authority_checker.hpp>
#include <eosio/chain/contracts/chain_initializer.hpp>
#include <eosio/chain/contracts/chain_initializer.hpp>
#include <eosio/chain/contracts/producer_objects.hpp>
#include <eosio/chain/wasm_interface.hpp>
#include <eosio/chain/wasm_interface.hpp>
...
@@ -309,11 +310,20 @@ signed_block chain_controller::_generate_block( block_timestamp_type when,
...
@@ -309,11 +310,20 @@ signed_block chain_controller::_generate_block( block_timestamp_type when,
_pending_block
->
producer
=
producer_obj
.
owner
;
_pending_block
->
producer
=
producer_obj
.
owner
;
_pending_block
->
previous
=
head_block_id
();
_pending_block
->
previous
=
head_block_id
();
const
auto
&
gpo
=
get_global_properties
();
if
(
gpo
.
pending_active_producers
.
size
()
&&
gpo
.
pending_active_producers
.
back
().
first
==
_pending_block
->
block_num
()
)
{
_pending_block
->
new_producers
=
gpo
.
pending_active_producers
.
back
().
second
;
}
if
(
!
(
skip
&
skip_producer_signature
)
)
if
(
!
(
skip
&
skip_producer_signature
)
)
_pending_block
->
sign
(
block_signing_key
);
_pending_block
->
sign
(
block_signing_key
);
_finalize_block
(
*
_pending_block
);
_finalize_block
(
*
_pending_block
);
_pending_block_session
->
push
();
_pending_block_session
->
push
();
auto
result
=
move
(
*
_pending_block
);
auto
result
=
move
(
*
_pending_block
);
...
@@ -751,15 +761,35 @@ void chain_controller::create_block_summary(const signed_block& next_block) {
...
@@ -751,15 +761,35 @@ void chain_controller::create_block_summary(const signed_block& next_block) {
});
});
}
}
void
chain_controller
::
update_global_properties
(
const
signed_block
&
b
)
{
void
chain_controller
::
update_global_properties
(
const
signed_block
&
b
)
{
try
{
// If we're at the end of a round, update the BlockchainConfiguration, producer schedule
// If we're at the end of a round, update the BlockchainConfiguration, producer schedule
// and "producers" special account authority
// and "producers" special account authority
if
(
b
.
block_num
()
%
config
::
blocks_per_round
==
0
)
{
if
(
b
.
block_num
()
%
config
::
blocks_per_round
==
0
)
{
const
auto
&
producers_by_vote
=
_db
.
get_index
<
contracts
::
producer_votes_multi_index
,
contracts
::
by_votes
>
();
auto
itr
=
producers_by_vote
.
begin
();
producer_schedule_type
schedule
;
uint32_t
count
=
0
;
while
(
itr
!=
producers_by_vote
.
end
()
)
{
schedule
[
count
].
producer_name
=
itr
->
owner_name
;
wdump
((
itr
->
owner_name
));
schedule
[
count
].
block_signing_key
=
get_producer
(
itr
->
owner_name
).
signing_key
;
idump
((
itr
->
owner_name
));
++
itr
;
}
const
auto
&
gpo
=
get_global_properties
();
if
(
schedule
!=
gpo
.
active_producers
)
{
_db
.
modify
(
gpo
,
[
&
](
auto
&
props
)
{
if
(
props
.
pending_active_producers
.
size
()
&&
props
.
pending_active_producers
.
back
().
first
==
head_block_num
()
+
1
)
props
.
pending_active_producers
.
back
().
second
=
schedule
;
else
props
.
pending_active_producers
.
push_back
(
make_pair
(
head_block_num
()
+
1
,
schedule
)
);
});
}
/*
/*
auto schedule = _admin->get_next_round(_db);
auto schedule = _admin->get_next_round(_db);
auto config = _admin->get_blockchain_configuration(_db, schedule);
auto config = _admin->get_blockchain_configuration(_db, schedule);
const auto& gpo = get_global_properties();
_db.modify(gpo, [schedule = std::move(schedule), config = std::move(config)] (global_property_object& gpo) {
_db.modify(gpo, [schedule = std::move(schedule), config = std::move(config)] (global_property_object& gpo) {
gpo.active_producers = std::move(schedule);
gpo.active_producers = std::move(schedule);
gpo.configuration = std::move(config);
gpo.configuration = std::move(config);
...
@@ -777,7 +807,7 @@ void chain_controller::update_global_properties(const signed_block& b) {
...
@@ -777,7 +807,7 @@ void chain_controller::update_global_properties(const signed_block& b) {
});
});
*/
*/
}
}
}
}
FC_CAPTURE_AND_RETHROW
()
}
void
chain_controller
::
add_checkpoints
(
const
flat_map
<
uint32_t
,
block_id_type
>&
checkpts
)
{
void
chain_controller
::
add_checkpoints
(
const
flat_map
<
uint32_t
,
block_id_type
>&
checkpts
)
{
for
(
const
auto
&
i
:
checkpts
)
for
(
const
auto
&
i
:
checkpts
)
...
@@ -1050,7 +1080,7 @@ void chain_controller::update_last_irreversible_block()
...
@@ -1050,7 +1080,7 @@ void chain_controller::update_last_irreversible_block()
if
(
old_last_irreversible_block
)
if
(
old_last_irreversible_block
)
last_block_on_disk
=
old_last_irreversible_block
->
block_num
();
last_block_on_disk
=
old_last_irreversible_block
->
block_num
();
if
(
last_block_on_disk
<
new_last_irreversible_block_num
)
if
(
last_block_on_disk
<
new_last_irreversible_block_num
)
{
for
(
auto
block_to_write
=
last_block_on_disk
+
1
;
for
(
auto
block_to_write
=
last_block_on_disk
+
1
;
block_to_write
<=
new_last_irreversible_block_num
;
block_to_write
<=
new_last_irreversible_block_num
;
++
block_to_write
)
{
++
block_to_write
)
{
...
@@ -1059,6 +1089,32 @@ void chain_controller::update_last_irreversible_block()
...
@@ -1059,6 +1089,32 @@ void chain_controller::update_last_irreversible_block()
_block_log
.
append
(
*
block
);
_block_log
.
append
(
*
block
);
applied_irreversible_block
(
*
block
);
applied_irreversible_block
(
*
block
);
}
}
}
if
(
new_last_irreversible_block_num
>
last_block_on_disk
)
{
/// TODO: use upper / lower bound to find
optional
<
producer_schedule_type
>
new_producer_schedule
;
for
(
const
auto
&
item
:
gpo
.
pending_active_producers
)
{
if
(
item
.
first
<
new_last_irreversible_block_num
)
{
new_producer_schedule
=
item
.
second
;
}
}
if
(
new_producer_schedule
)
{
_db
.
modify
(
gpo
,
[
&
](
auto
&
props
){
/// TODO: use upper / lower bound to remove range
while
(
gpo
.
pending_active_producers
.
size
()
)
{
if
(
gpo
.
pending_active_producers
.
front
().
first
<
new_last_irreversible_block_num
)
{
props
.
pending_active_producers
.
erase
(
props
.
pending_active_producers
.
begin
());
}
}
for
(
const
auto
&
n
:
*
new_producer_schedule
)
{
wdump
((
name
(
n
.
producer_name
))(
n
.
block_signing_key
));
}
//props.active_producers = *new_producer_schedule;
});
}
}
// Trim fork_database and undo histories
// Trim fork_database and undo histories
_fork_db
.
set_max_size
(
head_block_num
()
-
new_last_irreversible_block_num
+
1
);
_fork_db
.
set_max_size
(
head_block_num
()
-
new_last_irreversible_block_num
+
1
);
...
...
libraries/chain/include/eosio/chain/contracts/producer_objects.hpp
浏览文件 @
21e5edaf
...
@@ -138,7 +138,8 @@ using producer_votes_multi_index = chainbase::shared_multi_index_container<
...
@@ -138,7 +138,8 @@ using producer_votes_multi_index = chainbase::shared_multi_index_container<
composite_key
<
producer_votes_object
,
composite_key
<
producer_votes_object
,
member
<
producer_votes_object
,
share_type
,
&
producer_votes_object
::
votes
>
,
member
<
producer_votes_object
,
share_type
,
&
producer_votes_object
::
votes
>
,
member
<
producer_votes_object
,
producer_votes_object
::
id_type
,
&
producer_votes_object
::
id
>
member
<
producer_votes_object
,
producer_votes_object
::
id_type
,
&
producer_votes_object
::
id
>
>
>
,
composite_key_compare
<
std
::
greater
<
share_type
>
,
std
::
less
<
producer_votes_object
::
id_type
>
>
>
>
>
>
>
;
>
;
...
...
libraries/chain/include/eosio/chain/global_property_object.hpp
浏览文件 @
21e5edaf
...
@@ -25,11 +25,18 @@ namespace eosio { namespace chain {
...
@@ -25,11 +25,18 @@ namespace eosio { namespace chain {
*/
*/
class
global_property_object
:
public
chainbase
::
object
<
global_property_object_type
,
global_property_object
>
class
global_property_object
:
public
chainbase
::
object
<
global_property_object_type
,
global_property_object
>
{
{
OBJECT_CTOR
(
global_property_object
)
OBJECT_CTOR
(
global_property_object
,
(
pending_active_producers
)
)
id_type
id
;
id_type
id
;
chain_config
configuration
;
chain_config
configuration
;
producer_schedule_type
active_producers
;
producer_schedule_type
active_producers
;
/** every block that has change in producer schedule gets inserted into this list, this includes
* all blocks that see a change in producer signing keys or vote order.
*
* TODO: consider moving this to a more effeicent datatype
*/
shared_vector
<
pair
<
block_num_type
,
producer_schedule_type
>
>
pending_active_producers
;
};
};
...
...
libraries/chain/include/eosio/chain/producer_object.hpp
浏览文件 @
21e5edaf
...
@@ -19,6 +19,7 @@ class producer_object : public chainbase::object<producer_object_type, producer_
...
@@ -19,6 +19,7 @@ class producer_object : public chainbase::object<producer_object_type, producer_
int64_t
total_missed
=
0
;
int64_t
total_missed
=
0
;
uint32_t
last_confirmed_block_num
=
0
;
uint32_t
last_confirmed_block_num
=
0
;
/// The blockchain configuration values this producer recommends
/// The blockchain configuration values this producer recommends
chain_config
configuration
;
chain_config
configuration
;
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录