-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements for scheduled miniblocks and getShards call (#25)
* Improvements for scheduled miniblocks and getShards call * code review fixes * shardIds as instance variable instead of static --------- Co-authored-by: tanghel <[email protected]>
- Loading branch information
1 parent
dae4ef4
commit 2ba4f53
Showing
20 changed files
with
380 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { METACHAIN } from "./utils/constants"; | ||
import { HttpService } from "./utils/http.service"; | ||
|
||
export class ShardsMaintainerService { | ||
private shardIds: number[] | undefined = undefined; | ||
|
||
async get( | ||
baseUrl: string | undefined, | ||
timeout: number | undefined, | ||
) { | ||
if (this.shardIds != null) { | ||
return this.shardIds; | ||
} | ||
|
||
return this.shardIds = await this.getShards(baseUrl, timeout); | ||
} | ||
|
||
private async getShards( | ||
baseUrl: string | undefined, | ||
timeout: number | undefined, | ||
): Promise<number[]> { | ||
const httpService = new HttpService(baseUrl, timeout); | ||
const networkConfig = await httpService.get('network/config'); | ||
const shardCount = networkConfig.config.erd_num_shards_without_meta; | ||
|
||
const result = []; | ||
for (let i = 0; i < shardCount; i++) { | ||
result.push(i); | ||
} | ||
result.push(METACHAIN); | ||
|
||
return result; | ||
} | ||
} |
Oops, something went wrong.