Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
e48dde71
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,发现更多精彩内容 >>
提交
e48dde71
编写于
3月 28, 2018
作者:
A
arhag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove redundant validate_block_header when generating a block #1755
上级
6144bdfd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
17 deletion
+16
-17
libraries/chain/chain_controller.cpp
libraries/chain/chain_controller.cpp
+14
-14
libraries/chain/include/eosio/chain/chain_controller.hpp
libraries/chain/include/eosio/chain/chain_controller.hpp
+2
-3
未找到文件。
libraries/chain/chain_controller.cpp
浏览文件 @
e48dde71
...
...
@@ -256,7 +256,7 @@ transaction_trace chain_controller::push_transaction(const packed_transaction& t
});
}
FC_CAPTURE_AND_RETHROW
()
}
transaction_trace
chain_controller
::
_push_transaction
(
const
packed_transaction
&
trx
)
transaction_trace
chain_controller
::
_push_transaction
(
const
packed_transaction
&
trx
)
{
try
{
transaction_metadata
mtrx
(
trx
,
get_chain_id
(),
head_block_time
());
...
...
@@ -339,7 +339,7 @@ block_header chain_controller::head_block_header() const
{
auto
b
=
_fork_db
.
fetch_block
(
head_block_id
());
if
(
b
)
return
b
->
data
;
if
(
auto
head_block
=
fetch_block_by_id
(
head_block_id
()))
return
*
head_block
;
return
block_header
();
...
...
@@ -467,9 +467,8 @@ void chain_controller::_apply_cycle_trace( const cycle_trace& res )
* After applying all transactions successfully we can update
* the current block time, block number, producer stats, etc
*/
void
chain_controller
::
_finalize_block
(
const
block_trace
&
trace
)
{
try
{
void
chain_controller
::
_finalize_block
(
const
block_trace
&
trace
,
const
producer_object
&
signing_producer
)
{
try
{
const
auto
&
b
=
trace
.
block
;
const
producer_object
&
signing_producer
=
validate_block_header
(
_skip_flags
,
b
);
update_global_properties
(
b
);
update_global_dynamic_data
(
b
);
...
...
@@ -506,6 +505,7 @@ signed_block chain_controller::_generate_block( block_timestamp_type when,
{
try
{
try
{
FC_ASSERT
(
head_block_time
()
<
(
fc
::
time_point
)
when
,
"block must be generated at a timestamp after the head block time"
);
uint32_t
skip
=
_skip_flags
;
uint32_t
slot_num
=
get_slot_at_time
(
when
);
FC_ASSERT
(
slot_num
>
0
);
...
...
@@ -541,7 +541,7 @@ signed_block chain_controller::_generate_block( block_timestamp_type when,
if
(
!
(
skip
&
skip_producer_signature
)
)
_pending_block
->
sign
(
block_signing_key
);
_finalize_block
(
*
_pending_block_trace
);
_finalize_block
(
*
_pending_block_trace
,
producer_obj
);
_pending_block_session
->
push
();
...
...
@@ -628,6 +628,8 @@ void chain_controller::__apply_block(const signed_block& next_block)
uint32_t
skip
=
_skip_flags
;
const
producer_object
&
signing_producer
=
validate_block_header
(
skip
,
next_block
);
/*
FC_ASSERT((skip & skip_merkle_check)
|| next_block.transaction_merkle_root == next_block.calculate_merkle_root(),
...
...
@@ -635,8 +637,6 @@ void chain_controller::__apply_block(const signed_block& next_block)
("calc",next_block.calculate_merkle_root())("next_block",next_block)("id",next_block.id()));
*/
const
producer_object
&
signing_producer
=
validate_block_header
(
skip
,
next_block
);
/// regions must be listed in order
for
(
uint32_t
i
=
1
;
i
<
next_block
.
regions
.
size
();
++
i
)
FC_ASSERT
(
next_block
.
regions
[
i
-
1
].
region
<
next_block
.
regions
[
i
].
region
);
...
...
@@ -767,7 +767,7 @@ void chain_controller::__apply_block(const signed_block& next_block)
FC_ASSERT
(
next_block
.
action_mroot
==
next_block_trace
.
calculate_action_merkle_root
());
FC_ASSERT
(
transaction_metadata
::
calculate_transaction_merkle_root
(
input_metas
)
==
next_block
.
transaction_mroot
,
"merkle root does not match"
);
_finalize_block
(
next_block_trace
);
_finalize_block
(
next_block_trace
,
signing_producer
);
}
FC_CAPTURE_AND_RETHROW
(
(
next_block
.
block_num
())
)
}
flat_set
<
public_key_type
>
chain_controller
::
get_required_keys
(
const
transaction
&
trx
,
...
...
@@ -872,8 +872,8 @@ void chain_controller::validate_uniqueness( const transaction& trx )const {
EOS_ASSERT
(
transaction
==
nullptr
,
tx_duplicate
,
"transaction is not unique"
);
}
void
chain_controller
::
record_transaction
(
const
transaction
&
trx
)
{
void
chain_controller
::
record_transaction
(
const
transaction
&
trx
)
{
try
{
_db
.
create
<
transaction_object
>
([
&
](
transaction_object
&
transaction
)
{
transaction
.
trx_id
=
trx
.
id
();
...
...
@@ -881,10 +881,10 @@ void chain_controller::record_transaction(const transaction& trx)
});
}
catch
(
...
)
{
EOS_ASSERT
(
false
,
transaction_exception
,
"duplicate transaction ${id}"
,
"duplicate transaction ${id}"
,
(
"id"
,
trx
.
id
()
)
);
}
}
}
void
chain_controller
::
validate_tapos
(
const
transaction
&
trx
)
const
{
...
...
@@ -1473,7 +1473,7 @@ static void log_handled_exceptions(const transaction& trx) {
}
FC_CAPTURE_AND_LOG
((
trx
));
}
transaction_trace
chain_controller
::
__apply_transaction
(
transaction_metadata
&
meta
)
transaction_trace
chain_controller
::
__apply_transaction
(
transaction_metadata
&
meta
)
{
try
{
transaction_trace
result
(
meta
.
id
);
...
...
@@ -1517,7 +1517,7 @@ transaction_trace chain_controller::__apply_transaction( transaction_metadata& m
return
result
;
}
FC_CAPTURE_AND_RETHROW
()
}
transaction_trace
chain_controller
::
_apply_transaction
(
transaction_metadata
&
meta
)
transaction_trace
chain_controller
::
_apply_transaction
(
transaction_metadata
&
meta
)
{
try
{
try
{
auto
temp_session
=
_db
.
start_undo_session
(
true
);
...
...
libraries/chain/include/eosio/chain/chain_controller.hpp
浏览文件 @
e48dde71
...
...
@@ -267,7 +267,7 @@ namespace eosio { namespace chain {
uint32_t
head_block_num
()
const
;
block_id_type
head_block_id
()
const
;
account_name
head_block_producer
()
const
;
block_header
head_block_header
()
const
;
block_header
head_block_header
()
const
;
uint32_t
last_irreversible_block_num
()
const
;
...
...
@@ -387,7 +387,6 @@ namespace eosio { namespace chain {
///Steps involved in applying a new block
///@{
const
producer_object
&
validate_block_header
(
uint32_t
skip
,
const
signed_block
&
next_block
)
const
;
const
producer_object
&
_validate_block_header
(
const
signed_block
&
next_block
)
const
;
void
create_block_summary
(
const
signed_block
&
next_block
);
void
update_global_properties
(
const
signed_block
&
b
);
...
...
@@ -407,7 +406,7 @@ namespace eosio { namespace chain {
void
_start_pending_shard
();
void
_finalize_pending_cycle
();
void
_apply_cycle_trace
(
const
cycle_trace
&
trace
);
void
_finalize_block
(
const
block_trace
&
b
);
void
_finalize_block
(
const
block_trace
&
b
,
const
producer_object
&
signing_producer
);
transaction
_get_on_block_transaction
();
void
_apply_on_block_transaction
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录