Skip to content

Instantly share code, notes, and snippets.

@AndrewWestberg
Created December 18, 2019 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save AndrewWestberg/a576af1ebfa95fd87226bd249a2a84f0 to your computer and use it in GitHub Desktop.
Save AndrewWestberg/a576af1ebfa95fd87226bd249a2a84f0 to your computer and use it in GitHub Desktop.
#!/bin/bash
cd /home/USERNAME/cardano
BLOCK_HASH=`/home/USERNAME/.cargo/bin/jcli rest v0 node stats get --host http://127.0.0.1:3100/api | grep 'lastBlockHash:' | sed -e 's/^[[:space:]]*//' | sed -e 's/lastBlockHash: //'`
FOUND=`/usr/bin/node /home/USERNAME/cardano/check_for_block.js $BLOCK_HASH`
if [[ "$FOUND" -eq 1 ]]; then
echo "`date`: Block Found!!"
else
echo "`date`: Block Not Found!! $BLOCK_HASH" | mail -s "Jormungandr Error" ###########@msg.fi.google.com
fi
'use strict';
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
//let block_hash = 'fcaf44a6dd85848df400185e264e5b5a43df719a2a63f2f31164c52440110899';
let block_hash = process.argv[2];
let url = 'https://shelleyexplorer.cardano.org/en/block/'+block_hash+'/';
await page.goto(url, {waitUntil: 'networkidle2'});
await page.waitFor(3000);
const found = (await page.content()).match(new RegExp(block_hash,'gi')) ? '1' : '0';
console.log(found);
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment