Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
40caeaa3
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,发现更多精彩内容 >>
提交
40caeaa3
编写于
9月 09, 2017
作者:
P
Phil Mesnier
提交者:
GitHub
9月 09, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #388 from EOSIO/p2p-linux
P2P Linux platform fixes
上级
b327cafb
421d06a6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
17 deletion
+20
-17
plugins/net_plugin/net_plugin.cpp
plugins/net_plugin/net_plugin.cpp
+20
-17
未找到文件。
plugins/net_plugin/net_plugin.cpp
浏览文件 @
40caeaa3
...
@@ -97,14 +97,16 @@ namespace eos {
...
@@ -97,14 +97,16 @@ namespace eos {
class
connection
:
public
std
::
enable_shared_from_this
<
connection
>
{
class
connection
:
public
std
::
enable_shared_from_this
<
connection
>
{
public:
public:
const
size_t
kBufferSize
{
1024
*
1024
*
4
};
connection
(
string
endpoint
)
connection
(
string
endpoint
)
:
block_state
(),
:
block_state
(),
trx_state
(),
trx_state
(),
sync_received
(),
sync_received
(),
sync_requested
(),
sync_requested
(),
socket
(
std
::
make_shared
<
tcp
::
socket
>
(
std
::
ref
(
app
().
get_io_service
()
))),
socket
(
std
::
make_shared
<
tcp
::
socket
>
(
std
::
ref
(
app
().
get_io_service
()
))),
pending_message_size
(),
pending_message_size
(
0
),
pending_message_buffer
(),
pending_message_buffer
(
kBufferSize
),
send_buffer
(
kBufferSize
),
remote_node_id
(),
remote_node_id
(),
last_handshake
(),
last_handshake
(),
out_queue
(),
out_queue
(),
...
@@ -122,8 +124,9 @@ namespace eos {
...
@@ -122,8 +124,9 @@ namespace eos {
sync_received
(),
sync_received
(),
sync_requested
(),
sync_requested
(),
socket
(
s
),
socket
(
s
),
pending_message_size
(),
pending_message_size
(
0
),
pending_message_buffer
(),
pending_message_buffer
(
kBufferSize
),
send_buffer
(
kBufferSize
),
remote_node_id
(),
remote_node_id
(),
last_handshake
(),
last_handshake
(),
out_queue
(),
out_queue
(),
...
@@ -131,7 +134,7 @@ namespace eos {
...
@@ -131,7 +134,7 @@ namespace eos {
syncing
(
false
),
syncing
(
false
),
peer_addr
()
peer_addr
()
{
{
wlog
(
"created
connection from client
"
);
wlog
(
"created
network connection
"
);
boost
::
asio
::
ip
::
tcp
::
no_delay
option
(
true
);
boost
::
asio
::
ip
::
tcp
::
no_delay
option
(
true
);
socket
->
set_option
(
option
);
socket
->
set_option
(
option
);
initialize
();
initialize
();
...
@@ -145,7 +148,6 @@ namespace eos {
...
@@ -145,7 +148,6 @@ namespace eos {
}
}
void
initialize
()
{
void
initialize
()
{
pending_message_buffer
.
resize
(
1024
*
1024
*
4
);
auto
*
rnd
=
remote_node_id
.
data
();
auto
*
rnd
=
remote_node_id
.
data
();
rnd
[
0
]
=
0
;
rnd
[
0
]
=
0
;
}
}
...
@@ -158,6 +160,8 @@ namespace eos {
...
@@ -158,6 +160,8 @@ namespace eos {
uint32_t
pending_message_size
;
uint32_t
pending_message_size
;
vector
<
char
>
pending_message_buffer
;
vector
<
char
>
pending_message_buffer
;
uint32_t
send_message_size
;
vector
<
char
>
send_buffer
;
vector
<
char
>
blk_buffer
;
vector
<
char
>
blk_buffer
;
size_t
message_size
;
size_t
message_size
;
...
@@ -215,14 +219,13 @@ namespace eos {
...
@@ -215,14 +219,13 @@ namespace eos {
}
}
auto
&
m
=
out_queue
.
front
();
auto
&
m
=
out_queue
.
front
();
vector
<
char
>
buffer
;
send_message_size
=
fc
::
raw
::
pack_size
(
m
);
uint32_t
size
=
fc
::
raw
::
pack_size
(
m
);
fc
::
datastream
<
char
*>
ds
(
send_buffer
.
data
(),
send_message_size
+
sizeof
(
send_message_size
)
);
buffer
.
resize
(
size
+
sizeof
(
uint32_t
)
);
ds
.
write
(
(
char
*
)
&
send_message_size
,
sizeof
(
send_message_size
)
);
fc
::
datastream
<
char
*>
ds
(
buffer
.
data
(),
buffer
.
size
()
);
ds
.
write
(
(
char
*
)
&
size
,
sizeof
(
size
)
);
fc
::
raw
::
pack
(
ds
,
m
);
fc
::
raw
::
pack
(
ds
,
m
);
boost
::
asio
::
async_write
(
*
socket
,
boost
::
asio
::
buffer
(
buffer
.
data
(),
buffer
.
size
()
),
[
this
,
buf
=
std
::
move
(
buffer
)](
boost
::
system
::
error_code
ec
,
std
::
size_t
bytes_transferred
)
{
boost
::
asio
::
async_write
(
*
socket
,
boost
::
asio
::
buffer
(
send_buffer
,
send_message_size
+
sizeof
(
send_message_size
)
),
[
this
](
boost
::
system
::
error_code
ec
,
std
::
size_t
/*bytes_transferred*/
)
{
if
(
ec
)
{
if
(
ec
)
{
elog
(
"Error sending message: ${msg}"
,
(
"msg"
,
ec
.
message
()
)
);
elog
(
"Error sending message: ${msg}"
,
(
"msg"
,
ec
.
message
()
)
);
}
else
{
}
else
{
...
@@ -325,13 +328,13 @@ namespace eos {
...
@@ -325,13 +328,13 @@ namespace eos {
boost
::
asio
::
steady_timer
::
duration
connector_period
;
boost
::
asio
::
steady_timer
::
duration
connector_period
;
boost
::
asio
::
steady_timer
::
duration
txn_exp_period
;
boost
::
asio
::
steady_timer
::
duration
txn_exp_period
;
int16_t
network_version
;
int16_t
network_version
{
0
}
;
chain_id_type
chain_id
;
chain_id_type
chain_id
;
fc
::
sha256
node_id
;
fc
::
sha256
node_id
;
string
user_agent_name
;
string
user_agent_name
;
chain_plugin
*
chain_plug
;
chain_plugin
*
chain_plug
;
int32_t
just_send_it_max
;
size_t
just_send_it_max
;
bool
send_whole_blocks
;
bool
send_whole_blocks
;
node_transaction_index
local_txns
;
node_transaction_index
local_txns
;
...
@@ -416,10 +419,10 @@ namespace eos {
...
@@ -416,10 +419,10 @@ namespace eos {
boost
::
asio
::
async_read
(
*
conn
->
socket
,
boost
::
asio
::
async_read
(
*
conn
->
socket
,
boost
::
asio
::
buffer
((
char
*
)
buff
,
sizeof
(
conn
->
pending_message_size
)),
boost
::
asio
::
buffer
((
char
*
)
buff
,
sizeof
(
conn
->
pending_message_size
)),
[
this
,
c
](
boost
::
system
::
error_code
ec
,
std
::
size_t
bytes_transferred
)
{
[
this
,
c
](
boost
::
system
::
error_code
ec
,
std
::
size_t
/*bytes_transferred*/
)
{
//ilog( "read size handler..." );
//ilog( "read size handler..." );
if
(
!
ec
)
{
if
(
!
ec
)
{
connection_ptr
conn
=
c
.
lock
();
connection_ptr
conn
=
c
.
lock
();
if
(
conn
->
pending_message_size
<=
conn
->
pending_message_buffer
.
size
()
)
{
if
(
conn
->
pending_message_size
<=
conn
->
pending_message_buffer
.
size
()
)
{
start_reading_pending_buffer
(
conn
);
start_reading_pending_buffer
(
conn
);
return
;
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录