-
Notifications
You must be signed in to change notification settings - Fork 54
/
types.ts
49 lines (44 loc) · 1.77 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Cardano } from '@cardano-sdk/core';
import { DataSource } from 'typeorm';
import { Logger } from 'ts-log';
import { PgBossWorkerArgs } from '../Program/services/pgboss';
import { Pool } from 'pg';
import { PoolRegistrationEntity, PoolRewardsEntity, availableQueues } from '@cardano-sdk/projection-typeorm';
export type PgBossQueue = typeof availableQueues[number];
export type WorkerHandlerFactoryOptions = {
dataSource: DataSource;
db: Pool;
logger: Logger;
} & PgBossWorkerArgs;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type WorkerHandler = (data: any) => Promise<void>;
export type WorkerHandlerFactory = (options: WorkerHandlerFactoryOptions) => WorkerHandler;
/**
* The context in which the _stake pool rewards computation process_ runs, for a given stake pool, in a given epoch.
*
* It extends `PoolRewardsEntity`, other properties are input parameters or intermediate input parameter
* for the _computation process_.
*
* Each function taking part to the _computation process_ adds its result to the context so it can be
* used as input data for next functions or can compete to the composition of the final
* `PoolRewardsEntity` which will be saved to the DB.
*/
export type RewardsComputeContext = {
dataSource: DataSource;
db: Pool;
delegatorsIds?: string[];
idx: number;
lastSlot: Cardano.Slot;
lastRosEpochs: number;
logger: Logger;
membersIds?: string[];
ownersIds?: string[];
poolHashId?: string;
registration?: PoolRegistrationEntity;
totalStakePools: number;
} & PoolRewardsEntity &
Required<Pick<PoolRewardsEntity, 'epochNo' | 'stakePool'>>;
/** The input parameters to `computeROS`. */
export type RosComputeParams = Pick<RewardsComputeContext, 'dataSource' | 'logger' | 'stakePool'> & {
epochs?: number;
};