writeHeader writes a header into the local chain, given that its parent is already known. If the total difficulty of the newly inserted header becomes greater than the current known TD, the canonical chain is re-routed. Note: This method is not concurrent-safe with inserting blocks simultaneously i
(header *types.Header)
| 1857 | // in two scenarios: pure-header mode of operation (light clients), or properly |
| 1858 | // separated header/block phases (non-archive clients). |
| 1859 | func (bc *BlockChain) writeHeader(header *types.Header) error { |
| 1860 | bc.wg.Add(1) |
| 1861 | defer bc.wg.Done() |
| 1862 | |
| 1863 | bc.mu.Lock() |
| 1864 | defer bc.mu.Unlock() |
| 1865 | |
| 1866 | _, err := bc.hc.WriteHeader(header) |
| 1867 | return err |
| 1868 | } |
| 1869 | |
| 1870 | // CurrentHeader retrieves the current head header of the canonical chain. The |
| 1871 | // header is retrieved from the HeaderChain's internal cache. |
nothing calls this directly
no test coverage detected