prv21

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoBlockNumber int64 = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Rater

type Rater interface {
	AddRevision(ctx context.Context, ds model.DataSet, effectiveBlockNumber int64) (bool, error)
	AddRevocation(ctx context.Context, rid string) error
	Head(ctx context.Context) string
	HeadAt(ctx context.Context, blockID int64) string
}

Rater is an interface to PRV21 rating algorithm. It can be used by a custom index to algorithmically identify the "current" revision of the given variant, as well as its current revision at a given block height.

func NewRater

func NewRater(variantID string, store RevisionStore) Rater

type RaterImpl

type RaterImpl struct {
	// contains filtered or unexported fields
}

func (*RaterImpl) AddRevision

func (r *RaterImpl) AddRevision(ctx context.Context, ds model.DataSet, effectiveBlockNumber int64) (bool, error)

func (*RaterImpl) AddRevocation

func (r *RaterImpl) AddRevocation(ctx context.Context, rid string) error

func (*RaterImpl) Head

func (r *RaterImpl) Head(ctx context.Context) string

func (*RaterImpl) HeadAt

func (r *RaterImpl) HeadAt(ctx context.Context, blockID int64) string

type Revision

type Revision interface {
	RecordID() string
	Status() model.RecordStatus
	Block() int64
	EffectiveBlock() int64
	Locker() string
	Participant() string
	AssetID() string
	VariantID() string
	ImpressionID() string
	RevisionNumber() int64
	CreatedAt() time.Time
	HeadFrom() int64
	HeadTo() int64
}

type RevisionStore

type RevisionStore interface {
	Head(ctx context.Context, variantID string) (Revision, error)
	HeadAt(ctx context.Context, variantID string, blockNumber int64) (Revision, error)
	Revision(ctx context.Context, rid string) (Revision, error)
	CreateRevision(ctx context.Context, ds model.DataSet, effectiveBlockNumber int64,
		headFrom, headTo int64) error
	UpdateRevision(ctx context.Context, rid string, status model.RecordStatus,
		headFrom, headTo int64) error
	RevokeRevision(ctx context.Context, rid string) error
	SaveRevokedRevision(ctx context.Context, ds model.DataSet, effectiveBlockNumber int64) error
	DataSet(ctx context.Context, rid string) (model.DataSet, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL