-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview.html
More file actions
178 lines (159 loc) · 5.84 KB
/
Copy pathpreview.html
File metadata and controls
178 lines (159 loc) · 5.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mempool Galaxy — Preview</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; font-family: 'Courier New', monospace; }
canvas { display: block; border: 1px solid #111; }
.hud-top { position: absolute; top: 16px; left: 24px; color: #666; font-size: 12px; line-height: 1.8; }
.hud-top span { color: #aaa; }
.hud-tr { position: absolute; top: 16px; right: 24px; color: #666; font-size: 12px; text-align: right; line-height: 1.8; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #00ff44; vertical-align: middle; margin-left: 4px; box-shadow: 0 0 6px #00ff44; }
.hud-bot { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #333; font-size: 11px; letter-spacing: 2px; }
</style>
</head>
<body>
<div class="hud-top">
mempool <span>247,413 txs 312 vMB</span><br>
fees <span>p10:2 p25:8 p50:21 p75:67 p90:180 sat/vB</span>
</div>
<div class="hud-tr">
Bitcoin Core RPC <span class="dot"></span><br>
<span>block 898,241 14m ago</span>
</div>
<canvas id="c"></canvas>
<div class="hud-bot">+/- zoom arrows pan p pause r reset d demo q quit</div>
<script>
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const W = canvas.width, H = canvas.height;
const cx = W / 2, cy = H / 2;
function feeColor(sat) {
if (sat < 1) return [34, 34, 34];
if (sat < 5) return [51, 85, 255];
if (sat < 20) return [0, 170, 255];
if (sat < 50) return [0, 255, 136];
if (sat < 100) return [255, 238, 0];
if (sat < 300) return [255, 136, 0];
return [255, 255, 255];
}
// Background stars
const bgStars = Array.from({length: 300}, () => ({
x: Math.random() * W,
y: Math.random() * H,
r: Math.random() * 0.8 + 0.2,
a: Math.random() * 0.4 + 0.05,
}));
// Mempool particles
const N = 600;
const particles = [];
for (let i = 0; i < N; i++) {
const feeRate = Math.random() < 0.05
? Math.random() * 400 + 100 // white-hot core
: Math.random() < 0.2
? Math.random() * 80 + 20 // mid-range
: Math.random() * 10 + 0.5; // dusty outer
// Higher fee → tighter orbit radius
const maxR = Math.min(W, H) * 0.42;
const minR = Math.min(W, H) * 0.02;
const t = Math.pow(1 - feeRate / 450, 1.4);
const orbR = minR + t * (maxR - minR) + (Math.random() - 0.5) * 30;
const angle = Math.random() * Math.PI * 2;
const spiral = angle + orbR * 0.004; // spiral arm offset
particles.push({
x: cx + Math.cos(spiral) * orbR,
y: cy + Math.sin(spiral) * orbR * 0.55,
vx: (Math.random() - 0.5) * 0.12,
vy: (Math.random() - 0.5) * 0.08,
fee: feeRate,
r: Math.sqrt(feeRate / 30) * 1.2 + 0.6,
haloR: Math.sqrt(feeRate / 30) * 3.5 + 1.5,
angle,
orbR,
speed: (0.0004 + feeRate * 0.000003) * (Math.random() < 0.5 ? 1 : -1),
});
}
function draw() {
ctx.clearRect(0, 0, W, H);
// Background gradient
const bg = ctx.createRadialGradient(cx, cy, 0, cx, cy, Math.min(W, H) * 0.5);
bg.addColorStop(0, 'rgba(10,6,20,1)');
bg.addColorStop(0.4, 'rgba(4,2,12,1)');
bg.addColorStop(1, 'rgba(0,0,0,1)');
ctx.fillStyle = bg;
ctx.fillRect(0, 0, W, H);
// Background stars
for (const s of bgStars) {
ctx.beginPath();
ctx.arc(s.x, s.y, s.r, 0, Math.PI * 2);
ctx.fillStyle = `rgba(255,255,255,${s.a})`;
ctx.fill();
}
// Core glow
const cg = ctx.createRadialGradient(cx, cy, 0, cx, cy, 90);
cg.addColorStop(0, 'rgba(255,200,120,0.18)');
cg.addColorStop(0.5, 'rgba(100,60,200,0.07)');
cg.addColorStop(1, 'rgba(0,0,0,0)');
ctx.fillStyle = cg;
ctx.fillRect(0, 0, W, H);
// Sort: low fee first (high fee paints on top)
const sorted = [...particles].sort((a, b) => a.fee - b.fee);
for (const p of sorted) {
const [r, g, b] = feeColor(p.fee);
const alpha = Math.min(1, 0.25 + p.fee / 200);
// Glow halo
const grad = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, p.haloR);
grad.addColorStop(0, `rgba(${r},${g},${b},${alpha})`);
grad.addColorStop(0.45,`rgba(${r},${g},${b},${alpha * 0.3})`);
grad.addColorStop(1, `rgba(${r},${g},${b},0)`);
ctx.beginPath();
ctx.arc(p.x, p.y, p.haloR, 0, Math.PI * 2);
ctx.fillStyle = grad;
ctx.fill();
// Core dot
ctx.beginPath();
ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2);
ctx.fillStyle = `rgba(${r},${g},${b},${Math.min(1, alpha + 0.4)})`;
ctx.fill();
}
// Legend
const legend = [
{ label: '< 1', color: feeColor(0.5) },
{ label: '1–5', color: feeColor(3) },
{ label: '5–20', color: feeColor(12) },
{ label: '20–50', color: feeColor(35) },
{ label: '50–100', color: feeColor(75) },
{ label: '100–300',color: feeColor(200) },
{ label: '300+', color: feeColor(350) },
];
const lx = 24, ly = H - 26 - legend.length * 18;
for (let i = 0; i < legend.length; i++) {
const [r, g, b] = legend[i].color;
ctx.beginPath();
ctx.arc(lx + 5, ly + i * 18, 4, 0, Math.PI * 2);
ctx.fillStyle = `rgb(${r},${g},${b})`;
ctx.fill();
ctx.fillStyle = '#555';
ctx.font = '11px Courier New';
ctx.fillText(legend[i].label + ' sat/vB', lx + 14, ly + i * 18 + 4);
}
}
function tick() {
for (const p of particles) {
p.angle += p.speed;
const spiral = p.angle + p.orbR * 0.004;
const drift = 1 + Math.sin(p.angle * 3) * 0.03;
p.x = cx + Math.cos(spiral) * p.orbR * drift;
p.y = cy + Math.sin(spiral) * p.orbR * drift * 0.55;
}
draw();
requestAnimationFrame(tick);
}
tick();
</script>
</body>
</html>