Merge pull request #3772 from filecoin-project/fix/prune-protect-local

don't prune locally published messages
This commit is contained in:
Łukasz Magiera 2020-09-11 21:46:21 +02:00 committed by GitHub
commit aa83a4c1f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,10 +50,17 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro
pending, _ := mp.getPendingMessages(ts, ts) pending, _ := mp.getPendingMessages(ts, ts)
// priority actors -- not pruned // protected actors -- not pruned
priority := make(map[address.Address]struct{}) protected := make(map[address.Address]struct{})
// we never prune priority addresses
for _, actor := range mp.cfg.PriorityAddrs { for _, actor := range mp.cfg.PriorityAddrs {
priority[actor] = struct{}{} protected[actor] = struct{}{}
}
// we also never prune locally published messages
for actor := range mp.localAddrs {
protected[actor] = struct{}{}
} }
// Collect all messages to track which ones to remove and create chains for block inclusion // Collect all messages to track which ones to remove and create chains for block inclusion
@ -62,14 +69,14 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro
var chains []*msgChain var chains []*msgChain
for actor, mset := range pending { for actor, mset := range pending {
// we never prune priority actors // we never prune protected actors
_, keep := priority[actor] _, keep := protected[actor]
if keep { if keep {
keepCount += len(mset) keepCount += len(mset)
continue continue
} }
// not a priority actor, track the messages and create chains // not a protected actor, track the messages and create chains
for _, m := range mset { for _, m := range mset {
pruneMsgs[m.Message.Cid()] = m pruneMsgs[m.Message.Cid()] = m
} }