采用新结构:Action*.js 从 node.server 中删除,集中存放于本库。

这样消除了同一份代码出现在两处的不良结构,避免了同步的困难。
当 node.server 需要临时修改 ActionXxx.js 时,只要在 server.js 里临时 require('../tic.action').ActionXxx 即可。一处修改,到处可用。
This commit is contained in:
luk.lu
2019-04-09 20:16:58 +08:00
parent e2a0738a80
commit 4fe26a0b09
6 changed files with 381 additions and 20 deletions

View File

@@ -9,20 +9,23 @@ DAD.__proto__ = Action
const MOM = DAD.prototype
MOM.__proto__ = Action.prototype
DAD.validate = async function (action) {
MOM.validateMe = async function () {
// if (sender && sender.type !== 'multisig' && action.toAddress != action.actorAddress && sender.balance >= action.amount + action.fee){
let sender = await wo.Store.getBalance(action.actorAddress)
return action.actorAddress && action.toAddress && action.toAddress != action.actorAddress && action.amount && action.amount > 0 && sender >= action.amount + action.fee && action.fee >= wo.Config.MIN_FEE_ActionTransfer
let balance = await wo.Store.getBalance(this.actorAddress)
return this.actorAddress && this.toAddress && this.toAddress != this.actorAddress
&& this.amount && this.amount > 0 && this.fee >= wo.Config.MIN_FEE_ActionTransfer && balance >= this.amount + this.fee
}
DAD.execute = async function (action) {
let sender = await wo.Store.getBalance(action.actorAddress)
if (sender >= action.amount + action.fee) {
await wo.Store.decrease(action.actorAddress, action.amount + action.fee)
await wo.Store.increase(action.toAddress, action.amount)
return true
MOM.executeMe = async function () {
let balance = await wo.Store.getBalance(this.actorAddress)
if (balance >= this.amount + this.fee) {
await wo.Store.decrease(this.actorAddress, this.amount + this.fee)
await wo.Store.increase(this.toAddress, this.amount)
return this
}
return null
}
/** ****************** Public of class ********************/
DAD.api = {}