Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
2c8a55a2
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,发现更多精彩内容 >>
提交
2c8a55a2
编写于
4月 17, 2018
作者:
P
Phil Mesnier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#2454 add a check for old version based on git commit id
上级
1a3584e3
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
4849 addition
and
12 deletion
+4849
-12
plugins/net_plugin/include/eosio/net_plugin/old_versions.hpp
plugins/net_plugin/include/eosio/net_plugin/old_versions.hpp
+4796
-0
plugins/net_plugin/net_plugin.cpp
plugins/net_plugin/net_plugin.cpp
+53
-12
未找到文件。
plugins/net_plugin/include/eosio/net_plugin/old_versions.hpp
0 → 100644
浏览文件 @
2c8a55a2
此差异已折叠。
点击以展开。
plugins/net_plugin/net_plugin.cpp
浏览文件 @
2c8a55a2
...
@@ -262,6 +262,7 @@ namespace eosio {
...
@@ -262,6 +262,7 @@ namespace eosio {
*/
*/
chain
::
signature_type
sign_compact
(
const
chain
::
public_key_type
&
signer
,
const
fc
::
sha256
&
digest
)
const
;
chain
::
signature_type
sign_compact
(
const
chain
::
public_key_type
&
signer
,
const
fc
::
sha256
&
digest
)
const
;
bool
is_old_version
(
uint16_t
v
);
};
};
const
fc
::
string
logger_name
(
"net_plugin_impl"
);
const
fc
::
string
logger_name
(
"net_plugin_impl"
);
...
@@ -419,6 +420,7 @@ namespace eosio {
...
@@ -419,6 +420,7 @@ namespace eosio {
int16_t
sent_handshake_count
;
int16_t
sent_handshake_count
;
bool
connecting
;
bool
connecting
;
bool
syncing
;
bool
syncing
;
bool
backwards_compatibility
;
int
write_depth
;
int
write_depth
;
string
peer_addr
;
string
peer_addr
;
unique_ptr
<
boost
::
asio
::
steady_timer
>
response_expected
;
unique_ptr
<
boost
::
asio
::
steady_timer
>
response_expected
;
...
@@ -610,6 +612,7 @@ namespace eosio {
...
@@ -610,6 +612,7 @@ namespace eosio {
sent_handshake_count
(
0
),
sent_handshake_count
(
0
),
connecting
(
false
),
connecting
(
false
),
syncing
(
false
),
syncing
(
false
),
backwards_compatibility
(
false
),
write_depth
(
0
),
write_depth
(
0
),
peer_addr
(
endpoint
),
peer_addr
(
endpoint
),
response_expected
(),
response_expected
(),
...
@@ -633,6 +636,7 @@ namespace eosio {
...
@@ -633,6 +636,7 @@ namespace eosio {
sent_handshake_count
(
0
),
sent_handshake_count
(
0
),
connecting
(
true
),
connecting
(
true
),
syncing
(
false
),
syncing
(
false
),
backwards_compatibility
(
false
),
write_depth
(
0
),
write_depth
(
0
),
peer_addr
(),
peer_addr
(),
response_expected
(),
response_expected
(),
...
@@ -1317,16 +1321,21 @@ namespace eosio {
...
@@ -1317,16 +1321,21 @@ namespace eosio {
if
(
head
<
peer_lib
)
{
if
(
head
<
peer_lib
)
{
fc_dlog
(
logger
,
"sync check state 1"
);
fc_dlog
(
logger
,
"sync check state 1"
);
// wait for receipt of a notice message before initiating sync
// wait for receipt of a notice message before initiating sync
if
(
c
->
backwards_compatibility
)
{
start_sync
(
c
,
peer_lib
);
}
return
;
return
;
}
}
if
(
lib_num
>
msg
.
head_num
)
{
if
(
lib_num
>
msg
.
head_num
)
{
fc_dlog
(
logger
,
"sync check state 2"
);
fc_dlog
(
logger
,
"sync check state 2"
);
notice_message
note
;
if
(
msg
.
generation
>
1
||
!
c
->
backwards_compatibility
)
{
note
.
known_trx
.
pending
=
lib_num
;
notice_message
note
;
note
.
known_trx
.
mode
=
last_irr_catch_up
;
note
.
known_trx
.
pending
=
lib_num
;
note
.
known_blocks
.
mode
=
last_irr_catch_up
;
note
.
known_trx
.
mode
=
last_irr_catch_up
;
note
.
known_blocks
.
pending
=
head
;
note
.
known_blocks
.
mode
=
last_irr_catch_up
;
c
->
enqueue
(
note
);
note
.
known_blocks
.
pending
=
head
;
c
->
enqueue
(
note
);
}
c
->
syncing
=
true
;
c
->
syncing
=
true
;
return
;
return
;
}
}
...
@@ -1338,12 +1347,14 @@ namespace eosio {
...
@@ -1338,12 +1347,14 @@ namespace eosio {
}
}
else
{
else
{
fc_dlog
(
logger
,
"sync check state 4"
);
fc_dlog
(
logger
,
"sync check state 4"
);
notice_message
note
;
if
(
msg
.
generation
>
1
||
!
c
->
backwards_compatibility
)
{
note
.
known_trx
.
mode
=
none
;
notice_message
note
;
note
.
known_blocks
.
mode
=
catch_up
;
note
.
known_trx
.
mode
=
none
;
note
.
known_blocks
.
pending
=
head
;
note
.
known_blocks
.
mode
=
catch_up
;
note
.
known_blocks
.
ids
.
push_back
(
head_id
);
note
.
known_blocks
.
pending
=
head
;
c
->
enqueue
(
note
);
note
.
known_blocks
.
ids
.
push_back
(
head_id
);
c
->
enqueue
(
note
);
}
c
->
syncing
=
true
;
c
->
syncing
=
true
;
return
;
return
;
}
}
...
@@ -1994,6 +2005,7 @@ namespace eosio {
...
@@ -1994,6 +2005,7 @@ namespace eosio {
return
;
return
;
}
}
if
(
msg
.
network_version
!=
network_version
)
{
if
(
msg
.
network_version
!=
network_version
)
{
c
->
backwards_compatibility
=
is_old_version
(
msg
.
network_version
);
if
(
network_version_match
)
{
if
(
network_version_match
)
{
elog
(
"Peer network version does not match expected ${nv} but got ${mnv}"
,
elog
(
"Peer network version does not match expected ${nv} but got ${mnv}"
,
(
"nv"
,
network_version
)(
"mnv"
,
msg
.
network_version
));
(
"nv"
,
network_version
)(
"mnv"
,
msg
.
network_version
));
...
@@ -2096,6 +2108,7 @@ namespace eosio {
...
@@ -2096,6 +2108,7 @@ namespace eosio {
// notices of previously unknown blocks or txns,
// notices of previously unknown blocks or txns,
//
//
fc_dlog
(
logger
,
"got a notice_message from ${p}"
,
(
"p"
,
c
->
peer_name
()));
fc_dlog
(
logger
,
"got a notice_message from ${p}"
,
(
"p"
,
c
->
peer_name
()));
c
->
connecting
=
false
;
request_message
req
;
request_message
req
;
bool
send_req
=
false
;
bool
send_req
=
false
;
if
(
msg
.
known_trx
.
mode
!=
none
)
{
if
(
msg
.
known_trx
.
mode
!=
none
)
{
...
@@ -2867,4 +2880,32 @@ namespace eosio {
...
@@ -2867,4 +2880,32 @@ namespace eosio {
if
(
c
->
peer_addr
==
host
)
return
c
;
if
(
c
->
peer_addr
==
host
)
return
c
;
return
connection_ptr
();
return
connection_ptr
();
}
}
/*
* this really should be in apputils
*/
#include <eosio/net_plugin/old_versions.hpp>
std
::
set
<
uint16_t
>
known_old
;
std
::
set
<
uint16_t
>
known_new
;
bool
net_plugin_impl
::
is_old_version
(
uint16_t
v
)
{
if
(
known_old
.
find
(
v
)
!=
known_old
.
end
())
{
fc_ilog
(
logger
,
"version ${v} is known to be old"
,(
"v"
,
v
));
return
true
;
}
if
(
known_new
.
find
(
v
)
!=
known_new
.
end
())
{
fc_ilog
(
logger
,
"version ${v} is known to be new"
,(
"v"
,
v
));
return
false
;
}
for
(
auto
old
:
old_versions
)
{
if
(
v
==
(
uint16_t
)
old
)
{
fc_ilog
(
logger
,
"adding version ${v} to the known old set"
,(
"v"
,
v
));
known_old
.
insert
(
v
);
return
true
;
}
}
fc_ilog
(
logger
,
"adding version ${v} to the known new set"
,(
"v"
,
v
));
known_new
.
insert
(
v
);
return
false
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录