OSDN Git Service

fix status
authorHAOYUatHZ <haoyu@protonmail.com>
Fri, 30 Aug 2019 03:23:37 +0000 (11:23 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Fri, 30 Aug 2019 03:23:37 +0000 (11:23 +0800)
toolbar/precog/database/orm/node.go

index 83773f2..f0bb345 100644 (file)
@@ -2,8 +2,11 @@ package orm
 
 import (
        "encoding/json"
+       "errors"
        "fmt"
        "time"
+
+       "github.com/vapor/toolbar/precog/common"
 )
 
 type Node struct {
@@ -21,16 +24,10 @@ type Node struct {
 }
 
 func (n *Node) MarshalJSON() ([]byte, error) {
-       var status string
-       // TODO:
-       // switch c.Status {
-       // case common.CrossTxPendingStatus:
-       //      status = common.CrossTxPendingStatusLabel
-       // case common.CrossTxCompletedStatus:
-       //      status = common.CrossTxCompletedStatusLabel
-       // default:
-       //      return nil, errors.New("unknown cross-chain tx status")
-       // }
+       status, ok := common.StatusMap[n.Status]
+       if !ok {
+               return nil, errors.New("fail to look up status")
+       }
 
        return json.Marshal(&struct {
                Alias                    string    `json:"alias"`