Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
5aa500b5
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,发现更多精彩内容 >>
提交
5aa500b5
编写于
7月 01, 2017
作者:
P
Phil Mesnier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adding in block broadcast
上级
ad1a56bb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
6 deletion
+31
-6
plugins/net_plugin/include/eos/net_plugin/net_plugin.hpp
plugins/net_plugin/include/eos/net_plugin/net_plugin.hpp
+2
-0
plugins/net_plugin/net_plugin.cpp
plugins/net_plugin/net_plugin.cpp
+26
-4
plugins/producer_plugin/CMakeLists.txt
plugins/producer_plugin/CMakeLists.txt
+1
-1
plugins/producer_plugin/producer_plugin.cpp
plugins/producer_plugin/producer_plugin.cpp
+2
-1
未找到文件。
plugins/net_plugin/include/eos/net_plugin/net_plugin.hpp
浏览文件 @
5aa500b5
...
...
@@ -18,6 +18,8 @@ namespace eos {
void
plugin_startup
();
void
plugin_shutdown
();
void
broadcast_block
(
const
chain
::
signed_block
&
sb
);
private:
std
::
unique_ptr
<
class
net_plugin_impl
>
my
;
};
...
...
plugins/net_plugin/net_plugin.cpp
浏览文件 @
5aa500b5
...
...
@@ -3,6 +3,7 @@
#include <eos/net_plugin/net_plugin.hpp>
#include <eos/net_plugin/protocol.hpp>
#include <eos/chain/chain_controller.hpp>
#include <eos/chain/exceptions.hpp>
#include <fc/network/ip.hpp>
#include <fc/io/raw.hpp>
...
...
@@ -42,7 +43,7 @@ struct node_transaction_state {
struct
transaction_state
{
transaction_id_type
id
;
bool
is_known_by_peer
=
false
;
///< true if we sent or received this trx to this peer or received notice from peer
bool
is_noticed_to_peer
=
false
;
///< have we sent peer no
itce we know it (true if we re
eive from this peer)
bool
is_noticed_to_peer
=
false
;
///< have we sent peer no
tice we know it (true if we rec
eive from this peer)
uint32_t
block_num
=
-
1
;
///< the block number the transaction was included in
time_point
validated_time
;
///< infinity for unvalidated
time_point
requested_time
;
/// incase we fetch large trx
...
...
@@ -272,12 +273,21 @@ class net_plugin_impl {
hello
->
os
=
"other"
;
#endif
hello
->
agent
=
user_agent_name
;
update_handshake
();
}
void
update_handshake
()
{
hello
->
last_irreversible_block_id
=
chain_plug
->
chain
().
get_block_id_for_num
(
hello
->
last_irreversible_block_num
=
chain_plug
->
chain
().
last_irreversible_block_num
());
try
{
hello
->
last_irreversible_block_id
=
chain_plug
->
chain
().
get_block_id_for_num
(
hello
->
last_irreversible_block_num
=
chain_plug
->
chain
().
last_irreversible_block_num
());
ilog
(
"update_handshake my libnum = ${n}"
,(
"n"
,
hello
->
last_irreversible_block_num
));
}
catch
(
const
unknown_block_exception
&
ex
)
{
hello
->
last_irreversible_block_id
=
fc
::
sha256
::
hash
(
0
);
hello
->
last_irreversible_block_num
=
0
;
ilog
(
"update_handshake my libnum = ${n}"
,(
"n"
,
hello
->
last_irreversible_block_num
));
}
}
void
start_session
(
connection
*
con
)
{
...
...
@@ -328,6 +338,13 @@ class net_plugin_impl {
);
}
template
<
typename
T
>
void
send_all
(
const
T
&
msg
)
{
for
(
auto
&
c
:
connections
)
{
c
->
send
(
msg
);
}
}
void
handle_message
(
connection
&
c
,
const
handshake_message
&
msg
)
{
if
(
!
hello
)
{
init_handshake
();
...
...
@@ -350,6 +367,7 @@ class net_plugin_impl {
}
chain_controller
&
cc
=
chain_plug
->
chain
();
uint32_t
head
=
cc
.
head_block_num
();
ilog
(
"My head block = ${h} their lib = ${lib}"
,
(
"h"
,
head
)(
"lib"
,
msg
.
last_irreversible_block_num
));
if
(
msg
.
last_irreversible_block_num
>
head
)
{
uint32_t
delta
=
msg
.
last_irreversible_block_num
-
head
;
uint32_t
count
=
connections
.
size
();
...
...
@@ -547,4 +565,8 @@ try {
ilog
(
"exit shutdown"
);
}
FC_CAPTURE_AND_RETHROW
()
}
void
net_plugin
::
broadcast_block
(
const
chain
::
signed_block
&
sb
)
{
my
->
send_all
(
sb
);
}
}
plugins/producer_plugin/CMakeLists.txt
浏览文件 @
5aa500b5
...
...
@@ -5,7 +5,7 @@ add_library( producer_plugin
${
HEADERS
}
)
target_link_libraries
(
producer_plugin chain_plugin appbase eos_chain eos_utilities
)
target_link_libraries
(
producer_plugin
net_plugin
chain_plugin appbase eos_chain eos_utilities
)
target_include_directories
(
producer_plugin
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
...
...
plugins/producer_plugin/producer_plugin.cpp
浏览文件 @
5aa500b5
...
...
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include <eos/producer_plugin/producer_plugin.hpp>
#include <eos/net_plugin/net_plugin.hpp>
#include <eos/chain/producer_object.hpp>
...
...
@@ -304,7 +305,7 @@ block_production_condition::block_production_condition_enum producer_plugin_impl
);
capture
(
"n"
,
block
.
block_num
())(
"t"
,
block
.
timestamp
)(
"c"
,
now
);
// app().get_plugin<p2p
_plugin>().broadcast_block(block);
app
().
get_plugin
<
net
_plugin
>
().
broadcast_block
(
block
);
return
block_production_condition
::
produced
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录