Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
Update the info api
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonlatte committed Apr 9, 2018
1 parent 63fc8b4 commit 419c404
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
13 changes: 5 additions & 8 deletions server/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func connCheck(host, port string) bool {
}

func getConnectors() int {
resp, err := client.Get("https://127.0.0.1:2131/bitmarkd/info")
resp, err := client.Get("https://127.0.0.1:2131/bitmarkd/details")
if err != nil {
return 0
}
Expand All @@ -38,17 +38,14 @@ func getConnectors() int {
return 0
}

var result map[string]interface{}
var reply DetailReply
d := json.NewDecoder(&buf)
err = d.Decode(&result)
err = d.Decode(&reply)
if err != nil {
return 0
}
if count, ok := result["client_count"]; !ok {
return 0
} else {
return int(count.(float64))
}

return int(reply.Peers.Local)
}

func (ws *WebServer) ConnectionStatus(c *gin.Context) {
Expand Down
5 changes: 2 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/bitmark-inc/bitmark-node/config"
"github.com/bitmark-inc/bitmark-node/services"
"github.com/bitmark-inc/bitmarkd/rpc"
"github.com/gin-gonic/gin"
)

Expand Down Expand Up @@ -143,7 +142,7 @@ func (ws *WebServer) BitmarkdStartStop(c *gin.Context) {
return
case "info":

resp, err := client.Get("https://127.0.0.1:2131/bitmarkd/info")
resp, err := client.Get("https://127.0.0.1:2131/bitmarkd/details")
if err != nil {
c.String(500, "unable to get bitmark info")
return
Expand All @@ -157,7 +156,7 @@ func (ws *WebServer) BitmarkdStartStop(c *gin.Context) {
return
}

var reply rpc.InfoReply
var reply DetailReply
d := json.NewDecoder(&bb)

if err := d.Decode(&reply); err != nil {
Expand Down
24 changes: 24 additions & 0 deletions server/structs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package server

type Counters struct {
Pending int `json:"pending"`
Verified int `json:"verified"`
}

type BlockCounts struct {
Local uint64 `json:"local"`
Remote uint64 `json:"remote"`
}

type DetailReply struct {
Chain string `json:"chain"`
Mode string `json:"mode"`
Blocks BlockCounts `json:"blocks"`
RPCs uint64 `json:"rpcs"`
Peers BlockCounts `json:"peers"`
TransactionCounters Counters `json:"transactionCounters"`
Difficulty float64 `json:"difficulty"`
Version string `json:"version"`
Uptime string `json:"uptime"`
PublicKey string `json:"publicKey"`
}
4 changes: 2 additions & 2 deletions ui/src/app/node.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
<h3 class="paragraph-title ">Bitmark node info</h3>
<div class="row__box ">
<Box title="Network ID ">
<p>{{ this.bitmarkdInfo.public_key }}</p>
<p>{{ this.bitmarkdInfo.publicKey }}</p>
</Box>
<!-- End: box -->
<Box title="Current Block ">
<div class="blocks ">
<span class="blocks__num ">{{ this.bitmarkdInfo.blocks }}/{{ this.bitmarkdInfo.block_height || this.bitmarkdInfo.blocks }}</span>
<span class="blocks__num ">{{ this.bitmarkdInfo.blocks.local }}/{{ this.bitmarkdInfo.blocks.local || this.bitmarkdInfo.blocks.remote }}</span>
<span class="blocks__label ">
<template v-if="this.bitmarkdInfo.mode === 'Resynchronise'">Updating blockchain</template>
<template v-else-if="this.bitmarkdInfo.mode === 'Normal'">Latest block</template>
Expand Down

0 comments on commit 419c404

Please sign in to comment.