Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBInterface ¶
type DBInterface interface { // PutHeader stores a header at the specified height. PutHeader(height int, header *wire.BlockHeader) error // HeaderByHeight retrieves a header stored at the specified height. If no header was found, nil // is returned. HeaderByHeight(height int) (*wire.BlockHeader, error) // RevertTo deletes all headers after tip. RevertTo(tip int) error // Tip retrieves the current max. height. Tip() (int, error) // Flush forces the db changes to the filesystem. Flush() error }
DBInterface can be implemented by database backends to store/retrieve headers.
type Event ¶
type Event string
Event instances are sent to the onEvent callback.
const ( // EventSyncing is fired when the headers are syncing (a batch was downloaded but more are // coming). At the end, EventSynced is fired. EventSyncing Event = "syncing" // EventSynced is fired when the headers finished syncing. EventSynced Event = "synced" // EventNewTip is fired when a new tip is known. EventNewTip Event = "newTip" )
type Headers ¶
type Headers struct {
// contains filtered or unexported fields
}
Headers manages syncing blockchain headers.
func NewHeaders ¶
func NewHeaders( net *chaincfg.Params, db DBInterface, blockchain blockchain.Interface, log *logrus.Entry) *Headers
NewHeaders creates a new Headers instance.
func (*Headers) HeaderByHeight ¶
func (headers *Headers) HeaderByHeight(height int) (*wire.BlockHeader, error)
HeaderByHeight returns the header at the given height. Returns nil if the headers are not synced up to this height yet.
func (*Headers) Initialize ¶
func (headers *Headers) Initialize()
Initialize starts the syncing process.
func (*Headers) SubscribeEvent ¶
SubscribeEvent subscribes to header events. The provided callback will be notified of events. The returned function unsubscribes. FIXME: not thread-safe
Click to show internal directories.
Click to hide internal directories.