Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
4ad559c7
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,体验更适合开发者的 AI 搜索 >>
提交
4ad559c7
编写于
12月 14, 2019
作者:
W
wangxxzhiyy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update contracts
上级
beabe753
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
312 addition
and
120 deletion
+312
-120
contracts/hdddeposit/hdddeposit.abi
contracts/hdddeposit/hdddeposit.abi
+20
-1
contracts/hdddeposit/hdddeposit.cpp
contracts/hdddeposit/hdddeposit.cpp
+35
-1
contracts/hdddeposit/hdddeposit.hpp
contracts/hdddeposit/hdddeposit.hpp
+2
-0
contracts/hddpool/hddpool.abi
contracts/hddpool/hddpool.abi
+32
-9
contracts/hddpool/hddpool.cpp
contracts/hddpool/hddpool.cpp
+203
-84
contracts/hddpool/hddpool.hpp
contracts/hddpool/hddpool.hpp
+20
-25
未找到文件。
contracts/hdddeposit/hdddeposit.abi
浏览文件 @
4ad559c7
...
...
@@ -180,7 +180,21 @@
"type": "int64"
}
]
}
},
{
"name": "mchgdepacc",
"base": "",
"fields": [
{
"name": "minerid",
"type": "uint64"
},
{
"name": "new_depacc",
"type": "name"
}
]
}
],
"actions": [
{
...
...
@@ -217,6 +231,11 @@
"name": "setrate",
"type": "setrate",
"ricardian_contract": ""
},
{
"name": "mchgdepacc",
"type": "mchgdepacc",
"ricardian_contract": ""
}
],
"tables": [
...
...
contracts/hdddeposit/hdddeposit.cpp
浏览文件 @
4ad559c7
...
...
@@ -259,6 +259,40 @@ void hdddeposit::setrate(int64_t rate) {
}
void
hdddeposit
::
mchgdepacc
(
uint64_t
minerid
,
name
new_depacc
)
{
require_auth
(
new_depacc
);
minerdeposit_table
_mdeposit
(
_self
,
_self
);
const
auto
&
miner
=
_mdeposit
.
get
(
minerid
,
"no deposit record for this minerid"
);
eosio_assert
(
miner
.
account_name
!=
new_depacc
,
"must use different account to change deposit user"
);
depositpool_table
_deposit_old
(
_self
,
miner
.
account_name
.
value
);
const
auto
&
acc_old
=
_deposit_old
.
get
(
miner
.
account_name
,
"no deposit pool record for original deposit user"
);
depositpool_table
_deposit_new
(
_self
,
new_depacc
.
value
);
const
auto
&
acc_new
=
_deposit_new
.
get
(
new_depacc
.
value
,
"no deposit pool record for new deposit user"
);
eosio_assert
(
acc_new
.
deposit_free
.
amount
>=
miner
.
dep_total
.
amount
,
"new deposit user free deposit not enough"
);
eosio_assert
(
hddpool
::
get_miner_pool
(
minerid
)
==
new_depacc
,
"minerid not exist in new_depacc's storepool "
);
//变更原抵押账户的押金数量
_deposit_old
.
modify
(
acc_old
,
0
,
[
&
](
auto
&
a
)
{
a
.
deposit_free
+=
miner
.
deposit
;
});
//将矿机的押金数量重新恢复到未扣罚金的初始额度
_mdeposit
.
modify
(
miner
,
0
,
[
&
](
auto
&
a
)
{
a
.
account_name
=
new_depacc
;
a
.
deposit
=
a
.
dep_total
;
});
_deposit_new
.
modify
(
acc_new
,
0
,
[
&
](
auto
&
a
)
{
a
.
deposit_free
-=
miner
.
dep_total
;
});
}
void
hdddeposit
::
check_bp_account
(
account_name
bpacc
,
uint64_t
id
,
bool
isCheckId
)
{
account_name
shadow
;
uint64_t
seq_num
=
eosiosystem
::
getProducerSeq
(
bpacc
,
shadow
);
...
...
@@ -272,4 +306,4 @@ void hdddeposit::check_bp_account(account_name bpacc, uint64_t id, bool isCheckI
EOSIO_ABI
(
hdddeposit
,
(
paydeppool
)(
unpaydeppool
)(
paydeposit
)(
chgdeposit
)(
payforfeit
)(
delminer
)(
setrate
))
EOSIO_ABI
(
hdddeposit
,
(
paydeppool
)(
unpaydeppool
)(
paydeposit
)(
chgdeposit
)(
payforfeit
)(
delminer
)(
setrate
)
(
mchgdepacc
)
)
contracts/hdddeposit/hdddeposit.hpp
浏览文件 @
4ad559c7
...
...
@@ -25,6 +25,8 @@ class hdddeposit : public eosio::contract {
void
delminer
(
uint64_t
minerid
);
void
setrate
(
int64_t
rate
);
void
mchgdepacc
(
uint64_t
minerid
,
name
new_depacc
);
inline
asset
get_deposit
(
account_name
user
)
const
;
inline
asset
get_miner_deposit
(
uint64_t
minerid
)
const
;
inline
bool
is_deposit_enough
(
asset
deposit
,
uint64_t
max_space
)
const
;
...
...
contracts/hddpool/hddpool.abi
浏览文件 @
4ad559c7
...
...
@@ -196,6 +196,16 @@
}
]
},
{
"name": "calcprofit",
"base": "",
"fields": [
{
"name": "user",
"type": "name"
}
]
},
{
"name": "mchgspace",
"base": "",
...
...
@@ -547,7 +557,7 @@
]
},
{
"name": "user
acchdd
",
"name": "user
hddinfo
",
"base": "",
"fields": [
{
...
...
@@ -558,25 +568,33 @@
"name": "hdd_storehdd",
"type": "int64"
},
{
"name": "hdd_minerhdd",
"type": "int64"
},
{
"name": "hdd_per_cycle_fee",
"type": "int64"
},
{
"name": "hdd_space",
"name": "hdd_space
_store
",
"type": "uint64"
},
{
"name": "last_hdd_time",
"name": "last_hdd
store
_time",
"type": "uint64"
},
{
"name": "hdd_minerhdd",
"type": "int64"
},
{
"name": "hdd_per_cycle_profit",
"type": "int64"
},
{
"name": "hdd_space_profit",
"type": "uint64"
},
{
"name": "last_hddprofit_time",
"type": "uint64"
}
]
},
...
...
@@ -674,6 +692,11 @@
"type": "getbalance",
"ricardian_contract": ""
},
{
"name": "calcprofit",
"type": "calcprofit",
"ricardian_contract": ""
},
{
"name": "sellhdd",
"type": "sellhdd",
...
...
@@ -816,8 +839,8 @@
"key_types": []
},
{
"name": "user
acchdd
",
"type": "user
acchdd
",
"name": "user
hddinfo
",
"type": "user
hddinfo
",
"index_type": "i64",
"key_names": [],
"key_types": []
...
...
contracts/hddpool/hddpool.cpp
浏览文件 @
4ad559c7
此差异已折叠。
点击以展开。
contracts/hddpool/hddpool.hpp
浏览文件 @
4ad559c7
...
...
@@ -23,6 +23,7 @@ public:
~
hddpool
();
void
getbalance
(
name
user
,
uint8_t
acc_type
,
name
caller
);
void
calcprofit
(
name
user
);
void
buyhdd
(
name
from
,
name
receiver
,
int64_t
amount
);
void
sellhdd
(
name
user
,
int64_t
amount
);
void
sethfee
(
name
user
,
int64_t
fee
,
name
caller
);
...
...
@@ -48,6 +49,7 @@ public:
//change miner info related actions
void
mchgadminacc
(
uint64_t
minerid
,
name
new_adminacc
);
void
mchgowneracc
(
uint64_t
minerid
,
name
new_owneracc
);
void
mchgstrpool
(
uint64_t
minerid
,
name
new_poolid
);
void
mchgspace
(
uint64_t
minerid
,
uint64_t
max_space
);
//update hddpool params
...
...
@@ -62,14 +64,16 @@ private:
{
name
account_name
;
//账户名
int64_t
hdd_storehhdd
;
//用户数据存储的HDD数量
int64_t
hdd_minerhdd
;
//存储服务提供者的HDD收益数量
int64_t
hdd_per_cycle_fee
;
//用户存储数据的每周期费用
uint64_t
hdd_space
;
//用户存储数据占用的存储空间
uint64_t
last_hdd_time
;
//上次余额计算时间 microseconds from 1970
int64_t
hdd_per_cycle_profit
;
//reserve
uint64_t
hdd_space_store
;
//用户存储数据占用的存储空间
uint64_t
last_hddstore_time
;
//上次存储hdd余额计算时间 microseconds from 1970
int64_t
hdd_minerhdd
;
//存储服务提供者的HDD收益数量
int64_t
hdd_per_cycle_profit
;
//每周期收益
uint64_t
hdd_space_profit
;
//该收益账户名下所有矿机的总生产空间
uint64_t
last_hddprofit_time
;
//上次收益hdd余额计算时间 microseconds from 1970
uint64_t
primary_key
()
const
{
return
account_name
.
value
;
}
};
typedef
multi_index
<
N
(
user
acchdd
),
userhdd
>
userhdd_index
;
typedef
multi_index
<
N
(
user
hddinfo
),
userhdd
>
userhdd_index
;
struct
maccount
{
...
...
@@ -211,25 +215,16 @@ public:
return
0
;
}
};
/*
bool hddpool::is_miner_exist(uint64_t minerid) const
{
minerinfo_table _minerinfo( _self , _self );
auto itminerinfo = _minerinfo.find(minerid);
if(itminerinfo != _minerinfo.end())
return true;
static
name
get_miner_pool
(
uint64_t
minerid
)
{
name
pool
;
minerinfo_table
_minerinfo
(
N
(
hddpool12345
)
,
N
(
hddpool12345
)
);
auto
itminerinfo
=
_minerinfo
.
find
(
minerid
);
if
(
itminerinfo
!=
_minerinfo
.
end
())
{
pool
=
itminerinfo
->
owner
;
}
return
pool
;
}
return false;
}
};
uint64_t hddpool::get_miner_max_space(uint64_t minerid) const
{
minerinfo_table _minerinfo( _self , _self );
auto itminerinfo = _minerinfo.find(minerid);
if(itminerinfo != _minerinfo.end())
return itminerinfo->max_space;
return 0;
}
*/
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录