Skip to content

Commit

Permalink
Merge pull request #69 from push-protocol/init-did-support
Browse files Browse the repository at this point in the history
Init did support
  • Loading branch information
akp111 authored Oct 21, 2024
2 parents f832438 + 6b09e3b commit 2a02518
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 92 deletions.
1 change: 0 additions & 1 deletion src/helpers/dbHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { PgUtil } from '../utilz/pgUtil'
import StrUtil from '../utilz/strUtil'
import { arrayToMap } from '../utilz/typeConversionUtil'
import { WinstonUtil } from '../utilz/winstonUtil'
import { BlockUtil } from '../services/messaging-common/BlockUtil'

// postgres
// todo fix variable substitution, see #putValueInTable()
Expand Down
14 changes: 8 additions & 6 deletions src/rpc/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
// import the cpntrolers from the controllers folder

// TODO convert this to a single rpc object???

import { GetAccountInfo } from './get_accountInfo'
import { PushPutBlock } from './push_putBlock'
import { PushPutBlockHash } from './push_putBlockHash'
import { StorageGetTransaction } from './storage_getTransaction'
import { StorageGetTransactions } from './storage_getTransactions'
import { PushPutBlockHash } from './push_putBlockHash'
import { PushPutBlock } from './push_putBlock'
// put the controllers here
const controllers = {
storage_getTransactions: StorageGetTransactions.storageGetTransactions,
push_getTransactions: StorageGetTransactions.storageGetTransactions,
storage_getTransaction: StorageGetTransaction.storageGetTransaction,
get_accountInfo: GetAccountInfo.getAccountInfo,
push_accountInfo: GetAccountInfo.getAccountInfo,
push_putBlockHash: PushPutBlockHash.pushPutBlockHash,
push_putBlock: PushPutBlock.pushPutBlock
}

// put the after test controllers here, keep in mind to keep the function name same as controller
const afterController = {
storage_getTransactions: StorageGetTransactions.afterStorageGetTransactions,
push_getTransactions: StorageGetTransactions.afterStorageGetTransactions,
storage_getTransaction: StorageGetTransaction.afterStorageGetTransaction,
get_accountInfo: GetAccountInfo.afterGetAccountInfo,
push_accountInfo: GetAccountInfo.afterGetAccountInfo,
push_putBlockHash: PushPutBlockHash.afterPushPutBlockHash,
push_putBlock: PushPutBlock.afterPushPutBlock
}
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/push_putBlock.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Container from 'typedi'
import { z } from 'zod'

import LoggerInstance from '../loaders/logger'
import StorageNode from '../services/messaging/storageNode'
import Container from 'typedi'

const BlockItem = z.object({
id: z.number().optional(),
Expand Down
17 changes: 8 additions & 9 deletions src/services/block/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ export class Block {
}

static async getBulkBlocksByHash(blockHashes: string[]) {
const query = `SELECT object_hash FROM blocks WHERE object_hash = ANY($1::text[])`;
const query = `SELECT object_hash FROM blocks WHERE object_hash = ANY($1::text[])`
const result = await PgUtil.queryArr<{ id: number; object: string; object_hash: string }>(
query,
[blockHashes]
);
console.log('result:', result);
const foundHashes = result.map((row) => row.object_hash);
[blockHashes]
)
console.log('result:', result)
const foundHashes = result.map((row) => row.object_hash)

const statusArray = blockHashes.map((hash) =>
foundHashes.includes(hash) ? 'SEND' : 'NOT_SEND'
);
return { result: statusArray };
}

)
return { result: statusArray }
}
}
Loading

0 comments on commit 2a02518

Please sign in to comment.