-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from AbdulAhadArain/develop
Develop
- Loading branch information
Showing
23 changed files
with
9,492 additions
and
73 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
import { nodeService, blockService } from '../services'; | ||
|
||
import { ethers } from 'ethers'; | ||
import config from '../config/config'; | ||
|
||
export const syncNode = async ( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction, | ||
): Promise<void> => { | ||
try { | ||
const rpc = config.rpcUrl; | ||
const provider = new ethers.providers.JsonRpcProvider(rpc); | ||
const currentBlock = await provider.getBlockNumber(); | ||
const lastVisitedBlock = await blockService.getLastBlockNumber(); | ||
await nodeService.processBlockAndTransaction( | ||
lastVisitedBlock, | ||
currentBlock, | ||
); | ||
|
||
res.send({ status: 'ok' }); | ||
} catch (error) { | ||
next(error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { CronJob } from 'cron'; | ||
import nodeSync from './nodeSync'; | ||
|
||
const nodeSyncJob = new CronJob( | ||
'*/10 * * * *', | ||
function () { | ||
nodeSync(); | ||
}, | ||
null, | ||
true, | ||
); | ||
|
||
const startJobs = () => { | ||
nodeSyncJob.start(); | ||
}; | ||
export default startJobs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { nodeService, blockService } from '../services'; | ||
import { ethers } from 'ethers'; | ||
import config from '../config/config'; | ||
|
||
const nodeSyncJob = async () => { | ||
const rpc = config.rpcUrl; | ||
const provider = new ethers.providers.JsonRpcProvider(rpc); | ||
const currentBlock = await provider.getBlockNumber(); | ||
const lastVisitedBlock = await blockService.getLastBlockNumber(); | ||
await nodeService.processBlockAndTransaction(lastVisitedBlock, currentBlock); | ||
}; | ||
export default nodeSyncJob; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import mongoose, { Schema } from 'mongoose'; | ||
import { quantumPortalBlockFinalizationSchema } from './quantumPortalBlockFinalization.model'; | ||
|
||
const quantumPortalBlockSchema = new Schema({ | ||
hash: String, | ||
parentHash: String, | ||
number: Number, | ||
nonce: String, | ||
timestamp: Number, | ||
difficulty: Number, | ||
gasLimit: String, | ||
gasUsed: String, | ||
miner: String, | ||
extraData: String, | ||
transactions: [Object], | ||
baseFeePerGas: String, | ||
_difficulty: String, | ||
}); | ||
|
||
export const QuantumPortalBlockModel = mongoose.model( | ||
'quantumPortalBlock', | ||
quantumPortalBlockSchema, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import mongoose, { Schema } from 'mongoose'; | ||
|
||
const quantumPortalTransactionSchema = new Schema({ | ||
hash: String, | ||
type: Number, | ||
accessList: [Object], | ||
networkId: String, | ||
blockHash: String, | ||
blockNumber: Number, | ||
transactionIndex: Number, | ||
confirmations: Number, | ||
from: String, | ||
gasPrice: String, | ||
maxPriorityFeePerGas: String, | ||
maxFeePerGas: String, | ||
gasLimit: String, | ||
to: String, | ||
value: String, | ||
valueToDisplay: String, | ||
nonce: Number, | ||
data: String, | ||
r: String, | ||
s: String, | ||
v: Number, | ||
creates: String, | ||
chainId: Number, | ||
wait: String, | ||
}); | ||
|
||
export const QuantumPortalTransactionModel = mongoose.model( | ||
'quantumPortalTransaction', | ||
quantumPortalTransactionSchema, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import express from 'express'; | ||
import { nodeController } from '.././controllers'; | ||
|
||
const router = express.Router(); | ||
|
||
router.route('/sync').post(nodeController.syncNode); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.