/
status.go
40 lines (35 loc) 路 1.21 KB
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package api
import (
"fmt"
"github.com/MinterTeam/minter-go-node/version"
"github.com/tendermint/tendermint/rpc/core/types"
"time"
)
type StatusResponse struct {
MinterVersion string `json:"version"`
LatestBlockHash string `json:"latest_block_hash"`
LatestAppHash string `json:"latest_app_hash"`
LatestBlockHeight int64 `json:"latest_block_height"`
LatestBlockTime time.Time `json:"latest_block_time"`
StateHistory string `json:"state_history"`
TmStatus *core_types.ResultStatus `json:"tm_status"`
}
func Status() (*StatusResponse, error) {
result, err := client.Status()
if err != nil {
return nil, err
}
stateHistory := "off"
if minterCfg.BaseConfig.KeepStateHistory {
stateHistory = "on"
}
return &StatusResponse{
MinterVersion: version.Version,
LatestBlockHash: fmt.Sprintf("%X", result.SyncInfo.LatestBlockHash),
LatestAppHash: fmt.Sprintf("%X", result.SyncInfo.LatestAppHash),
LatestBlockHeight: result.SyncInfo.LatestBlockHeight,
LatestBlockTime: result.SyncInfo.LatestBlockTime,
StateHistory: stateHistory,
TmStatus: result,
}, nil
}