Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
d2c972bc
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,发现更多精彩内容 >>
提交
d2c972bc
编写于
3月 01, 2018
作者:
A
arhag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Complete first idx256 test case and fix to fixed_key
上级
e1d462a9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
13 deletion
+77
-13
contracts/eosiolib/fixed_key.hpp
contracts/eosiolib/fixed_key.hpp
+16
-4
contracts/test_api_multi_index/test_multi_index.cpp
contracts/test_api_multi_index/test_multi_index.cpp
+42
-5
libraries/chain/include/eosio/chain/fixed_key.hpp
libraries/chain/include/eosio/chain/fixed_key.hpp
+19
-4
未找到文件。
contracts/eosiolib/fixed_key.hpp
浏览文件 @
d2c972bc
...
...
@@ -12,8 +12,20 @@
namespace
eosio
{
template
<
size_t
Size
>
class
fixed_key
;
template
<
size_t
Size
>
bool
operator
==
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
template
<
size_t
Size
>
bool
operator
!=
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
template
<
size_t
Size
>
bool
operator
>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
template
<
size_t
Size
>
bool
operator
<
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
/**
* @defgroup fixed_key fixed size key sorted lexicographically
...
...
@@ -143,13 +155,13 @@ namespace eosio {
}
// Comparison operators
friend
bool
operator
==
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
==
<>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
!=
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
!=
<>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
>
<>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
<
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
<
<>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
private:
...
...
contracts/test_api_multi_index/test_multi_index.cpp
浏览文件 @
d2c972bc
...
...
@@ -31,7 +31,7 @@ namespace _test_multi_index {
key256
sec
;
auto
primary_key
()
const
{
return
id
;
}
key256
get_secondary
()
const
{
return
sec
;
}
const
key256
&
get_secondary
()
const
{
return
sec
;
}
EOSLIB_SERIALIZE
(
record_idx256
,
(
id
)(
sec
)
)
};
...
...
@@ -295,22 +295,25 @@ void test_multi_index::idx256_general()
print
(
"Testing key256 secondary index.
\n
"
);
multi_index
<
table_name
,
record
,
indexed_by
<
N
(
bysecondary
),
const_mem_fun
<
record
,
key256
,
&
record
::
get_secondary
>
>
indexed_by
<
N
(
bysecondary
),
const_mem_fun
<
record
,
const
key256
&
,
&
record
::
get_secondary
>
>
>
table
(
current_receiver
(),
current_receiver
()
);
auto
fourtytwo
=
key256
::
make_from_word_sequence
<
uint64_t
>
(
0ULL
,
0ULL
,
0ULL
,
42ULL
);
auto
onetwothreefour
=
key256
::
make_from_word_sequence
<
uint64_t
>
(
1ULL
,
2ULL
,
3ULL
,
4ULL
);
const
auto
&
entry1
=
table
.
emplace
(
payer
,
[
&
](
auto
&
o
)
{
o
.
id
=
1
;
o
.
sec
=
key256
::
make_from_word_sequence
<
uint64_t
>
(
0ULL
,
0ULL
,
0ULL
,
42ULL
)
;
o
.
sec
=
fourtytwo
;
});
const
auto
&
entry2
=
table
.
emplace
(
payer
,
[
&
](
auto
&
o
)
{
o
.
id
=
2
;
o
.
sec
=
key256
::
make_from_word_sequence
<
uint64_t
>
(
1ULL
,
2ULL
,
3ULL
,
4ULL
)
;
o
.
sec
=
onetwothreefour
;
});
const
auto
&
entry3
=
table
.
emplace
(
payer
,
[
&
](
auto
&
o
)
{
o
.
id
=
3
;
o
.
sec
=
key256
::
make_from_word_sequence
<
uint64_t
>
(
0ULL
,
0ULL
,
0ULL
,
42ULL
)
;
o
.
sec
=
fourtytwo
;
});
const
auto
*
e
=
table
.
find
(
2
);
...
...
@@ -320,13 +323,26 @@ void test_multi_index::idx256_general()
print
(
" ID="
,
item
.
primary_key
(),
", secondary="
,
item
.
sec
,
"
\n
"
);
}
{
auto
itr
=
table
.
begin
();
eosio_assert
(
itr
->
primary_key
()
==
1
&&
itr
->
get_secondary
()
==
fourtytwo
,
"idx256_general - primary key sort"
);
++
itr
;
eosio_assert
(
itr
->
primary_key
()
==
2
&&
itr
->
get_secondary
()
==
onetwothreefour
,
"idx256_general - primary key sort"
);
++
itr
;
eosio_assert
(
itr
->
primary_key
()
==
3
&&
itr
->
get_secondary
()
==
fourtytwo
,
"idx256_general - primary key sort"
);
++
itr
;
eosio_assert
(
itr
==
table
.
end
(),
"idx256_general - primary key sort"
);
}
auto
secidx
=
table
.
get_index
<
N
(
bysecondary
)
>
();
auto
lower1
=
secidx
.
lower_bound
(
key256
::
make_from_word_sequence
<
uint64_t
>
(
0ULL
,
0ULL
,
0ULL
,
40ULL
));
print
(
"First entry with a secondary key of at least 40 has ID="
,
lower1
->
id
,
".
\n
"
);
eosio_assert
(
lower1
->
id
==
1
,
"idx256_general - lower_bound"
);
auto
lower2
=
secidx
.
lower_bound
(
key256
::
make_from_word_sequence
<
uint64_t
>
(
0ULL
,
0ULL
,
0ULL
,
50ULL
));
print
(
"First entry with a secondary key of at least 50 has ID="
,
lower2
->
id
,
".
\n
"
);
eosio_assert
(
lower2
->
id
==
2
,
"idx256_general - lower_bound"
);
if
(
&*
lower2
==
e
)
{
print
(
"Previously found entry is the same as the one found earlier with a primary key value of 2.
\n
"
);
...
...
@@ -338,9 +354,21 @@ void test_multi_index::idx256_general()
cout
<<
item
.
sec
<<
"
\n
"
;
}
{
auto
itr
=
secidx
.
begin
();
eosio_assert
(
itr
->
primary_key
()
==
1
,
"idx256_general - secondary key sort"
);
++
itr
;
eosio_assert
(
itr
->
primary_key
()
==
3
,
"idx256_general - secondary key sort"
);
++
itr
;
eosio_assert
(
itr
->
primary_key
()
==
2
,
"idx256_general - secondary key sort"
);
++
itr
;
eosio_assert
(
itr
==
secidx
.
end
(),
"idx256_general - secondary key sort"
);
}
auto
upper
=
secidx
.
upper_bound
(
key256
::
make_from_word_sequence
<
uint64_t
>
(
0ULL
,
0ULL
,
0ULL
,
42ULL
));
print
(
"First entry with a secondary key greater than 42 has ID="
,
upper
->
id
,
".
\n
"
);
eosio_assert
(
upper
->
id
==
2
,
"idx256_general - upper_bound"
);
print
(
"Removed entry with ID="
,
lower1
->
id
,
".
\n
"
);
table
.
remove
(
*
lower1
);
...
...
@@ -349,4 +377,13 @@ void test_multi_index::idx256_general()
for
(
const
auto
&
item
:
table
)
{
print
(
" ID="
,
item
.
primary_key
(),
", secondary="
,
item
.
sec
,
"
\n
"
);
}
{
auto
itr
=
table
.
begin
();
eosio_assert
(
itr
->
primary_key
()
==
2
&&
itr
->
get_secondary
()
==
onetwothreefour
,
"idx256_general - primary key sort after remove"
);
++
itr
;
eosio_assert
(
itr
->
primary_key
()
==
3
&&
itr
->
get_secondary
()
==
fourtytwo
,
"idx256_general - primary key sort after remove"
);
++
itr
;
eosio_assert
(
itr
==
table
.
end
(),
"idx256_general - primary key sort after remove"
);
}
}
libraries/chain/include/eosio/chain/fixed_key.hpp
浏览文件 @
d2c972bc
...
...
@@ -12,6 +12,21 @@
namespace
eosio
{
template
<
size_t
Size
>
class
fixed_key
;
template
<
size_t
Size
>
bool
operator
==
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
template
<
size_t
Size
>
bool
operator
!=
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
template
<
size_t
Size
>
bool
operator
>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
template
<
size_t
Size
>
bool
operator
<
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
/**
* @defgroup fixed_key fixed size key sorted lexicographically
* @ingroup types
...
...
@@ -188,13 +203,13 @@ namespace eosio {
}
// Comparison operators
friend
bool
operator
==
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
==
<>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
!=
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
!=
<>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
>
<>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
<
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
friend
bool
operator
<
<>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
);
private:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录