prysm-pulse/slasher/detection/attestations/iface/iface.go
Ivan Martinez e7b94123ce
Add interface for spanner and MockSpanner (#4956)
* Add interface for spanner

* Add MockSpanner for future testing

* Add comment

* gazelle
2020-02-26 22:48:02 -06:00

25 lines
799 B
Go

package iface
import (
"context"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/slasher/detection/attestations/types"
)
// SpanDetector defines an interface for Spanners to follow to allow mocks.
type SpanDetector interface {
// Read functions.
DetectSlashingForValidator(
ctx context.Context,
validatorIdx uint64,
attData *ethpb.AttestationData,
) (*types.DetectionResult, error)
SpanForEpochByValidator(ctx context.Context, valIdx uint64, epoch uint64) ([2]uint16, error)
ValidatorSpansByEpoch(ctx context.Context, epoch uint64) map[uint64][2]uint16
// Write functions.
UpdateSpans(ctx context.Context, att *ethpb.IndexedAttestation) error
DeleteValidatorSpansByEpoch(ctx context.Context, validatorIdx uint64, epoch uint64) error
}