Commit 2959fd01 authored by linj's avatar linj

query Query_GetRetrieveInfo 兼容处理

parent 1452730f
......@@ -5,6 +5,8 @@
package executor
import (
"fmt"
"github.com/33cn/chain33/types"
rt "github.com/33cn/plugin/plugin/dapp/retrieve/types"
)
......@@ -25,14 +27,29 @@ func (r *Retrieve) Query_GetRetrieveInfo(in *rt.ReqRetrieveInfo) (types.Message,
// 在指定asset 的情况下, 显示具体asset 的找回状态
if info.Status == retrievePerform && in.GetAssetExec() != "" {
asset, err := getRetrieveAsset(r.GetLocalDB(), in.BackupAddress, in.DefaultAddress, in.AssetExec, in.AssetSymbol)
if asset == nil {
// retrievePerform状态下,不存在即可以找回,但还没找回
info.Status = retrievePrepare
info.RemainTime = zeroRemainTime
// retrievePerform状态下,不存在有两种情况
// 1 还没找回, 2 fork 之前是没有coins 找回记录的
count := r.GetLocalDB().PrefixCount(calcRetrieveAssetPrefix(in.BackupAddress, in.DefaultAddress))
// 2 fork 之前是 没有coins 找回记录的, 相当于都找回了
if count == 0 {
return info, nil
}
return asset, err
asset, _ := getRetrieveAsset(r.GetLocalDB(), in.BackupAddress, in.DefaultAddress, in.AssetExec, in.AssetSymbol)
if asset != nil {
return asset, nil
}
// 1 还没找回
info.Status = retrievePrepare
info.RemainTime = zeroRemainTime
return info, nil
}
return info, nil
}
func calcRetrieveAssetPrefix(backupAddr, defaultAddr string) []byte {
key := fmt.Sprintf("LODB-retrieve-backup-asset:%s:%s:", backupAddr, defaultAddr)
return []byte(key)
}
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