Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
30c5c22e
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,发现更多精彩内容 >>
提交
30c5c22e
编写于
10月 16, 2017
作者:
D
Daniel Larimer
提交者:
GitHub
10月 16, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #553 from EOSIO/547-update-key64x64x64-object-index
Update key64x64x64 object index
上级
5fabfcee
16ddef44
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
59 deletion
+59
-59
contracts/test_api/test_db.cpp
contracts/test_api/test_db.cpp
+25
-21
libraries/chain/include/eos/chain/key_value_object.hpp
libraries/chain/include/eos/chain/key_value_object.hpp
+6
-5
libraries/chain/include/eos/chain/message_handling_contexts.hpp
...ies/chain/include/eos/chain/message_handling_contexts.hpp
+22
-5
libraries/chain/include/eos/chain/record_functions.hpp
libraries/chain/include/eos/chain/record_functions.hpp
+5
-27
tests/api_tests/api_tests.cpp
tests/api_tests/api_tests.cpp
+1
-1
未找到文件。
contracts/test_api/test_db.cpp
浏览文件 @
30c5c22e
...
...
@@ -5,16 +5,16 @@
#include "test_api.hpp"
int
primary
[
11
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
};
int
secondary
[
11
]
=
{
7
,
0
,
1
,
3
,
6
,
9
,
2
,
4
,
5
,
10
,
8
};
int
tertiary
[
11
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
};
int
secondary
[
11
]
=
{
7
,
0
,
1
,
3
,
6
,
9
,
10
,
2
,
4
,
5
,
8
};
int
tertiary
[
11
]
=
{
0
,
1
0
,
1
,
2
,
4
,
3
,
5
,
6
,
7
,
8
,
9
};
int
primary_lb
[
11
]
=
{
0
,
0
,
0
,
3
,
3
,
3
,
6
,
7
,
7
,
9
,
9
};
int
secondary_lb
[
11
]
=
{
0
,
0
,
2
,
0
,
2
,
2
,
0
,
7
,
8
,
0
,
2
};
int
tertiary_lb
[
11
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
1
0
};
int
secondary_lb
[
11
]
=
{
0
,
0
,
10
,
0
,
10
,
10
,
0
,
7
,
8
,
0
,
10
};
int
tertiary_lb
[
11
]
=
{
0
,
1
,
2
,
3
,
2
,
5
,
6
,
7
,
8
,
9
,
0
};
int
primary_ub
[
11
]
=
{
3
,
3
,
3
,
6
,
6
,
6
,
7
,
9
,
9
,
-
1
,
-
1
};
int
secondary_ub
[
11
]
=
{
2
,
2
,
8
,
2
,
8
,
8
,
2
,
0
,
-
1
,
2
,
8
};
int
tertiary_ub
[
11
]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
-
1
};
int
secondary_ub
[
11
]
=
{
10
,
10
,
8
,
10
,
8
,
8
,
10
,
0
,
-
1
,
10
,
8
};
int
tertiary_ub
[
11
]
=
{
1
,
2
,
3
,
5
,
3
,
6
,
7
,
8
,
9
,
-
1
,
1
};
#pragma pack(push, 1)
struct
TestModel
{
...
...
@@ -715,17 +715,17 @@ unsigned int test_db::key_i64i64i64_general() {
uint32_t
res
=
0
;
TestModel3xi64
records
[]
=
{
{
1
,
1
,
0
,
N
()},
// 0
{
1
,
1
,
1
,
N
()},
// 1
{
1
,
2
,
2
,
N
()},
// 2
{
2
,
1
,
3
,
N
()},
// 3
{
2
,
2
,
4
,
N
()},
// 4
{
2
,
2
,
5
,
N
()},
// 5
{
3
,
1
,
6
,
N
()},
// 6
{
4
,
0
,
7
,
N
()},
// 7
{
4
,
5
,
8
,
N
()},
// 8
{
5
,
1
,
9
,
N
()},
// 9
{
5
,
2
,
10
,
N
()},
//10
{
1
,
1
,
0
,
N
()},
// 0
<---------------------------
{
1
,
1
,
1
,
N
()},
// 1
|
{
1
,
2
,
2
,
N
()},
// 2
<--------------- |
{
2
,
1
,
3
,
N
()},
// 3
| |
{
2
,
2
,
2
,
N
()},
// 4 same {secondary,tertiary} |
{
2
,
2
,
5
,
N
()},
// 5
|
{
3
,
1
,
6
,
N
()},
// 6
|
{
4
,
0
,
7
,
N
()},
// 7
|
{
4
,
5
,
8
,
N
()},
// 8
|
{
5
,
1
,
9
,
N
()},
// 9
|
{
5
,
2
,
0
,
N
()},
//10 same {tertiary}-------------
};
store_set_in_table
(
records
,
sizeof
(
records
)
/
sizeof
(
records
[
0
]),
N
(
table0
));
...
...
@@ -746,7 +746,7 @@ unsigned int test_db::key_i64i64i64_general() {
#define BS(X) ((X) ? "true" : "false")
#define TABLE1_ASSERT(I, V, msg) \
if(LOGME) {\
eos::print(msg, " : ", res, " a:", V.a, " b:", V.b, " c:", V.c, " t:", V.table, " ("); \
eos::print(msg, " : ", res, " a:", V.a, " b:", V.b, " c:", V.c, " t:", V.table, "
inx:", uint64_t(I), "
("); \
eos::print(BS(res == sizeof(V)), " ", BS(records[I].a == V.a), " ", BS(records[I].b == V.b), " ", BS(records[I].c == V.c), " => ", N(table1), ")\n"); \
} \
WASM_ASSERT( res == sizeof(V) && records[I].a == V.a && records[I].b == V.b && \
...
...
@@ -784,7 +784,7 @@ unsigned int test_db::key_i64i64i64_general() {
V
=
{
11
,
0
};
LOAD_OK
(
secondary
,
i64i64i64
,
N
(
table1
),
7
,
"i64x3 LOAD secondary 0"
);
V
=
{
11
,
1
};
LOAD_OK
(
secondary
,
i64i64i64
,
N
(
table1
),
0
,
"i64x3 LOAD secondary 1"
);
V
=
{
11
,
2
};
LOAD_OK
(
secondary
,
i64i64i64
,
N
(
table1
),
2
,
"i64x3 LOAD secondary 2"
);
V
=
{
11
,
2
};
LOAD_OK
(
secondary
,
i64i64i64
,
N
(
table1
),
10
,
"i64x3 LOAD secondary 2"
);
V
=
{
11
,
3
};
LOAD_ER
(
secondary
,
i64i64i64
,
N
(
table1
),
"i64x3 LOAD secondary fail 3"
);
V
=
{
11
,
4
};
LOAD_ER
(
secondary
,
i64i64i64
,
N
(
table1
),
"i64x3 LOAD secondary fail 4"
);
V
=
{
11
,
5
};
LOAD_OK
(
secondary
,
i64i64i64
,
N
(
table1
),
8
,
"i64x3 LOAD secondary 5"
);
...
...
@@ -794,13 +794,13 @@ unsigned int test_db::key_i64i64i64_general() {
V
=
{
11
,
12
,
1
};
LOAD_OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
1
,
"i64x3 LOAD tertiary 1"
);
V
=
{
11
,
12
,
2
};
LOAD_OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
2
,
"i64x3 LOAD tertiary 2"
);
V
=
{
11
,
12
,
3
};
LOAD_OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
3
,
"i64x3 LOAD tertiary 3"
);
V
=
{
11
,
12
,
4
};
LOAD_
OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
4
,
"i64x3 LOAD tertiary 4"
);
V
=
{
11
,
12
,
4
};
LOAD_
ER
(
tertiary
,
i64i64i64
,
N
(
table1
)
,
"i64x3 LOAD tertiary 4"
);
V
=
{
11
,
12
,
5
};
LOAD_OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
5
,
"i64x3 LOAD tertiary 5"
);
V
=
{
11
,
12
,
6
};
LOAD_OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
6
,
"i64x3 LOAD tertiary 6"
);
V
=
{
11
,
12
,
7
};
LOAD_OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
7
,
"i64x3 LOAD tertiary 7"
);
V
=
{
11
,
12
,
8
};
LOAD_OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
8
,
"i64x3 LOAD tertiary 8"
);
V
=
{
11
,
12
,
9
};
LOAD_OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
9
,
"i64x3 LOAD tertiary 9"
);
V
=
{
11
,
12
,
10
};
LOAD_
OK
(
tertiary
,
i64i64i64
,
N
(
table1
),
10
,
"i64x3 LOAD tertiary 10"
);
V
=
{
11
,
12
,
10
};
LOAD_
ER
(
tertiary
,
i64i64i64
,
N
(
table1
)
,
"i64x3 LOAD tertiary 10"
);
V
=
{
11
,
12
,
11
};
LOAD_ER
(
tertiary
,
i64i64i64
,
N
(
table1
),
"i64x3 LOAD tertiary fail 11"
);
#define NEXT_ALL(I, O, T) \
...
...
@@ -827,6 +827,10 @@ unsigned int test_db::key_i64i64i64_general() {
} while(--j>0); \
}
NEXT_ALL
(
primary
,
i64i64i64
,
N
(
table1
));
NEXT_ALL
(
secondary
,
i64i64i64
,
N
(
table1
));
NEXT_ALL
(
tertiary
,
i64i64i64
,
N
(
table1
));
PREV_ALL
(
primary
,
i64i64i64
,
N
(
table1
));
PREV_ALL
(
secondary
,
i64i64i64
,
N
(
table1
));
PREV_ALL
(
tertiary
,
i64i64i64
,
N
(
table1
));
...
...
libraries/chain/include/eos/chain/key_value_object.hpp
浏览文件 @
30c5c22e
...
...
@@ -172,18 +172,19 @@ namespace eos { namespace chain {
member
<
key64x64x64_value_object
,
AccountName
,
&
key64x64x64_value_object
::
code
>
,
member
<
key64x64x64_value_object
,
AccountName
,
&
key64x64x64_value_object
::
table
>
,
member
<
key64x64x64_value_object
,
uint64_t
,
&
key64x64x64_value_object
::
secondary_key
>
,
member
<
key64x64x64_value_object
,
uint64_t
,
&
key64x64x64_value_object
::
tertiary_key
>
>
,
composite_key_compare
<
std
::
less
<
AccountName
>
,
std
::
less
<
AccountName
>
,
std
::
less
<
AccountName
>
,
std
::
less
<
uint64_t
>
,
std
::
less
<
uint64_t
>
>
member
<
key64x64x64_value_object
,
uint64_t
,
&
key64x64x64_value_object
::
tertiary_key
>
,
member
<
key64x64x64_value_object
,
typename
key64x64x64_value_object
::
id_type
,
&
key64x64x64_value_object
::
id
>
>
>
,
ordered_unique
<
tag
<
by_scope_tertiary
>
,
composite_key
<
key64x64x64_value_object
,
member
<
key64x64x64_value_object
,
AccountName
,
&
key64x64x64_value_object
::
scope
>
,
member
<
key64x64x64_value_object
,
AccountName
,
&
key64x64x64_value_object
::
code
>
,
member
<
key64x64x64_value_object
,
AccountName
,
&
key64x64x64_value_object
::
table
>
,
member
<
key64x64x64_value_object
,
uint64_t
,
&
key64x64x64_value_object
::
tertiary_key
>
member
<
key64x64x64_value_object
,
uint64_t
,
&
key64x64x64_value_object
::
tertiary_key
>
,
member
<
key64x64x64_value_object
,
typename
key64x64x64_value_object
::
id_type
,
&
key64x64x64_value_object
::
id
>
>
,
composite_key_compare
<
std
::
less
<
AccountName
>
,
std
::
less
<
AccountName
>
,
std
::
less
<
AccountName
>
,
std
::
less
<
uint64_t
>
>
composite_key_compare
<
std
::
less
<
AccountName
>
,
std
::
less
<
AccountName
>
,
std
::
less
<
AccountName
>
,
std
::
less
<
uint64_t
>
,
std
::
less
<
typename
key64x64x64_value_object
::
id_type
>
>
>
>
>
;
...
...
libraries/chain/include/eos/chain/message_handling_contexts.hpp
浏览文件 @
30c5c22e
...
...
@@ -160,10 +160,18 @@ public:
int32_t
next_record
(
Name
scope
,
Name
code
,
Name
table
,
typename
IndexType
::
value_type
::
key_type
*
keys
,
char
*
value
,
uint32_t
valuelen
)
{
require_scope
(
scope
);
const
auto
&
idx
=
db
.
get_index
<
IndexType
,
Scope
>
();
auto
tuple
=
next_record_tuple
<
typename
IndexType
::
value_type
,
Scope
>::
get
(
scope
,
code
,
table
,
keys
);
const
auto
&
pidx
=
db
.
get_index
<
IndexType
,
by_scope_primary
>
();
auto
tuple
=
next_record_tuple
<
typename
IndexType
::
value_type
>::
get
(
scope
,
code
,
table
,
keys
);
auto
pitr
=
pidx
.
find
(
tuple
);
auto
itr
=
idx
.
lower_bound
(
tuple
);
if
(
pitr
==
pidx
.
end
())
return
-
1
;
const
auto
&
fidx
=
db
.
get_index
<
IndexType
>
();
auto
itr
=
fidx
.
indicies
().
template
project
<
Scope
>(
pitr
);
const
auto
&
idx
=
db
.
get_index
<
IndexType
,
Scope
>
();
if
(
itr
==
idx
.
end
()
||
itr
->
scope
!=
scope
||
...
...
@@ -195,9 +203,18 @@ public:
int32_t
previous_record
(
Name
scope
,
Name
code
,
Name
table
,
typename
IndexType
::
value_type
::
key_type
*
keys
,
char
*
value
,
uint32_t
valuelen
)
{
require_scope
(
scope
);
const
auto
&
pidx
=
db
.
get_index
<
IndexType
,
by_scope_primary
>
();
auto
tuple
=
next_record_tuple
<
typename
IndexType
::
value_type
>::
get
(
scope
,
code
,
table
,
keys
);
auto
pitr
=
pidx
.
find
(
tuple
);
if
(
pitr
==
pidx
.
end
())
return
-
1
;
const
auto
&
fidx
=
db
.
get_index
<
IndexType
>
();
auto
itr
=
fidx
.
indicies
().
template
project
<
Scope
>(
pitr
);
const
auto
&
idx
=
db
.
get_index
<
IndexType
,
Scope
>
();
auto
tuple
=
next_record_tuple
<
typename
IndexType
::
value_type
,
Scope
>::
get
(
scope
,
code
,
table
,
keys
);
auto
itr
=
idx
.
lower_bound
(
tuple
);
if
(
itr
==
idx
.
end
()
||
itr
==
idx
.
begin
()
||
...
...
libraries/chain/include/eos/chain/record_functions.hpp
浏览文件 @
30c5c22e
...
...
@@ -220,59 +220,37 @@ struct front_record_tuple<keystr_value_object> {
// };
//next_record_tuple (same for previous)
template
<
typename
T
,
typename
Q
>
template
<
typename
T
>
struct
next_record_tuple
{};
template
<
>
struct
next_record_tuple
<
key_value_object
,
by_scope_primary
>
{
struct
next_record_tuple
<
key_value_object
>
{
inline
static
auto
get
(
Name
scope
,
Name
code
,
Name
table
,
uint64_t
*
keys
)
{
return
boost
::
make_tuple
(
AccountName
(
scope
),
AccountName
(
code
),
AccountName
(
table
),
*
keys
);
}
};
template
<
>
struct
next_record_tuple
<
keystr_value_object
,
by_scope_primary
>
{
struct
next_record_tuple
<
keystr_value_object
>
{
inline
static
auto
get
(
Name
scope
,
Name
code
,
Name
table
,
std
::
string
*
keys
)
{
return
boost
::
make_tuple
(
AccountName
(
scope
),
AccountName
(
code
),
AccountName
(
table
),
keys
->
data
());
}
};
template
<
>
struct
next_record_tuple
<
key128x128_value_object
,
by_scope_primary
>
{
struct
next_record_tuple
<
key128x128_value_object
>
{
inline
static
auto
get
(
Name
scope
,
Name
code
,
Name
table
,
uint128_t
*
keys
)
{
return
boost
::
make_tuple
(
uint64_t
(
scope
),
uint64_t
(
code
),
uint64_t
(
table
),
*
keys
,
*
(
keys
+
1
));
}
};
template
<
>
struct
next_record_tuple
<
key128x128_value_object
,
by_scope_secondary
>
{
inline
static
auto
get
(
Name
scope
,
Name
code
,
Name
table
,
uint128_t
*
keys
)
{
return
boost
::
make_tuple
(
uint64_t
(
scope
),
uint64_t
(
code
),
uint64_t
(
table
),
*
(
keys
+
1
),
*
keys
);
}
};
template
<
>
struct
next_record_tuple
<
key64x64x64_value_object
,
by_scope_primary
>
{
struct
next_record_tuple
<
key64x64x64_value_object
>
{
inline
static
auto
get
(
Name
scope
,
Name
code
,
Name
table
,
uint64_t
*
keys
)
{
return
boost
::
make_tuple
(
uint64_t
(
scope
),
uint64_t
(
code
),
uint64_t
(
table
),
*
keys
,
*
(
keys
+
1
),
*
(
keys
+
2
));
}
};
template
<
>
struct
next_record_tuple
<
key64x64x64_value_object
,
by_scope_secondary
>
{
inline
static
auto
get
(
Name
scope
,
Name
code
,
Name
table
,
uint64_t
*
keys
)
{
return
boost
::
make_tuple
(
uint64_t
(
scope
),
uint64_t
(
code
),
uint64_t
(
table
),
*
(
keys
+
1
),
*
(
keys
+
2
));
}
};
template
<
>
struct
next_record_tuple
<
key64x64x64_value_object
,
by_scope_tertiary
>
{
inline
static
auto
get
(
Name
scope
,
Name
code
,
Name
table
,
uint64_t
*
keys
)
{
return
boost
::
make_tuple
(
uint64_t
(
scope
),
uint64_t
(
code
),
uint64_t
(
table
),
*
(
keys
+
2
));
}
};
//lower_bound_tuple
...
...
tests/api_tests/api_tests.cpp
浏览文件 @
30c5c22e
...
...
@@ -199,7 +199,7 @@ void send_set_code_message(testing_blockchain& chain, types::setcode& handler, A
BOOST_FIXTURE_TEST_CASE
(
test_all
,
testing_fixture
)
{
try
{
//auto wasm = assemble_wast( readFile2("/home/matu/Documents/Dev/eos/contracts/test_api/test_api.wast").c_str() );
//auto wasm = assemble_wast( readFile2("/home/matu/Documents/Dev/eos/
build/
contracts/test_api/test_api.wast").c_str() );
auto
wasm
=
assemble_wast
(
test_api_wast
);
Make_Blockchain
(
chain
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录