Skip to content

Commit

Permalink
fix: a minor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdesu committed Feb 1, 2024
1 parent fe118f8 commit eb44880
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/mainnet.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
CkbOfficialNodeRpc: 'https://mainnet.ckb.dev/'
CkbOfficialNodeRpc: 'http://127.0.0.1:8114'

Env: mainnet

Expand Down
2 changes: 1 addition & 1 deletion config/testnet.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
CkbOfficialNodeRpc: 'https://testnet.ckb.dev/'
CkbOfficialNodeRpc: 'http://127.0.0.1:8224'

Env: testnet

Expand Down
19 changes: 10 additions & 9 deletions src/controller/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,28 +140,29 @@ export async function updateController (argv: Arguments<{ type: string }>) {
let privateKey
switch (argv.type) {
case 'blocknumber':
lockScript = config.Blocknumber.PayersLockScript
privateKey = config.Blocknumber.PayersPrivateKey
infoModel.infoData = BigInt(data.number)

// Ensure that the blocknumber continues to increase.
if (infoModel.infoData <= latestValue) {
logger.info(`The node has been left behind, skip updating. current(${infoModel.infoData}) <= latest(${latestValue}) .`, { cell_data: cellData, waited_blocks: waitedBlocks })
return
}

lockScript = config.Blocknumber.PayersLockScript
privateKey = config.Blocknumber.PayersPrivateKey
infoModel.infoData = BigInt(data.number)
since = dataToSince(infoModel.infoData, SinceFlag.AbsoluteHeight)
break
case 'timestamp':
// Ensure that the timestamp continues to increase.
if (infoModel.infoData <= latestValue) {
logger.info(`The node has been left behind, skip updating. current(${infoModel.infoData}) <= latest(${latestValue}) .`, { cell_data: cellData, waited_blocks: waitedBlocks })
return
}

lockScript = config.Timestamp.PayersLockScript
privateKey = config.Timestamp.PayersPrivateKey
try {
infoModel.infoData = await getLatestTimestamp(data.number)

// Ensure that the timestamp continues to increase.
if (infoModel.infoData <= latestValue) {
logger.info(`The node has been left behind, skip updating. current(${infoModel.infoData}) <= latest(${latestValue}) .`, { cell_data: cellData, waited_blocks: waitedBlocks })
return
}
} catch (e) {
await notifyWithThreshold(logger, 'fetch-timestamp-error', THEORETIC_BLOCK_1_M * 5, TIME_1_M * 5, `${e}`, 'Check if CKB node is offline and its JSON RPC is reachable.')
return
Expand Down

0 comments on commit eb44880

Please sign in to comment.