Skip to content

Commit

Permalink
Let spaghetti calculate cost for blocks instead of setting it
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopeereboom committed Jul 26, 2024
1 parent ba358b8 commit 7cca949
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions database/tbcd/level/level.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func (l *ldb) BlockInsert(ctx context.Context, b *btcutil.Block) (int64, error)
if err = bDB.Put(b.Hash()[:], rawBlock, nil); err != nil {
return -1, fmt.Errorf("blocks insert put: %w", err)
}
l.blockCache.Set(string(b.Hash()[:]), b, int64(32+len(rawBlock)))
l.blockCache.Set(string(b.Hash()[:]), b, 0) // let cache calculate cost
}

// Remove block identifier from blocks missing
Expand Down Expand Up @@ -698,7 +698,7 @@ func (l *ldb) BlockByHash(ctx context.Context, hash *chainhash.Hash) (*btcutil.B
return nil, fmt.Errorf("block decode: %w", err)
}
b.SetHeight(int32(bh.Height))
l.blockCache.Set(string(hash[:]), b, int64(32+len(eb)))
l.blockCache.Set(string(hash[:]), b, 0) // let cache calculate cost

return b, nil
}
Expand Down

0 comments on commit 7cca949

Please sign in to comment.