Skip to content

Commit

Permalink
chore: block/blockstoreutil remove unused ProcRmOutput function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed Apr 1, 2022
1 parent 16a13ce commit a126fbc
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions blocks/blockstoreutil/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"io"

cid "github.com/ipfs/go-cid"
bs "github.com/ipfs/go-ipfs-blockstore"
Expand Down Expand Up @@ -95,30 +94,3 @@ func FilterPinned(ctx context.Context, pins pin.Pinner, out chan<- interface{},
}
return stillOkay
}

// ProcRmOutput takes a function which returns a result from RmBlocks or EOF if there is no input.
// It then writes to stdout/stderr according to the RemovedBlock object returned from the function.
func ProcRmOutput(next func() (interface{}, error), sout io.Writer, serr io.Writer) error {
someFailed := false
for {
res, err := next()
if err == io.EOF {
break
} else if err != nil {
return err
}
r := res.(*RemovedBlock)
if r.Hash == "" && r.Error != nil {
return fmt.Errorf("aborted: %w", r.Error)
} else if r.Error != nil {
someFailed = true
fmt.Fprintf(serr, "cannot remove %s: %v\n", r.Hash, r.Error)
} else {
fmt.Fprintf(sout, "removed %s\n", r.Hash)
}
}
if someFailed {
return fmt.Errorf("some blocks not removed")
}
return nil
}

0 comments on commit a126fbc

Please sign in to comment.