Skip to content

Commit

Permalink
feat: add chainName to config; throw error when found S3 key in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
fibonacci998 committed Feb 5, 2024
1 parent 7eda6d7 commit 5666f07
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion ci/config.json.ci
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"chainId": "aura-testnet-2",
"chainName": "aura",
"networkPrefixAddress": "aura",
"consensusPrefixAddress": "valcons",
"validatorPrefixAddress": "valoper",
Expand Down Expand Up @@ -281,7 +282,8 @@
"uploadBlockRawLogToS3": {
"key": "uploadBlockRawLogToS3",
"millisecondCrawl": 1000,
"blocksPerCall": 100
"blocksPerCall": 100,
"overwriteS3IfFound": true
},
"uploadTransactionRawLogToS3": {
"key": "uploadTransactionRawLogToS3",
Expand Down
4 changes: 3 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"chainId": "aura-testnet",
"chainName": "aura",
"networkPrefixAddress": "aura",
"consensusPrefixAddress": "valcons",
"validatorPrefixAddress": "valoper",
Expand Down Expand Up @@ -284,7 +285,8 @@
"uploadBlockRawLogToS3": {
"key": "uploadBlockRawLogToS3",
"millisecondCrawl": 1000,
"blocksPerCall": 100
"blocksPerCall": 100,
"overwriteS3IfFound": true
},
"uploadTransactionRawLogToS3": {
"key": "uploadTransactionRawLogToS3",
Expand Down
9 changes: 6 additions & 3 deletions src/common/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ export default class Utils {
console.error(err);
return err;
});
if (foundS3Object && !overwrite) {
console.warn(`This S3 key is found in S3: ${fileName}`);
return;
if (foundS3Object) {
const err = `This S3 key is found in S3: ${fileName}`;
console.warn(err);
if (!overwrite) {
throw new Error(err);
}
}

// eslint-disable-next-line consistent-return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ export default class UploadBlockRawLogToS3 extends BullableService {
Utils.uploadDataToS3(
block.height.toString(),
s3Client,
`rawlog/${config.chainId}/block/${block.height}`,
`rawlog/${config.chainName}/${config.chainId}/block/${block.height}`,
'application/json',
Buffer.from(JSON.stringify(block.data)),
Config.BUCKET,
Config.S3_GATEWAY,
false
config.uploadBlockRawLogToS3.overwriteS3IfFound
)
)
)
).catch((err) => {
this.logger.error(err);
throw err;
})
).filter((e) => e !== undefined);

const stringListUpdate = resultUploadS3.map(
Expand Down

0 comments on commit 5666f07

Please sign in to comment.