{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package blockledger\n\n## Functions\n\n```go\nfunc CreateNextBlock(rl Reader, messages []*cb.Envelope) *cb.Block\n```\nCreateNextBlock provides a utility way to construct the next block from contents and metadata for a given ledger XXX This will need to be modified to accept marshaled envelopes\n\n\tto accommodate non-deterministic marshaling\n\n```go\nfunc GetBlock(rl Reader, index uint64) *cb.Block\n```\nGetBlock is a utility method for retrieving a single block\n\n## Types\n\n```go\ntype Factory interface {\n\t// GetOrCreate gets an existing ledger (if it exists)\n\t// or creates it if it does not\n\tGetOrCreate(chainID string) (ReadWriter, error)\n\n\t// ChainIDs returns the chain IDs the Factory is aware of\n\tChainIDs() []string\n\n\t// Close releases all resources acquired by the factory\n\tClose()\n}\n```\nFactory retrieves or creates new ledgers by chainID\n\n```go\ntype Iterator interface {\n\t// Next blocks until there is a new block available, or returns an error if\n\t// the next block is no longer retrievable\n\tNext() (*cb.Block, cb.Status)\n\t// Close releases resources acquired by the Iterator\n\tClose()\n}\n```\nIterator is useful for a chain Reader to stream blocks as they are created\n\n```go\ntype NotFoundErrorIterator struct{}\n```\nNotFoundErrorIterator simply always returns an error of cb.Status\\_NOT\\_FOUND, and is generally useful for implementations of the Reader interface\n\n```go\nfunc (nfei *NotFoundErrorIterator) Close()\n```\nClose does nothing\n\n```go\nfunc (nfei *NotFoundErrorIterator) Next() (*cb.Block, cb.Status)\n```\nNext returns nil, cb.Status\\_NOT\\_FOUND\n\n```go\nfunc (nfei *NotFoundErrorIterator) ReadyChan() \u003c-chan struct{}\n```\nReadyChan returns a closed channel\n\n```go\ntype ReadWriter interface {\n\tReader\n\tWriter\n}\n```\nReadWriter encapsulates the read/write functions of the ledger\n\n```go\ntype Reader interface {\n\t// Iterator returns an Iterator, as specified by an ab.SeekInfo message, and\n\t// its starting block number\n\tIterator(startType *ab.SeekPosition) (Iterator, uint64)\n\t// Height returns the number of blocks on the ledger\n\tHeight() uint64\n}\n```\nReader allows the caller to inspect the ledger\n\n```go\ntype Writer interface {\n\t// Append a new block to the ledger\n\tAppend(block *cb.Block) error\n}\n```\nWriter allows the caller to modify the ledger\n\n","path":"github.com/eric-erki/https-hyperledger.org/common/ledger/blockledger","name":"blockledger","synopsis":"","isRedistributable":true}
