Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
36bc2a73
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,发现更多精彩内容 >>
提交
36bc2a73
编写于
10月 11, 2018
作者:
T
Todd Fleming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
state history: fetch blocks
上级
6de4046d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
78 addition
and
9 deletion
+78
-9
plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_plugin.hpp
...clude/eosio/state_history_plugin/state_history_plugin.hpp
+3
-1
plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp
...osio/state_history_plugin/state_history_serialization.hpp
+1
-3
plugins/state_history_plugin/state_history_plugin.cpp
plugins/state_history_plugin/state_history_plugin.cpp
+15
-0
plugins/state_history_plugin/state_history_plugin_abi.cpp
plugins/state_history_plugin/state_history_plugin_abi.cpp
+59
-5
未找到文件。
plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_plugin.hpp
浏览文件 @
36bc2a73
...
...
@@ -39,6 +39,8 @@ struct get_block_request_v0 {
struct
get_block_result_v0
{
uint32_t
block_num
=
0
;
fc
::
optional
<
bytes
>
block
;
fc
::
optional
<
bytes
>
block_state
;
fc
::
optional
<
bytes
>
traces
;
fc
::
optional
<
bytes
>
deltas
;
};
...
...
@@ -70,4 +72,4 @@ FC_REFLECT_EMPTY(eosio::get_status_request_v0);
FC_REFLECT
(
eosio
::
get_status_result_v0
,
(
last_irreversible_block_num
)(
last_irreversible_block_id
)(
state_begin_block_num
)(
state_end_block_num
));
FC_REFLECT
(
eosio
::
get_block_request_v0
,
(
block_num
));
FC_REFLECT
(
eosio
::
get_block_result_v0
,
(
block_num
)(
traces
)(
deltas
));
FC_REFLECT
(
eosio
::
get_block_result_v0
,
(
block_num
)(
block
)(
block_state
)(
traces
)(
deltas
));
plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp
浏览文件 @
36bc2a73
...
...
@@ -180,7 +180,6 @@ datastream<ST>& operator<<(datastream<ST>&
template
<
typename
ST
>
datastream
<
ST
>&
operator
<<
(
datastream
<
ST
>&
ds
,
const
history_serial_wrapper
<
eosio
::
chain
::
producer_key
>&
obj
)
{
fc
::
raw
::
pack
(
ds
,
fc
::
unsigned_int
(
0
));
fc
::
raw
::
pack
(
ds
,
as_type
<
uint64_t
>
(
obj
.
obj
.
producer_name
.
value
));
fc
::
raw
::
pack
(
ds
,
as_type
<
eosio
::
chain
::
public_key_type
>
(
obj
.
obj
.
block_signing_key
));
return
ds
;
...
...
@@ -189,9 +188,8 @@ datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosi
template
<
typename
ST
>
datastream
<
ST
>&
operator
<<
(
datastream
<
ST
>&
ds
,
const
history_serial_wrapper
<
eosio
::
chain
::
shared_producer_schedule_type
>&
obj
)
{
fc
::
raw
::
pack
(
ds
,
fc
::
unsigned_int
(
0
));
fc
::
raw
::
pack
(
ds
,
as_type
<
uint32_t
>
(
obj
.
obj
.
version
));
history_serialize_container
(
ds
,
obj
.
obj
.
producers
);
history_serialize_container
(
ds
,
as_type
<
eosio
::
chain
::
shared_vector
<
eosio
::
chain
::
producer_key
>>
(
obj
.
obj
.
producers
)
);
return
ds
;
}
...
...
plugins/state_history_plugin/state_history_plugin.cpp
浏览文件 @
36bc2a73
...
...
@@ -70,6 +70,7 @@ auto catch_and_log(F f) {
struct
state_history_plugin_impl
:
std
::
enable_shared_from_this
<
state_history_plugin_impl
>
{
chain_plugin
*
chain_plug
=
nullptr
;
history_log
block_state_log
{
"block_state_history"
};
history_log
trace_log
{
"trace_history"
};
history_log
chain_state_log
{
"chain_state_history"
};
bool
stopping
=
false
;
...
...
@@ -93,6 +94,11 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
stream
.
read
(
result
->
data
(),
s
);
}
void
get_block
(
uint32_t
block_num
,
fc
::
optional
<
bytes
>&
result
)
{
auto
p
=
chain_plug
->
chain
().
fetch_block_by_number
(
block_num
);
result
=
fc
::
raw
::
pack
(
*
p
);
}
struct
session
:
std
::
enable_shared_from_this
<
session
>
{
std
::
shared_ptr
<
state_history_plugin_impl
>
plugin
;
std
::
unique_ptr
<
ws
::
stream
<
tcp
::
socket
>>
stream
;
...
...
@@ -183,6 +189,8 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
// ilog("${b} get_block_request_v0", ("b", req.block_num));
get_block_result_v0
result
{
req
.
block_num
};
// todo: client select which datasets to receive
plugin
->
get_block
(
req
.
block_num
,
result
.
block
);
plugin
->
get_data
(
plugin
->
block_state_log
,
req
.
block_num
,
result
.
block_state
);
plugin
->
get_data
(
plugin
->
trace_log
,
req
.
block_num
,
result
.
traces
);
plugin
->
get_data
(
plugin
->
chain_state_log
,
req
.
block_num
,
result
.
deltas
);
send
(
std
::
move
(
result
));
...
...
@@ -276,10 +284,15 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
void
on_accepted_block
(
const
block_state_ptr
&
block_state
)
{
// todo: config options
store_block_state
(
block_state
);
store_traces
(
block_state
);
store_chain_state
(
block_state
);
}
void
store_block_state
(
const
block_state_ptr
&
block_state
)
{
// todo
}
void
store_traces
(
const
block_state_ptr
&
block_state
)
{
std
::
vector
<
transaction_trace_ptr
>
traces
;
for
(
auto
&
p
:
block_state
->
trxs
)
{
...
...
@@ -406,6 +419,8 @@ void state_history_plugin::plugin_initialize(const variables_map& options) {
}
boost
::
filesystem
::
create_directories
(
state_history_dir
);
my
->
block_state_log
.
open
((
state_history_dir
/
"block_state_history.log"
).
string
(),
(
state_history_dir
/
"block_state_history.index"
).
string
());
my
->
trace_log
.
open
((
state_history_dir
/
"trace_history.log"
).
string
(),
(
state_history_dir
/
"trace_history.index"
).
string
());
my
->
chain_state_log
.
open
((
state_history_dir
/
"chain_state_history.log"
).
string
(),
...
...
plugins/state_history_plugin/state_history_plugin_abi.cpp
浏览文件 @
36bc2a73
...
...
@@ -20,6 +20,8 @@ extern const char* const state_history_plugin_abi = R"({
{
"name": "get_block_result_v0", "fields": [
{ "name": "block_num", "type": "uint32" },
{ "name": "block", "type": "bytes?" },
{ "name": "block_state", "type": "bytes?" },
{ "name": "traces", "type": "bytes?" },
{ "name": "deltas", "type": "bytes?" }
]
...
...
@@ -94,6 +96,56 @@ extern const char* const state_history_plugin_abi = R"({
{ "name": "action_traces", "type": "action_trace[]" }
]
},
{
"name": "packed_transaction", "fields": [
{ "name": "signatures", "type": "signature[]" },
{ "name": "compression", "type": "uint8" },
{ "name": "packed_context_free_data", "type": "bytes" },
{ "name": "packed_trx", "type": "bytes" }
]
},
{
"name": "transaction_receipt_header", "fields": [
{ "name": "status", "type": "uint8" },
{ "name": "cpu_usage_us", "type": "uint32" },
{ "name": "net_usage_words", "type": "varuint32" }
]
},
{
"name": "transaction_receipt", "base": "transaction_receipt_header", "fields": [
{ "name": "trx", "type": "transaction_variant" }
]
},
{
"name": "extension", "fields": [
{ "name": "type", "type": "uint16" },
{ "name": "data", "type": "bytes" }
]
},
{
"name": "block_header", "fields": [
{ "name": "timestamp", "type": "block_timestamp_type" },
{ "name": "producer", "type": "name" },
{ "name": "confirmed; ", "type": "uint16" },
{ "name": "previous", "type": "checksum256" },
{ "name": "transaction_mroot", "type": "checksum256" },
{ "name": "action_mroot", "type": "checksum256" },
{ "name": "schedule_version", "type": "uint32" },
{ "name": "new_producers", "type": "producer_schedule?" },
{ "name": "header_extensions", "type": "extension[]" }
]
},
{
"name": "signed_block_header", "base": "block_header", "fields": [
{ "name": "producer_signature", "type": "signature" }
]
},
{
"name": "signed_block", "base": "signed_block_header", "fields": [
{ "name": "transactions", "type": "transaction_receipt[]" },
{ "name": "block_extensions", "type": "extension[]" }
]
},
{
"name": "account_v0", "fields": [
{ "type": "uint64", "name": "id" },
...
...
@@ -189,13 +241,13 @@ extern const char* const state_history_plugin_abi = R"({
]
},
{
"name": "producer_key
_v0
", "fields": [
"name": "producer_key", "fields": [
{ "type": "name", "name": "producer_name" },
{ "type": "public_key", "name": "block_signing_key" }
]
},
{
"name": "
shared_producer_schedule_type_v0
", "fields": [
"name": "
producer_schedule
", "fields": [
{ "type": "uint32", "name": "version" },
{ "type": "producer_key[]", "name": "producers" }
]
...
...
@@ -225,7 +277,7 @@ extern const char* const state_history_plugin_abi = R"({
"name": "global_property_v0", "fields": [
{ "type": "uint64", "name": "id" },
{ "type": "uint32?", "name": "proposed_schedule_block_num" },
{ "type": "
shared_producer_schedule_typ
e", "name": "proposed_schedule" },
{ "type": "
producer_schedul
e", "name": "proposed_schedule" },
{ "type": "chain_config", "name": "configuration" }
]
},
...
...
@@ -379,6 +431,9 @@ extern const char* const state_history_plugin_abi = R"({
]
}
],
"types": [
{ "new_type_name": "transaction_id", "type": "checksum256" }
],
"variants": [
{ "name": "request", "types": ["get_status_request_v0", "get_block_request_v0"] },
{ "name": "result", "types": ["get_status_result_v0", "get_block_result_v0"] },
...
...
@@ -387,6 +442,7 @@ extern const char* const state_history_plugin_abi = R"({
{ "name": "action_receipt", "types": ["action_receipt_v0"] },
{ "name": "action_trace", "types": ["action_trace_v0"] },
{ "name": "transaction_trace", "types": ["transaction_trace_v0"] },
{ "name": "transaction_variant", "types": ["transaction_id", "packed_transaction"] },
{ "name": "table_delta", "types": ["table_delta_v0"] },
{ "name": "account", "types": ["account_v0"] },
...
...
@@ -398,8 +454,6 @@ extern const char* const state_history_plugin_abi = R"({
{ "name": "index256", "types": ["index256_v0"] },
{ "name": "index_double", "types": ["index_double_v0"] },
{ "name": "index_long_double", "types": ["index_long_double_v0"] },
{ "name": "producer_key", "types": ["producer_key_v0"] },
{ "name": "shared_producer_schedule_type", "types": ["shared_producer_schedule_type_v0"] },
{ "name": "chain_config", "types": ["chain_config_v0"] },
{ "name": "global_property", "types": ["global_property_v0"] },
{ "name": "dynamic_global_property", "types": ["dynamic_global_property_v0"] },
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录