Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Sep 16, 2024
1 parent 2ab2b35 commit 1745614
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 135 deletions.
6 changes: 5 additions & 1 deletion internal/api/v3/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ func (s *EventService) didCommitBlock(e events.DidCommitBlock) error {
func (s *EventService) loadBlockInfo(batch *database.Batch, e *api.BlockEvent) {
defer batch.Discard()

// Check for an entry in the new block ledger. If the conversion process is
// incomplete there will be empty entries, so we also need to check for that
// (hence l1.Index == 0). If there is not an entry in the new block ledger
// or it is empty, check for an old block ledger account.
var entries []*protocol.BlockEntry
if _, l1, e1 := batch.Account(s.partition.Ledger()).BlockLedger().Find(record.NewKey(e.Index)).Exact().Get(); e1 == nil {
if _, l1, e1 := batch.Account(s.partition.Ledger()).BlockLedger().Find(record.NewKey(e.Index)).Exact().Get(); e1 == nil || l1.Index == 0 {
entries = l1.Entries
} else if l2, e2 := batch.Account(s.partition.BlockLedger(e.Index)).Main().Get(); e2 == nil && l2.Type() == protocol.AccountTypeBlockLedger {
entries = l2.(*protocol.BlockLedger).Entries
Expand Down
3 changes: 2 additions & 1 deletion internal/core/execute/v2/block/block_end.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ func (b *Block) executePostUpdateActions() error {
if err != nil {
return errors.UnknownError.WithFormat("add ledger entry for block %d: %w", i+j, err)
}
err = b.Batch.BPT().Delete(b.Batch.Account(b.Executor.Describe.BlockLedger(entry.BlockIndex)).Key())
blockLedgerAccount := b.Batch.Account(b.Executor.Describe.BlockLedger(entry.BlockIndex))
err = b.Batch.BPT().Delete(blockLedgerAccount.Key())
if err != nil {
return errors.UnknownError.WithFormat("delete BPT entry for block ledger %d: %w", i+j, err)
}
Expand Down
92 changes: 0 additions & 92 deletions pkg/database/indexing/range.go

This file was deleted.

41 changes: 0 additions & 41 deletions pkg/database/indexing/range_test.go

This file was deleted.

1 change: 1 addition & 0 deletions pkg/database/indexing/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (v *Value[V]) Get() (V, error) {
dec := binDecPool.Get(bytes.NewReader(v.data))
defer binDecPool.Put(dec)
err := dec.Decode(&v.value)
v.valueOk = err == nil
return v.value, err
}

Expand Down

0 comments on commit 1745614

Please sign in to comment.