|
|
|
@ -1,11 +1,11 @@ |
|
|
|
import axios from 'axios' |
|
|
|
import axios from 'axios'; |
|
|
|
import consola from 'consola' |
|
|
|
import consola from 'consola'; |
|
|
|
import config from '@/params/config.json' |
|
|
|
import config from '@/params/config.json'; |
|
|
|
import networks from '@/params/networks.json' |
|
|
|
import networks from '@/params/networks.json'; |
|
|
|
|
|
|
|
|
|
|
|
const TARGET_TIME = networks[config.network].blockTime |
|
|
|
const TARGET_TIME = networks[config.network].blockTime; |
|
|
|
const EPOCH_LENGTH = networks[config.network].epochLength |
|
|
|
const EPOCH_LENGTH = networks[config.network].epochLength; |
|
|
|
const API_URL = config.api + '/api' |
|
|
|
const API_URL = config.api + '/api'; |
|
|
|
|
|
|
|
|
|
|
|
export const state = () => ({ |
|
|
|
export const state = () => ({ |
|
|
|
env: { |
|
|
|
env: { |
|
|
|
@ -40,39 +40,44 @@ export const state = () => ({ |
|
|
|
epoch: 0, |
|
|
|
epoch: 0, |
|
|
|
dagSize: 0, // in MB
|
|
|
|
dagSize: 0, // in MB
|
|
|
|
now: Date.now(), // global now Date for time since calcs
|
|
|
|
now: Date.now(), // global now Date for time since calcs
|
|
|
|
}) |
|
|
|
percent: 0, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export const mutations = { |
|
|
|
export const mutations = { |
|
|
|
SET_STATS(state, info) { |
|
|
|
SET_STATS(state, info) { |
|
|
|
state.minersOnline = info.minersOnline || state.minersOnline |
|
|
|
state.minersOnline = info.minersOnline || state.minersOnline; |
|
|
|
state.poolHashRate = info.poolHashRate || state.poolHashRate |
|
|
|
state.poolHashRate = info.poolHashRate || state.poolHashRate; |
|
|
|
state.lastBlockFound = info.lastBlockFound || state.lastBlockFound |
|
|
|
state.lastBlockFound = info.lastBlockFound || state.lastBlockFound; |
|
|
|
state.roundShares = info.roundShares || state.roundShares |
|
|
|
state.roundShares = info.roundShares || state.roundShares; |
|
|
|
state.poolFee = info.poolFee || state.poolFee |
|
|
|
state.poolFee = info.poolFee || state.poolFee; |
|
|
|
state.height = info.height || state.height |
|
|
|
state.height = info.height || state.height; |
|
|
|
state.difficulty = info.difficulty || state.difficulty |
|
|
|
state.difficulty = info.difficulty || state.difficulty; |
|
|
|
state.networkHashrate = state.difficulty / info.blocktime // Verwenden Sie die blocktime von der API
|
|
|
|
state.networkHashrate = state.difficulty / info.blocktime; // Use the blocktime from the API
|
|
|
|
state.epoch = Math.trunc(info.height / EPOCH_LENGTH) |
|
|
|
state.epoch = Math.trunc(info.height / EPOCH_LENGTH); |
|
|
|
state.dagSize = state.epoch * 8192 / 1024 / 1024 + 1 |
|
|
|
state.dagSize = (state.epoch * 8192) / 1024 / 1024 + 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate the percent
|
|
|
|
|
|
|
|
const percent = (state.roundShares / state.difficulty) * 100; |
|
|
|
|
|
|
|
state.percent = percent.toFixed(0); // Store the result in the state
|
|
|
|
}, |
|
|
|
}, |
|
|
|
SET_MINERS(state, miners) { |
|
|
|
SET_MINERS(state, miners) { |
|
|
|
state.miners = miners |
|
|
|
state.miners = miners; |
|
|
|
}, |
|
|
|
}, |
|
|
|
SET_BLOCKS(state, blocks) { |
|
|
|
SET_BLOCKS(state, blocks) { |
|
|
|
state.blocks = blocks |
|
|
|
state.blocks = blocks; |
|
|
|
}, |
|
|
|
}, |
|
|
|
SET_PAYMENTS(state, txns) { |
|
|
|
SET_PAYMENTS(state, txns) { |
|
|
|
state.payments = txns |
|
|
|
state.payments = txns; |
|
|
|
}, |
|
|
|
}, |
|
|
|
SET_NOW(state, now) { |
|
|
|
SET_NOW(state, now) { |
|
|
|
state.now = now |
|
|
|
state.now = now; |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export const actions = { |
|
|
|
export const actions = { |
|
|
|
async stats({ commit }) { |
|
|
|
async stats({ commit }) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { data } = await axios.get(API_URL + '/stats') |
|
|
|
const { data } = await axios.get(`${API_URL}/stats`); |
|
|
|
if (data) { |
|
|
|
if (data) { |
|
|
|
const info = { |
|
|
|
const info = { |
|
|
|
minersOnline: data.minersTotal, |
|
|
|
minersOnline: data.minersTotal, |
|
|
|
@ -80,45 +85,50 @@ export const actions = { |
|
|
|
height: data.nodes[0].height, |
|
|
|
height: data.nodes[0].height, |
|
|
|
difficulty: data.nodes[0].difficulty, |
|
|
|
difficulty: data.nodes[0].difficulty, |
|
|
|
lastBlockFound: data.stats.lastBlockFound, |
|
|
|
lastBlockFound: data.stats.lastBlockFound, |
|
|
|
blocktime: data.nodes[0].blocktime, // Hinzufügen der blocktime von der API
|
|
|
|
blocktime: data.nodes[0].blocktime, // Add the blocktime from the API
|
|
|
|
} |
|
|
|
roundShares: data.stats.roundShares, // Extrahieren Sie den Wert von roundShares aus den API-Daten
|
|
|
|
commit('SET_STATS', info) |
|
|
|
}; |
|
|
|
|
|
|
|
commit('SET_STATS', info); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
consola.error(new Error(error)) |
|
|
|
consola.error(error); |
|
|
|
|
|
|
|
throw new Error('Failed to fetch stats'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
async miners({ commit }) { |
|
|
|
async miners({ commit }) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { data } = await axios.get(API_URL + '/miners') |
|
|
|
const { data } = await axios.get(`${API_URL}/miners`); |
|
|
|
if (data) { |
|
|
|
if (data) { |
|
|
|
commit('SET_MINERS', data.miners) |
|
|
|
commit('SET_MINERS', data.miners); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
consola.error(new Error(error)) |
|
|
|
consola.error(error); |
|
|
|
|
|
|
|
throw new Error('Failed to fetch miners'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
async blocks({ commit }) { |
|
|
|
async blocks({ commit }) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { data } = await axios.get(API_URL + '/blocks') |
|
|
|
const { data } = await axios.get(`${API_URL}/blocks`); |
|
|
|
if (data) { |
|
|
|
if (data) { |
|
|
|
commit('SET_BLOCKS', data) |
|
|
|
commit('SET_BLOCKS', data); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
consola.error(new Error(error)) |
|
|
|
consola.error(error); |
|
|
|
|
|
|
|
throw new Error('Failed to fetch blocks'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
async payments({ commit }) { |
|
|
|
async payments({ commit }) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { data } = await axios.get(API_URL + '/payments') |
|
|
|
const { data } = await axios.get(`${API_URL}/payments`); |
|
|
|
if (data) { |
|
|
|
if (data) { |
|
|
|
commit('SET_PAYMENTS', data) |
|
|
|
commit('SET_PAYMENTS', data); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
consola.error(new Error(error)) |
|
|
|
consola.error(error); |
|
|
|
|
|
|
|
throw new Error('Failed to fetch payments'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
now({ commit }) { |
|
|
|
now({ commit }) { |
|
|
|
commit('SET_NOW', Date.now()) |
|
|
|
commit('SET_NOW', Date.now()); |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
}; |
|
|
|
|