Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
dbbd1ddc
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,发现更多精彩内容 >>
提交
dbbd1ddc
编写于
2月 15, 2018
作者:
A
arhag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compilation issues regarding uint256 usage
上级
f6e4e3a0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
48 deletion
+48
-48
contracts/eosiolib/types.h
contracts/eosiolib/types.h
+7
-15
contracts/eosiolib/types.hpp
contracts/eosiolib/types.hpp
+8
-0
contracts/identity/identity.hpp
contracts/identity/identity.hpp
+27
-27
contracts/multi_index_test/multi_index_test.cpp
contracts/multi_index_test/multi_index_test.cpp
+6
-6
未找到文件。
contracts/eosiolib/types.h
浏览文件 @
dbbd1ddc
...
...
@@ -64,21 +64,13 @@ struct account_permission {
permission_name
permission
;
};
union
{
uint8_t
bytes
[
8
];
uint16_t
uint16
[
8
];
uint32_t
uint32
[
8
];
uint64_t
uint64
[
4
];
uint128_t
uint128
[
2
];
}
typedef
uint256
;
bool
operator
==
(
const
uint256
&
a
,
const
uint256
&
b
)
{
return
a
.
uint128
[
0
]
==
b
.
uint128
[
0
]
&&
a
.
uint128
[
1
]
==
b
.
uint128
[
1
];
}
bool
operator
!=
(
const
uint256
&
a
,
const
uint256
&
b
)
{
return
!
(
a
==
b
);
}
typedef
union
{
uint8_t
bytes
[
32
];
uint16_t
uint16s
[
16
];
uint32_t
uint32s
[
8
];
uint64_t
uint64s
[
4
];
uint128_t
uint128s
[
2
];
}
uint256
;
#ifdef __cplusplus
}
/// extern "C"
...
...
contracts/eosiolib/types.hpp
浏览文件 @
dbbd1ddc
...
...
@@ -89,5 +89,13 @@ namespace eosio {
};
/// @}
bool
operator
==
(
const
uint256
&
a
,
const
uint256
&
b
)
{
return
a
.
uint128s
[
0
]
==
b
.
uint128s
[
0
]
&&
a
.
uint128s
[
1
]
==
b
.
uint128s
[
1
];
}
bool
operator
!=
(
const
uint256
&
a
,
const
uint256
&
b
)
{
return
!
(
a
==
b
);
}
}
// namespace eos
contracts/identity/identity.hpp
浏览文件 @
dbbd1ddc
...
...
@@ -20,30 +20,30 @@ namespace identity {
/**
* This contract maintains a graph database of certified statements about an
* identity. An identity is separated from the concept of an account because
* the mapping of identity to accounts is subject to community consensus.
* the mapping of identity to accounts is subject to community consensus.
*
* Some use cases need a global source of trust, this trust rooted in the voter
* who selects block producers. A block producer's opinion is "trusted" and so
* is the opinion of anyone the block producer marks as "trusted".
*
* is the opinion of anyone the block producer marks as "trusted".
*
* When a block producer is voted out the implicit trust in every certification
* they made or those they trusted made is removed. All users are liable for
* making false certifications.
* they made or those they trusted made is removed. All users are liable for
* making false certifications.
*
* An account needs to claim the identity and a trusted account must certify the
* claim.
* claim.
*
* Data for an identity is stored:
*
* DeployToAccount / identity / certs / [property, trusted, certifier] => value
*
* Questions database is designed to answer:
*
* 1. has $identity.$unique been certified a "trusted" certifier
* 2. has $identity.$property been certified by $account
*
* 1. has $identity.$unique been certified a "trusted" certifier
* 2. has $identity.$property been certified by $account
* 3. has $identity.$trusted been certified by a "trusted" certifier
* 4. what account has authority to speak on behalf of identity?
* - for each trusted owner certification
* - for each trusted owner certification
* check to see if the account has claimed it
*
* 5. what identity does account have authority to speak on behalf?
...
...
@@ -52,12 +52,12 @@ namespace identity {
*
* This database structure enables parallel opeartions on independent identities.
*
* When an account certs a property we check to see if that
* When an account certs a property we check to see if that
*/
template
<
uint64_t
DeployToAccount
>
class
contract
{
public:
static
const
uint64_t
code
=
DeployToAccount
;
typedef
uint64_t
identity_name
;
typedef
uint64_t
property_name
;
...
...
@@ -66,14 +66,14 @@ namespace identity {
/**
* This action create a new globally unique 64 bit identifier,
* to minimize collisions each account is automatically assigned
* a 32 bit identity prefix based upon hash(account_name) ^ hash(tapos).
* a 32 bit identity prefix based upon hash(account_name) ^ hash(tapos).
*
* With this method no two accounts are likely to be assigned the same
* 32 bit prefix consistantly due to the constantly changing tapos. This prevents
* abuse of 'creator' selection to generate intentional conflicts with other users.
*
* The creator can determine the last 32 bits using an algorithm of their choice. We
* presume the creator's algorithm can avoid collisions with itself.
* presume the creator's algorithm can avoid collisions with itself.
*
* Even if two accounts get a collision in first 32 bits, a proper creator algorithm
* should generate randomness in last 32 bits that will minimize collisions. In event
...
...
@@ -94,25 +94,25 @@ namespace identity {
struct
certvalue
{
property_name
property
;
///< name of property, base32 encoded i64
string
type
;
///< defines type serialized in data
vector
<
char
>
data
;
///<
vector
<
char
>
data
;
///<
string
memo
;
///< meta data documenting basis of certification
uint8_t
confidence
=
1
;
///< used to define liability for lies,
uint8_t
confidence
=
1
;
///< used to define liability for lies,
/// 0 to delete
EOSLIB_SERIALIZE
(
certvalue
,
(
property
)(
type
)(
data
)(
memo
)(
confidence
)
)
};
struct
certprop
:
public
action_meta
<
code
,
N
(
certprop
)
>
struct
certprop
:
public
action_meta
<
code
,
N
(
certprop
)
>
{
account_name
bill_storage_to
;
///< account which is paying for storage
account_name
certifier
;
account_name
certifier
;
identity_name
identity
;
vector
<
certvalue
>
values
;
EOSLIB_SERIALIZE
(
certprop
,
(
bill_storage_to
)(
certifier
)(
identity
)(
values
)
)
};
struct
settrust
:
public
action_meta
<
code
,
N
(
settrust
)
>
struct
settrust
:
public
action_meta
<
code
,
N
(
settrust
)
>
{
account_name
trustor
;
///< the account authorizing the trust
account_name
trusting
;
///< the account receiving the trust
...
...
@@ -122,7 +122,7 @@ namespace identity {
};
/**
* Defines an object in an i64i64i64 table
* Defines an object in an i64i64i64 table
*/
struct
certrow
{
uint64_t
id
;
...
...
@@ -135,10 +135,10 @@ namespace identity {
uint64_t
primary_key
()
const
{
return
id
;
}
constexpr
static
uint256
key
(
uint64_t
property
,
uint64_t
trusted
,
uint64_t
certifier
)
{
uint256
key
;
key
.
uint64
[
0
]
=
property
;
key
.
uint64
[
1
]
=
trusted
;
key
.
uint64
[
2
]
=
certifier
;
key
.
uint64
[
3
]
=
0
;
key
.
uint64
s
[
0
]
=
property
;
key
.
uint64
s
[
1
]
=
trusted
;
key
.
uint64
s
[
2
]
=
certifier
;
key
.
uint64
s
[
3
]
=
0
;
return
key
;
}
uint256
get_key
()
const
{
return
key
(
property
,
trusted
,
certifier
);
};
...
...
@@ -147,7 +147,7 @@ namespace identity {
};
struct
identrow
{
uint64_t
identity
;
uint64_t
identity
;
account_name
creator
;
uint64_t
primary_key
()
const
{
return
identity
;
}
...
...
@@ -175,7 +175,7 @@ namespace identity {
}
static
account_name
get_owner_for_identity
(
identity_name
ident
)
{
// for each trusted owner certification
// for each trusted owner certification
// check to see if the certification is still trusted
// check to see if the account has claimed it
certs_table
certs
(
code
,
ident
);
...
...
@@ -299,7 +299,7 @@ namespace identity {
auto
ptr
=
t
.
find
(
cert
.
identity
);
eosio_assert
(
ptr
!=
nullptr
,
"identity does not exist"
);
/// the table exists in the scope of the identity
/// the table exists in the scope of the identity
certs_table
certs
(
code
,
cert
.
identity
);
bool
trusted
=
is_trusted
(
cert
.
certifier
);
...
...
contracts/multi_index_test/multi_index_test.cpp
浏览文件 @
dbbd1ddc
...
...
@@ -104,17 +104,17 @@ namespace multi_index_test {
const
auto
&
entry1
=
testtable
.
emplace
(
payer
,
[
&
](
auto
&
o
)
{
o
.
id
=
1
;
o
.
val
=
uint256
{.
word
s
=
{
0
,
0
,
0
,
42
}};
o
.
val
=
uint256
{.
uint64
s
=
{
0
,
0
,
0
,
42
}};
});
const
auto
&
entry2
=
testtable
.
emplace
(
payer
,
[
&
](
auto
&
o
)
{
o
.
id
=
2
;
o
.
val
=
uint256
{.
word
s
=
{
1
,
2
,
3
,
4
}};
o
.
val
=
uint256
{.
uint64
s
=
{
1
,
2
,
3
,
4
}};
});
const
auto
&
entry3
=
testtable
.
emplace
(
payer
,
[
&
](
auto
&
o
)
{
o
.
id
=
3
;
o
.
val
=
uint256
{.
word
s
=
{
0
,
0
,
0
,
42
}};
o
.
val
=
uint256
{.
uint64
s
=
{
0
,
0
,
0
,
42
}};
});
const
auto
*
e
=
testtable
.
find
(
2
);
...
...
@@ -126,10 +126,10 @@ namespace multi_index_test {
auto
validx
=
testtable
.
get_index
<
N
(
byval
)
>
();
auto
lower1
=
validx
.
lower_bound
(
uint256
{.
word
s
=
{
0
,
0
,
0
,
40
}});
auto
lower1
=
validx
.
lower_bound
(
uint256
{.
uint64
s
=
{
0
,
0
,
0
,
40
}});
print
(
"First entry with a val of at least 40 has ID="
,
lower1
->
id
,
".
\n
"
);
auto
lower2
=
validx
.
lower_bound
(
uint256
{.
word
s
=
{
0
,
0
,
0
,
50
}});
auto
lower2
=
validx
.
lower_bound
(
uint256
{.
uint64
s
=
{
0
,
0
,
0
,
50
}});
print
(
"First entry with a val of at least 50 has ID="
,
lower2
->
id
,
".
\n
"
);
if
(
&*
lower2
==
e
)
{
...
...
@@ -142,7 +142,7 @@ namespace multi_index_test {
cout
<<
item
.
val
<<
"
\n
"
;
}
auto
upper
=
validx
.
upper_bound
(
uint256
{.
word
s
=
{
0
,
0
,
0
,
42
}});
auto
upper
=
validx
.
upper_bound
(
uint256
{.
uint64
s
=
{
0
,
0
,
0
,
42
}});
print
(
"First entry with a val greater than 42 has ID="
,
upper
->
id
,
".
\n
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录