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

36
ActionRegisterChain.js Normal file
View File

@@ -0,0 +1,36 @@
const Action = require('./Action.js')
const DAD = module.exports = function ActionRegisterChain (prop) {
this._class = this.constructor.name
this.setProp(prop) // 没有定义 ActionTransfer.prototype._model因此继承了上级Action.prototype._model因此通过this.setProp继承了上级Action定义的实例自有数据。另一个方案是调用 Action.call(this, prop)
this.type = this.constructor.name
}
DAD.__proto__ = Action
const MOM = DAD.prototype
MOM.__proto__ = Action.prototype
MOM.validateMe = function () {
let result = (this.fee >= wo.Config.MIN_FEE_ActionRegisterChain || 0) &&
// 检查事务内容数据,是否符合本类事务的格式和语义要求:
this.json &&
this.json.consensus && // 共识机制
this.json.network && // 网络机制
this.json.chain && // 区块机制
this.json.chain.period && // 出块周期
this.json.chain.size // 区块大小
return result
}
MOM.executableMe = async function() {
// todo: 检查是否已有同名的应用链?以及其他检查。
let balance = await wo.Store.getBalance(this.actorAddress)
return balance >= this.fee
}
MOM.executeMe = async function () {
return this
}
/** ****************** Public of class ********************/
DAD.api = {}