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:
parent
e3a4b447a0
commit
3e602dcd07
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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("")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue