More data in chainwatch

This commit is contained in:
Łukasz Magiera 2019-12-12 14:53:38 +01:00
parent ee979a20f8
commit 7556d44b15
2 changed files with 29 additions and 3 deletions

View File

@ -48,6 +48,7 @@ var dotCmd = &cli.Command{
hasstr := ""
if !has {
col = 0xffffffff
hasstr = " UNSYNCED"
}

View File

@ -101,7 +101,14 @@ create table if not exists blocks
miner text not null
constraint blocks_id_address_map_miner_fk
references id_address_map (address),
timestamp int not null
timestamp int not null,
vrfproof blob,
tickets int not null,
eprof blob,
prand blob,
ep0partial blob,
ep0sector int not null,
ep0challangei int not null
);
create unique index if not exists block_cid_uindex
@ -296,13 +303,31 @@ func (st *storage) storeHeaders(bhs map[cid.Cid]*types.BlockHeader, sync bool) e
return err
}
stmt, err := tx.Prepare(`insert into blocks (cid, parentWeight, parentStateRoot, height, miner, "timestamp") values (?, ?, ?, ?, ?, ?) on conflict do nothing`)
stmt, err := tx.Prepare(`insert into blocks (cid, parentWeight, parentStateRoot, height, miner, "timestamp", vrfproof, tickets, eprof, prand, ep0partial, ep0sector, ep0challangei) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict do nothing`)
if err != nil {
return err
}
defer stmt.Close()
for _, bh := range bhs {
if _, err := stmt.Exec(bh.Cid().String(), bh.ParentWeight.String(), bh.ParentStateRoot.String(), bh.Height, bh.Miner.String(), bh.Timestamp); err != nil {
l := len(bh.EPostProof.Candidates)
if len(bh.EPostProof.Candidates) == 0 {
bh.EPostProof.Candidates = append(bh.EPostProof.Candidates, types.EPostTicket{})
}
if _, err := stmt.Exec(bh.Cid().String(),
bh.ParentWeight.String(),
bh.ParentStateRoot.String(),
bh.Height,
bh.Miner.String(),
bh.Timestamp,
bh.Ticket.VRFProof,
l,
bh.EPostProof.Proof,
bh.EPostProof.PostRand,
bh.EPostProof.Candidates[0].Partial,
bh.EPostProof.Candidates[0].SectorID,
bh.EPostProof.Candidates[0].ChallengeIndex,
); err != nil {
return err
}
}