Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
a4258b74
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,发现更多精彩内容 >>
提交
a4258b74
编写于
8月 30, 2017
作者:
P
Pravin Bezwada
提交者:
Andrianto Lie
9月 01, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Documented class API with examples at class level.`
上级
eff9ce47
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
719 addition
and
8 deletion
+719
-8
contracts/eoslib/db.h
contracts/eoslib/db.h
+632
-5
contracts/eoslib/message.h
contracts/eoslib/message.h
+20
-2
contracts/eoslib/message.hpp
contracts/eoslib/message.hpp
+13
-0
contracts/eoslib/token.hpp
contracts/eoslib/token.hpp
+54
-1
未找到文件。
contracts/eoslib/db.h
浏览文件 @
a4258b74
此差异已折叠。
点击以展开。
contracts/eoslib/message.h
浏览文件 @
a4258b74
...
...
@@ -37,14 +37,23 @@ extern "C" {
* @param msg - a pointer where up to @ref len bytes of the current message will be copied
* @param len - len of the current message to be copied
* @return the number of bytes copied to msg
* Example
* @code
* char buffer[128];
* uint32_t total = readMessage(buffer, 64);
* @endcode
*/
uint32_t
readMessage
(
void
*
msg
,
uint32_t
len
);
/**
* Get the length of the current message's data field
* This method is useful for dynamicly sized messages
* @brief Get the leng
ht
of current message's data field
* This method is useful for dynamic
al
ly sized messages
* @brief Get the leng
th
of current message's data field
* @return the length of the current message's data field
* Example
* @code
* uint32_t msgsize = messageSize();
* @endcode
*/
uint32_t
messageSize
();
...
...
@@ -52,6 +61,10 @@ extern "C" {
* Verifies that @ref name exists in the set of notified accounts on a message. Throws if not found
* @brief Verify specified account exists in the set of notified accounts
* @param name - name of the account to be verified
* Example
* @code
* requireNotice(N(MyAccount)); // throws exception if MyAccount is not found in recipients list.
* @endcode
*/
void
requireNotice
(
AccountName
name
);
...
...
@@ -59,6 +72,10 @@ extern "C" {
* Verifies that @ref name exists in the set of provided auths on a message. Throws if not found
* @brief Verify specified account exists in the set of provided auths
* @param name - name of the account to be verified
* Example
* @code
* requireAuth(N(MyAccount)); // throws exception if MyAccount is not found in authentication list.
* @endcode
*/
void
requireAuth
(
AccountName
name
);
...
...
@@ -75,6 +92,7 @@ extern "C" {
* @brief Aborts processing of this message and unwinds all pending changes
* @param test - 0 to abort, 1 to ignore
* @param cstr - a null terminated message to explain the reason for failure
*/
void
assert
(
uint32_t
test
,
const
char
*
cstr
);
...
...
contracts/eoslib/message.hpp
浏览文件 @
a4258b74
...
...
@@ -18,6 +18,15 @@ namespace eos {
* This method attempts to reinterpret the message body as type T. This will only work
* if the message has no dynamic fields and the struct packing on type T is properly defined.
* @brief Interpret the message body as type T
* Example
* @code
*
* struct MyMessage {
* uint32_t time;
* };
*
* MyMessage msg = currentMessage<MyMessage>();
* @endcode
*/
template
<
typename
T
>
T
currentMessage
()
{
...
...
@@ -40,6 +49,10 @@ namespace eos {
* @note message.code is also considered as part of the set of notified accounts
*
* @brief Verify specified accounts exist in the set of notified accounts
* Example
* @code
* requireNotice(N(Account1), N(Account2), N(Account3)); // throws exception if any of them not in set.
* @endcode
*/
template
<
typename
...
Accounts
>
void
requireNotice
(
AccountName
name
,
Accounts
...
accounts
){
...
...
contracts/eoslib/token.hpp
浏览文件 @
a4258b74
...
...
@@ -26,6 +26,30 @@ namespace eos {
* @tparam NumberType - numeric type of the token
* @tparam CurrencyType - type of the currency (e.g. eos) represented as an unsigned 64 bit integer
* @ingroup tokens
* @code
* typedef eos::token<uint32_t, N(MyToken)> MyToken;
* MyToken a(128);
* a.print(); // Output: 128 MyToken
* MyToken b(64);
* a += b;
* a.print(); // Output: 192 MyToken
* b.print(); // Output: 64 MyToken
* a -= b;
* a.print(); // Output: 128 MyToken
* b.print(); // Output: 64 MyToken
* b -= a; // Throws integer underflow exception
* MyToken c = a + b;
* c.print(); // Output: 192 MyToken
* MyToken d = a - b;
* d.print(); // Output: 64 MyToken
* MyToken maxToken(std::numeric_limits<uint32_t>::max());
* maxToken += b; // Throws integer overflow exception
* std::cout << (maxToken > b); // Output: true
* std::cout << (b > maxToken); // Output: false
* std::cout << (bool)maxToken; // Output: true
* std::cout << (a == b); // Output: false
* std::cout << (a != b); // Output: true
* @endcode
*/
template
<
typename
NumberType
,
uint64_t
CurrencyType
=
N
(
eos
)
>
struct
token
{
...
...
@@ -179,12 +203,35 @@ namespace eos {
/**
* Defines a fixed precision price between two tokens.
* A price is written as X Base/Quote.
* A price is written as X Base/Quote.
Where X is a power of 10 which makes it simpler to just shift the decimal.
* It supports the following operator: /, \, <=, <, ==, !=, >=, > and also print functionality
* @brief Defines a fixed precision price between two tokens.
* @tparam BaseToken - represents the type of the base token
* @tparam QuoteToken - represents the type of the quote token
* @ingroup tokens
* @code
* typedef eos::token<uint64_t, N(MyBaseToken)> MyBaseToken;
* typedef eos::token<uint64_t, N(MyQuoteToken)> MyQuoteToken;
* typedef price<MyBaseToken, MyQuoteToken> MyBaseToQuotePrice;
* MyBaseToken zeroBaseToken;
* MyQuoteToken zeroQuoteToken;
* MyBaseToQuotePrice zeroBaseToQuote(zeroBaseToken, zeroQuoteToken); // throws invalid price exception
* MyBaseToken baseToken(128);
* MyQuoteToken quoteToken(128);
* MyBaseToQuotePrice aPrice(baseToken, quoteToken);
* aPrice.print(); // Output: 1e+15. MyBaseToken / MyQuoteToken
* MyQuoteToken anotherQuote = baseToken / price;
* std::cout << (anotherQuote == quoteToken); // Output: true
* MyBaseToken anotherBase = quoteToken * price;
* std::cout << (anotherBase == baseToken); // Output: true
* MyBaseToQuotePrice anotherPrice(baseToken, quoteToken);
* std::cout << (aPrice == anotherPrice); // Output: true
* std::cout << (aPrice != anotherPrice); // Output: false
* MyBaseToken base256(256);
* MyBaseToQuotePrice price2(base256, quoteToken);
* std::cout << (price2 > aPrice); // Output: true
* std::cout << (aPrice < price2); // Output: true
* @endcode
*/
template
<
typename
BaseToken
,
typename
QuoteToken
>
struct
price
...
...
@@ -327,6 +374,12 @@ namespace eos {
* The binary structure of the `transfer` message type for the `eos` contract.
* @brief The binary structure of the `transfer` message type for the `eos` contract.
* @ingroup tokens
* @code
* Transfer MeToYou;
* MeToYou.from = N(Me);
* MeToYou.to = N(You);
* MeToYou.quantity = Tokens(100);
* @endcode
*/
struct
Transfer
{
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录