Documentation ¶
Overview ¶
Package identifiers aides in the parsing of command line block and/or transaction identifiers
Index ¶
- func GetBlockNumberMap(chain string, ids []Identifier) (map[base.Blknum]bool, error)
- func GetBlockNumbers(chain string, ids []Identifier) ([]base.Blknum, error)
- func GetBounds(chain string, ids *[]Identifier) (ret base.BlockRange, err error)
- func GetTransactionIds(chain string, ids []Identifier) ([]types.Appearance, error)
- func IdsToApps(chain string, ids []Identifier) ([]types.Appearance, int, error)
- type Identifier
- type IdentifierType
- type Modifier
- type Point
- type Range
- type WrongModifierError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBlockNumberMap ¶
func GetBlockNumbers ¶
func GetBlockNumbers(chain string, ids []Identifier) ([]base.Blknum, error)
func GetBounds ¶
func GetBounds(chain string, ids *[]Identifier) (ret base.BlockRange, err error)
GetBounds returns the earliest and latest blocks for an array of identifiers
func GetTransactionIds ¶
func GetTransactionIds(chain string, ids []Identifier) ([]types.Appearance, error)
func IdsToApps ¶
func IdsToApps(chain string, ids []Identifier) ([]types.Appearance, int, error)
Types ¶
type Identifier ¶
type Identifier struct { StartType IdentifierType `json:"startType,omitempty"` Start Point `json:"start,omitempty"` EndType IdentifierType `json:"endType,omitempty"` End Point `json:"end,omitempty"` ModifierType IdentifierType `json:"modifierType,omitempty"` Modifier Modifier `json:"modifier,omitempty"` Orig string `json:"-"` }
func NewBlockRange ¶
func NewBlockRange(rangeStr string) (*Identifier, error)
NewBlockRange parses a string containing block range and returns a struct that always has Start, StartType, EndType, ModifierType fields and may as well have End and Modifier, if they are defined. *Type fields can be used to quickly check what is the type of the values.
Consult ./parser.go for the supported format TODO: This does not handle the zero block correctly
func NewTxRange ¶
func NewTxRange(rangeStr string) (*Identifier, error)
func (*Identifier) ResolveBlocks ¶
func (id *Identifier) ResolveBlocks(chain string) ([]base.Blknum, error)
ResolveBlocks resolves a list of identifiers to a list of blocks (excluding the last block)
func (*Identifier) ResolveTxs ¶
func (id *Identifier) ResolveTxs(chain string) ([]types.Appearance, error)
func (*Identifier) String ¶
func (id *Identifier) String() string
func (*Identifier) UnmarshalJSON ¶
func (id *Identifier) UnmarshalJSON(data []byte) error
type IdentifierType ¶
type IdentifierType int64
const ( NotDefined IdentifierType = iota BlockNumber BlockTimestamp BlockHash BlockDate BlockSpecial TransactionIndex TransactionHash Period Step )
func (IdentifierType) String ¶
func (id IdentifierType) String() string
type Modifier ¶
type Modifier struct { Step uint `parser:"@Unsigned" json:"step,omitempty"` Period string `parser:"| @('hourly'|'daily'|'weekly'|'monthly'|'quarterly'|'annually'|'next'|'prev'|'all')" json:"period,omitempty"` }
Modifier changes the meaning of the given range. For example, if step of 10 is provided, the range does not mean "each block from start to end" anymore, but instead "every 10th block from start to end". Similarly a period can be provided to get only blocks based on frequency (e.g. weekly)
type Point ¶
type Point struct { Number uint `parser:"@Hex|@Unsigned" json:"number,omitempty"` Hash string `parser:"| @Hash" json:"hash,omitempty"` Date string `parser:"| @Date" json:"date,omitempty"` Special string `parser:"| @Special" json:"special,omitempty"` }
A Point carries information about when a range starts or ends. It can be a block number, a date or special name (e.g. "london" is translated to block 12965000)
type Range ¶
Range is uses after having defined both Point and Modifier, we can construct our Range, which consist of a starting point, optionally followed by an ending point and optionally finished by a modifier. Separators for points and modifier are defined above as PointSeparator and ModifierSeparator
type WrongModifierError ¶
type WrongModifierError struct {
Token string
}
func (*WrongModifierError) Error ¶
func (e *WrongModifierError) Error() string