Documentation
¶
Index ¶
- Variables
- type AdvisoryLock
- type Database
- func (d *Database) Close(ctx context.Context) error
- func (d *Database) Connect(ctx context.Context) error
- func (d *Database) FindActors(ctx context.Context, batchSize int, minHeight, maxHeight int64, codes []string) (visor.ProcessingActorList, error)
- func (d *Database) FindGasOutputsMessages(ctx context.Context, batchSize int, minHeight, maxHeight int64) ([]*derived.ProcessingGasOutputs, error)
- func (d *Database) GetActorByHead(ctx context.Context, head string) (*visor.ProcessingActor, error)
- func (d *Database) GetSchemaVersions(ctx context.Context) (int, int, error)
- func (d *Database) LeaseActors(ctx context.Context, claimUntil time.Time, batchSize int, ...) (visor.ProcessingActorList, error)
- func (d *Database) LeaseGasOutputsMessages(ctx context.Context, claimUntil time.Time, batchSize int, ...) ([]*derived.ProcessingGasOutputs, error)
- func (d *Database) LeaseStateChanges(ctx context.Context, claimUntil time.Time, batchSize int, ...) (visor.ProcessingTipSetList, error)
- func (d *Database) LeaseTipSetEconomics(ctx context.Context, claimUntil time.Time, batchSize int, ...) (visor.ProcessingTipSetList, error)
- func (d *Database) LeaseTipSetMessages(ctx context.Context, claimUntil time.Time, batchSize int, ...) (visor.ProcessingTipSetList, error)
- func (d *Database) MarkActorComplete(ctx context.Context, height int64, head string, code string, ...) error
- func (d *Database) MarkGasOutputsMessagesComplete(ctx context.Context, height int64, cid string, completedAt time.Time, ...) error
- func (d *Database) MarkStateChangeComplete(ctx context.Context, tsk string, height int64, completedAt time.Time, ...) error
- func (d *Database) MarkTipSetEconomicsComplete(ctx context.Context, tipset string, height int64, completedAt time.Time, ...) error
- func (d *Database) MarkTipSetMessagesComplete(ctx context.Context, tipset string, height int64, completedAt time.Time, ...) error
- func (d *Database) MigrateSchema(ctx context.Context) error
- func (d *Database) MigrateSchemaTo(ctx context.Context, target int) error
- func (d *Database) MostRecentAddedTipSet(ctx context.Context) (*visor.ProcessingTipSet, error)
- func (d *Database) Persist(ctx context.Context, p model.PersistableWithTx) error
- func (d *Database) UnprocessedIndexedTipSets(ctx context.Context, maxHeight, limit int) (visor.ProcessingTipSetList, error)
- func (d *Database) VerifyCurrentSchema(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrSchemaTooOld = errors.New("database schema is too old and requires migration") ErrSchemaTooNew = errors.New("database schema is too new for this version of visor") )
var ErrLockNotAcquired = errors.New("lock not acquired")
var ErrLockNotReleased = errors.New("lock not released")
Functions ¶
This section is empty.
Types ¶
type AdvisoryLock ¶
type AdvisoryLock int64
An AdvisoryLock is a lock that is managed by Postgres but is only enforced by the application. Advisory locks are automatically released at the end of a session. It is safe to hold both a shared and exclusive lock within a single session.
var (
SchemaLock AdvisoryLock = 1
)
Advisory locks
func (AdvisoryLock) LockExclusive ¶
func (l AdvisoryLock) LockExclusive(ctx context.Context, db *pg.DB) error
LockShared tries to acquire a session scoped exclusive advisory lock.
func (AdvisoryLock) LockShared ¶
func (l AdvisoryLock) LockShared(ctx context.Context, db *pg.DB) error
LockShared tries to acquire a session scoped shared advisory lock.
func (AdvisoryLock) UnlockExclusive ¶
func (l AdvisoryLock) UnlockExclusive(ctx context.Context, db *pg.DB) error
UnlockExclusive releases an exclusive advisory lock.
func (AdvisoryLock) UnlockShared ¶
func (l AdvisoryLock) UnlockShared(ctx context.Context, db *pg.DB) error
UnlockShared releases a shared advisory lock.
type Database ¶
func NewDatabase ¶
func (*Database) Connect ¶
Connect opens a connection to the database and checks that the schema is compatible the the version required by this version of visor. ErrSchemaTooOld is returned if the database schema is older than the current schema, ErrSchemaTooNew if it is newer.
func (*Database) FindActors ¶ added in v0.3.0
func (d *Database) FindActors(ctx context.Context, batchSize int, minHeight, maxHeight int64, codes []string) (visor.ProcessingActorList, error)
FindActors finds a set of actors to process but does not take a lease out. minHeight and maxHeight define an inclusive range of heights to process.
func (*Database) FindGasOutputsMessages ¶ added in v0.3.0
func (d *Database) FindGasOutputsMessages(ctx context.Context, batchSize int, minHeight, maxHeight int64) ([]*derived.ProcessingGasOutputs, error)
FindGasOutputsMessages finds a set of messages that have receipts for gas output processing but does not take a lease out. minHeight and maxHeight define an inclusive range of heights to process.
func (*Database) GetActorByHead ¶
GetActorByHead returns an actor without a lease by its CID
func (*Database) GetSchemaVersions ¶
GetSchemaVersions returns the schema version in the database and the latest schema version defined by the available migrations.
func (*Database) LeaseActors ¶
func (d *Database) LeaseActors(ctx context.Context, claimUntil time.Time, batchSize int, minHeight, maxHeight int64, codes []string) (visor.ProcessingActorList, error)
LeaseActors leases a set of actors to process. minHeight and maxHeight define an inclusive range of heights to process.
func (*Database) LeaseGasOutputsMessages ¶
func (d *Database) LeaseGasOutputsMessages(ctx context.Context, claimUntil time.Time, batchSize int, minHeight, maxHeight int64) ([]*derived.ProcessingGasOutputs, error)
LeaseGasOutputsMessages leases a set of messages that have receipts for gas output processing. minHeight and maxHeight define an inclusive range of heights to process.
func (*Database) LeaseStateChanges ¶
func (*Database) LeaseTipSetEconomics ¶ added in v0.3.0
func (d *Database) LeaseTipSetEconomics(ctx context.Context, claimUntil time.Time, batchSize int, minHeight, maxHeight int64) (visor.ProcessingTipSetList, error)
LeaseTipSetEconomics leases a set of tipsets containing chain economics to process. minHeight and maxHeight define an inclusive range of heights to process. TODO: refactor all the tipset leasing methods into a more general function
func (*Database) LeaseTipSetMessages ¶
func (d *Database) LeaseTipSetMessages(ctx context.Context, claimUntil time.Time, batchSize int, minHeight, maxHeight int64) (visor.ProcessingTipSetList, error)
LeaseTipSetMessages leases a set of tipsets containing messages to process. minHeight and maxHeight define an inclusive range of heights to process.
func (*Database) MarkActorComplete ¶
func (*Database) MarkGasOutputsMessagesComplete ¶
func (*Database) MarkStateChangeComplete ¶
func (*Database) MarkTipSetEconomicsComplete ¶ added in v0.3.0
func (*Database) MarkTipSetMessagesComplete ¶
func (*Database) MigrateSchema ¶
MigrateSchema migrates the database schema to the latest version based on the list of migrations available
func (*Database) MigrateSchemaTo ¶
MigrateSchema migrates the database schema to a specific version. Note that downgrading a schema to an earlier version is destructive and may result in the loss of data.