Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
c56e69e0
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,发现更多精彩内容 >>
提交
c56e69e0
编写于
9月 05, 2017
作者:
M
Matias Romeo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement db str functions
上级
f80383f7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
64 addition
and
3 deletion
+64
-3
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+64
-3
未找到文件。
libraries/chain/wasm_interface.cpp
浏览文件 @
c56e69e0
...
...
@@ -54,6 +54,23 @@ DEFINE_INTRINSIC_FUNCTION0(env,checktime,checktime,none) {
return
func
(
wasm
.
current_apply_context
,
keys
,
value
,
valuelen
);
}
template
<
typename
Function
>
int32_t
validate_str
(
int32_t
keyptr
,
int32_t
keylen
,
int32_t
valueptr
,
int32_t
valuelen
,
Function
func
)
{
auto
&
wasm
=
wasm_interface
::
get
();
FC_ASSERT
(
wasm
.
current_apply_context
,
"no apply context found"
);
char
*
key
=
memoryArrayPtr
<
char
>
(
wasm
.
current_memory
,
keyptr
,
keylen
);
char
*
value
=
memoryArrayPtr
<
char
>
(
wasm
.
current_memory
,
valueptr
,
valuelen
);
//shared_string keys(allocator<char>);
//keys.assign(key, keylen);
std
::
string
keys
(
key
,
keylen
);
return
func
(
wasm
.
current_apply_context
,
&
keys
,
value
,
valuelen
);
}
#define READ_RECORD(READFUNC, INDEX, SCOPE) \
auto lambda = [&](apply_context* ctx, INDEX::value_type::key_type* keys, char *data, uint32_t datalen) -> int32_t { \
auto res = ctx->READFUNC<INDEX, SCOPE>( Name(scope), Name(code), Name(table), keys, data, datalen); \
...
...
@@ -104,9 +121,6 @@ DEFINE_INTRINSIC_FUNCTION0(env,checktime,checktime,none) {
DEFINE_RECORD_UPDATE_FUNCTIONS
(
i64
,
key_value_index
);
DEFINE_RECORD_READ_FUNCTIONS
(
i64
,,
key_value_index
,
by_scope_primary
);
DEFINE_RECORD_UPDATE_FUNCTIONS
(
str
,
keystr_value_index
);
DEFINE_RECORD_READ_FUNCTIONS
(
str
,,
keystr_value_index
,
by_scope_primary
);
DEFINE_RECORD_UPDATE_FUNCTIONS
(
i128i128
,
key128x128_value_index
);
DEFINE_RECORD_READ_FUNCTIONS
(
i128i128
,
primary_
,
key128x128_value_index
,
by_scope_primary
);
...
...
@@ -117,6 +131,53 @@ DEFINE_RECORD_READ_FUNCTIONS(i64i64i64, primary_, key64x64x64_value_index, by_
DEFINE_RECORD_READ_FUNCTIONS
(
i64i64i64
,
secondary_
,
key64x64x64_value_index
,
by_scope_secondary
);
DEFINE_RECORD_READ_FUNCTIONS
(
i64i64i64
,
tertiary_
,
key64x64x64_value_index
,
by_scope_tertiary
);
#define UPDATE_RECORD_STR(FUNCTION) \
auto lambda = [&](apply_context* ctx, std::string* keys, char *data, uint32_t datalen) -> int32_t { \
return ctx->FUNCTION<keystr_value_object>( Name(scope), Name(ctx->code.value), Name(table), keys, data, datalen); \
}; \
return validate_str<decltype(lambda)>(keyptr, keylen, valueptr, valuelen, lambda);
#define READ_RECORD_STR(FUNCTION) \
auto lambda = [&](apply_context* ctx, std::string* keys, char *data, uint32_t datalen) -> int32_t { \
auto res = ctx->FUNCTION<keystr_value_index, by_scope_primary>( Name(scope), Name(code), Name(table), keys, data, datalen); \
return res; \
}; \
return validate_str<decltype(lambda)>(keyptr, keylen, valueptr, valuelen, lambda);
DEFINE_INTRINSIC_FUNCTION6
(
env
,
store_str
,
store_str
,
i32
,
i64
,
scope
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
UPDATE_RECORD_STR
(
store_record
)
}
DEFINE_INTRINSIC_FUNCTION6
(
env
,
update_str
,
update_str
,
i32
,
i64
,
scope
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
UPDATE_RECORD_STR
(
update_record
)
}
DEFINE_INTRINSIC_FUNCTION4
(
env
,
remove_str
,
remove_str
,
i32
,
i64
,
scope
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
)
{
int32_t
valueptr
=
0
,
valuelen
=
0
;
UPDATE_RECORD_STR
(
remove_record
)
}
DEFINE_INTRINSIC_FUNCTION7
(
env
,
load_str
,
load_str
,
i32
,
i64
,
scope
,
i64
,
code
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
READ_RECORD_STR
(
load_record
)
}
DEFINE_INTRINSIC_FUNCTION7
(
env
,
front_str
,
front_str
,
i32
,
i64
,
scope
,
i64
,
code
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
READ_RECORD_STR
(
front_record
)
}
DEFINE_INTRINSIC_FUNCTION7
(
env
,
back_str
,
back_str
,
i32
,
i64
,
scope
,
i64
,
code
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
READ_RECORD_STR
(
back_record
)
}
DEFINE_INTRINSIC_FUNCTION7
(
env
,
next_str
,
next_str
,
i32
,
i64
,
scope
,
i64
,
code
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
READ_RECORD_STR
(
next_record
)
}
DEFINE_INTRINSIC_FUNCTION7
(
env
,
previous_str
,
previous_str
,
i32
,
i64
,
scope
,
i64
,
code
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
READ_RECORD_STR
(
previous_record
)
}
DEFINE_INTRINSIC_FUNCTION7
(
env
,
lower_bound_str
,
lower_bound_str
,
i32
,
i64
,
scope
,
i64
,
code
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
READ_RECORD_STR
(
lower_bound_record
)
}
DEFINE_INTRINSIC_FUNCTION7
(
env
,
upper_bound_str
,
upper_bound_str
,
i32
,
i64
,
scope
,
i64
,
code
,
i64
,
table
,
i32
,
keyptr
,
i32
,
keylen
,
i32
,
valueptr
,
i32
,
valuelen
)
{
READ_RECORD_STR
(
upper_bound_record
)
}
DEFINE_INTRINSIC_FUNCTION3
(
env
,
assert_sha256
,
assert_sha256
,
none
,
i32
,
dataptr
,
i32
,
datalen
,
i32
,
hash
)
{
FC_ASSERT
(
datalen
>
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录