Skip to content

Commit db5d66c

Browse files
authored
No external binary anymore + fixed pause error
1 parent e432978 commit db5d66c

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

forkwatch.bat

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
@ECHO OFF
2-
REM forkwatch.bat v1.0.3 - qSebastiaNp
2+
REM forkwatch.bat v1.0.4 - qSebastiaNp
33
SETLOCAL EnableExtensions EnableDelayedExpansion
44

55
REM config
66
REM use hash of (blockheight - $SAFEMARGIN) to rule out orphan hashes
77
SET SAFEMARGIN=50
88
SET TRANSCENDENCE=transcendence-cli.exe
9-
REM download newest jq-win32.exe from here (https://stedolan.github.io/jq/download/) and put it in this same directory or enter the path
10-
SET JQ=jq-win32.exe
119
SET IFTTTKEY=none
1210

1311
REM no need to change anything from here --->
@@ -19,13 +17,6 @@ IF NOT EXIST %TRANSCENDENCE% (
1917
EXIT /b 1
2018
)
2119

22-
REM check if jq file exists
23-
IF NOT EXIST %JQ% (
24-
ECHO * Could not find %JQ%. Please check the configuration at the top of this script.
25-
PAUSE
26-
EXIT /b 1
27-
)
28-
2920
REM check if wallet is running
3021
tasklist /FI "IMAGENAME eq transcendence-qt.exe" 2>NUL | find /I /N "transcendence-qt.exe">NUL
3122
IF NOT "%ERRORLEVEL%" == "0" (
@@ -37,8 +28,13 @@ IF NOT "%ERRORLEVEL%" == "0" (
3728
)
3829
)
3930

40-
FOR /F "Delims=" %%A IN ('"curl -s https://explorer.teloscoin.org/ext/getmasternodecount"') DO SET "MNCOUNT=%%~A"
41-
FOR /F "Delims=" %%B IN ('"%TRANSCENDENCE% masternode count | %JQ% ."stable""') DO SET "LOCALMNCOUNT=%%~B"
31+
FOR /F "Delims=" %%A IN ('"CALL curl -s https://explorer.teloscoin.org/ext/getmasternodecount"') DO SET "MNCOUNT=%%~A"
32+
FOR /F "Delims=" %%B IN ('"CALL %TRANSCENDENCE% masternode count"') DO SET "LOCALMNCOUNT=!LOCALMNCOUNT!%%B"
33+
SET LOCALMNCOUNT=%LOCALMNCOUNT:"=%
34+
SET "LOCALMNCOUNT=%LOCALMNCOUNT:~2,-2%"
35+
SET "LOCALMNCOUNT=%LOCALMNCOUNT:: ==%"
36+
SET "%LOCALMNCOUNT:, =" & SET "%"
37+
SET LOCALMNCOUNT=%stable%
4238

4339
REM check if explorer knows enough masternodes, ELSE it may be forked
4440
SET /A "x=%LOCALMNCOUNT% / 2"
@@ -49,17 +45,19 @@ IF %MNCOUNT% LSS %x% (
4945
)
5046

5147
REM output blockhash overview
52-
FOR /F "Delims=" %%C IN ('"curl -s https://explorer.teloscoin.org/api/getblockcount"') DO SET "BLOCKHEIGHT=%%~C"
48+
FOR /F "Delims=" %%C IN ('"CALL curl -s https://explorer.teloscoin.org/api/getblockcount"') DO SET "BLOCKHEIGHT=%%~C"
5349
SET /A "SAFEBLOCKHEIGHT=%BLOCKHEIGHT% - %SAFEMARGIN%"
5450

55-
FOR /F "Delims=" %%D IN ('"%TRANSCENDENCE% getblockhash %SAFEBLOCKHEIGHT%"') DO SET "LOCALHASH=%%~D"
51+
FOR /F "Delims=" %%D IN ('"CALL %TRANSCENDENCE% getblockhash %SAFEBLOCKHEIGHT%"') DO SET "LOCALHASH=%%~D"
5652
ECHO Local : %LOCALHASH%
5753

5854
@ping -n 2 localhost> nul
59-
FOR /F "Delims=" %%E IN ('"curl -s https://explorer.teloscoin.org/api/getblockhash?index=%SAFEBLOCKHEIGHT%"') DO SET "EXPLORERHASH=%%~E"
55+
FOR /F "Delims=" %%E IN ('"CALL curl -s https://explorer.teloscoin.org/api/getblockhash?index=%SAFEBLOCKHEIGHT%"') DO SET "EXPLORERHASH=%%~E"
6056
ECHO Explorer: %EXPLORERHASH%
6157

62-
FOR /F "Delims=" %%F IN ('"curl -s https://telos.polispay.com/api/block-index/%SAFEBLOCKHEIGHT% | %JQ% ."blockHash""') DO SET "POLISHASH=%%~F"
58+
FOR /F "Delims=" %%F IN ('"CALL curl -s https://telos.polispay.com/api/block-index/%SAFEBLOCKHEIGHT%"') DO SET "POLISHASH=%%~F"
59+
SET "POLISHASH=%POLISHASH:~14,64%"
60+
6361
ECHO PolisPay: %POLISHASH%
6462
ECHO.
6563

@@ -98,7 +96,7 @@ IF "%EXPLORERHASH%" == "%LOCALHASH%" (
9896
REM send push notification - read README.MD
9997
IF NOT "%IFTTTKEY%" == "none" (
10098
FOR /F "Delims=" %%G IN ('"hostname"') DO SET "HOSTNAME=%%~G"
101-
curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"It seems %HOSTNAME% is FORKED.\"}" https://maker.ifttt.com/trigger/notify/with/key/%IFTTTKEY% >NUL
99+
CALL curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"It seems %HOSTNAME% is FORKED.\"}" https://maker.ifttt.com/trigger/notify/with/key/%IFTTTKEY% >NUL
102100
)
103101
PAUSE
104102
EXIT /b 1

0 commit comments

Comments
 (0)