Make mempool.space instance configurable, change ntp server to global pool
This commit is contained in:
parent
18faece660
commit
cc28df888b
5 changed files with 34 additions and 5 deletions
|
@ -171,6 +171,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="mempoolInstance" class="col-sm-6 col-form-label">Mempool Instance</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="mempoolInstance" id="mempoolInstance" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class=" col-sm-6">
|
||||
<div class="form-check form-switch">
|
||||
|
|
|
@ -10,7 +10,10 @@ getBcStatus = () => {
|
|||
.then(jsonData => {
|
||||
var source = document.getElementById("entry-template").innerHTML;
|
||||
var template = Handlebars.compile(source);
|
||||
var context = { currentScreen: jsonData.currentScreen, rendered: jsonData.rendered, data: jsonData.data, screens: screens, ledStatus: jsonData.ledStatus ? jsonData.ledStatus.map((t) => (t).toString(16)) : [] };
|
||||
|
||||
var context = { timerRunning: jsonData.timerRunning, currentScreen: jsonData.currentScreen, rendered: jsonData.rendered, data: jsonData.data, screens: screens, ledStatus: jsonData.ledStatus ? jsonData.ledStatus.map((t) => (t).toString(16)) : [] };
|
||||
|
||||
|
||||
document.getElementById('output').innerHTML = template(context);
|
||||
})
|
||||
.catch(err => {
|
||||
|
@ -54,7 +57,7 @@ fetch('/api/settings', {
|
|||
document.getElementById('ledBrightness').value = jsonData.ledBrightness;
|
||||
document.getElementById('fullRefreshMin').value = jsonData.fullRefreshMin;
|
||||
document.getElementById('wpTimeout').value = jsonData.wpTimeout;
|
||||
|
||||
document.getElementById('mempoolInstance').value = jsonData.mempoolInstance;
|
||||
|
||||
if (jsonData.gitRev)
|
||||
document.getElementById('gitRev').innerHTML = "Version: " + jsonData.gitRev;
|
||||
|
@ -144,3 +147,11 @@ changeScreen = (id) => {
|
|||
//error block
|
||||
});
|
||||
}
|
||||
|
||||
toggleTimer = (currentStatus) => {
|
||||
if (currentStatus) {
|
||||
fetch('/api/action/pause');
|
||||
} else {
|
||||
fetch('/api/action/timer_restart');
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#define NTP_SERVER "nl.pool.ntp.org"
|
||||
#define NTP_SERVER "pool.ntp.org"
|
||||
#define DEFAULT_MEMPOOL_INSTANCE "mempool.bitcoin.nl"
|
||||
|
||||
#define FONT_SMALL Antonio_SemiBold20pt7b
|
||||
#define FONT_BIG Antonio_SemiBold90pt7b
|
||||
|
|
|
@ -154,6 +154,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
|
|||
root["rpcPort"] = preferences.getUInt("rpcPort", BITCOIND_PORT);
|
||||
root["rpcUser"] = preferences.getString("rpcUser", BITCOIND_RPC_USER);
|
||||
root["rpcHost"] = preferences.getString("rpcHost", BITCOIND_HOST);
|
||||
root["mempoolInstance"] = preferences.getString("mempoolInstance", DEFAULT_MEMPOOL_INSTANCE);
|
||||
|
||||
#ifdef IS_BW
|
||||
root["epdColors"] = 2;
|
||||
#else
|
||||
|
@ -222,6 +224,16 @@ void onApiSettingsPost(AsyncWebServerRequest *request)
|
|||
settingsChanged = true;
|
||||
}
|
||||
|
||||
if (request->hasParam("mempoolInstance", true))
|
||||
{
|
||||
AsyncWebParameter *mempoolInstance = request->getParam("mempoolInstance", true);
|
||||
|
||||
preferences.putString("mempoolInstance", mempoolInstance->value().c_str());
|
||||
Serial.print("Setting mempool instance to ");
|
||||
Serial.println(mempoolInstance->value().c_str());
|
||||
settingsChanged = true;
|
||||
}
|
||||
|
||||
if (request->hasParam("ledBrightness", true))
|
||||
{
|
||||
AsyncWebParameter *ledBrightness = request->getParam("ledBrightness", true);
|
||||
|
|
|
@ -20,7 +20,6 @@ void checkBitcoinBlock(void *pvParameters)
|
|||
int blockHeight = preferences.getUInt("blockHeight", currentBlockHeight);
|
||||
|
||||
HTTPClient http;
|
||||
http.setReuse(true);
|
||||
useBitcoind = preferences.getBool("useNode", false) && wifiClientInsecure.connect(preferences.getString("rpcHost", BITCOIND_HOST).c_str(), preferences.getUInt("rpcPort", BITCOIND_PORT));
|
||||
if (useBitcoind)
|
||||
Serial.println("bitcoind node is reachable, using this for blocks.");
|
||||
|
@ -58,7 +57,7 @@ void checkBitcoinBlock(void *pvParameters)
|
|||
}
|
||||
else
|
||||
{
|
||||
http.begin("https://mempool.bitcoin.nl/api/blocks/tip/height");
|
||||
http.begin("https://" + preferences.getString("mempoolInstance", DEFAULT_MEMPOOL_INSTANCE) + "/api/blocks/tip/height");
|
||||
http.addHeader("User-Agent", "BTClock/1.0");
|
||||
int httpCode = http.GET();
|
||||
|
||||
|
|
Loading…
Reference in a new issue