Skip to content

Commit

Permalink
Problem fixed, adjust logs output
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhaixian1984 committed Nov 7, 2024
1 parent e6935c1 commit c4d9e23
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/chain/parachain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ParachainApi {
const account = eJson.account;
const cid = Buffer.from(eJson.cid.substr(2), 'hex').toString();
const size = eJson.size;
const isPermanent = eJson.isPermanent;
const isPermanent = eJson.isPermanent ? true : false;
await dbOps.addRecord(
account,
account,
Expand All @@ -84,7 +84,6 @@ export class ParachainApi {
tx.hash.toHex(),
getTimestamp(),
);
logger.info(`Get one file record from xstorage-para at '${bn}': ${cid}`);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/chain/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ShadowApi {
const account = eJson.account;
const cid = Buffer.from(eJson.cid.substr(2), 'hex').toString();
const size = eJson.size;
const isPermanent = eJson.isPermanent;
const isPermanent = eJson.isPermanent ? true : false;
await dbOps.addRecord(
account,
account,
Expand All @@ -84,7 +84,6 @@ export class ShadowApi {
tx.hash.toHex(),
getTimestamp(),
);
logger.info(`Get one file record from xstorage at '${bn}': ${cid}`);
}
}
}
Expand Down
25 changes: 12 additions & 13 deletions src/db/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ export function createRecordOperator(db: Database): DbOperator {
timestamp: number,
): Promise<void> => {
try {
logger.info(`Add ${chainType} task successfully.`);
logger.info(` customer:${customer}`);
logger.info(` merchant:${merchant}`);
logger.info(` cid:${cid}`);
logger.info(` size:${size}`);
logger.info(` token:${token}`);
logger.info(` price:${price}`);
logger.info(` blockNumber:${blockNumber}`);
logger.info(` isPermanent:${isPermanent}`);
logger.info(` txHash:${txHash}`);
logger.info(` timestamp:${timestamp}`);

await db.run(
'insert into record ' +
'(`customer`, `merchant`, `cid`, `size`, `token`, `price`, `blockNumber`, `chainType`, `isPermanent`, `txHash`, `timestamp`, `tryout`, `status`)' +
Expand All @@ -59,8 +47,19 @@ export function createRecordOperator(db: Database): DbOperator {
'new',
],
);

logger.info(`Add ${chainType} task successfully.`);
logger.info(` customer:${customer}`);
logger.info(` merchant:${merchant}`);
logger.info(` cid:${cid}`);
logger.info(` size:${size}`);
logger.info(` token:${token}`);
logger.info(` price:${price}`);
logger.info(` blockNumber:${blockNumber}`);
logger.info(` isPermanent:${isPermanent}`);
logger.info(` txHash:${txHash}`);
logger.info(` timestamp:${timestamp}`);
} catch(e) {
logger.error(`Error in addRecord: ${e}`);
const err_code = JSON.parse(JSON.stringify(e)).code;
if (err_code !== 'SQLITE_CONSTRAINT') {
throw e;
Expand Down

0 comments on commit c4d9e23

Please sign in to comment.