Documentation ¶
Index ¶
- Constants
- func DecodeTips(encodings []string) map[common.Hash]HeaderRecord
- func InitHardCodedTips(network string) map[common.Hash]HeaderRecord
- func ReadFilesAndBuffer(files []string, headerBuf *HeaderBuffer, ...) error
- type Anchor
- type AnchorTipItem
- type AnchorTipQueue
- type CalcDifficultyFunc
- type ChainSegment
- type HeaderBuffer
- func (hb *HeaderBuffer) AddHeader(headerRaw []byte, height uint64)
- func (hb *HeaderBuffer) Clear()
- func (hb *HeaderBuffer) Flush(w io.Writer) error
- func (hb *HeaderBuffer) IsEmpty() bool
- func (hb *HeaderBuffer) Len() int
- func (hb *HeaderBuffer) Less(i, j int) bool
- func (hb *HeaderBuffer) Read(p []byte) (int, error)
- func (hb *HeaderBuffer) Swap(i, j int)
- type HeaderDownload
- func (hd *HeaderDownload) AddHeaderToBuffer(headerRaw []byte, blockHeight uint64)
- func (hd *HeaderDownload) AddSegmentToBuffer(segment *ChainSegment, start, end int)
- func (hd *HeaderDownload) AnchorState() string
- func (hd *HeaderDownload) Connect(segment *ChainSegment, start, end int, currentTime uint64) error
- func (hd *HeaderDownload) ExtendDown(segment *ChainSegment, start, end int, hardCoded bool, currentTime uint64) error
- func (hd *HeaderDownload) ExtendUp(segment *ChainSegment, start, end int, currentTime uint64) error
- func (hd *HeaderDownload) FindAnchors(segment *ChainSegment) (found bool, start int, anchorParent common.Hash, invalidAnchors []int)
- func (hd *HeaderDownload) FindTip(segment *ChainSegment, start int) (found bool, end int, penalty Penalty)
- func (hd *HeaderDownload) FlushBuffer() error
- func (hd *HeaderDownload) HasTip(tipHash common.Hash) bool
- func (hd *HeaderDownload) InvalidateAnchors(anchorParent common.Hash, invalidAnchors []int) (tombstones []common.Hash, err error)
- func (hd *HeaderDownload) NewAnchor(segment *ChainSegment, start, end int, currentTime uint64) error
- func (hd *HeaderDownload) PrepareStageData() (files []string, buffer *HeaderBuffer)
- func (hd *HeaderDownload) Progress() (files int, buffer int, headersAdded int)
- func (hd *HeaderDownload) Ready() (bool, uint64)
- func (hd *HeaderDownload) RecoverFromDb(db ethdb.Database, currentTime uint64) error
- func (hd *HeaderDownload) RecoverFromFiles(currentTime uint64, hardTips map[common.Hash]HeaderRecord) error
- func (hd *HeaderDownload) RequestMoreHeaders(currentTime, timeout uint64) ([]*HeaderRequest, *time.Timer)
- func (hd *HeaderDownload) SetHardCodedTips(hardTips map[common.Hash]HeaderRecord)
- func (hd *HeaderDownload) SingleHeaderAsSegment(headerRaw []byte, header *types.Header) ([]*ChainSegment, Penalty, error)
- func (hd *HeaderDownload) SplitIntoSegments(headersRaw [][]byte, msg []*types.Header) ([]*ChainSegment, Penalty, error)
- func (hd *HeaderDownload) StageReadyChannel() chan struct{}
- func (hd *HeaderDownload) VerifySeals(segment *ChainSegment, anchorFound, tipFound bool, start, end int, ...) (hardCoded bool, err error)
- type HeaderInserter
- type HeaderRecord
- type HeaderRequest
- type HeadersByBlockHeight
- type Heap
- type HeapElem
- type PeerHandle
- type PeerPenalty
- type Penalty
- type RequestQueue
- type RequestQueueItem
- type Tip
- type TipQueueItem
- type VerifySealFunc
Constants ¶
const AnchorSerLen = 32 + 8 + 8 /* maxTipHeight */
Variables ¶
This section is empty.
Functions ¶
func DecodeTips ¶
func DecodeTips(encodings []string) map[common.Hash]HeaderRecord
func InitHardCodedTips ¶
func InitHardCodedTips(network string) map[common.Hash]HeaderRecord
func ReadFilesAndBuffer ¶
Types ¶
type AnchorTipItem ¶
type AnchorTipItem struct {
// contains filtered or unexported fields
}
AnchorTipItem is element of the priority queue of tips belonging to an anchor This queue is prioritised by block heights, lowest block height being first out
type AnchorTipQueue ¶
type AnchorTipQueue []AnchorTipItem
func (AnchorTipQueue) Len ¶
func (atq AnchorTipQueue) Len() int
func (AnchorTipQueue) Less ¶
func (atq AnchorTipQueue) Less(i, j int) bool
func (*AnchorTipQueue) Pop ¶
func (atq *AnchorTipQueue) Pop() interface{}
func (*AnchorTipQueue) Push ¶
func (atq *AnchorTipQueue) Push(x interface{})
func (AnchorTipQueue) Swap ¶
func (atq AnchorTipQueue) Swap(i, j int)
type CalcDifficultyFunc ¶
type ChainSegment ¶
First item in ChainSegment is the anchor ChainSegment must be contigous and must not include bad headers
type HeaderBuffer ¶
type HeaderBuffer struct {
// contains filtered or unexported fields
}
func (*HeaderBuffer) AddHeader ¶
func (hb *HeaderBuffer) AddHeader(headerRaw []byte, height uint64)
func (*HeaderBuffer) Clear ¶
func (hb *HeaderBuffer) Clear()
func (*HeaderBuffer) IsEmpty ¶
func (hb *HeaderBuffer) IsEmpty() bool
func (*HeaderBuffer) Len ¶
func (hb *HeaderBuffer) Len() int
func (*HeaderBuffer) Less ¶
func (hb *HeaderBuffer) Less(i, j int) bool
func (*HeaderBuffer) Swap ¶
func (hb *HeaderBuffer) Swap(i, j int)
type HeaderDownload ¶
type HeaderDownload struct { RequestQueueTimer *time.Timer // contains filtered or unexported fields }
func NewHeaderDownload ¶
func NewHeaderDownload( initialHash common.Hash, filesDir string, bufferLimit, tipLimit, initPowDepth int, calcDifficultyFunc CalcDifficultyFunc, verifySealFunc VerifySealFunc, newAnchorFutureLimit, newAnchorPastLimit uint64, ) *HeaderDownload
func (*HeaderDownload) AddHeaderToBuffer ¶
func (hd *HeaderDownload) AddHeaderToBuffer(headerRaw []byte, blockHeight uint64)
func (*HeaderDownload) AddSegmentToBuffer ¶
func (hd *HeaderDownload) AddSegmentToBuffer(segment *ChainSegment, start, end int)
AddSegmentToBuffer adds another segment to the buffer and return true if the buffer is now full
func (*HeaderDownload) AnchorState ¶
func (hd *HeaderDownload) AnchorState() string
func (*HeaderDownload) Connect ¶
func (hd *HeaderDownload) Connect(segment *ChainSegment, start, end int, currentTime uint64) error
Connect connects some working trees using anchors of some, and a tip of another
func (*HeaderDownload) ExtendDown ¶
func (hd *HeaderDownload) ExtendDown(segment *ChainSegment, start, end int, hardCoded bool, currentTime uint64) error
ExtendDown extends some working trees down from the anchor, using given chain segment it creates a new anchor and collects all the tips from the attached anchors to it
func (*HeaderDownload) ExtendUp ¶
func (hd *HeaderDownload) ExtendUp(segment *ChainSegment, start, end int, currentTime uint64) error
ExtendUp extends a working tree up from the tip, using given chain segment
func (*HeaderDownload) FindAnchors ¶
func (hd *HeaderDownload) FindAnchors(segment *ChainSegment) (found bool, start int, anchorParent common.Hash, invalidAnchors []int)
FindAnchors attempts to find anchors to which given chain segment can be attached to
func (*HeaderDownload) FindTip ¶
func (hd *HeaderDownload) FindTip(segment *ChainSegment, start int) (found bool, end int, penalty Penalty)
FindTip attempts to find tip of a tree that given chain segment can be attached to the given chain segment may be found invalid relative to a working tree, in this case penalty for peer is returned
func (*HeaderDownload) FlushBuffer ¶
func (hd *HeaderDownload) FlushBuffer() error
func (*HeaderDownload) InvalidateAnchors ¶
func (hd *HeaderDownload) InvalidateAnchors(anchorParent common.Hash, invalidAnchors []int) (tombstones []common.Hash, err error)
InvalidateAnchors removes trees with given anchor hashes (belonging to the given anchor parent)
func (*HeaderDownload) NewAnchor ¶
func (hd *HeaderDownload) NewAnchor(segment *ChainSegment, start, end int, currentTime uint64) error
func (*HeaderDownload) PrepareStageData ¶
func (hd *HeaderDownload) PrepareStageData() (files []string, buffer *HeaderBuffer)
func (*HeaderDownload) Progress ¶
func (hd *HeaderDownload) Progress() (files int, buffer int, headersAdded int)
func (*HeaderDownload) Ready ¶
func (hd *HeaderDownload) Ready() (bool, uint64)
func (*HeaderDownload) RecoverFromDb ¶
func (hd *HeaderDownload) RecoverFromDb(db ethdb.Database, currentTime uint64) error
func (*HeaderDownload) RecoverFromFiles ¶
func (hd *HeaderDownload) RecoverFromFiles(currentTime uint64, hardTips map[common.Hash]HeaderRecord) error
func (*HeaderDownload) RequestMoreHeaders ¶
func (hd *HeaderDownload) RequestMoreHeaders(currentTime, timeout uint64) ([]*HeaderRequest, *time.Timer)
func (*HeaderDownload) SetHardCodedTips ¶
func (hd *HeaderDownload) SetHardCodedTips(hardTips map[common.Hash]HeaderRecord)
func (*HeaderDownload) SingleHeaderAsSegment ¶
func (hd *HeaderDownload) SingleHeaderAsSegment(headerRaw []byte, header *types.Header) ([]*ChainSegment, Penalty, error)
SingleHeaderAsSegment converts message containing 1 header into one singleton chain segment
func (*HeaderDownload) SplitIntoSegments ¶
func (hd *HeaderDownload) SplitIntoSegments(headersRaw [][]byte, msg []*types.Header) ([]*ChainSegment, Penalty, error)
SplitIntoSegments converts message containing headers into a collection of chain segments
func (*HeaderDownload) StageReadyChannel ¶
func (hd *HeaderDownload) StageReadyChannel() chan struct{}
func (*HeaderDownload) VerifySeals ¶
func (hd *HeaderDownload) VerifySeals(segment *ChainSegment, anchorFound, tipFound bool, start, end int, currentTime uint64) (hardCoded bool, err error)
VerifySeals verifies Proof Of Work for the part of the given chain segment It reports first verification error, or returns the powDepth that the anchor of this chain segment should have, if created
type HeaderInserter ¶
type HeaderInserter struct {
// contains filtered or unexported fields
}
HeaderInserter incapsulates necessary variable for inserting header records to the database, abstracting away the source of these headers The headers are "fed" by repeatedly calling the FeedHeader function.
func NewHeaderInserter ¶
func NewHeaderInserter(logPrefix string, tx, batch ethdb.DbWithPendingMutations, localTd *big.Int, headerProgress uint64) *HeaderInserter
func (*HeaderInserter) FeedHeader ¶
func (hi *HeaderInserter) FeedHeader(header *types.Header, blockHeight uint64) error
func (*HeaderInserter) GetHighest ¶
func (hi *HeaderInserter) GetHighest() uint64
func (*HeaderInserter) UnwindPoint ¶
func (hi *HeaderInserter) UnwindPoint() uint64
type HeaderRecord ¶
HeaderRecord encapsulates two forms of the same header - raw RLP encoding (to avoid duplicated decodings and encodings), and parsed value types.Header
type HeaderRequest ¶
Request for chain segment starting with hash and going to its parent, etc, with length headers in total
type HeadersByBlockHeight ¶
Implements sort.Interface so we can sort the incoming header in the message by block height
func (HeadersByBlockHeight) Len ¶
func (h HeadersByBlockHeight) Len() int
func (HeadersByBlockHeight) Less ¶
func (h HeadersByBlockHeight) Less(i, j int) bool
func (HeadersByBlockHeight) Swap ¶
func (h HeadersByBlockHeight) Swap(i, j int)
type HeapElem ¶
type HeapElem struct {
// contains filtered or unexported fields
}
Heap element for merging together header files
type PeerHandle ¶
type PeerHandle int // This is int just for the PoC phase - will be replaced by more appropriate type to find a peer
type PeerPenalty ¶
type PeerPenalty struct {
// contains filtered or unexported fields
}
func (PeerPenalty) String ¶
func (pp PeerPenalty) String() string
type RequestQueue ¶
type RequestQueue []RequestQueueItem
func (RequestQueue) Len ¶
func (rq RequestQueue) Len() int
func (RequestQueue) Less ¶
func (rq RequestQueue) Less(i, j int) bool
func (*RequestQueue) Pop ¶
func (rq *RequestQueue) Pop() interface{}
func (*RequestQueue) Push ¶
func (rq *RequestQueue) Push(x interface{})
func (RequestQueue) Swap ¶
func (rq RequestQueue) Swap(i, j int)
type RequestQueueItem ¶
type RequestQueueItem struct {
// contains filtered or unexported fields
}
type TipQueueItem ¶
type TipQueueItem struct {
// contains filtered or unexported fields
}