short-circuit block headers on sort weight computation
This commit is contained in:
parent
bf7aeb3167
commit
55a9e0ccd1
@ -1237,6 +1237,20 @@ func (s *SplitStore) isOldBlockHeader(c cid.Cid, epoch abi.ChainEpoch) (isOldBlo
|
|||||||
return isOldBlock, err
|
return isOldBlock, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SplitStore) isBlockHeader(c cid.Cid) (isBlock bool, err error) {
|
||||||
|
if c.Prefix().Codec != cid.DagCBOR {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.view(c, func(data []byte) error {
|
||||||
|
var hdr types.BlockHeader
|
||||||
|
isBlock = hdr.UnmarshalCBOR(bytes.NewBuffer(data)) == nil
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
return isBlock, err
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SplitStore) moveColdBlocks(cold []cid.Cid) error {
|
func (s *SplitStore) moveColdBlocks(cold []cid.Cid) error {
|
||||||
batch := make([]blocks.Block, 0, batchSize)
|
batch := make([]blocks.Block, 0, batchSize)
|
||||||
|
|
||||||
@ -1302,6 +1316,13 @@ func (s *SplitStore) sortObjects(cids []cid.Cid) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w++
|
w++
|
||||||
|
|
||||||
|
// short-circuit block headers or else we'll walk the entire chain
|
||||||
|
isBlock, err := s.isBlockHeader(c)
|
||||||
|
if isBlock || err == bstore.ErrNotFound {
|
||||||
|
return errStopWalk
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(_ cid.Cid, leaves int) {
|
func(_ cid.Cid, leaves int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user