Skip to content

Commit

Permalink
remove retry info and noop in case of empty block
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed May 13, 2024
1 parent abc78f1 commit a5d329c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions pruner/light/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ import (
"context"

"github.com/ipfs/boxo/blockservice"
"github.com/ipfs/go-datastore"

"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/share"
"github.com/celestiaorg/celestia-node/share/ipld"
)

type Pruner struct {
bserv blockservice.BlockService
ds datastore.Datastore
}

func NewPruner(bserv blockservice.BlockService) *Pruner {
return &Pruner{bserv: bserv}
func NewPruner(bserv blockservice.BlockService, ds datastore.Datastore) *Pruner {
return &Pruner{bserv: bserv, ds: ds}
}

func (p *Pruner) Prune(ctx context.Context, h *header.ExtendedHeader) error {
dah := h.DAH
if share.DataHash(dah.Hash()).IsEmptyRoot() {
return nil
}

var roots [][]byte
roots = append(roots, h.DAH.RowRoots...)
roots = append(roots, h.DAH.ColumnRoots...)
Expand All @@ -28,5 +36,15 @@ func (p *Pruner) Prune(ctx context.Context, h *header.ExtendedHeader) error {
}
}

key := rootKey(dah)
err := p.ds.Delete(ctx, key)
if err != nil {
return err
}

return nil
}

func rootKey(root *share.Root) datastore.Key {
return datastore.NewKey(root.String())
}

0 comments on commit a5d329c

Please sign in to comment.