keep headers hot when running with a noop splitstore
This commit is contained in:
parent
7c814cd2e3
commit
997f2c098b
@ -96,6 +96,11 @@ type Config struct {
|
||||
//
|
||||
// Supported values are: "bloom" (default if omitted), "bolt".
|
||||
MarkSetType string
|
||||
|
||||
// HotHeaders indicates whether to keep chain block headers in hotstore or not.
|
||||
// This is necessary, and automatically set by DI in lotus node construction, if
|
||||
// you are running with a noop coldstore.
|
||||
HotHeaders bool
|
||||
}
|
||||
|
||||
// ChainAccessor allows the Splitstore to access the chain. It will most likely
|
||||
@ -112,6 +117,8 @@ type SplitStore struct {
|
||||
critsection int32 // compaction critical section
|
||||
closing int32 // the split store is closing
|
||||
|
||||
cfg *Config
|
||||
|
||||
baseEpoch abi.ChainEpoch
|
||||
syncGapEpoch abi.ChainEpoch
|
||||
warmupEpoch abi.ChainEpoch
|
||||
@ -154,6 +161,7 @@ func Open(path string, ds dstore.Datastore, hot, cold bstore.Blockstore, cfg *Co
|
||||
|
||||
// and now we can make a SplitStore
|
||||
ss := &SplitStore{
|
||||
cfg: cfg,
|
||||
ds: ds,
|
||||
hot: hot,
|
||||
cold: cold,
|
||||
@ -859,8 +867,8 @@ func (s *SplitStore) walk(ts *types.TipSet, boundary abi.ChainEpoch, inclMsgs bo
|
||||
return xerrors.Errorf("error unmarshaling block header (cid: %s): %w", c, err)
|
||||
}
|
||||
|
||||
// don't walk under the boundary
|
||||
if hdr.Height < boundary {
|
||||
// don't walk under the boundary, unless we are keeping the headers hot
|
||||
if hdr.Height < boundary && !s.cfg.HotHeaders {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -868,20 +876,22 @@ func (s *SplitStore) walk(ts *types.TipSet, boundary abi.ChainEpoch, inclMsgs bo
|
||||
return err
|
||||
}
|
||||
|
||||
if inclMsgs {
|
||||
if err := s.walkLinks(hdr.Messages, walked, f); err != nil {
|
||||
return xerrors.Errorf("error walking messages (cid: %s): %w", hdr.Messages, err)
|
||||
if hdr.Height >= boundary {
|
||||
if inclMsgs {
|
||||
if err := s.walkLinks(hdr.Messages, walked, f); err != nil {
|
||||
return xerrors.Errorf("error walking messages (cid: %s): %w", hdr.Messages, err)
|
||||
}
|
||||
|
||||
if err := s.walkLinks(hdr.ParentMessageReceipts, walked, f); err != nil {
|
||||
return xerrors.Errorf("error walking message receipts (cid: %s): %w", hdr.ParentMessageReceipts, err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.walkLinks(hdr.ParentMessageReceipts, walked, f); err != nil {
|
||||
return xerrors.Errorf("error walking message receipts (cid: %s): %w", hdr.ParentMessageReceipts, err)
|
||||
if err := s.walkLinks(hdr.ParentStateRoot, walked, f); err != nil {
|
||||
return xerrors.Errorf("error walking state root (cid: %s): %w", hdr.ParentStateRoot, err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.walkLinks(hdr.ParentStateRoot, walked, f); err != nil {
|
||||
return xerrors.Errorf("error walking state root (cid: %s): %w", hdr.ParentStateRoot, err)
|
||||
}
|
||||
|
||||
toWalk = append(toWalk, hdr.Parents...)
|
||||
return nil
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ func SplitBlockstore(cfg *config.Chainstore) func(lc fx.Lifecycle, r repo.Locked
|
||||
cfg := &splitstore.Config{
|
||||
TrackingStoreType: cfg.Splitstore.TrackingStoreType,
|
||||
MarkSetType: cfg.Splitstore.MarkSetType,
|
||||
HotHeaders: cfg.Splitstore.ColdStoreType == "noop",
|
||||
}
|
||||
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user