Merge branch 'master' into internal-state
This commit is contained in:
commit
1a953ea2a4
@ -117,6 +117,8 @@ func main() {
|
|||||||
chanOsSignal = make(chan os.Signal, 1)
|
chanOsSignal = make(chan os.Signal, 1)
|
||||||
signal.Notify(chanOsSignal, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
|
signal.Notify(chanOsSignal, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
|
||||||
|
|
||||||
|
glog.Infof("Blockbook: %+v", common.GetVersionInfo())
|
||||||
|
|
||||||
if *prof != "" {
|
if *prof != "" {
|
||||||
go func() {
|
go func() {
|
||||||
log.Println(http.ListenAndServe(*prof, nil))
|
log.Println(http.ListenAndServe(*prof, nil))
|
||||||
|
|||||||
@ -1,12 +1,16 @@
|
|||||||
UPDATE_VENDOR ?= 1
|
UPDATE_VENDOR ?= 1
|
||||||
|
VERSION ?= devel
|
||||||
|
GITCOMMIT = $(shell cd /src && git describe --tags --always --dirty)
|
||||||
|
BUILDTIME = $(shell date --iso-8601=seconds)
|
||||||
|
LDFLAGS := -X blockbook/common.version=$(VERSION) -X blockbook/common.gitcommit=$(GITCOMMIT) -X blockbook/common.buildtime=$(BUILDTIME)
|
||||||
|
|
||||||
build: prepare-sources
|
build: prepare-sources
|
||||||
cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook -ldflags="-s -w"
|
cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook -ldflags="-s -w $(LDFLAGS)"
|
||||||
cp $(CURDIR)/blockbook /out/blockbook
|
cp $(CURDIR)/blockbook /out/blockbook
|
||||||
chown $(PACKAGER) /out/blockbook
|
chown $(PACKAGER) /out/blockbook
|
||||||
|
|
||||||
build-debug: prepare-sources
|
build-debug: prepare-sources
|
||||||
cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook
|
cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook -ldflags="$(LDFLAGS)"
|
||||||
cp $(CURDIR)/blockbook /out/blockbook
|
cp $(CURDIR)/blockbook /out/blockbook
|
||||||
chown $(PACKAGER) /out/blockbook
|
chown $(PACKAGER) /out/blockbook
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@ cp -r /src/configs .
|
|||||||
cp -r /src/static static
|
cp -r /src/static static
|
||||||
mkdir cert && cp /src/server/testcert.* cert
|
mkdir cert && cp /src/server/testcert.* cert
|
||||||
|
|
||||||
|
export VERSION=$(dpkg-parsechangelog | sed -rne 's/^Version: ([0-9.]+)([-+~].+)?$/\1/p')
|
||||||
|
|
||||||
dpkg-buildpackage -us -uc
|
dpkg-buildpackage -us -uc
|
||||||
mv ../*.deb /out
|
mv ../*.deb /out
|
||||||
chown $PACKAGER /out/*.deb
|
chown $PACKAGER /out/*.deb
|
||||||
|
|||||||
27
common/version.go
Normal file
27
common/version.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
|
var (
|
||||||
|
version = "unknown"
|
||||||
|
gitcommit = "unknown"
|
||||||
|
buildtime = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
|
type VersionInfo struct {
|
||||||
|
Version string `json:"version"`
|
||||||
|
GitCommit string `json:"gitcommit"`
|
||||||
|
BuildTime string `json:"buildtime"`
|
||||||
|
GoVersion string `json:"goversion"`
|
||||||
|
OSArch string `json:"os/arch"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetVersionInfo() VersionInfo {
|
||||||
|
return VersionInfo{
|
||||||
|
Version: version,
|
||||||
|
GitCommit: gitcommit,
|
||||||
|
BuildTime: buildtime,
|
||||||
|
GoVersion: runtime.Version(),
|
||||||
|
OSArch: runtime.GOOS + "/" + runtime.GOARCH,
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,7 +19,7 @@ import (
|
|||||||
"github.com/martinboehm/golang-socketio/transport"
|
"github.com/martinboehm/golang-socketio/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
const blockbookAbout = "Blockbook v0.0.1, blockchain indexer for TREZOR wallet https://trezor.io/. Do not use for any other purpose."
|
const blockbookAbout = "Blockbook - blockchain indexer for TREZOR wallet https://trezor.io/. Do not use for any other purpose."
|
||||||
|
|
||||||
// SocketIoServer is handle to SocketIoServer
|
// SocketIoServer is handle to SocketIoServer
|
||||||
type SocketIoServer struct {
|
type SocketIoServer struct {
|
||||||
@ -140,6 +140,7 @@ func (s *SocketIoServer) apiBlockIndex(w http.ResponseWriter, r *http.Request) {
|
|||||||
type resBlockIndex struct {
|
type resBlockIndex struct {
|
||||||
BlockHash string `json:"blockHash"`
|
BlockHash string `json:"blockHash"`
|
||||||
About string `json:"about"`
|
About string `json:"about"`
|
||||||
|
common.VersionInfo
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
var hash string
|
var hash string
|
||||||
@ -157,7 +158,11 @@ func (s *SocketIoServer) apiBlockIndex(w http.ResponseWriter, r *http.Request) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Error(err)
|
glog.Error(err)
|
||||||
} else {
|
} else {
|
||||||
r := resBlockIndex{BlockHash: hash, About: blockbookAbout}
|
r := resBlockIndex{
|
||||||
|
BlockHash: hash,
|
||||||
|
About: blockbookAbout,
|
||||||
|
VersionInfo: common.GetVersionInfo(),
|
||||||
|
}
|
||||||
json.NewEncoder(w).Encode(r)
|
json.NewEncoder(w).Encode(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user