diff --git a/blockbook.go b/blockbook.go index 224acd29..9a06d856 100644 --- a/blockbook.go +++ b/blockbook.go @@ -309,7 +309,17 @@ func main() { } func newInternalState(coin string, d *db.RocksDB) (*common.InternalState, error) { - return d.LoadInternalState(coin) + is, err := d.LoadInternalState(coin) + if err != nil { + return nil, err + } + name, err := os.Hostname() + if err != nil { + glog.Error("get hostname ", err) + } else { + is.Host = name + } + return is, nil } func tickAndDebounce(tickTime time.Duration, debounceTime time.Duration, input chan struct{}, f func()) { diff --git a/common/internalstate.go b/common/internalstate.go index 0b1573e8..7ff0836e 100644 --- a/common/internalstate.go +++ b/common/internalstate.go @@ -27,6 +27,7 @@ type InternalState struct { mux sync.Mutex Coin string `json:"coin"` + Host string `json:"host"` DbState uint32 `json:"dbState"` diff --git a/server/socketio.go b/server/socketio.go index 7be24718..c96d4dfc 100644 --- a/server/socketio.go +++ b/server/socketio.go @@ -144,7 +144,7 @@ func (s *SocketIoServer) addressRedirect(w http.ResponseWriter, r *http.Request) type resAboutBlockbookPublic struct { Coin string `json:"coin"` - About string `json:"about"` + Host string `json:"host"` Version string `json:"version"` GitCommit string `json:"gitcommit"` BuildTime string `json:"buildtime"` @@ -153,6 +153,7 @@ type resAboutBlockbookPublic struct { LastBlockTime time.Time `json:"lastBlockTime"` InSyncMempool bool `json:"inSyncMempool"` LastMempoolTime time.Time `json:"lastMempoolTime"` + About string `json:"about"` } func (s *SocketIoServer) index(w http.ResponseWriter, r *http.Request) { @@ -161,7 +162,7 @@ func (s *SocketIoServer) index(w http.ResponseWriter, r *http.Request) { ms, mt := s.is.GetMempoolSyncState() a := resAboutBlockbookPublic{ Coin: s.is.Coin, - About: blockbookAbout, + Host: s.is.Host, Version: vi.Version, GitCommit: vi.GitCommit, BuildTime: vi.BuildTime, @@ -170,6 +171,7 @@ func (s *SocketIoServer) index(w http.ResponseWriter, r *http.Request) { LastBlockTime: st, InSyncMempool: ms, LastMempoolTime: mt, + About: blockbookAbout, } buf, err := json.MarshalIndent(a, "", " ") if err != nil {