@@ -208,11 +208,18 @@ func (d *DecayedLog) garbageCollector(epochClient *chainntnfs.BlockEpochEvent) {
208208 // Perform a bout of garbage collection using the
209209 // epoch's block height.
210210 height := uint32 (epoch .Height )
211- if err := d .gcExpiredHashes (height ); err != nil {
211+ numExpired , err := d .gcExpiredHashes (height )
212+ if err != nil {
212213 sphxLog .Errorf ("unable to expire hashes at " +
213214 "height=%d" , height )
214215 }
215216
217+ if numExpired > 0 {
218+ sphxLog .Infof ("Garbage collected %v shared " +
219+ "secret hashes at height=%v" ,
220+ numExpired , height )
221+ }
222+
216223 case <- d .quit :
217224 // Received shutdown request.
218225 sphxLog .Infof ("Decaying hash log received " +
@@ -224,8 +231,12 @@ func (d *DecayedLog) garbageCollector(epochClient *chainntnfs.BlockEpochEvent) {
224231
225232// gcExpiredHashes purges the decaying log of all entries whose CLTV expires
226233// below the provided height.
227- func (d * DecayedLog ) gcExpiredHashes (height uint32 ) error {
228- return d .db .Batch (func (tx * bolt.Tx ) error {
234+ func (d * DecayedLog ) gcExpiredHashes (height uint32 ) (uint32 , error ) {
235+ var numExpiredHashes uint32
236+
237+ err := d .db .Batch (func (tx * bolt.Tx ) error {
238+ numExpiredHashes = 0
239+
229240 // Grab the shared hash bucket
230241 sharedHashes := tx .Bucket (sharedHashBucket )
231242 if sharedHashes == nil {
@@ -243,6 +254,8 @@ func (d *DecayedLog) gcExpiredHashes(height uint32) error {
243254 // array which we'll loop over and delete every
244255 // hash contained from the db.
245256 expiredCltv = append (expiredCltv , k )
257+ numExpiredHashes ++
258+ fmt .Println ("inc" )
246259 }
247260
248261 return nil
@@ -262,6 +275,11 @@ func (d *DecayedLog) gcExpiredHashes(height uint32) error {
262275
263276 return nil
264277 })
278+ if err != nil {
279+ return 0 , nil
280+ }
281+
282+ return numExpiredHashes , nil
265283}
266284
267285// hashSharedSecret Sha-256 hashes the shared secret and returns the first
0 commit comments