Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
6e3eb5dc
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,发现更多精彩内容 >>
未验证
提交
6e3eb5dc
编写于
5月 30, 2018
作者:
D
Daniel Larimer
提交者:
GitHub
5月 30, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3595 from EOSIO/gh#3567-bnet-shutdown
Gh#3567 bnet additional threading fixes
上级
dc1fa733
d3a77774
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
24 deletion
+24
-24
plugins/bnet_plugin/bnet_plugin.cpp
plugins/bnet_plugin/bnet_plugin.cpp
+24
-24
未找到文件。
plugins/bnet_plugin/bnet_plugin.cpp
浏览文件 @
6e3eb5dc
...
...
@@ -1055,26 +1055,22 @@ namespace eosio {
class
bnet_plugin_impl
:
public
std
::
enable_shared_from_this
<
bnet_plugin_impl
>
{
public:
bnet_plugin_impl
()
{
_peer_pk
=
fc
::
crypto
::
private_key
::
generate
();
_peer_id
=
_peer_pk
.
get_public_key
();
}
string
_bnet_endpoint_address
=
"0.0.0.0"
;
uint16_t
_bnet_endpoint_port
=
4321
;
bool
_request_trx
=
true
;
public_key_type
_peer_id
;
private_key_type
_peer_pk
;
/// one time random key to identify this process
bnet_plugin_impl
()
=
default
;
const
private_key_type
_peer_pk
=
fc
::
crypto
::
private_key
::
generate
();
/// one time random key to identify this process
public_key_type
_peer_id
=
_peer_pk
.
get_public_key
();
string
_bnet_endpoint_address
=
"0.0.0.0"
;
uint16_t
_bnet_endpoint_port
=
4321
;
bool
_request_trx
=
true
;
std
::
vector
<
std
::
string
>
_connect_to_peers
;
/// list of peers to connect to
std
::
vector
<
std
::
thread
>
_socket_threads
;
int32_t
_num_threads
=
1
;
std
::
unique_ptr
<
boost
::
asio
::
io_context
>
_ioc
;
// lifetime guarded by shared_ptr of bnet_plugin_impl
std
::
shared_ptr
<
listener
>
_listener
;
std
::
shared_ptr
<
boost
::
asio
::
deadline_timer
>
_timer
;
std
::
vector
<
std
::
string
>
_connect_to_peers
;
/// list of peers to connect to
std
::
vector
<
std
::
thread
>
_socket_threads
;
int32_t
_num_threads
=
1
;
std
::
map
<
const
session
*
,
std
::
weak_ptr
<
session
>
>
_sessions
;
std
::
unique_ptr
<
boost
::
asio
::
io_context
>
_ioc
;
// lifetime guarded by shared_ptr of bnet_plugin_impl
std
::
shared_ptr
<
listener
>
_listener
;
std
::
shared_ptr
<
boost
::
asio
::
deadline_timer
>
_timer
;
// only access on app io_service
std
::
map
<
const
session
*
,
std
::
weak_ptr
<
session
>
>
_sessions
;
// only access on app io_service
channels
::
irreversible_block
::
channel_type
::
handle
_on_irb_handle
;
channels
::
accepted_block
::
channel_type
::
handle
_on_accepted_block_handle
;
...
...
@@ -1091,6 +1087,7 @@ namespace eosio {
}
void
on_session_close
(
const
session
*
s
)
{
if
(
!
app
().
get_io_service
().
get_executor
().
running_in_this_thread
()
)
{
elog
(
"wrong strand"
);
}
auto
itr
=
_sessions
.
find
(
s
);
if
(
_sessions
.
end
()
!=
itr
)
_sessions
.
erase
(
itr
);
...
...
@@ -1098,14 +1095,16 @@ namespace eosio {
template
<
typename
Call
>
void
for_each_session
(
Call
callback
)
{
for
(
const
auto
&
item
:
_sessions
)
{
if
(
auto
ses
=
item
.
second
.
lock
()
)
{
ses
->
_ios
.
post
(
boost
::
asio
::
bind_executor
(
ses
->
_strand
,
[
ses
,
cb
=
callback
](){
cb
(
ses
);
}
));
app
().
get_io_service
().
post
([
this
,
callback
=
callback
]
{
for
(
const
auto
&
item
:
_sessions
)
{
if
(
auto
ses
=
item
.
second
.
lock
())
{
ses
->
_ios
.
post
(
boost
::
asio
::
bind_executor
(
ses
->
_strand
,
[
ses
,
cb
=
callback
]()
{
cb
(
ses
);
}
));
}
}
}
}
);
}
void
on_accepted_transaction
(
transaction_metadata_ptr
trx
)
{
...
...
@@ -1152,6 +1151,7 @@ namespace eosio {
};
void
on_reconnect_peers
()
{
if
(
!
app
().
get_io_service
().
get_executor
().
running_in_this_thread
()
)
{
elog
(
"wrong strand"
);
}
for
(
const
auto
&
peer
:
_connect_to_peers
)
{
bool
found
=
false
;
for
(
const
auto
&
con
:
_sessions
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录