Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
4c0c3b31
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,发现更多精彩内容 >>
提交
4c0c3b31
编写于
4月 13, 2017
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor generated transactions in block header
上级
d153ca0b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
36 deletion
+27
-36
libraries/chain/database.cpp
libraries/chain/database.cpp
+9
-16
libraries/chain/include/eos/chain/protocol/block.hpp
libraries/chain/include/eos/chain/protocol/block.hpp
+4
-14
libraries/chain/protocol/block.cpp
libraries/chain/protocol/block.cpp
+14
-6
未找到文件。
libraries/chain/database.cpp
浏览文件 @
4c0c3b31
...
...
@@ -431,25 +431,18 @@ void database::_apply_block(const signed_block& next_block)
* for transactions when validating broadcast transactions or
* when building a block.
*/
for
(
const
auto
&
cycle
:
next_block
.
cycles
)
for
(
const
auto
&
thread
:
cycle
)
for
(
const
auto
&
trx
:
thread
.
input_transactions
)
{
struct
{
using
result_type
=
void
;
void
operator
()(
const
signed_transaction
&
trx
)
{
db
.
apply_transaction
(
trx
);
}
void
operator
()(
generated_transaction_id_type
)
{
for
(
const
auto
&
cycle
:
next_block
.
cycles
)
{
for
(
const
auto
&
thread
:
cycle
)
{
for
(
const
auto
&
trx
:
thread
.
generated_input
)
{
#warning TODO: Process generated transaction
}
database
&
db
;
}
visitor
{
*
this
};
trx
.
visit
(
visitor
);
++
_current_trx_in_block
;
}
for
(
const
auto
&
trx
:
thread
.
user_input
)
{
apply_transaction
(
trx
);
++
_current_trx_in_block
;
}
}
}
update_global_dynamic_data
(
next_block
);
update_signing_producer
(
signing_producer
,
next_block
);
...
...
libraries/chain/include/eos/chain/protocol/block.hpp
浏览文件 @
4c0c3b31
...
...
@@ -49,19 +49,9 @@ namespace eos { namespace chain {
};
struct
thread
{
using
input_transaction
=
static_variant
<
signed_transaction
,
generated_transaction_id_type
>
;
struct
input_transaction_digest_visitor
{
using
result_type
=
digest_type
;
result_type
operator
()
(
const
signed_transaction
&
t
)
const
{
return
t
.
merkle_digest
();
}
result_type
operator
()
(
const
generated_transaction_id_type
&
id
)
const
{
return
id
;
}
};
vector
<
input_transaction
>
input_transactions
;
vector
<
generated_transaction
>
output_transactions
;
vector
<
generated_transaction_id_type
>
generated_input
;
vector
<
signed_transaction
>
user_input
;
vector
<
generated_transaction
>
output_transactions
;
digest_type
merkle_digest
()
const
;
};
...
...
@@ -78,5 +68,5 @@ namespace eos { namespace chain {
FC_REFLECT
(
eos
::
chain
::
block_header
,
(
previous
)(
timestamp
)(
producer
)(
transaction_merkle_root
))
FC_REFLECT_DERIVED
(
eos
::
chain
::
signed_block_header
,
(
eos
::
chain
::
block_header
),
(
producer_signature
))
FC_REFLECT
(
eos
::
chain
::
thread
,
(
input_transactions
)(
output_transactions
))
FC_REFLECT
(
eos
::
chain
::
thread
,
(
generated_input
)(
user_input
)(
output_transactions
))
FC_REFLECT_DERIVED
(
eos
::
chain
::
signed_block
,
(
eos
::
chain
::
signed_block_header
),
(
cycles
))
libraries/chain/protocol/block.cpp
浏览文件 @
4c0c3b31
...
...
@@ -88,12 +88,20 @@ namespace eos { namespace chain {
}
digest_type
thread
::
merkle_digest
()
const
{
vector
<
digest_type
>
ids
;
input_transaction_digest_visitor
v
;
std
::
transform
(
input_transactions
.
begin
(),
input_transactions
.
end
(),
std
::
back_inserter
(
ids
),
[
v
=
input_transaction_digest_visitor
()](
const
input_transaction
&
t
)
{
return
t
.
visit
(
v
);
});
std
::
transform
(
output_transactions
.
begin
(),
output_transactions
.
end
(),
std
::
back_inserter
(
ids
),
std
::
bind
(
&
generated_transaction
::
merkle_digest
,
std
::
placeholders
::
_1
));
vector
<
digest_type
>
ids
=
generated_input
;
ids
.
reserve
(
ids
.
size
()
+
user_input
.
size
()
+
output_transactions
.
size
()
);
for
(
const
auto
&
trx
:
user_input
)
ids
.
push_back
(
trx
.
digest
()
);
/**
* When generating the merkle hash of an output transaction we hash it
* a second time. This is because the transaction has not been confirmed as
* "valid and applied" just "produced". Later, when this transaction is included
* as part of "generated input" its ID will be used without the extra hash.
*/
for
(
const
auto
&
trx
:
output_transactions
)
ids
.
push_back
(
digest_type
::
hash
(
trx
.
digest
())
);
return
merkle
(
ids
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录