Chain provides a complete, minimal blockchain database. It delegates the underlying storage to other objects, and uses validation logic from package validation to decide what objects can be safely stored.
| 111 | // validation logic from package validation to decide what |
| 112 | // objects can be safely stored. |
| 113 | type Chain struct { |
| 114 | InitialBlockHash bc.Hash |
| 115 | bb *BlockBuilder |
| 116 | |
| 117 | state struct { |
| 118 | cond sync.Cond // protects height, block, snapshot |
| 119 | height uint64 |
| 120 | snapshot *state.Snapshot // current only if leader |
| 121 | } |
| 122 | store Store |
| 123 | |
| 124 | lastQueuedSnapshotHeight uint64 // atomic access only |
| 125 | blocksPerSnapshot uint64 |
| 126 | pendingSnapshots chan *state.Snapshot |
| 127 | } |
| 128 | |
| 129 | // NewChain returns a new Chain using store as the underlying storage. |
| 130 | func NewChain(ctx context.Context, initialBlock *bc.Block, store Store, heights <-chan uint64) (*Chain, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected