| 1206 | } |
| 1207 | |
| 1208 | func (c *Chain) updateMetrics() { |
| 1209 | head := c.rt.getHead() |
| 1210 | c.expVars.Get(mwMinerChainBlockCount).(*expvar.Int).Set(int64(head.node.count)) |
| 1211 | c.expVars.Get(mwMinerChainBlockHeight).(*expvar.Int).Set(int64(head.Height)) |
| 1212 | c.expVars.Get(mwMinerChainBlockHash).(*expvar.String).Set(head.Head.String()) |
| 1213 | |
| 1214 | b := head.node.load() |
| 1215 | if b == nil { |
| 1216 | // load manually |
| 1217 | var err error |
| 1218 | b, err = c.FetchBlock(head.Height) |
| 1219 | if err != nil { |
| 1220 | return |
| 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | c.expVars.Get(mwMinerChainBlockTimestamp).(*expvar.String).Set(b.Timestamp().String()) |
| 1225 | } |
| 1226 | |
| 1227 | func (c *Chain) getCurrentHeight() int32 { |
| 1228 | return c.rt.getHead().Height |