Documentation ¶
Overview ¶
Package tslib provides conversions between four data types: block numbers, dates, Linux timestamps, and "special" named blocks. The function names are self-explanitory.
Note: Because the relationship between block numbers and timestamps is a per-chain value, some of these functions require a `chain` name. It is assumed the chain is properly configured.
Index ¶
- Variables
- func Append(chain string, tsArray []TimestampRecord) error
- func ClearCache(chain string)
- func EstablishTimestamps(chain string, publisher base.Address) error
- func FromBnToDate(chain string, bn base.Blknum) (gostradamus.DateTime, error)
- func FromBnToName(chain string, bn base.Blknum) (string, error)
- func FromBnToNamedBlock(chain string, bn base.Blknum) (*types.NamedBlock, error)
- func FromBnToTs(chain string, bn base.Blknum) (base.Timestamp, error)
- func FromDateToBn(chain, dateStr string) (base.Blknum, error)
- func FromDateToTs(dateStr string) (base.Timestamp, error)
- func FromNameToBn(chain, name string) (base.Blknum, error)
- func FromNameToDate(chain, name string) (gostradamus.DateTime, error)
- func FromTsToBn(chain string, ts base.Timestamp) (base.Blknum, error)
- func FromTsToDate(ts base.Timestamp) (gostradamus.DateTime, error)
- func GetSpecials(chain string) (specials []types.NamedBlock, err error)
- func IsSpecialBlock(chain, needle string) bool
- func NTimestamps(chain string) (base.Blknum, error)
- func RangeToBounds(chain string, rng *base.FileRange) types.RangeDates
- func Repair(chain string, bn base.Blknum) error
- func Truncate(chain string, maxBn base.Blknum) error
- type TimestampDatabase
- type TimestampRecord
Constants ¶
This section is empty.
Variables ¶
var ErrInTheFuture = errors.New("timestamp in the future")
Functions ¶
func Append ¶
func Append(chain string, tsArray []TimestampRecord) error
func ClearCache ¶
func ClearCache(chain string)
func FromBnToDate ¶
FromBnToDate returns a chain-specific date given a block number.
func FromBnToName ¶
FromBnToName returns the block's chain-specific name (if found) given its block number
func FromBnToNamedBlock ¶
FromBnToNamedBlock returns the block's chain-specific name (if found) given its block number
func FromBnToTs ¶
FromBnToTs returns a chain-specific Linux timestamp given a block number
func FromDateToBn ¶
FromDateToBn returns a chain-specific block number given a date string (date strings are valid JSON dates).
func FromDateToTs ¶
FromDateToTs returns a Linux timestamp given a date string (not chain-specific)
func FromNameToBn ¶
FromNameToBn returns the chain-specific block number (if found) given the name of a special block. The list of special blocks is per-chain.
func FromNameToDate ¶
func FromNameToDate(chain, name string) (gostradamus.DateTime, error)
FromNameToDate returns a chain-specific date (if found) given its chain-specific name
func FromTsToBn ¶
FromTsToBn returns a chain-specific block number given a Linux timestamp.
func FromTsToDate ¶
func FromTsToDate(ts base.Timestamp) (gostradamus.DateTime, error)
FromTsToDate returns a date given a Linux timestamp (not chain-specific)
func GetSpecials ¶
func GetSpecials(chain string) (specials []types.NamedBlock, err error)
GetSpecials returns a chain-specific list of special block names and numbers
func IsSpecialBlock ¶
IsSpecialBlock returns true if the given chain-specific name is a special block
func NTimestamps ¶
NTimestamps returns the number of records in the timestamp file
func RangeToBounds ¶
func RangeToBounds(chain string, rng *base.FileRange) types.RangeDates
Types ¶
type TimestampDatabase ¶
type TimestampDatabase struct {
// contains filtered or unexported fields
}
type TimestampRecord ¶
func FromBn ¶
func FromBn(chain string, bn base.Blknum) (*TimestampRecord, error)
FromBn is a local function that returns a Timestamp record given a blockNum. It loads the timestamp file into memory if it isn't already loaded
func FromTs ¶
func FromTs(chain string, ts base.Timestamp) (*TimestampRecord, error)
FromTs is a local function that returns a Timestamp record given a Unix timestamp. It loads the timestamp file into memory if it isn't already. If the timestamp requested is past the end of the timestamp file, it estimates the block number and returns and error