HeaderChain implements the basic block header chain logic that is shared by core.BlockChain and light.LightChain. It is not usable in itself, only as a part of either structure. It is not thread safe either, the encapsulating chain structures should do the necessary mutex locking/unlocking.
| 49 | // It is not thread safe either, the encapsulating chain structures should do |
| 50 | // the necessary mutex locking/unlocking. |
| 51 | type HeaderChain struct { |
| 52 | config *configs.ChainConfig |
| 53 | |
| 54 | chainDb database.Database |
| 55 | genesisHeader *types.Header |
| 56 | |
| 57 | currentHeader atomic.Value // Current head of the header chain (may be above the block chain!) |
| 58 | currentHeaderHash common.Hash // Hash of the current head of the header chain (prevent recomputing all the time) |
| 59 | |
| 60 | headerCache *lru.Cache // Cache for the most recent block headers |
| 61 | numberCache *lru.Cache // Cache for the most recent block numbers |
| 62 | |
| 63 | procInterrupt func() bool |
| 64 | |
| 65 | rand *mrand.Rand |
| 66 | engine consensus.Engine |
| 67 | |
| 68 | knownHeadNumber uint64 // number of known head of current chain |
| 69 | knownHeadHash common.Hash // hash of known head of current chain |
| 70 | knownHeadLock sync.RWMutex |
| 71 | } |
| 72 | |
| 73 | // NewHeaderChain creates a new HeaderChain structure. |
| 74 | // getValidator should return the parent's validator |
nothing calls this directly
no outgoing calls
no test coverage detected