WIP fixing queries
This commit is contained in:
parent
04691a13da
commit
1018999096
@ -23,7 +23,7 @@ var dotCmd = &cli.Command{
|
||||
tosee, err := strconv.ParseInt(cctx.Args().Get(1), 10, 32)
|
||||
maxH := minH + tosee
|
||||
|
||||
res, err := st.db.Query("select block, parent, b.miner, b.height from block_parents inner join blocks b on block_parents.block = b.cid where b.height > ? and b.height < ?", minH, maxH)
|
||||
res, err := st.db.Query("select block, parent, b.miner, b.height from block_parents inner join blocks b on block_parents.block = b.cid where b.height > $1 and b.height < $2", minH, maxH)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -22,17 +22,19 @@ func subMpool(ctx context.Context, api aapi.FullNode, st *storage) {
|
||||
|
||||
log.Info("mpool message")
|
||||
|
||||
go func() {
|
||||
err := st.storeMessages(map[cid.Cid]*types.Message{
|
||||
change.Message.Message.Cid(): &change.Message.Message,
|
||||
})
|
||||
if err != nil {
|
||||
//log.Error(err)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
if err := st.storeMpoolInclusion(change.Message.Message.Cid()); err != nil {
|
||||
log.Error(err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ func openStorage(dbSource string) (*storage, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
db.SetMaxOpenConns(1350)
|
||||
|
||||
st := &storage{db: db}
|
||||
|
||||
return st, st.setup()
|
||||
@ -182,7 +184,7 @@ create table if not exists miner_heads
|
||||
worker text not null,
|
||||
peerid text not null,
|
||||
sectorsize bigint not null,
|
||||
power text not null,
|
||||
power bigint not null,
|
||||
active bool,
|
||||
ppe bigint not null,
|
||||
slashed_at bigint not null,
|
||||
|
@ -153,10 +153,10 @@ func (h *handler) netPower(slashFilt string) (types.BigInt, error) {
|
||||
if slashFilt != "" {
|
||||
slashFilt = " where " + slashFilt
|
||||
}
|
||||
return h.queryNum(`select sum(power) from (
|
||||
select miner_heads.power, miner_heads.slashed_at, max(height) from miner_heads
|
||||
return h.queryNum(`select sum(a.power) from (
|
||||
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
|
||||
group by miner_heads.addr)` + slashFilt)
|
||||
group by miner_heads.addr) a` + slashFilt)
|
||||
}
|
||||
|
||||
func (h *handler) queryNum(q string, p ...interface{}) (types.BigInt, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user