github.com/aergoio/aergo@v1.3.1/cmd/aergocli/util/base64ToHex.go (about) 1 package util 2 3 import ( 4 "encoding/hex" 5 "encoding/json" 6 7 "github.com/aergoio/aergo/types" 8 ) 9 10 type InOutBlockchainStatus struct { 11 Hash string 12 Height uint64 13 ConsensusInfo *json.RawMessage `json:",omitempty"` 14 ChainIdHash string 15 ChainStat *json.RawMessage `json:",omitempty"` 16 ChainInfo *InOutChainInfo `json:",omitempty"` 17 } 18 19 func ConvHexBlockchainStatus(in *types.BlockchainStatus) string { 20 out := &InOutBlockchainStatus{} 21 out.Hash = hex.EncodeToString(in.BestBlockHash) 22 out.Height = in.BestHeight 23 out.ChainIdHash = hex.EncodeToString(in.BestChainIdHash) 24 jsonout, err := json.Marshal(out) 25 if err != nil { 26 return "" 27 } 28 return string(jsonout) 29 }