1. 把 validateMe 分解成 静态数据检查(给客户端调用)validateMe 和 动态可执行性检查(给链节点调用)executableMe.

2. 在 Action.api.prepare() 里,生成可运行的对象 typedAction 存入 ActionPool,而不是仅仅存数据 option.Action进去。
3. 删除 Action.getJson(),把 DAD.verifyXxx(action) 都改为 MOM.verifyXxx().
4. 添加了 ActionRegisterChain.js 作为 应用链注册事务。
This commit is contained in:
luk.lu
2019-04-11 15:59:26 +08:00
committed by luk.lu
parent 044c2175d6
commit a289a4b2ad
5 changed files with 129 additions and 55 deletions

View File

@@ -137,28 +137,28 @@ step3:发起人申请执行
}
}
*/
MOM.validateMe = async function () {
if (this.json.act === 'createTransfer') // 创建挂起的多重签名事务
{
return wo.Crypto.isAddress(this.toAddress) &&
this.fee >= wo.Config.MIN_FEE_ActionTransfer &&
this.toAddress != this.actorAddress
}
MOM.executableMe = async function () {
if (this.json.act === 'createTransfer') { // 创建挂起的多重签名事务
DAD.pendingPool[this.hash] = this
return false
} else if (this.json.act === 'addSig') // 签名者签名
{
} else if (this.json.act === 'addSig') { // 签名者签名
DAD.pendingPool[this.hash].json[this.actorPubkey] = this.json.signature
return false
} else {
return wo.Crypto.isAddress(this.toAddress) &&
this.fee >= wo.Config.MIN_FEE_ActionTransfer &&
(await wo.Store.getBalance(this.actorAddress)) >= this.amount + this.fee && // Todo:引入缓存账户
this.toAddress != this.actorAddress
}
return true
}
MOM.executeMe = async function () {
switch (this.json.act) {
// 多重签名账户注册
case 'sign':
{
case 'sign': {
let actor = await wo.Account.getOne({ Account: { address: this.actorAddress } })
if (actor && actor.type !== 'multisig') {
// 检查账户类型,只有不是多重签名账户的才可以执行
@@ -173,8 +173,7 @@ MOM.executeMe = async function () {
return this
}
// 多重签名账户执行转账
case 'emitTransfer':
{
case 'emitTransfer': {
let sender = await wo.Account.getOne({ Account: { address: this.actorAddress } })
if (sender && this.checkMultiSig(sender) && this.toAddress != this.actorAddress && sender.balance >= this.amount + this.fee) {
await sender.setMe({ Account: { balance: sender.balance - this.amount - this.fee }, cond: { address: sender.address } })