chainwatch: fix ui queries

This commit is contained in:
Łukasz Magiera 2019-12-13 12:48:42 +01:00
parent f2ea12571f
commit a246be587e
2 changed files with 5 additions and 4 deletions

View File

@ -21,7 +21,7 @@
Messages: Messages:
<table> <table>
<tr><td>Dir</td><td>Peer</td><td>Nonce</td><td>Value</td><td>Block</td><td>Mpool Wait</td></tr> <tr><td>Dir</td><td>Peer</td><td>Nonce</td><td>Value</td><td>Block</td><td>Mpool Wait</td></tr>
{{ range messages "`from` = $1 or `to` = $2" $wallet $wallet $wallet}} {{ range messages "\"from\" = $1 or \"to\" = $1" $wallet}}
<tr> <tr>
{{ if eq .From.String $wallet }} {{ if eq .From.String $wallet }}
<td>To</td><td>{{.To.String}}</td> <td>To</td><td>{{.To.String}}</td>

View File

@ -153,10 +153,9 @@ func (h *handler) netPower(slashFilt string) (types.BigInt, error) {
if slashFilt != "" { if slashFilt != "" {
slashFilt = " where " + slashFilt slashFilt = " where " + slashFilt
} }
return h.queryNum(`select sum(a.power) from ( return h.queryNum(`select sum(power) from (select distinct on (addr) power, slashed_at from miner_heads
select max(miner_heads.power), miner_heads.slashed_at, height as power from miner_heads
inner join blocks b on miner_heads.stateroot = b.parentStateRoot inner join blocks b on miner_heads.stateroot = b.parentStateRoot
group by miner_heads.addr) a` + slashFilt) order by addr, height desc) as p` + slashFilt)
} }
func (h *handler) queryNum(q string, p ...interface{}) (types.BigInt, error) { func (h *handler) queryNum(q string, p ...interface{}) (types.BigInt, error) {
@ -214,6 +213,8 @@ func (h *handler) messages(filter string, args ...interface{}) (out []types.Mess
filter = " where " + filter filter = " where " + filter
} }
log.Info("select * from messages "+filter)
rws, err := h.st.db.Query("select * from messages "+filter, args...) rws, err := h.st.db.Query("select * from messages "+filter, args...)
if err != nil { if err != nil {
return nil, err return nil, err