Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
4ac9898f
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,发现更多精彩内容 >>
提交
4ac9898f
编写于
5月 23, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chain_plugin parameter --contracts-console added #3339
上级
2ca45172
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
90 addition
and
53 deletion
+90
-53
libraries/chain/apply_context.cpp
libraries/chain/apply_context.cpp
+13
-13
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+4
-0
libraries/chain/include/eosio/chain/controller.hpp
libraries/chain/include/eosio/chain/controller.hpp
+3
-0
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+65
-39
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+1
-0
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+4
-1
未找到文件。
libraries/chain/apply_context.cpp
浏览文件 @
4ac9898f
...
...
@@ -16,7 +16,6 @@ using boost::container::flat_set;
namespace
eosio
{
namespace
chain
{
static
inline
void
print_debug
(
account_name
receiver
,
const
action_trace
&
ar
)
{
if
(
fc
::
logger
::
get
(
DEFAULT_LOGGER
).
is_enabled
(
fc
::
log_level
::
debug
))
{
if
(
!
ar
.
console
.
empty
())
{
auto
prefix
=
fc
::
format_string
(
"
\n
[(${a},${n})->${r}]"
,
...
...
@@ -28,7 +27,6 @@ static inline void print_debug(account_name receiver, const action_trace& ar) {
+
ar
.
console
+
prefix
+
": CONSOLE OUTPUT END ====================="
);
}
}
}
action_trace
apply_context
::
exec_one
()
...
...
@@ -75,7 +73,9 @@ action_trace apply_context::exec_one()
trx_context
.
executed
.
emplace_back
(
move
(
r
)
);
if
(
control
.
contracts_console
()
)
{
print_debug
(
receiver
,
t
);
}
reset_console
();
...
...
libraries/chain/controller.cpp
浏览文件 @
4ac9898f
...
...
@@ -1283,6 +1283,10 @@ bool controller::skip_auth_check()const {
return
my
->
replaying_irreversible
&&
!
my
->
conf
.
force_all_checks
;
}
bool
controller
::
contracts_console
()
const
{
return
my
->
conf
.
contracts_console
;
}
const
apply_handler
*
controller
::
find_apply_handler
(
account_name
receiver
,
account_name
scope
,
action_name
act
)
const
{
auto
native_handler_scope
=
my
->
apply_handlers
.
find
(
receiver
);
...
...
libraries/chain/include/eosio/chain/controller.hpp
浏览文件 @
4ac9898f
...
...
@@ -42,6 +42,7 @@ namespace eosio { namespace chain {
uint64_t
shared_memory_size
=
chain
::
config
::
default_shared_memory_size
;
bool
read_only
=
false
;
bool
force_all_checks
=
false
;
bool
contracts_console
=
false
;
genesis_state
genesis
;
wasm_interface
::
vm_type
wasm_runtime
=
chain
::
config
::
default_wasm_runtime
;
...
...
@@ -151,6 +152,7 @@ namespace eosio { namespace chain {
bool
skip_auth_check
()
const
;
bool
contracts_console
()
const
;
signal
<
void
(
const
block_state_ptr
&
)
>
accepted_block_header
;
signal
<
void
(
const
block_state_ptr
&
)
>
accepted_block
;
...
...
@@ -206,6 +208,7 @@ FC_REFLECT( eosio::chain::controller::config,
(
reversible_cache_size
)
(
shared_memory_dir
)(
shared_memory_size
)(
read_only
)
(
force_all_checks
)
(
contracts_console
)
(
genesis
)
(
wasm_runtime
)
)
libraries/chain/wasm_interface.cpp
浏览文件 @
4ac9898f
...
...
@@ -977,26 +977,36 @@ class action_api : public context_aware_api {
class
console_api
:
public
context_aware_api
{
public:
console_api
(
apply_context
&
ctx
)
:
context_aware_api
(
ctx
,
true
){}
:
context_aware_api
(
ctx
,
true
)
,
ignore
(
!
ctx
.
control
.
contracts_console
())
{}
// Kept as intrinsic rather than implementing on WASM side (using prints_l and strlen) because strlen is faster on native side.
void
prints
(
null_terminated_ptr
str
)
{
if
(
!
ignore
)
{
context
.
console_append
<
const
char
*>
(
str
);
}
}
void
prints_l
(
array_ptr
<
const
char
>
str
,
size_t
str_len
)
{
if
(
!
ignore
)
{
context
.
console_append
(
string
(
str
,
str_len
));
}
}
void
printi
(
int64_t
val
)
{
if
(
!
ignore
)
{
context
.
console_append
(
val
);
}
}
void
printui
(
uint64_t
val
)
{
if
(
!
ignore
)
{
context
.
console_append
(
val
);
}
}
void
printi128
(
const
__int128
&
val
)
{
if
(
!
ignore
)
{
bool
is_negative
=
(
val
<
0
);
unsigned
__int128
val_magnitude
;
...
...
@@ -1013,13 +1023,17 @@ class console_api : public context_aware_api {
context
.
console_append
(
fc
::
variant
(
v
).
get_string
());
}
}
void
printui128
(
const
unsigned
__int128
&
val
)
{
if
(
!
ignore
)
{
fc
::
uint128_t
v
(
val
>>
64
,
static_cast
<
uint64_t
>
(
val
)
);
context
.
console_append
(
fc
::
variant
(
v
).
get_string
());
}
}
void
printsf
(
float
val
)
{
if
(
!
ignore
)
{
// Assumes float representation on native side is the same as on the WASM side
auto
&
console
=
context
.
get_console_stream
();
auto
orig_prec
=
console
.
precision
();
...
...
@@ -1029,8 +1043,10 @@ class console_api : public context_aware_api {
console
.
precision
(
orig_prec
);
}
}
void
printdf
(
double
val
)
{
if
(
!
ignore
)
{
// Assumes double representation on native side is the same as on the WASM side
auto
&
console
=
context
.
get_console_stream
();
auto
orig_prec
=
console
.
precision
();
...
...
@@ -1040,6 +1056,7 @@ class console_api : public context_aware_api {
console
.
precision
(
orig_prec
);
}
}
void
printqf
(
const
float128_t
&
val
)
{
/*
...
...
@@ -1054,6 +1071,7 @@ class console_api : public context_aware_api {
* having to deal with long doubles at all.
*/
if
(
!
ignore
)
{
auto
&
console
=
context
.
get_console_stream
();
auto
orig_prec
=
console
.
precision
();
...
...
@@ -1065,14 +1083,22 @@ class console_api : public context_aware_api {
console
.
precision
(
orig_prec
);
}
}
void
printn
(
const
name
&
value
)
{
if
(
!
ignore
)
{
context
.
console_append
(
value
.
to_string
());
}
}
void
printhex
(
array_ptr
<
const
char
>
data
,
size_t
data_len
)
{
if
(
!
ignore
)
{
context
.
console_append
(
fc
::
to_hex
(
data
,
data_len
));
}
}
private:
bool
ignore
;
};
#define DB_API_METHOD_WRAPPERS_SIMPLE_SECONDARY(IDX, TYPE)\
...
...
libraries/testing/tester.cpp
浏览文件 @
4ac9898f
...
...
@@ -41,6 +41,7 @@ namespace eosio { namespace testing {
cfg
.
shared_memory_dir
=
tempdir
.
path
()
/
"shared"
;
cfg
.
shared_memory_size
=
1024
*
1024
*
8
;
cfg
.
reversible_cache_size
=
1024
*
1024
*
8
;
cfg
.
contracts_console
=
true
;
cfg
.
genesis
.
initial_timestamp
=
fc
::
time_point
::
from_iso_string
(
"2020-01-01T00:00:00.000"
);
cfg
.
genesis
.
initial_key
=
get_public_key
(
config
::
system_account_name
,
"active"
);
...
...
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
4ac9898f
...
...
@@ -139,6 +139,8 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
"clear chain database, recover as many blocks as possible from the block log, and then replay those blocks"
)
(
"resync-blockchain"
,
bpo
::
bool_switch
()
->
default_value
(
false
),
"clear chain database and block log"
)
(
"contracts-console"
,
bpo
::
bool_switch
()
->
default_value
(
false
),
"print contract's output to console"
)
;
}
...
...
@@ -202,6 +204,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
my
->
chain_config
->
wasm_runtime
=
*
my
->
wasm_runtime
;
my
->
chain_config
->
force_all_checks
=
options
.
at
(
"force-all-checks"
).
as
<
bool
>
();
my
->
chain_config
->
contracts_console
=
options
.
at
(
"contracts-console"
).
as
<
bool
>
();
if
(
options
.
at
(
"resync-blockchain"
).
as
<
bool
>
()
)
{
ilog
(
"Resync requested: wiping database and blocks"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录