Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
1bbe9db7
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,发现更多精彩内容 >>
提交
1bbe9db7
编写于
4月 13, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
progress
上级
ab83927a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
99 addition
and
27 deletion
+99
-27
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+89
-4
libraries/chain/include/eosio/chain/block_state.hpp
libraries/chain/include/eosio/chain/block_state.hpp
+7
-9
libraries/chain/main.cpp
libraries/chain/main.cpp
+3
-14
未找到文件。
libraries/chain/controller.cpp
浏览文件 @
1bbe9db7
...
...
@@ -163,6 +163,7 @@ struct controller_impl {
}
/**
* This method will backup all tranasctions in the current pending block,
* undo the pending block, call f(), and then push the pending transactions
...
...
@@ -203,6 +204,73 @@ struct controller_impl {
});
}
transaction_trace_ptr
push_transaction
(
const
transaction_metadata_ptr
&
trx
)
{
return
db
.
with_write_lock
(
[
&
](){
return
apply_transaction
(
trx
);
});
}
void
record_transaction
(
const
transaction_metadata_ptr
&
trx
)
{
try
{
_db
.
create
<
transaction_object
>
([
&
](
transaction_object
&
transaction
)
{
transaction
.
trx_id
=
trx
->
id
;
transaction
.
expiration
=
trx
->
trx
.
expiration
;
});
}
catch
(
...
)
{
EOS_ASSERT
(
false
,
transaction_exception
,
"duplicate transaction ${id}"
,
(
"id"
,
trx
.
id
()
)
);
}
}
void
start_transaction
(
const
transaction_metadata_ptr
&
trx
)
{
record_transaction
(
trx
);
}
transaction_trace_ptr
apply_transaction
(
const
transaction_metadata_ptr
&
trx
,
bool
implicit
=
false
)
{
auto
trx_session
=
db
.
start_undo_session
();
// TODO: notify pre transaction
start_transaction
(
trx
);
for
(
const
auto
&
act
:
trx
->
trx
.
context_free_actions
)
{
apply_action
(
act
,
...
);
/*
apply_context context( self, db, act, trx );
context.context_free = true;
context.exec();
receipt.kcpu_usage += context.kcpu_usage
*/
}
for
(
const
auto
&
act
:
trx
->
trx
.
actions
)
{
auto
act_session
=
db
.
start_undo_session
();
// TODO: notify pre action
/*
apply_context context( self, db, act, trx );
context.exec();
receipt.kcpu_usage += context.kcpu_usage
*/
// TODO: notify post action
act_session
.
squash
();
}
finalize_transaction
();
// TODO: notify post transaction
trx_session
.
squash
();
push_transaction_receipt
(
trx
,
type
);
}
block_state_ptr
push_block_impl
(
const
signed_block_ptr
&
b
)
{
#if 0
...
...
@@ -268,6 +336,20 @@ struct controller_impl {
} /// validate_net_usage
*/
transaction_trace_ptr
apply_transaction
(
const
transaction_metadata_ptr
&
trx
)
{
auto
trx_trace
=
std
::
make_shared
<
transaction_trace
>
();
trx_trace
->
action_traces
.
reserve
(
trx
->
trx
.
actions
.
size
()
);
trx_trace
->
action_receipts
.
reserve
(
trx
->
trx
.
actions
.
size
()
);
for
(
const
auto
&
act
:
trx
->
trx
.
actions
)
{
// trx_trace->action_receipts.emplace_back( apply_action( act
}
return
trx_trace
;
}
void
finalize_block
(
const
block_trace
&
trace
)
{
try
{
...
...
@@ -437,15 +519,18 @@ void controller::start_block( block_timestamp_type when ) {
FC_ASSERT
(
!
my
->
pending
);
my
->
pending
=
my
->
db
.
start_undo_session
(
true
);
my
->
pending
->
_pending_block_state
=
std
::
make_shared
<
block_state
>
(
*
my
->
head
,
when
);
auto
t
=
my
->
get_on_block_transaction
();
// apply_transaction(
// idump((t));
}
void
controller
::
finalize_block
()
{
auto
p
=
my
->
pending
->
_pending_block_state
;
/// set trx mroot and act mroot
my
->
pending
->
_pending_block_state
->
id
=
my
->
pending
->
_pending_block_state
->
header
.
id
();
/// set trx mroot and act mroot on pending.header and pending.block (which also has copy of header)
//
my->pending->_pending_block_state->id = my->pending->_pending_block_state->header.id();
}
void
controller
::
sign_block
(
std
::
function
<
signature_type
(
const
digest_type
&
)
>
signer_callback
)
{
...
...
@@ -474,7 +559,7 @@ void controller::push_block( const signed_block_ptr& b ) {
}
transaction_trace_ptr
controller
::
push_transaction
(
const
transaction_metadata_ptr
&
trx
)
{
return
my
->
push_transaction
();
}
transaction_trace_ptr
controller
::
push_transaction
()
{
...
...
libraries/chain/include/eosio/chain/block_state.hpp
浏览文件 @
1bbe9db7
...
...
@@ -11,12 +11,10 @@ namespace eosio { namespace chain {
struct
action_receipt
{
account_name
receiver
;
action
act
;
uint32_t
block_sequence
;
uint32_t
block_sequence
;
/// block num
uint32_t
sender_sequence
;
fc
::
sha256
transaction_id_type
;
/// the trx that started this action
transaction_id_type
trx_id
;
/// the trx that started this action
uint16_t
trx_action_dispatch_seq
;
///< the relative order for implied trx
uint16_t
trx_action_creator_seq
;
///< the dispatch seq of the action that created this dispatch
uint16_t
trx_action_dispatch_count
;
///< the total number of actions dispatched by transaction when this action was dispatched
/// TODO: add code/scope/rw sequence numbers
};
...
...
@@ -38,7 +36,7 @@ namespace eosio { namespace chain {
struct
block_trace
{
fc
::
microseconds
ellapsed
;
uint64_t
cpu_usage
;
vector
<
transaction_trace
>
trx_traces
;
vector
<
transaction_trace
_ptr
>
trx_traces
;
};
typedef
std
::
shared_ptr
<
block_trace
>
block_trace_ptr
;
...
...
libraries/chain/main.cpp
浏览文件 @
1bbe9db7
...
...
@@ -9,19 +9,7 @@ int main( int argc, char** argv ) {
controller
c
(
{}
);
controller
c2
(
{.
shared_memory_dir
=
"c2dir"
,
.
block_log_dir
=
"c2dir"
}
);
c
.
start_block
();
c
.
finalize_block
();
c
.
sign_block
(
[](
digest_type
d
)
{
auto
priv
=
fc
::
variant
(
"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
).
as
<
private_key_type
>
();
return
priv
.
sign
(
d
);
});
c
.
commit_block
();
c2
.
push_block
(
c
.
head_block_state
()
->
block
);
for
(
uint32_t
i
=
0
;
i
<
4
;
++
i
)
{
ilog
(
"============================================================
\n
"
);
c
.
start_block
();
c
.
finalize_block
();
c
.
sign_block
(
[](
digest_type
d
)
{
...
...
@@ -29,9 +17,10 @@ for( uint32_t i = 0; i < 4; ++i ) {
return
priv
.
sign
(
d
);
});
c
.
commit_block
();
c2
.
push_block
(
c
.
head_block_state
()
->
block
);
idump
((
c
.
head_block_
num
())(
c2
.
head_block_state
()
->
dpos_last_irreversible_blocknum
));
idump
((
c2
.
head_block_
num
())(
c2
.
head_block_state
()
->
dpos_last_irreversible_blocknum
));
idump
((
c
.
head_block_
state
()
->
header
));
idump
((
c2
.
head_block_
state
()
->
header
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录