Show blockbook status in case of backend error

This commit is contained in:
Martin Boehm 2019-06-05 13:29:06 +02:00
parent d7d596bf4b
commit d26995a1e4
3 changed files with 29 additions and 16 deletions

View File

@ -341,17 +341,18 @@ type BlockbookInfo struct {
// BackendInfo is used to get information about blockchain // BackendInfo is used to get information about blockchain
type BackendInfo struct { type BackendInfo struct {
Chain string `json:"chain"` BackendError string `json:"error,omitempty"`
Blocks int `json:"blocks"` Chain string `json:"chain,omitempty"`
Headers int `json:"headers"` Blocks int `json:"blocks,omitempty"`
Bestblockhash string `json:"bestBlockHash"` Headers int `json:"headers,omitempty"`
Difficulty string `json:"difficulty"` BestBlockHash string `json:"bestBlockHash,omitempty"`
SizeOnDisk int64 `json:"sizeOnDisk"` Difficulty string `json:"difficulty,omitempty"`
Version string `json:"version"` SizeOnDisk int64 `json:"sizeOnDisk,omitempty"`
Subversion string `json:"subversion"` Version string `json:"version,omitempty"`
ProtocolVersion string `json:"protocolVersion"` Subversion string `json:"subversion,omitempty"`
Timeoffset float64 `json:"timeOffset"` ProtocolVersion string `json:"protocolVersion,omitempty"`
Warnings string `json:"warnings"` Timeoffset float64 `json:"timeOffset,omitempty"`
Warnings string `json:"warnings,omitempty"`
} }
// SystemInfo contains information about the running blockbook and backend instance // SystemInfo contains information about the running blockbook and backend instance

View File

@ -1091,13 +1091,18 @@ func (w *Worker) ComputeFeeStats(blockFrom, blockTo int, stopCompute chan os.Sig
// GetSystemInfo returns information about system // GetSystemInfo returns information about system
func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) { func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) {
start := time.Now() start := time.Now()
ci, err := w.chain.GetChainInfo()
if err != nil {
return nil, errors.Annotatef(err, "GetChainInfo")
}
vi := common.GetVersionInfo() vi := common.GetVersionInfo()
inSync, bestHeight, lastBlockTime := w.is.GetSyncState() inSync, bestHeight, lastBlockTime := w.is.GetSyncState()
inSyncMempool, lastMempoolTime, mempoolSize := w.is.GetMempoolSyncState() inSyncMempool, lastMempoolTime, mempoolSize := w.is.GetMempoolSyncState()
ci, err := w.chain.GetChainInfo()
var backendError string
if err != nil {
backendError = errors.Annotatef(err, "GetChainInfo").Error()
ci = &bchain.ChainInfo{}
// set not in sync in case of backend error
inSync = false
inSyncMempool = false
}
var columnStats []common.InternalStateColumn var columnStats []common.InternalStateColumn
var internalDBSize int64 var internalDBSize int64
if internal { if internal {
@ -1125,7 +1130,8 @@ func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) {
About: Text.BlockbookAbout, About: Text.BlockbookAbout,
} }
backendInfo := &BackendInfo{ backendInfo := &BackendInfo{
Bestblockhash: ci.Bestblockhash, BackendError: backendError,
BestBlockHash: ci.Bestblockhash,
Blocks: ci.Blocks, Blocks: ci.Blocks,
Chain: ci.Chain, Chain: ci.Chain,
Difficulty: ci.Difficulty, Difficulty: ci.Difficulty,

View File

@ -58,6 +58,12 @@
<h3>Backend</h3> <h3>Backend</h3>
<table class="table data-table"> <table class="table data-table">
<tbody> <tbody>
{{- if $be.BackendError -}}
<tr>
<td style="width: 30%;">Backend Error</td>
<td class="data text-danger">{{$be.BackendError}}</td>
</tr>
{{- end -}}
<tr> <tr>
<td style="width: 30%;">Chain</td> <td style="width: 30%;">Chain</td>
<td class="data">{{$be.Chain}}</td> <td class="data">{{$be.Chain}}</td>