rwadurian/backend/services/contribution-service/src/domain/events/network-progress-updated.ev...

32 lines
1.1 KiB
TypeScript

/**
* 全网认种进度更新事件
* 用于同步全网算力系数到 mining-admin-service
*/
export class NetworkProgressUpdatedEvent {
static readonly EVENT_TYPE = 'NetworkProgressUpdated';
static readonly AGGREGATE_TYPE = 'NetworkProgress';
constructor(
public readonly totalTreeCount: number,
public readonly totalAdoptionOrders: number,
public readonly totalAdoptedUsers: number,
public readonly currentUnit: number,
public readonly currentMultiplier: string,
public readonly currentContributionPerTree: string,
public readonly nextUnitTreeCount: number,
) {}
toPayload(): Record<string, any> {
return {
eventType: NetworkProgressUpdatedEvent.EVENT_TYPE,
totalTreeCount: this.totalTreeCount,
totalAdoptionOrders: this.totalAdoptionOrders,
totalAdoptedUsers: this.totalAdoptedUsers,
currentUnit: this.currentUnit,
currentMultiplier: this.currentMultiplier,
currentContributionPerTree: this.currentContributionPerTree,
nextUnitTreeCount: this.nextUnitTreeCount,
};
}
}