Skip to content

Commit

Permalink
feat(store): prune block function (#1399)
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy authored Jul 8, 2024
1 parent a32d37c commit 5fc8261
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,26 @@ func (s *store) WriteBatch() error {
func (s *store) IsBanned(addr crypto.Address) bool {
return s.config.BannedAddrs[addr]
}

func (s *store) pruneBlock(blockHeight uint32) (bool, error) { //nolint
s.lk.Lock()
defer s.lk.Unlock()

blkData, err := s.blockStore.block(blockHeight)
if err != nil {
return false, err
}

blk, err := block.FromBytes(blkData)
if err != nil {
return false, err
}

s.batch.Delete(blockHashKey(blk.Hash()))

for _, t := range blk.Transactions() {
s.batch.Delete(t.ID().Bytes())
}

return true, nil
}

0 comments on commit 5fc8261

Please sign in to comment.