short-circuit fil commitments

they don't make it to the blockstore anyway
This commit is contained in:
vyzo 2021-07-05 11:32:52 +03:00
parent 839f7bd2b5
commit 2ea2abc07d

View File

@ -634,6 +634,10 @@ func (s *SplitStore) doTxnProtect(root cid.Cid, batch map[cid.Cid]struct{}) erro
// consituents. THIS NEEDS TO BE FIXED -- but until then we do this missing dance business // consituents. THIS NEEDS TO BE FIXED -- but until then we do this missing dance business
err := s.walkObjectIncomplete(root, cid.NewSet(), err := s.walkObjectIncomplete(root, cid.NewSet(),
func(c cid.Cid) error { func(c cid.Cid) error {
if isFilCommitment(c) {
return errStopWalk
}
if c != root { if c != root {
_, ok := batch[c] _, ok := batch[c]
if ok { if ok {
@ -717,10 +721,14 @@ func (s *SplitStore) doWarmup(curTs *types.TipSet) error {
xcount := int64(0) xcount := int64(0)
missing := int64(0) missing := int64(0)
err := s.walkChain(curTs, epoch, false, err := s.walkChain(curTs, epoch, false,
func(cid cid.Cid) error { func(c cid.Cid) error {
if isFilCommitment(c) {
return errStopWalk
}
count++ count++
has, err := s.hot.Has(cid) has, err := s.hot.Has(c)
if err != nil { if err != nil {
return err return err
} }
@ -729,7 +737,7 @@ func (s *SplitStore) doWarmup(curTs *types.TipSet) error {
return nil return nil
} }
blk, err := s.cold.Get(cid) blk, err := s.cold.Get(c)
if err != nil { if err != nil {
if err == bstore.ErrNotFound { if err == bstore.ErrNotFound {
missing++ missing++
@ -824,6 +832,10 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
var count int64 var count int64
err = s.walkChain(curTs, boundaryEpoch, true, err = s.walkChain(curTs, boundaryEpoch, true,
func(c cid.Cid) error { func(c cid.Cid) error {
if isFilCommitment(c) {
return errStopWalk
}
count++ count++
return markSet.Mark(c) return markSet.Mark(c)
}) })
@ -883,6 +895,10 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
err = s.walkObjectIncomplete(c, walked, err = s.walkObjectIncomplete(c, walked,
func(c cid.Cid) error { func(c cid.Cid) error {
if isFilCommitment(c) {
return errStopWalk
}
mark, err := markSet.Has(c) mark, err := markSet.Has(c)
if err != nil { if err != nil {
return xerrors.Errorf("error checking markset for %s: %w", c, err) return xerrors.Errorf("error checking markset for %s: %w", c, err)
@ -948,6 +964,10 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
walked := cid.NewSet() walked := cid.NewSet()
for c := range towalk { for c := range towalk {
if isFilCommitment(c) {
continue
}
mark, err := markSet.Has(c) mark, err := markSet.Has(c)
if err != nil { if err != nil {
return xerrors.Errorf("error checking markset for %s: %w", c, err) return xerrors.Errorf("error checking markset for %s: %w", c, err)
@ -959,6 +979,10 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
err = s.walkObjectIncomplete(c, walked, err = s.walkObjectIncomplete(c, walked,
func(c cid.Cid) error { func(c cid.Cid) error {
if isFilCommitment(c) {
return errStopWalk
}
mark, err := markSet.Has(c) mark, err := markSet.Has(c)
if err != nil { if err != nil {
return xerrors.Errorf("error checking markset for %s: %w", c, err) return xerrors.Errorf("error checking markset for %s: %w", c, err)
@ -1516,3 +1540,12 @@ func bytesToUint64(buf []byte) uint64 {
i, _ := binary.Uvarint(buf) i, _ := binary.Uvarint(buf)
return i return i
} }
func isFilCommitment(c cid.Cid) bool {
switch c.Prefix().Codec {
case cid.FilCommitmentSealed, cid.FilCommitmentUnsealed:
return true
default:
return false
}
}