Skip to content

Commit

Permalink
Revert to the original index applied in the tables
Browse files Browse the repository at this point in the history
  • Loading branch information
jairajdev committed Aug 6, 2024
1 parent 6798be2 commit 9896f3c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
24 changes: 12 additions & 12 deletions src/Data/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ async function syncFromNetworkConfig(): Promise<any> {
try {
// Define the query function to get the network config from a node
const queryFn = async (node): Promise<object> => {
const REQUEST_NETCONFIG_TIMEOUT_SECOND = 2 // 2s timeout
const REQUEST_NETCONFIG_TIMEOUT_SECOND = 3 // 3s timeout
try {
const response = await P2P.getJson(
`http://${node.ip}:${node.port}/netconfig`,
Expand Down Expand Up @@ -566,17 +566,17 @@ async function syncFromNetworkConfig(): Promise<any> {
configChangeMaxCyclesToKeep,
maxCyclesShardDataToKeep,
} = tallyItem.value.config.stateManager
const devPublicKeys = tallyItem.value.config.debug.devPublicKeys
const devPublicKey =
devPublicKeys &&
Object.keys(devPublicKeys).length >= 3 &&
Object.keys(devPublicKeys).find((key) => devPublicKeys[key] === 3)
if (
devPublicKey &&
typeof devPublicKey === typeof config.DevPublicKey &&
devPublicKey !== config.DevPublicKey
)
updateConfig({ DevPublicKey: devPublicKey })
// const devPublicKeys = tallyItem.value.config.debug.devPublicKeys
// const devPublicKey =
// devPublicKeys &&
// Object.keys(devPublicKeys).length >= 3 &&
// Object.keys(devPublicKeys).find((key) => devPublicKeys[key] === 3)
// if (
// devPublicKey &&
// typeof devPublicKey === typeof config.DevPublicKey &&
// devPublicKey !== config.DevPublicKey
// )
// updateConfig({ DevPublicKey: devPublicKey })
if (
!Utils.isUndefined(newPOQReceipt) &&
typeof newPOQReceipt === typeof config.newPOQReceipt &&
Expand Down
19 changes: 7 additions & 12 deletions src/dbstore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ export const initializeDB = async (config: Config): Promise<void> => {
'CREATE TABLE if not exists `transactions` (`txId` TEXT NOT NULL UNIQUE PRIMARY KEY, `appReceiptId` TEXT, `timestamp` BIGINT NOT NULL, `cycleNumber` NUMBER NOT NULL, `data` JSON NOT NULL, `originalTxData` JSON NOT NULL)'
)
await db.runCreate(
'CREATE INDEX if not exists `transactions_cycleNumber` ON `transactions` (`cycleNumber` ASC)'
)
await db.runCreate(
'CREATE INDEX if not exists `transactions_timestamp` ON `transactions` (`timestamp` ASC)'
'CREATE INDEX if not exists `transactions_idx` ON `transactions` (`cycleNumber` DESC, `timestamp` DESC)'
)
await db.runCreate(
'CREATE INDEX if not exists `transactions_appReceiptId_idx` ON `transactions` (`appReceiptId`)'
Expand All @@ -22,22 +19,20 @@ export const initializeDB = async (config: Config): Promise<void> => {
await db.runCreate(
'CREATE TABLE if not exists `accounts` (`accountId` TEXT NOT NULL UNIQUE PRIMARY KEY, `data` JSON NOT NULL, `timestamp` BIGINT NOT NULL, `hash` TEXT NOT NULL, `cycleNumber` NUMBER NOT NULL, `isGlobal` BOOLEAN NOT NULL)'
)
await db.runCreate('CREATE INDEX if not exists `accounts_cycleNumber` ON `accounts` (`cycleNumber` ASC)')
await db.runCreate('CREATE INDEX if not exists `accounts_timestamp` ON `accounts` (`timestamp` ASC)')
await db.runCreate(
'CREATE INDEX if not exists `accounts_idx` ON `accounts` (`cycleNumber` DESC, `timestamp` DESC)'
)
await db.runCreate(
'CREATE TABLE if not exists `receipts` (`receiptId` TEXT NOT NULL UNIQUE PRIMARY KEY, `tx` JSON NOT NULL, `cycle` NUMBER NOT NULL, `timestamp` BIGINT NOT NULL, `beforeStateAccounts` JSON, `accounts` JSON NOT NULL, `appliedReceipt` JSON NOT NULL, `appReceiptData` JSON, `executionShardKey` TEXT NOT NULL, `globalModification` BOOLEAN NOT NULL)'
)
await db.runCreate('CREATE INDEX if not exists `receipts_cycle` ON `receipts` (`cycle` ASC)')
await db.runCreate('CREATE INDEX if not exists `receipts_timestamp` ON `receipts` (`timestamp` ASC)')

await db.runCreate('CREATE INDEX if not exists `receipts_idx` ON `receipts` (`cycle` ASC, `timestamp` ASC)')
await db.runCreate(
'CREATE TABLE if not exists `originalTxsData` (`txId` TEXT NOT NULL, `timestamp` BIGINT NOT NULL, `cycle` NUMBER NOT NULL, `originalTxData` JSON NOT NULL, PRIMARY KEY (`txId`, `timestamp`))'
)
await db.runCreate('CREATE INDEX if not exists `originalTxsData_cycle` ON `originalTxsData` (`cycle` ASC)')
await db.runCreate(
'CREATE INDEX if not exists `originalTxsData_timestamp` ON `originalTxsData` (`timestamp` ASC)'
'CREATE INDEX if not exists `originalTxsData_idx` ON `originalTxsData` (`cycle` ASC, `timestamp` ASC)'
)
await db.runCreate('CREATE INDEX if not exists `originalTxsData_txId` ON `originalTxsData` (`txId`)')
await db.runCreate('CREATE INDEX if not exists `originalTxsData_txId_idx` ON `originalTxsData` (`txId`)')
}

export const closeDatabase = async (): Promise<void> => {
Expand Down

0 comments on commit 9896f3c

Please sign in to comment.