<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "BitcoinKernel",
  "identifier" : "/documentation/BitcoinKernel/ChainstateManager/bestEntry",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "BitcoinKernel"
    ],
    "preciseIdentifier" : "s:13BitcoinKernel17ChainstateManagerC9bestEntryAA09BlockTreeF0Cvp"
  },
  "title" : "bestEntry"
}
-->

# bestEntry

The best (tip) block tree entry — the block with the most cumulative
proof-of-work that the kernel currently considers the chain’s head.

```
var bestEntry: BlockTreeEntry { get }
```

## Discussion

A **view type** whose lifetime is tied to this manager; keep the
manager alive while you hold the returned [`BlockTreeEntry`](/documentation/BitcoinKernel/BlockTreeEntry), or
promote to an owned [`BlockTreeEntrySnapshot`](/documentation/BitcoinKernel/BlockTreeEntrySnapshot) for safe storage.
Reads [`bestEntry`](/documentation/BitcoinKernel/ChainstateManager/bestEntry) repeatedly during a sync run to track progress.

Traps with `preconditionFailure` if the chainstate manager has no
best header — currently observable only after a `(true, true)` wipe
before genesis is re-loaded. See
`upstream-issues/bitcoin/chainstate-get-best-entry-null-after-wipe.md`
in the swift-bitcoinkernel repo. The trap converts what would otherwise
be a SIGSEGV inside `btck_block_tree_entry_get_height` into a
diagnosable Swift fatal error.