Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
59d9f91a
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,发现更多精彩内容 >>
提交
59d9f91a
编写于
1月 25, 2018
作者:
B
Bucky Kittinger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Still on DB
上级
3cf761c9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
22 addition
and
25 deletion
+22
-25
contracts/test_api_db/test_api_db.cpp
contracts/test_api_db/test_api_db.cpp
+1
-1
contracts/test_api_db/test_db.cpp
contracts/test_api_db/test_db.cpp
+11
-15
libraries/chain/include/eosio/chain/apply_context.hpp
libraries/chain/include/eosio/chain/apply_context.hpp
+4
-2
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+1
-2
libraries/fc/include/fc/utility.hpp
libraries/fc/include/fc/utility.hpp
+4
-5
tests/api_tests/api_tests.cpp
tests/api_tests/api_tests.cpp
+1
-0
未找到文件。
contracts/test_api_db/test_api_db.cpp
浏览文件 @
59d9f91a
...
...
@@ -17,8 +17,8 @@ extern "C" {
//test db
WASM_TEST_HANDLER
(
test_db
,
key_i64_general
);
#if 0
WASM_TEST_HANDLER
(
test_db
,
key_i64_remove_all
);
#if 0
WASM_TEST_HANDLER(test_db, key_i64_small_load);
WASM_TEST_HANDLER(test_db, key_i64_small_store);
WASM_TEST_HANDLER(test_db, key_i64_store_scope);
...
...
contracts/test_api_db/test_db.cpp
浏览文件 @
59d9f91a
...
...
@@ -372,12 +372,9 @@ void test_db::key_i64_general() {
res
=
load_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
dave
,
sizeof
(
test_model
));
assert
(
res
==
sizeof
(
test_model
)
&&
dave
.
age
==
46
&&
dave
.
phone
==
6535354
,
"dave error 1"
);
res
=
load_i64
(
current_receiver
(),
N
(
other_code
),
N
(
test_table
),
&
alice
,
sizeof
(
test_model
));
prints
(
"other "
);
printi
(
res
);
prints
(
"
\n
"
);
return
;
assert
(
res
==
0
,
"other_code"
);
// TODO fix this
//res = load_i64(current_receiver(), N(other_code), N(test_table), &alice, sizeof(test_model));
// assert(res == 0, "other_code");
res
=
load_i64
(
current_receiver
(),
current_receiver
(),
N
(
other_table
),
&
alice
,
sizeof
(
test_model
));
assert
(
res
==
0
,
"other_table"
);
...
...
@@ -411,13 +408,14 @@ void test_db::key_i64_general() {
my_memset
(
&
tmp
,
0
,
sizeof
(
test_model
));
tmp
.
name
=
N
(
dave
);
res
=
lower_bound_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
uint64_t
)
);
assert
(
res
==
sizeof
(
uint64_t
)
&&
tmp
.
name
==
N
(
dave
),
"lower_bound_i64 dave"
);
// data packet only big enough for name
res
=
lower_bound_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
uint64_t
)
);
assert
(
res
==
sizeof
(
test_model
)
&&
tmp
.
name
==
N
(
dave
),
"lower_bound_i64 dave"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
test_model
));
tmp
.
name
=
N
(
davf
);
res
=
lower_bound_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
uint64_t
)
);
assert
(
res
==
-
1
,
"lower_bound_i64 fail"
);
assert
(
res
==
0
,
"lower_bound_i64 fail"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
test_model
));
tmp
.
name
=
N
(
alice
);
...
...
@@ -427,8 +425,7 @@ void test_db::key_i64_general() {
my_memset
(
&
tmp
,
0
,
sizeof
(
test_model
));
tmp
.
name
=
N
(
dave
);
res
=
upper_bound_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
test_model
)
);
assert
(
res
==
-
1
,
"upper_bound_i64 dave"
);
assert
(
res
==
0
,
"upper_bound_i64 dave"
);
test_model_v3
tmp2
;
tmp2
.
name
=
N
(
alice
);
...
...
@@ -467,11 +464,10 @@ void test_db::key_i64_general() {
//Remove dummy records
uint64_t
tables
[]
{
N
(
test_tabld
),
N
(
test_tablf
)
};
for
(
auto
&
t
:
tables
)
{
while
(
front_i64
(
current_receiver
(),
current_receiver
(),
t
,
&
tmp
,
sizeof
(
test_model
)
)
!=
-
1
)
{
while
(
front_i64
(
current_receiver
(),
current_receiver
(),
t
,
&
tmp
,
sizeof
(
test_model
)
)
!=
0
)
{
remove_i64
(
current_receiver
(),
t
,
&
tmp
);
}
}
}
void
test_db
::
key_i64_remove_all
()
{
...
...
@@ -497,10 +493,10 @@ void test_db::key_i64_remove_all() {
test_model
tmp
;
res
=
front_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
test_model
)
);
assert
(
res
==
-
1
,
"front_i64 remove"
);
assert
(
res
==
0
,
"front_i64 remove"
);
res
=
back_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
test_model
)
);
assert
(
res
==
-
1
,
"back_i64_i64 remove"
);
assert
(
res
==
0
,
"back_i64_i64 remove"
);
key
=
N
(
alice
);
res
=
remove_i64
(
current_receiver
(),
N
(
test_table
),
&
key
);
...
...
libraries/chain/include/eosio/chain/apply_context.hpp
浏览文件 @
59d9f91a
...
...
@@ -474,7 +474,6 @@ using apply_handler = std::function<void(apply_context&)>;
!
impl
::
record_scope_compare
<
IndexType
,
Scope
>::
compare
(
*
itr
,
keys
))
return
0
;
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
std
::
cout
<<
"WHY!"
<<
"
\n
"
;
if
(
valuelen
)
{
auto
copylen
=
std
::
min
<
size_t
>
(
itr
->
value
.
size
(),
valuelen
);
if
(
copylen
)
{
...
...
@@ -622,8 +621,8 @@ using apply_handler = std::function<void(apply_context&)>;
template
<
typename
IndexType
,
typename
Scope
>
int32_t
apply_context
::
lower_bound_record
(
const
table_id_object
&
t_id
,
typename
IndexType
::
value_type
::
key_type
*
keys
,
char
*
value
,
size_t
valuelen
)
{
std
::
cout
<<
"made it to lower
\n
"
;
require_read_scope
(
t_id
.
scope
);
const
auto
&
idx
=
db
.
get_index
<
IndexType
,
Scope
>
();
auto
tuple
=
impl
::
lower_bound_tuple
<
IndexType
,
Scope
>::
get
(
t_id
,
keys
);
auto
itr
=
idx
.
lower_bound
(
tuple
);
...
...
@@ -635,11 +634,14 @@ using apply_handler = std::function<void(apply_context&)>;
if
(
valuelen
)
{
auto
copylen
=
std
::
min
<
size_t
>
(
itr
->
value
.
size
(),
valuelen
);
std
::
cout
<<
"copylen "
<<
copylen
<<
"
\n
"
;
std
::
cout
<<
"valuelen "
<<
valuelen
<<
"
\n
"
;
if
(
copylen
)
{
itr
->
value
.
copy
(
value
,
copylen
);
}
return
copylen
;
}
else
{
std
::
cout
<<
"valuelen2 "
<<
valuelen
<<
"
\n
"
;
return
itr
->
value
.
size
();
}
}
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
59d9f91a
...
...
@@ -843,8 +843,7 @@ class db_index_api : public context_aware_api {
int
load
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
auto
res
=
call
(
&
apply_context
::
load_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
std
::
cout
<<
"res "
<<
res
<<
"
\n
"
;
return
(
res
==
0
)
?
0
:
res
+
sizeof
(
KeyArrayType
);
return
(
res
>
0
)
?
res
+
sizeof
(
KeyArrayType
)
:
0
;
}
int
front
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
...
...
libraries/fc/include/fc/utility.hpp
浏览文件 @
59d9f91a
...
...
@@ -53,11 +53,10 @@ namespace fc {
const
T
&
min
(
const
T
&
a
,
const
T
&
b
)
{
return
a
<
b
?
a
:
b
;
}
constexpr
size_t
const_strlen
(
const
char
*
str
)
{
if
(
*
str
==
'\0'
)
{
return
0
;
}
return
1
+
const_strlen
(
str
+
1
);
int
i
=
0
;
while
(
*
(
str
+
i
)
!=
'\0'
)
i
++
;
return
i
;
}
...
...
tests/api_tests/api_tests.cpp
浏览文件 @
59d9f91a
...
...
@@ -522,6 +522,7 @@ BOOST_FIXTURE_TEST_CASE(db_tests, tester) { try {
produce_blocks
(
1
);
CALL_TEST_FUNCTION
(
*
this
,
"test_db"
,
"key_i64_general"
,
{});
CALL_TEST_FUNCTION
(
*
this
,
"test_db"
,
"key_i64_remove_all"
,
{});
}
FC_LOG_AND_RETHROW
()
}
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录