Documentation ¶
Index ¶
- Variables
- func PrettyBlockNum(b uint64) string
- func RangeBoundaryNames() []string
- func RoundToBundleEndBlock(block, fileBlockSize uint64) uint64
- func RoundToBundleStartBlock(block, fileBlockSize uint64) uint64
- type BlockNum
- type BlockRange
- func GetBlockRangeFromArg(in string) (out BlockRange, err error)
- func GetBlockRangeFromArgDefault(in string, defaultRange BlockRange) (out BlockRange, err error)
- func GetBlockRangeFromFlag(cmd *cobra.Command, flagName string) (out BlockRange, err error)
- func GetBlockRangeFromFlagDefault(cmd *cobra.Command, flagName string, defaultRange BlockRange) (out BlockRange, err error)
- func NewClosedRange(start int64, stop uint64) BlockRange
- func NewOpenRange(start int64) BlockRange
- func ParseBlockRange(input string, firstStreamableBlock uint64) (out BlockRange, err error)deprecated
- func ParseBlockRangeDefault(input string, firstStreamableBlock uint64, defaultRange BlockRange) (out BlockRange, err error)
- func (b BlockRange) BlockCount() int64
- func (b BlockRange) Contains(blockNum uint64, endBoundary RangeBoundary) bool
- func (b BlockRange) GetStartBlock() int64
- func (b BlockRange) GetStopBlockOr(defaultIfOpenRange uint64) uint64
- func (b BlockRange) IsClosed() bool
- func (b BlockRange) IsOpen() bool
- func (b BlockRange) IsResolved() bool
- func (b BlockRange) ReprocRange() string
- func (b BlockRange) Split(chunkSize uint64, endBoundary RangeBoundary) ([]BlockRange, error)
- func (b BlockRange) String() string
- func (b BlockRange) ToBstreamRange(endBoundary RangeBoundary) *bstream.Range
- type RangeBoundary
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidRangeBoundary = fmt.Errorf("not a valid RangeBoundary, try [%s]", strings.Join(_RangeBoundaryNames, ", "))
Functions ¶
func PrettyBlockNum ¶
func RangeBoundaryNames ¶
func RangeBoundaryNames() []string
RangeBoundaryNames returns a list of possible string values of RangeBoundary.
func RoundToBundleEndBlock ¶
func RoundToBundleStartBlock ¶
Types ¶
type BlockRange ¶
BlockRange is actually an UnresolvedBlockRange so both the start and end could be negative values.
This is in opposition to `bstream.Range` which is a resolved range meaning that start/stop values will never be negative.
func GetBlockRangeFromArg ¶
func GetBlockRangeFromArg(in string) (out BlockRange, err error)
GetBlockRangeFromArg returns the block range from the given argument or the range [HEAD, +∞] if the argument is empty.
func GetBlockRangeFromArgDefault ¶ added in v1.2.5
func GetBlockRangeFromArgDefault(in string, defaultRange BlockRange) (out BlockRange, err error)
GetBlockRangeFromArgDefault returns a block range from a string argument, using the default block range `defaultRange` if the input is empty.
func GetBlockRangeFromFlag ¶
func GetBlockRangeFromFlag(cmd *cobra.Command, flagName string) (out BlockRange, err error)
GetBlockRangeFromFlag returns the block range from the given flag name or the range [HEAD, +∞] if the flag is not set.
func GetBlockRangeFromFlagDefault ¶ added in v1.2.5
func GetBlockRangeFromFlagDefault(cmd *cobra.Command, flagName string, defaultRange BlockRange) (out BlockRange, err error)
GetBlockRangeFromFlagDefault returns a block range from a flag, using the default block range `defaultRange` if the flag is not set at all.
func NewClosedRange ¶
func NewClosedRange(start int64, stop uint64) BlockRange
func NewOpenRange ¶
func NewOpenRange(start int64) BlockRange
func ParseBlockRange
deprecated
func ParseBlockRange(input string, firstStreamableBlock uint64) (out BlockRange, err error)
Deprecated: use ParseBlockRangeDefault instead and provide the default range when the input is empty.
func ParseBlockRangeDefault ¶ added in v1.2.5
func ParseBlockRangeDefault(input string, firstStreamableBlock uint64, defaultRange BlockRange) (out BlockRange, err error)
ParseBlockRangeDefault parses a block range from a string, using the default block range `defaultRange` if the input is empty. The input "-1" is interpreted as an open range from [HEAD, +∞].
The accepted inputs are: - ":" (an open range from 0 to +∞) - "-1" (an open range from HEAD to +∞, equivalent to "-1:") - "123" (a single block leading to a closed range from 123 to 123) - "123:456" (a range of blocks) - "123:" (a range of blocks from 123 to +∞) - ":456" (a range of blocks from <firstStreamableBlock> to 456) - "-1:456" (a range of blocks from HEAD to +∞ (assuming HEAD is before 456))
func (BlockRange) BlockCount ¶
func (b BlockRange) BlockCount() int64
func (BlockRange) Contains ¶
func (b BlockRange) Contains(blockNum uint64, endBoundary RangeBoundary) bool
func (BlockRange) GetStartBlock ¶
func (b BlockRange) GetStartBlock() int64
func (BlockRange) GetStopBlockOr ¶
func (b BlockRange) GetStopBlockOr(defaultIfOpenRange uint64) uint64
func (BlockRange) IsClosed ¶
func (b BlockRange) IsClosed() bool
func (BlockRange) IsOpen ¶
func (b BlockRange) IsOpen() bool
func (BlockRange) IsResolved ¶
func (b BlockRange) IsResolved() bool
IsResolved returns true if the range is both closed and fully resolved (e.g. both start and stop are positive values). Returns false otherwise.
func (BlockRange) ReprocRange ¶
func (b BlockRange) ReprocRange() string
func (BlockRange) Split ¶
func (b BlockRange) Split(chunkSize uint64, endBoundary RangeBoundary) ([]BlockRange, error)
func (BlockRange) String ¶
func (b BlockRange) String() string
func (BlockRange) ToBstreamRange ¶
func (b BlockRange) ToBstreamRange(endBoundary RangeBoundary) *bstream.Range
type RangeBoundary ¶
type RangeBoundary int
ENUM(
Inclusive Exclusive
)
const ( EndBoundaryInclusive RangeBoundary = RangeBoundaryInclusive EndBoundaryExclusive = RangeBoundaryExclusive )
const ( // RangeBoundaryInclusive is a RangeBoundary of type Inclusive. RangeBoundaryInclusive RangeBoundary = iota // RangeBoundaryExclusive is a RangeBoundary of type Exclusive. RangeBoundaryExclusive )
func ParseRangeBoundary ¶
func ParseRangeBoundary(name string) (RangeBoundary, error)
ParseRangeBoundary attempts to convert a string to a RangeBoundary.
func (RangeBoundary) IsValid ¶ added in v1.6.0
func (x RangeBoundary) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (RangeBoundary) MarshalText ¶
func (x RangeBoundary) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (RangeBoundary) String ¶
func (x RangeBoundary) String() string
String implements the Stringer interface.
func (*RangeBoundary) UnmarshalText ¶
func (x *RangeBoundary) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.