Skip to content

Commit 2800478

Browse files
committed
feat: first iteration at coretime impl
1 parent 82b9b38 commit 2800478

File tree

12 files changed

+525
-412
lines changed

12 files changed

+525
-412
lines changed

src/chains-config/kusamaControllers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const kusamaControllers: ControllerConfig = {
5454
'TransactionMaterial',
5555
'TransactionSubmit',
5656
'CoretimeGeneric',
57-
'CoretimeRelay',
5857
],
5958
options: {
6059
finalizes: true,

src/chains-config/polkadotControllers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const polkadotControllers: ControllerConfig = {
5454
'TransactionMaterial',
5555
'TransactionSubmit',
5656
'CoretimeGeneric',
57-
'CoretimeRelay',
5857
],
5958
options: {
6059
finalizes: true,

src/chains-config/westendControllers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export const westendControllers: ControllerConfig = {
5353
'TransactionMaterial',
5454
'TransactionSubmit',
5555
'CoretimeGeneric',
56-
'CoretimeRelay',
5756
],
5857
options: {
5958
finalizes: true,

src/controllers/coretime/CoretimeChainController.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,22 @@ export default class CoretimeChainController extends AbstractController<Coretime
2828
// TODO: check if its either coretime or relay chain, if neither error out
2929
protected initRoutes(): void {
3030
this.safeMountAsyncGetHandlers([
31-
['/sale', this.getCoretimeSaleInfo],
32-
['/bulk', this.getBulk],
33-
['/leases', this.getLeases],
31+
['/leases', this.getLeases], // :taskId
3432
['/regions', this.getRegions],
35-
['/cores', this.getWorkload],
33+
['/renewals', this.getRenewals],
34+
['/reservations', this.getReservations],
3635
]);
3736
}
38-
/*
39-
relay => => use coretimeAssignmentProvider || onDemandAssignmentProvider
40-
coretime => bulk time info => use broker
41-
42-
from relay chains:
43-
-
44-
*/
4537

4638
private checkCoretimeModule = (): void => {
4739
if (this.api.query.onDemandAssignmentProvider && this.api.query.coretimeAssignmentProvider) {
4840
return;
4941
} else if (this.api.query.broker) {
5042
return;
5143
}
52-
console.log(this.api.consts);
5344
throw new Error('One or more coretime modules are not available on this network.');
5445
};
5546

56-
// get overview on coretime
57-
private getBulk: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
58-
this.checkCoretimeModule();
59-
60-
const hash = await this.getHashFromAt(at);
61-
62-
CoretimeChainController.sanitizedSend(res, await this.service.getBulkInfo(hash));
63-
};
64-
6547
private getLeases: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
6648
this.checkCoretimeModule();
6749

@@ -70,27 +52,27 @@ export default class CoretimeChainController extends AbstractController<Coretime
7052
CoretimeChainController.sanitizedSend(res, await this.service.getCoretimeLeases(hash));
7153
};
7254

73-
private getCoretimeSaleInfo: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
55+
private getRegions: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
7456
this.checkCoretimeModule();
7557

7658
const hash = await this.getHashFromAt(at);
7759

78-
CoretimeChainController.sanitizedSend(res, await this.service.getCoretimeSaleInfo(hash));
60+
CoretimeChainController.sanitizedSend(res, await this.service.getCoretimeRegions(hash));
7961
};
8062

81-
private getRegions: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
63+
private getReservations: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
8264
this.checkCoretimeModule();
8365

8466
const hash = await this.getHashFromAt(at);
8567

86-
CoretimeChainController.sanitizedSend(res, await this.service.getCoretimeRegions(hash));
68+
CoretimeChainController.sanitizedSend(res, await this.service.getCoretimeReservations(hash));
8769
};
8870

89-
private getWorkload: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
71+
private getRenewals: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
9072
this.checkCoretimeModule();
9173

9274
const hash = await this.getHashFromAt(at);
9375

94-
CoretimeChainController.sanitizedSend(res, await this.service.getCoretimeCores(hash));
76+
CoretimeChainController.sanitizedSend(res, await this.service.getCoretimeRenewals(hash));
9577
};
9678
}

src/controllers/coretime/CoretimeGenericController.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,11 @@ export default class CoretimeGenericController extends AbstractController<Coreti
2828
// TODO: check if its either coretime or relay chain, if neither error out
2929
protected initRoutes(): void {
3030
this.safeMountAsyncGetHandlers([
31-
// sale info
32-
// configuration
33-
// status
3431
['/info', this.getCoretimeOverview],
35-
// bulk leases
36-
// leases and regions?
37-
// ['/workload', this.getParachains],
38-
// ondemand status
39-
// ['/workplan', this.getParachains],
32+
['/cores', this.getCoretimeCores],
4033
]);
4134
}
42-
/*
43-
relay => => use coretimeAssignmentProvider || onDemandAssignmentProvider
44-
coretime => bulk time info => use broker
4535

46-
from relay chains:
47-
-
48-
*/
49-
50-
// get overview on coretime
5136
private getCoretimeOverview: RequestHandler = async ({ query: { at } }, res): Promise<void> => {
5237
this.checkCoretimeModule();
5338

@@ -56,13 +41,22 @@ export default class CoretimeGenericController extends AbstractController<Coreti
5641
CoretimeGenericController.sanitizedSend(res, await this.service.getCoretimeInfo(hash));
5742
};
5843

44+
private getCoretimeCores: RequestHandler = async ({ query: { at, core } }, res): Promise<void> => {
45+
this.checkCoretimeModule();
46+
47+
const hash = await this.getHashFromAt(at);
48+
49+
const coreId = core ? (core as unknown as string) : undefined;
50+
51+
CoretimeGenericController.sanitizedSend(res, await this.service.getCoretimeCores(hash, coreId));
52+
};
53+
5954
private checkCoretimeModule = (): void => {
6055
if (this.api.query.onDemandAssignmentProvider && this.api.query.coretimeAssignmentProvider) {
6156
return;
6257
} else if (this.api.query.broker) {
6358
return;
6459
}
65-
console.log(this.api.consts);
6660
throw new Error('One or more coretime modules are not available on this network.');
6761
};
6862
}

src/controllers/coretime/CoretimeRelayController.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/controllers/coretime/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@
1616

1717
export { default as CoretimeChain } from './CoretimeChainController';
1818
export { default as CoretimeGeneric } from './CoretimeGenericController';
19-
export { default as CoretimeRelay } from './CoretimeRelayController';

src/controllers/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
} from './accounts';
2828
import { Blocks, BlocksExtrinsics, BlocksRawExtrinsics, BlocksTrace } from './blocks';
2929
import { ContractsInk } from './contracts';
30-
import { CoretimeChain, CoretimeGeneric, CoretimeRelay } from './coretime';
30+
import { CoretimeChain, CoretimeGeneric } from './coretime';
3131
import { NodeNetwork, NodeTransactionPool, NodeVersion } from './node';
3232
import {
3333
PalletsAssetConversion,
@@ -92,5 +92,4 @@ export const controllers = {
9292
Paras,
9393
CoretimeGeneric,
9494
CoretimeChain,
95-
CoretimeRelay,
9695
};

0 commit comments

Comments
 (0)