Merge pull request #618 from filecoin-project/feat/early-temp-persist
persist blocks as they come in
This commit is contained in:
commit
3c1c7ec682
@ -73,7 +73,7 @@ func HandleIncomingMessages(ctx context.Context, mpool *chain.MessagePool, msub
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := mpool.Add(m); err != nil {
|
if err := mpool.Add(m); err != nil {
|
||||||
log.Errorf("failed to add message from network to message pool (From: %s, To: %s, Nonce: %d, Value: %s): %+v", m.Message.From, m.Message.To, m.Message.Nonce, types.FIL(m.Message.Value), err)
|
log.Warnf("failed to add message from network to message pool (From: %s, To: %s, Nonce: %d, Value: %s): %+v", m.Message.From, m.Message.To, m.Message.Nonce, types.FIL(m.Message.Value), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,13 @@ func (syncer *Syncer) InformNewHead(from peer.ID, fts *store.FullTipSet) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: IMPORTANT(GARBAGE) this needs to be put in the 'temporary' side of
|
||||||
|
// the blockstore
|
||||||
|
if err := syncer.store.PersistBlockHeaders(fts.TipSet().Blocks()...); err != nil {
|
||||||
|
log.Warn("failed to persist incoming block header: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
syncer.peerHeadsLk.Lock()
|
syncer.peerHeadsLk.Lock()
|
||||||
syncer.peerHeads[from] = fts.TipSet()
|
syncer.peerHeads[from] = fts.TipSet()
|
||||||
syncer.peerHeadsLk.Unlock()
|
syncer.peerHeadsLk.Unlock()
|
||||||
@ -147,7 +154,12 @@ func (syncer *Syncer) ValidateMsgMeta(fblk *types.FullBlock) error {
|
|||||||
scids = append(scids, &c)
|
scids = append(scids, &c)
|
||||||
}
|
}
|
||||||
|
|
||||||
bs := amt.WrapBlockstore(syncer.store.Blockstore())
|
// TODO: IMPORTANT(GARBAGE). These message puts and the msgmeta
|
||||||
|
// computation need to go into the 'temporary' side of the blockstore when
|
||||||
|
// we implement that
|
||||||
|
blockstore := syncer.store.Blockstore()
|
||||||
|
|
||||||
|
bs := amt.WrapBlockstore(blockstore)
|
||||||
smroot, err := computeMsgMeta(bs, bcids, scids)
|
smroot, err := computeMsgMeta(bs, bcids, scids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("validating msgmeta, compute failed: %w", err)
|
return xerrors.Errorf("validating msgmeta, compute failed: %w", err)
|
||||||
@ -157,6 +169,20 @@ func (syncer *Syncer) ValidateMsgMeta(fblk *types.FullBlock) error {
|
|||||||
return xerrors.Errorf("messages in full block did not match msgmeta root in header (%s != %s)", fblk.Header.Messages, smroot)
|
return xerrors.Errorf("messages in full block did not match msgmeta root in header (%s != %s)", fblk.Header.Messages, smroot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, m := range fblk.BlsMessages {
|
||||||
|
_, err := store.PutMessage(blockstore, m)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("putting bls message to blockstore after msgmeta computation: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, m := range fblk.SecpkMessages {
|
||||||
|
_, err := store.PutMessage(blockstore, m)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("putting bls message to blockstore after msgmeta computation: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,19 +132,19 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api api.FullNode,
|
|||||||
|
|
||||||
p2pSk, err := makeHostKey(lr)
|
p2pSk, err := makeHostKey(lr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return xerrors.Errorf("make host key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
peerid, err := peer.IDFromPrivateKey(p2pSk)
|
peerid, err := peer.IDFromPrivateKey(p2pSk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return xerrors.Errorf("peer ID from private key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var addr address.Address
|
var addr address.Address
|
||||||
if act := cctx.String("actor"); act != "" {
|
if act := cctx.String("actor"); act != "" {
|
||||||
a, err := address.NewFromString(act)
|
a, err := address.NewFromString(act)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return xerrors.Errorf("failed parsing actor flag value (%q): %w", act, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := configureStorageMiner(ctx, api, a, peerid, cctx.Bool("genesis-miner")); err != nil {
|
if err := configureStorageMiner(ctx, api, a, peerid, cctx.Bool("genesis-miner")); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user