Documentation ¶
Overview ¶
Package filters specifies utilities for building a set of data attribute filters to be used when filtering data through database queries in practice. For example, one can specify a filter query for data by start epoch + end epoch + shard for attestations, build a filter as follows, and respond to it accordingly:
f := filters.NewFilter().SetStartEpoch(3).SetEndEpoch(5) for k, v := range f.Filters() { switch k { case filters.StartEpoch: // Verify data matches filter criteria... case filters.EndEpoch: // Verify data matches filter criteria... } }
Index ¶
- type FilterType
- type QueryFilter
- func (q *QueryFilter) Filters() map[FilterType]interface{}
- func (q *QueryFilter) SetEndEpoch(val types.Epoch) *QueryFilter
- func (q *QueryFilter) SetEndSlot(val types.Slot) *QueryFilter
- func (q *QueryFilter) SetHeadBlockRoot(val []byte) *QueryFilter
- func (q *QueryFilter) SetParentRoot(val []byte) *QueryFilter
- func (q *QueryFilter) SetSlotStep(val uint64) *QueryFilter
- func (q *QueryFilter) SetSourceEpoch(val types.Epoch) *QueryFilter
- func (q *QueryFilter) SetSourceRoot(val []byte) *QueryFilter
- func (q *QueryFilter) SetStartEpoch(val types.Epoch) *QueryFilter
- func (q *QueryFilter) SetStartSlot(val types.Slot) *QueryFilter
- func (q *QueryFilter) SetTargetEpoch(val types.Epoch) *QueryFilter
- func (q *QueryFilter) SetTargetRoot(val []byte) *QueryFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterType ¶
type FilterType uint8
FilterType defines an enum which is used as the keys in a map that tracks set attribute filters for data as part of the `FilterQuery` struct type.
const ( // ParentRoot defines a filter for parent roots of blocks using Simple Serialize (SSZ). ParentRoot FilterType = iota // StartSlot is used for range filters of objects by their slot (inclusive). StartSlot // EndSlot is used for range filters of objects by their slot (inclusive). EndSlot // StartEpoch is used for range filters of objects by their epoch (inclusive). StartEpoch // EndEpoch is used for range filters of objects by their epoch (inclusive). EndEpoch // HeadBlockRoot defines a filter for the head block root attribute of objects. HeadBlockRoot // SourceEpoch defines a filter for the source epoch attribute of objects. SourceEpoch // SourceRoot defines a filter for the source root attribute of objects. SourceRoot // TargetEpoch defines a filter for the target epoch attribute of objects. TargetEpoch // TargetRoot defines a filter for the target root attribute of objects. TargetRoot // SlotStep is used for range filters of objects by their slot in step increments. SlotStep )
type QueryFilter ¶
type QueryFilter struct {
// contains filtered or unexported fields
}
QueryFilter defines a generic interface for type-asserting specific filters to use in querying DB objects.
func NewFilter ¶
func NewFilter() *QueryFilter
NewFilter instantiates a new QueryFilter type used to build filters for certain Ethereum data types by attribute.
func (*QueryFilter) Filters ¶
func (q *QueryFilter) Filters() map[FilterType]interface{}
Filters returns and underlying map of FilterType to interface{}, giving us a copy of the currently set filters which can then be iterated over and type asserted for use anywhere.
func (*QueryFilter) SetEndEpoch ¶
func (q *QueryFilter) SetEndEpoch(val types.Epoch) *QueryFilter
SetEndEpoch enables filtering by the EndEpoch attribute of an object (inclusive).
func (*QueryFilter) SetEndSlot ¶
func (q *QueryFilter) SetEndSlot(val types.Slot) *QueryFilter
SetEndSlot enables filtering by all the items that end at a slot (inclusive).
func (*QueryFilter) SetHeadBlockRoot ¶
func (q *QueryFilter) SetHeadBlockRoot(val []byte) *QueryFilter
SetHeadBlockRoot allows for filtering by the beacon block root data attribute of an object.
func (*QueryFilter) SetParentRoot ¶
func (q *QueryFilter) SetParentRoot(val []byte) *QueryFilter
SetParentRoot allows for filtering by the parent root data attribute of an object.
func (*QueryFilter) SetSlotStep ¶ added in v0.3.2
func (q *QueryFilter) SetSlotStep(val uint64) *QueryFilter
SetSlotStep enables filtering by slot for every step interval. For example, a slot range query for blocks from 0 to 9 with a step of 2 would return objects at slot 0, 2, 4, 6, 8.
func (*QueryFilter) SetSourceEpoch ¶
func (q *QueryFilter) SetSourceEpoch(val types.Epoch) *QueryFilter
SetSourceEpoch enables filtering by the source epoch data attribute of an object.
func (*QueryFilter) SetSourceRoot ¶
func (q *QueryFilter) SetSourceRoot(val []byte) *QueryFilter
SetSourceRoot allows for filtering by the source root data attribute of an object.
func (*QueryFilter) SetStartEpoch ¶
func (q *QueryFilter) SetStartEpoch(val types.Epoch) *QueryFilter
SetStartEpoch enables filtering by the StartEpoch attribute of an object (inclusive).
func (*QueryFilter) SetStartSlot ¶
func (q *QueryFilter) SetStartSlot(val types.Slot) *QueryFilter
SetStartSlot enables filtering by all the items that begin at a slot (inclusive).
func (*QueryFilter) SetTargetEpoch ¶
func (q *QueryFilter) SetTargetEpoch(val types.Epoch) *QueryFilter
SetTargetEpoch enables filtering by the target epoch data attribute of an object.
func (*QueryFilter) SetTargetRoot ¶
func (q *QueryFilter) SetTargetRoot(val []byte) *QueryFilter
SetTargetRoot allows for filtering by the target root data attribute of an object.