Commit 7b04d42e authored by mdj33's avatar mdj33 Committed by vipwzw

improve code

parent 38ab5f3a
...@@ -992,7 +992,7 @@ func isInIgnoreHeightList(str string, status *pt.ParacrossNodeStatus) (bool, err ...@@ -992,7 +992,7 @@ func isInIgnoreHeightList(str string, status *pt.ParacrossNodeStatus) (bool, err
if len(e) <= 2 { if len(e) <= 2 {
return false, errors.Wrapf(types.ErrInvalidParam, "wrong config str=%s,title=%s", str, status.Title) return false, errors.Wrapf(types.ErrInvalidParam, "wrong config str=%s,title=%s", str, status.Title)
} }
if strings.ToLower("user.p."+e[0]+".") != strings.ToLower(status.Title) { if strings.ToLower(pt.ParaPrefix+e[0]+".") != strings.ToLower(status.Title) {
return false, errors.Wrapf(types.ErrInvalidParam, "wrong title str=%s,title=%s", str, status.Title) return false, errors.Wrapf(types.ErrInvalidParam, "wrong title str=%s,title=%s", str, status.Title)
} }
...@@ -1035,7 +1035,7 @@ func isInHitHeightList(str string, status *pt.ParacrossNodeStatus) (bool, error) ...@@ -1035,7 +1035,7 @@ func isInHitHeightList(str string, status *pt.ParacrossNodeStatus) (bool, error)
if len(e) <= 2 { if len(e) <= 2 {
return false, errors.Wrapf(types.ErrInvalidParam, "wrong config str=%s,title=%s", str, status.Title) return false, errors.Wrapf(types.ErrInvalidParam, "wrong config str=%s,title=%s", str, status.Title)
} }
if strings.ToLower("user.p."+e[0]+".") != strings.ToLower(status.Title) { if strings.ToLower(pt.ParaPrefix+e[0]+".") != strings.ToLower(status.Title) {
return false, errors.Wrapf(types.ErrInvalidParam, "wrong title str=%s,title=%s", str, status.Title) return false, errors.Wrapf(types.ErrInvalidParam, "wrong title str=%s,title=%s", str, status.Title)
} }
if e[1] != pt.ParaCrossAssetTxHitKey { if e[1] != pt.ParaCrossAssetTxHitKey {
...@@ -1063,11 +1063,11 @@ func checkIsIgnoreHeight(heightList []string, status *pt.ParacrossNodeStatus) (b ...@@ -1063,11 +1063,11 @@ func checkIsIgnoreHeight(heightList []string, status *pt.ParacrossNodeStatus) (b
} }
var hitStr, ignoreStr string var hitStr, ignoreStr string
hitPrefix := strings.ToLower(status.Title + pt.ParaCrossAssetTxHitKey) hitPrefix := strings.ToLower(status.Title + pt.ParaCrossAssetTxHitKey)[len(pt.ParaPrefix):]
ignorePrefix := strings.ToLower(status.Title + pt.ParaCrossAssetTxIgnoreKey) ignorePrefix := strings.ToLower(status.Title + pt.ParaCrossAssetTxIgnoreKey)[len(pt.ParaPrefix):]
for _, s := range heightList { for _, s := range heightList {
desStr := pt.ParaPrefix + strings.ToLower(s) desStr := strings.ToLower(s)
if strings.HasPrefix(desStr, hitPrefix) { if strings.HasPrefix(desStr, hitPrefix) {
if len(hitStr) > 0 { if len(hitStr) > 0 {
return false, errors.Wrapf(types.ErrInvalidParam, "checkIsInIgnoreHeightList repeate=%s", hitPrefix) return false, errors.Wrapf(types.ErrInvalidParam, "checkIsInIgnoreHeightList repeate=%s", hitPrefix)
......
...@@ -880,7 +880,7 @@ func TestVerifyBlsSign(t *testing.T) { ...@@ -880,7 +880,7 @@ func TestVerifyBlsSign(t *testing.T) {
func TestCheckIsIgnoreHeight(t *testing.T) { func TestCheckIsIgnoreHeight(t *testing.T) {
status1 := &pt.ParacrossNodeStatus{ status1 := &pt.ParacrossNodeStatus{
Title: "user.p.mc.", Title: "user.p.MC.",
Height: 1000, Height: 1000,
} }
strList := []string{"mcc.hit.260", "mc.hit.7.9.250", "mc.ignore.1-100.200-300"} strList := []string{"mcc.hit.260", "mc.hit.7.9.250", "mc.ignore.1-100.200-300"}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment