mirror of
https://github.com/seigler/dash-visualizer
synced 2025-07-27 01:36:10 +00:00
Fix txes piling up
This commit is contained in:
parent
66283fcfe2
commit
4036462321
3 changed files with 16 additions and 27 deletions
32
app/App.js
32
app/App.js
|
@ -9,7 +9,6 @@ import { PSDENOMINATIONS, COLORS, PAINT } from './constants';
|
||||||
export default class App {
|
export default class App {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.blockRefs = [];
|
this.blockRefs = [];
|
||||||
this.mempoolRefs = [];
|
|
||||||
this.blockList = document.getElementById('blockList');
|
this.blockList = document.getElementById('blockList');
|
||||||
this.connectionStatus = document.getElementById('connectionStatus');
|
this.connectionStatus = document.getElementById('connectionStatus');
|
||||||
this.hero = document.getElementById('hero');
|
this.hero = document.getElementById('hero');
|
||||||
|
@ -109,32 +108,29 @@ export default class App {
|
||||||
fetch('https://insight.dash.org/insight-api/block/' + data)
|
fetch('https://insight.dash.org/insight-api/block/' + data)
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
let mined = [];
|
let leftovers = [];
|
||||||
for (var i in data.tx) {
|
for (var i in data.tx) {
|
||||||
const txid = data.tx[i];
|
const txid = data.tx[i];
|
||||||
let paint = document.getElementById(txid);
|
let paint = document.getElementById(txid);
|
||||||
if (paint) {
|
if (paint) {
|
||||||
mined.push(paint);
|
|
||||||
completedBlock.insertBefore(paint, completedBlock.firstChild);
|
completedBlock.insertBefore(paint, completedBlock.firstChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mempoolRefs = this.mempoolRefs.filter(item => !mined.includes(item));
|
Array.from(this.hero.children).forEach(item => {
|
||||||
this.mempoolRefs.forEach(item => {
|
if (item.data_ignored > 3) {
|
||||||
item.classList.add('stale');
|
item.remove();
|
||||||
item.data_ignored = item.data_ignored ? item.data_ignored + 1 : 1;
|
} else {
|
||||||
});
|
if (item.data_ignored) {
|
||||||
this.mempoolRefs.filter(item => {
|
item.data_ignored++;
|
||||||
if (item.data_ignored > 4) {
|
} else {
|
||||||
try {
|
item.classList.add('stale');
|
||||||
this.hero.removeChild(item);
|
item.data_ignored = 1;
|
||||||
} catch (err) { }
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
completedBlock.appendChild(blockLink);
|
completedBlock.appendChild(blockLink);
|
||||||
if (this.blockRefs.unshift(this.completedBlock) > 8) {
|
if (this.blockRefs.unshift(this.completedBlock) > 8) {
|
||||||
let toDelete = this.blockRefs.pop();
|
var toDelete = this.blockRefs.pop();
|
||||||
if (toDelete) {
|
if (toDelete) {
|
||||||
toDelete.remove();
|
toDelete.remove();
|
||||||
}
|
}
|
||||||
|
@ -187,10 +183,6 @@ export default class App {
|
||||||
paint.style.setProperty('--size', Math.log(1 + tx.value)/Math.log(2));
|
paint.style.setProperty('--size', Math.log(1 + tx.value)/Math.log(2));
|
||||||
paint.style.setProperty('--rotation', tx.rotation * 360 + 'deg');
|
paint.style.setProperty('--rotation', tx.rotation * 360 + 'deg');
|
||||||
paint.style.setProperty('--color', tx.color);
|
paint.style.setProperty('--color', tx.color);
|
||||||
if (addToMempool && this.mempoolRefs.unshift(paint) > 200) {
|
|
||||||
let toDelete = this.mempoolRefs.pop();
|
|
||||||
toDelete.remove();
|
|
||||||
}
|
|
||||||
target.appendChild(paint);
|
target.appendChild(paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,7 @@ export const PAINT = {
|
||||||
'paint-big07.svg',
|
'paint-big07.svg',
|
||||||
'paint-big08.svg',
|
'paint-big08.svg',
|
||||||
'paint-big09.svg',
|
'paint-big09.svg',
|
||||||
'paint-big00.svg',
|
'paint-big10.svg',
|
||||||
'paint-big01.svg',
|
|
||||||
'paint-big11.svg',
|
'paint-big11.svg',
|
||||||
'paint-big12.svg'
|
'paint-big12.svg'
|
||||||
],
|
],
|
||||||
|
@ -37,8 +36,7 @@ export const PAINT = {
|
||||||
'paint07.svg',
|
'paint07.svg',
|
||||||
'paint08.svg',
|
'paint08.svg',
|
||||||
'paint09.svg',
|
'paint09.svg',
|
||||||
'paint00.svg',
|
'paint10.svg',
|
||||||
'paint01.svg',
|
'paint11.svg',
|
||||||
'paint11.svg'
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,6 @@ body {
|
||||||
background-color: #bbb;
|
background-color: #bbb;
|
||||||
color: black;
|
color: black;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
* {
|
* {
|
||||||
-webkit-box-sizing: inherit;
|
-webkit-box-sizing: inherit;
|
||||||
|
@ -45,7 +44,7 @@ a {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
#hero {
|
#hero {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
left: 41.125%;
|
left: 41.125%;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
width: 77.5vw;
|
width: 77.5vw;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue