Documentation ¶
Index ¶
Constants ¶
View Source
const AddrLength = 20
AddrLength is byte length of eth account address.
Variables ¶
View Source
var ErrAddrLength = errs.Class(fmt.Sprintf("Address must be %v bytes in length", AddrLength))
ErrAddrLength represents the error that the address is the wrong length.
View Source
var ( // ErrNoHeader is error thrown when there is no header in db. ErrNoHeader = errs.New("HeadersDB: header not found") )
Functions ¶
This section is empty.
Types ¶
type Address ¶
Address is wallet address on eth chain.
func AddressFromBytes ¶
AddressFromBytes creates a new address from hex bytes.
func AddressFromHex ¶
AddressFromHex creates new address from hex string.
type Header ¶
Header holds ethereum blockchain block header indexed data. No need to keep number as big.Int right now as block count on ethereum mainnet is far from overflowing int64 capacity.
type HeadersCache ¶
type HeadersCache struct {
// contains filtered or unexported fields
}
HeadersCache cache for blockchain block headers.
func NewHeadersCache ¶
func NewHeadersCache(log *zap.Logger, db HeadersDB) *HeadersCache
NewHeadersCache creates new headers cache.
type HeadersDB ¶
type HeadersDB interface { // Insert inserts new header to cache db. Insert(ctx context.Context, hash Hash, number int64, timestamp time.Time) error // Delete deletes header from db by hash. Delete(ctx context.Context, hash Hash) error // DeleteBefore deletes headers before the given time. DeleteBefore(ctx context.Context, before time.Time) (err error) // Get retrieves header by hash. Get(ctx context.Context, hash Hash) (Header, error) // GetByNumber retrieves header by number. GetByNumber(ctx context.Context, number int64) (Header, error) // List retrieves all headers stored in cache db. List(ctx context.Context) ([]Header, error) }
HeadersDB is ethereum blockchain block header indexed cache.
architecture: Database
Click to show internal directories.
Click to hide internal directories.