diff --git a/package-lock.json b/package-lock.json index e1c2ead..23102a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ton-http-api", - "version": "2.0.6", + "version": "2.0.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ton-http-api", - "version": "2.0.6", + "version": "2.0.7", "license": "MIT", "dependencies": { "@ton/core": "^0.55.0", diff --git a/package.json b/package.json index 9843a21..9c03e7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ton-http-api", - "version": "2.0.6", + "version": "2.0.7", "description": "The lightweight TON Typescript Library", "main": "dist/index.js", "keywords": [ diff --git a/src/TonSubscriberV2/TonRedisBlockStorageV2.ts b/src/TonSubscriberV2/TonRedisBlockStorageV2.ts index fcee191..77d48e9 100644 --- a/src/TonSubscriberV2/TonRedisBlockStorageV2.ts +++ b/src/TonSubscriberV2/TonRedisBlockStorageV2.ts @@ -20,11 +20,11 @@ export class TonRedisBlockStorageV2 implements TonBlockStorageV2 { continue; } - if (await this.#redis.hexists("ton:shardchain_blocks", `${workchain}_${shard}_${seqno}`)) { + if (await this.#redis.hexists("ton:shardchain:blocks", `${workchain}_${shard}_${seqno}`)) { continue; } - await this.#redis.hset("ton:shardchain_blocks", { + await this.#redis.hset("ton:shardchain:blocks", { [`${workchain}_${shard}_${seqno}`]: 0 }); } @@ -35,10 +35,10 @@ export class TonRedisBlockStorageV2 implements TonBlockStorageV2 { * @param seqno */ async insertMasterchainBlock(seqno: number) { - if (await this.#redis.hexists("ton:masterchain_blocks", `${seqno}`)) { + if (await this.#redis.hexists("ton:masterchain:blocks", `${seqno}`)) { throw Error(`masterchain block already exists! seqno: ${seqno}`); } - await this.#redis.hset("ton:masterchain_blocks", { + await this.#redis.hset("ton:masterchain:blocks", { [seqno]: 1 }); } @@ -47,7 +47,7 @@ export class TonRedisBlockStorageV2 implements TonBlockStorageV2 { * Get the last inserted masterchain block from the masterchain hashtable. */ async getLastMasterchainBlock() { - const masterchainBlocks = await this.#redis.hgetall("ton:masterchain_blocks"); + const masterchainBlocks = await this.#redis.hgetall("ton:masterchain:blocks"); const data = Object.keys(masterchainBlocks) .map(x => Number(x)) .sort((a, b) => b - a); @@ -58,8 +58,7 @@ export class TonRedisBlockStorageV2 implements TonBlockStorageV2 { * Get the last unprocessed shardchain block from the shardchains hashtable. */ async getUnprocessedShardchainBlock() { - const shardchainBlocks = await this.#redis.hgetall("ton:shardchain_blocks"); - // console.log(shardchainBlocks); + const shardchainBlocks = await this.#redis.hgetall("ton:shardchain:blocks"); for (const key in shardchainBlocks) { if (shardchainBlocks[key] !== undefined && !parseInt(shardchainBlocks[key])) { const data = key.split("_"); @@ -82,13 +81,13 @@ export class TonRedisBlockStorageV2 implements TonBlockStorageV2 { * @param prevShardBlocks */ async setShardchainBlockProcessed(workchain: number, shard: string, seqno: number, prevShardBlocks: BlockIdExt[]) { - if (!await this.#redis.hexists("ton:shardchain_blocks", `${workchain}_${shard}_${seqno}`)) { + if (!await this.#redis.hexists("ton:shardchain:blocks", `${workchain}_${shard}_${seqno}`)) { throw Error( `shardchain not found! workchain: ${workchain} / shard: ${shard} / seqno: ${seqno}` ); } - await this.#redis.hset("ton:shardchain_blocks", { + await this.#redis.hset("ton:shardchain:blocks", { [`${workchain}_${shard}_${seqno}`]: 1 }); await this.insertShardchainBlocks(prevShardBlocks); @@ -98,7 +97,7 @@ export class TonRedisBlockStorageV2 implements TonBlockStorageV2 { * Clean up the hashtables. */ async clean() { - await this.#redis.del("ton:masterchain_blocks"); - await this.#redis.del("ton:shardchain_blocks"); + await this.#redis.del("ton:masterchain:blocks"); + await this.#redis.del("ton:shardchain:blocks"); } } diff --git a/src/TonSubscriberV3/TonRedisBlockStorageV3.ts b/src/TonSubscriberV3/TonRedisBlockStorageV3.ts index 5c09174..046a78d 100644 --- a/src/TonSubscriberV3/TonRedisBlockStorageV3.ts +++ b/src/TonSubscriberV3/TonRedisBlockStorageV3.ts @@ -14,10 +14,10 @@ export class TonRedisBlockStorageV3 implements TonBlockStorageV3 { * @param seqno */ async insertMasterchainBlock(seqno: number) { - if (await this.#redis.hexists("ton:masterchain_blocks", `${seqno}`)) { + if (await this.#redis.hexists("ton:masterchain:blocks", `${seqno}`)) { throw Error(`masterchain block already exists! seqno: ${seqno}`); } - await this.#redis.hset("ton:masterchain_blocks", { + await this.#redis.hset("ton:masterchain:blocks", { [seqno]: 1 }); } @@ -26,7 +26,7 @@ export class TonRedisBlockStorageV3 implements TonBlockStorageV3 { * Get the last inserted masterchain block from the masterchain hashtable. */ async getLastMasterchainBlock() { - const masterchainBlocks = await this.#redis.hgetall("ton:masterchain_blocks"); + const masterchainBlocks = await this.#redis.hgetall("ton:masterchain:blocks"); const data = Object.keys(masterchainBlocks) .map(x => Number(x)) .sort((a, b) => b - a); @@ -37,6 +37,6 @@ export class TonRedisBlockStorageV3 implements TonBlockStorageV3 { * Clean up the hashtable. */ async clean() { - await this.#redis.del("ton:masterchain_blocks"); + await this.#redis.del("ton:masterchain:blocks"); } }