Skip to content

Commit 666c28e

Browse files
authored
Merge pull request #64 from HathorNetwork/dev
release: v1.4.1-alpha
2 parents ad315e2 + 7ffeadb commit 666c28e

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.4.0-alpha",
2+
"version": "1.4.1-alpha",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ export interface RawTxResponse {
310310
export enum Severity {
311311
CRITICAL = 'critical',
312312
MAJOR = 'major',
313+
MEDIUM = 'medium',
313314
MINOR = 'minor',
314315
WARNING = 'warning',
315316
INFO = 'info',

src/utils.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ export const IGNORE_TXS: Map<string, string[]> = new Map<string, string[]>([
6363
const TX_CACHE_SIZE: number =
6464
parseInt(process.env.TX_CACHE_SIZE as string) || 200;
6565

66+
function getAlertSeverityForReorgSize(reorg_size: number) {
67+
if (reorg_size < 3) return Severity.INFO;
68+
else if (reorg_size < 5) return Severity.WARNING;
69+
else if (reorg_size < 10) return Severity.MINOR;
70+
else if (reorg_size < 20) return Severity.MEDIUM;
71+
else if (reorg_size < 30) return Severity.MAJOR;
72+
else return Severity.CRITICAL;
73+
}
74+
6675
/**
6776
* Download and parse a tx by it's id
6877
*
@@ -460,10 +469,12 @@ export async function* syncToLatestBlock(): AsyncGenerator<StatusEvent> {
460469
if (meta.voided_by && meta.voided_by.length && meta.voided_by.length > 0) {
461470
const reorgSize = fullNodeBestBlock.height - ourBestBlock.height;
462471

472+
const severity = getAlertSeverityForReorgSize(reorgSize);
473+
463474
addAlert(
464475
`Re-org on ${process.env.NETWORK}`,
465476
`The daemon's best block has been voided, handling re-org`,
466-
Severity.INFO,
477+
severity,
467478
{
468479
'Wallet Service best block': ourBestBlock.txId,
469480
'Fullnode best block': fullNodeBestBlock.txId,

test/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ test('syncToLatestBlockGen should yield an error when our best block height is h
174174
expect(addAlertMock).toHaveBeenCalledWith(
175175
`Re-org on ${process.env.NETWORK}`,
176176
'The daemon\'s best block has been voided, handling re-org',
177-
Severity.INFO,
177+
Severity.WARNING,
178178
{
179179
'Wallet Service best block': '000001517136ab420446a80b212715160c4693deabfa72d1f2e99683fdcb845e',
180180
'Fullnode best block': '0000018b4b08ad8668a42af30185e4ff228b5d2afc41ce7ee5cb7a085342ffda',

0 commit comments

Comments
 (0)