feat: add auto determine fabric internal rule

Now internal rule manager will automatically use fabric internal rule address when it can not find wasm address
This commit is contained in:
levi9311 2020-04-16 11:26:56 +08:00
parent e3a4b447a0
commit 3e602dcd07
2 changed files with 7 additions and 2 deletions

View File

@ -286,7 +286,7 @@ func (x *Interchain) HandleIBTP(data []byte) *boltvm.Response {
x.GetObject(x.appchainKey(ibtp.From), &app)
// get validation rule contract address
res := x.CrossInvoke(constant.RuleManagerContractAddr.String(), "GetRuleAddress", pb.String(ibtp.From))
res := x.CrossInvoke(constant.RuleManagerContractAddr.String(), "GetRuleAddress", pb.String(ibtp.From), pb.String(app.ChainType))
if !res.Ok {
return boltvm.Error("this appchain don't register rule")
}

View File

@ -3,6 +3,7 @@ package contracts
import (
"fmt"
"github.com/meshplus/bitxhub/internal/validator"
"github.com/meshplus/bitxhub/pkg/vm/boltvm"
)
@ -36,7 +37,7 @@ func (r *RuleManager) RegisterRule(id string, address string) *boltvm.Response {
return boltvm.Success(nil)
}
func (r *RuleManager) GetRuleAddress(id string) *boltvm.Response {
func (r *RuleManager) GetRuleAddress(id, chainType string) *boltvm.Response {
rl := &rule{}
ok := r.GetObject(r.ruleKey(id), rl)
@ -44,6 +45,10 @@ func (r *RuleManager) GetRuleAddress(id string) *boltvm.Response {
return boltvm.Success([]byte(rl.Address))
}
if chainType == "fabric" {
return boltvm.Success([]byte(validator.FabricRuleAddr))
}
return boltvm.Error("")
}