@@ -208,11 +208,18 @@ func (d *DecayedLog) garbageCollector(epochClient *chainntnfs.BlockEpochEvent) {
208
208
// Perform a bout of garbage collection using the
209
209
// epoch's block height.
210
210
height := uint32 (epoch .Height )
211
- if err := d .gcExpiredHashes (height ); err != nil {
211
+ numExpired , err := d .gcExpiredHashes (height )
212
+ if err != nil {
212
213
sphxLog .Errorf ("unable to expire hashes at " +
213
214
"height=%d" , height )
214
215
}
215
216
217
+ if numExpired > 0 {
218
+ sphxLog .Infof ("Garbage collected %v shared " +
219
+ "secret hashes at height=%v" ,
220
+ numExpired , height )
221
+ }
222
+
216
223
case <- d .quit :
217
224
// Received shutdown request.
218
225
sphxLog .Infof ("Decaying hash log received " +
@@ -224,8 +231,12 @@ func (d *DecayedLog) garbageCollector(epochClient *chainntnfs.BlockEpochEvent) {
224
231
225
232
// gcExpiredHashes purges the decaying log of all entries whose CLTV expires
226
233
// 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
+
229
240
// Grab the shared hash bucket
230
241
sharedHashes := tx .Bucket (sharedHashBucket )
231
242
if sharedHashes == nil {
@@ -243,6 +254,8 @@ func (d *DecayedLog) gcExpiredHashes(height uint32) error {
243
254
// array which we'll loop over and delete every
244
255
// hash contained from the db.
245
256
expiredCltv = append (expiredCltv , k )
257
+ numExpiredHashes ++
258
+ fmt .Println ("inc" )
246
259
}
247
260
248
261
return nil
@@ -262,6 +275,11 @@ func (d *DecayedLog) gcExpiredHashes(height uint32) error {
262
275
263
276
return nil
264
277
})
278
+ if err != nil {
279
+ return 0 , nil
280
+ }
281
+
282
+ return numExpiredHashes , nil
265
283
}
266
284
267
285
// hashSharedSecret Sha-256 hashes the shared secret and returns the first
0 commit comments