Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
692c49a8
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,发现更多精彩内容 >>
提交
692c49a8
编写于
6月 29, 2017
作者:
N
Nathan Hourt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup in chain_controller
Remove the node_property_object, and other cruft.
上级
8eb17ff1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
104 deletion
+12
-104
libraries/chain/chain_controller.cpp
libraries/chain/chain_controller.cpp
+12
-35
libraries/chain/include/eos/chain/chain_controller.hpp
libraries/chain/include/eos/chain/chain_controller.hpp
+0
-21
libraries/chain/include/eos/chain/node_property_object.hpp
libraries/chain/include/eos/chain/node_property_object.hpp
+0
-48
未找到文件。
libraries/chain/chain_controller.cpp
浏览文件 @
692c49a8
...
...
@@ -178,9 +178,9 @@ bool chain_controller::push_block(const signed_block& new_block, uint32_t skip)
bool
chain_controller
::
_push_block
(
const
signed_block
&
new_block
)
{
try
{
uint32_t
skip
=
get_node_properties
().
skip_flags
;
uint32_t
skip
=
_
skip_flags
;
if
(
!
(
skip
&
skip_fork_db
))
{
/// TODO: if the block is greater than the head block and before the next maitenance interval
/// TODO: if the block is greater than the head block and before the next mai
n
tenance interval
// verify that the block signer is in the current set of active producers.
shared_ptr
<
fork_item
>
new_head
=
_fork_db
.
push_block
(
new_block
);
...
...
@@ -259,10 +259,8 @@ bool chain_controller::_push_block(const signed_block& new_block)
void
chain_controller
::
push_transaction
(
const
SignedTransaction
&
trx
,
uint32_t
skip
)
{
try
{
with_skip_flags
(
skip
,
[
&
]()
{
with_producing
([
&
](){
_db
.
with_write_lock
([
&
]()
{
_push_transaction
(
trx
);
});
_db
.
with_write_lock
([
&
]()
{
_push_transaction
(
trx
);
});
});
}
FC_CAPTURE_AND_RETHROW
((
trx
))
}
...
...
@@ -293,15 +291,13 @@ signed_block chain_controller::generate_block(
uint32_t
skip
/* = 0 */
)
{
try
{
return
with_producing
(
[
&
]()
{
return
with_skip_flags
(
skip
,
[
&
](){
auto
b
=
_db
.
with_write_lock
(
[
&
](){
return
_generate_block
(
when
,
producer
,
block_signing_private_key
);
});
push_block
(
b
);
return
b
;
return
with_skip_flags
(
skip
,
[
&
](){
auto
b
=
_db
.
with_write_lock
(
[
&
](){
return
_generate_block
(
when
,
producer
,
block_signing_private_key
);
});
});
push_block
(
b
,
skip
);
return
b
;
});
}
FC_CAPTURE_AND_RETHROW
(
(
when
)
)
}
signed_block
chain_controller
::
_generate_block
(
...
...
@@ -311,7 +307,7 @@ signed_block chain_controller::_generate_block(
)
{
try
{
uint32_t
skip
=
get_node_properties
().
skip_flags
;
uint32_t
skip
=
_
skip_flags
;
uint32_t
slot_num
=
get_slot_at_time
(
when
);
FC_ASSERT
(
slot_num
>
0
);
AccountName
scheduled_producer
=
get_scheduled_producer
(
slot_num
);
...
...
@@ -454,11 +450,10 @@ void chain_controller::apply_block(const signed_block& next_block, uint32_t skip
with_skip_flags
(
skip
,
[
&
](){
_apply_block
(
next_block
);
});
}
void
chain_controller
::
_apply_block
(
const
signed_block
&
next_block
)
{
try
{
uint32_t
next_block_num
=
next_block
.
block_num
();
uint32_t
skip
=
get_node_properties
().
skip_flags
;
uint32_t
skip
=
_
skip_flags
;
FC_ASSERT
((
skip
&
skip_merkle_check
)
||
next_block
.
transaction_merkle_root
==
next_block
.
calculate_merkle_root
(),
""
,
(
"next_block.transaction_merkle_root"
,
next_block
.
transaction_merkle_root
)
...
...
@@ -752,18 +747,10 @@ types::AccountName chain_controller::head_block_producer() const {
return
{};
}
const
node_property_object
&
chain_controller
::
get_node_properties
()
const
{
return
_node_property_object
;
}
const
producer_object
&
chain_controller
::
get_producer
(
const
types
::
AccountName
&
ownerName
)
const
{
return
_db
.
get
<
producer_object
,
by_owner
>
(
ownerName
);
}
node_property_object
&
chain_controller
::
node_properties
()
{
return
_node_property_object
;
}
uint32_t
chain_controller
::
last_irreversible_block_num
()
const
{
return
get_dynamic_global_properties
().
last_irreversible_block_num
;
}
...
...
@@ -785,16 +772,6 @@ void chain_controller::initialize_chain(chain_initializer_interface& starter)
{
try
{
if
(
!
_db
.
find
<
global_property_object
>
())
{
_db
.
with_write_lock
([
this
,
&
starter
]
{
struct
auth_inhibitor
{
auth_inhibitor
(
chain_controller
&
db
)
:
db
(
db
),
old_flags
(
db
.
node_properties
().
skip_flags
)
{
db
.
node_properties
().
skip_flags
|=
skip_authority_check
;
}
~
auth_inhibitor
()
{
db
.
node_properties
().
skip_flags
=
old_flags
;
}
private:
chain_controller
&
db
;
uint32_t
old_flags
;
}
inhibitor
(
*
this
);
auto
initial_timestamp
=
starter
.
get_chain_start_time
();
FC_ASSERT
(
initial_timestamp
!=
time_point_sec
(),
"Must initialize genesis timestamp."
);
FC_ASSERT
(
initial_timestamp
.
sec_since_epoch
()
%
config
::
BlockIntervalSeconds
==
0
,
...
...
libraries/chain/include/eos/chain/chain_controller.hpp
浏览文件 @
692c49a8
...
...
@@ -24,7 +24,6 @@
#pragma once
#include <eos/chain/global_property_object.hpp>
#include <eos/chain/account_object.hpp>
#include <eos/chain/node_property_object.hpp>
#include <eos/chain/fork_database.hpp>
#include <eos/chain/block_log.hpp>
...
...
@@ -149,16 +148,6 @@ namespace eos { namespace chain {
return
f
();
}
template
<
typename
Function
>
auto
with_producing
(
Function
&&
f
)
->
decltype
((
*
((
Function
*
)
nullptr
))())
{
auto
old_producing
=
_producing
;
auto
on_exit
=
fc
::
make_scoped_exit
(
[
&
](){
_producing
=
old_producing
;
}
);
_producing
=
true
;
return
f
();
}
template
<
typename
Function
>
auto
without_pending_transactions
(
Function
&&
f
)
->
decltype
((
*
((
Function
*
)
nullptr
))())
{
...
...
@@ -174,13 +163,9 @@ namespace eos { namespace chain {
return
f
();
}
void
pop_block
();
void
clear_pending
();
/**
* @brief Get the producer scheduled for block production in a slot.
*
...
...
@@ -219,7 +204,6 @@ namespace eos { namespace chain {
const
global_property_object
&
get_global_properties
()
const
;
const
dynamic_global_property_object
&
get_dynamic_global_properties
()
const
;
const
node_property_object
&
get_node_properties
()
const
;
const
producer_object
&
get_producer
(
const
AccountName
&
ownerName
)
const
;
time_point_sec
head_block_time
()
const
;
...
...
@@ -229,8 +213,6 @@ namespace eos { namespace chain {
uint32_t
block_interval
()
const
{
return
config
::
BlockIntervalSeconds
;
}
node_property_object
&
node_properties
();
uint32_t
last_irreversible_block_num
()
const
;
protected:
...
...
@@ -297,14 +279,11 @@ namespace eos { namespace chain {
optional
<
database
::
session
>
_pending_tx_session
;
deque
<
SignedTransaction
>
_pending_transactions
;
bool
_producing
=
false
;
bool
_pushing
=
false
;
uint64_t
_skip_flags
=
0
;
flat_map
<
uint32_t
,
block_id_type
>
_checkpoints
;
node_property_object
_node_property_object
;
typedef
pair
<
AccountName
,
TypeName
>
handler_key
;
map
<
AccountName
,
map
<
handler_key
,
message_validate_handler
>
>
message_validate_handlers
;
map
<
AccountName
,
map
<
handler_key
,
precondition_validate_handler
>
>
precondition_validate_handlers
;
...
...
libraries/chain/include/eos/chain/node_property_object.hpp
已删除
100644 → 0
浏览文件 @
8eb17ff1
/*
* Copyright (c) 2017, Respective Authors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#include <eos/chain/types.hpp>
namespace
eos
{
namespace
chain
{
/**
* @brief Contains per-node database configuration.
*
* Transactions are evaluated differently based on per-node state.
* Settings here may change based on whether the node is syncing or up-to-date.
* Or whether the node is a producer node. Or if we're processing a
* transaction in a producer-signed block vs. a fresh transaction
* from the p2p network. Or configuration-specified tradeoffs of
* performance/hardfork resilience vs. paranoia.
*/
class
node_property_object
{
public:
node_property_object
(){}
~
node_property_object
(){}
uint32_t
skip_flags
=
0
;
std
::
map
<
block_id_type
,
std
::
vector
<
fc
::
variant_object
>
>
debug_updates
;
};
}
}
// eos::chain
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录