From 370700bce734af6b8872dfc3d6234def21440b35 Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Mon, 13 May 2024 13:54:51 -0700 Subject: [PATCH] add reprovide buffer for better batching --- ipfs/provide.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ipfs/provide.go b/ipfs/provide.go index 013d34d..4b0dbd6 100644 --- a/ipfs/provide.go +++ b/ipfs/provide.go @@ -103,7 +103,10 @@ func (r *Reprovider) Run(ctx context.Context, interval, timeout time.Duration, b announced := make([]cid.Cid, 0, len(cids)) keys := make([]multihash.Multihash, 0, len(cids)) - minAnnouncement := time.Now().Add(-interval) + // include a slight buffer for CIDs that are about to expire + // so they will be provided as one batch + buffer := interval / 10 + minAnnouncement := time.Now().Add(-interval).Add(buffer) for _, c := range cids { // only provide CIDs that have not been provided within the // last interval