improve uptime

This commit is contained in:
BitcoinVM 2024-03-04 14:41:46 +08:00
parent 5c341e9306
commit 5a385a8e9e

View File

@ -11,13 +11,32 @@ const bars = computed(() => {
const uptime = Array(50).fill({ height: 0, color: 'bg-secondary' }); const uptime = Array(50).fill({ height: 0, color: 'bg-secondary' });
if(!props.blocks) return uptime if(!props.blocks) return uptime
props.blocks.forEach((element) => { props.blocks.forEach((element) => {
const has = element.signatures?.findIndex( // @deprecated
// const has = element.signatures?.findIndex(
// (sig) => sig.validator_address === props.validator
// );
// // console.log(has, props.validato, element)
// uptime.push({
// height: element.height,
// color: has > -1 ? 'bg-green-500' : 'bg-red-500',
// });
// show flag nil
const signature = element.signatures?.find(
(sig) => sig.validator_address === props.validator (sig) => sig.validator_address === props.validator
); );
// console.log(has, props.validato, element) // console.log("sign", signature)
let color = `bg-red-500`
if(signature) {
if(signature.block_id_flag === 'BLOCK_ID_FLAG_COMMIT') {
color = `bg-green-500`
} else {
color = `bg-yellow-500`
}
}
uptime.push({ uptime.push({
height: element.height, height: element.height,
color: has > -1 ? 'bg-green-500' : 'bg-red-500', color,
}); });
uptime.shift(); uptime.shift();
}); });