mirror of
https://github.com/mempool/mempool.git
synced 2025-09-29 07:53:44 +02:00
nits
This commit is contained in:
@@ -40,6 +40,7 @@ export class TaprootAddressScriptsComponent implements OnChanges {
|
|||||||
depth: number = 0;
|
depth: number = 0;
|
||||||
depthShown: number;
|
depthShown: number;
|
||||||
height: number;
|
height: number;
|
||||||
|
levelHeight: number = 40;
|
||||||
fullTreeShown: boolean;
|
fullTreeShown: boolean;
|
||||||
|
|
||||||
chartOptions: EChartsOption = {};
|
chartOptions: EChartsOption = {};
|
||||||
@@ -99,7 +100,7 @@ export class TaprootAddressScriptsComponent implements OnChanges {
|
|||||||
this.fullTreeShown = show;
|
this.fullTreeShown = show;
|
||||||
this.depthShown = show ? this.depth : Math.min(this.depth, this.croppedTreeDepth);
|
this.depthShown = show ? this.depth : Math.min(this.depth, this.croppedTreeDepth);
|
||||||
if (show) {
|
if (show) {
|
||||||
this.height = (this.depthShown + 1) * 40;
|
this.height = (this.depthShown + 1) * this.levelHeight;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.prepareChartOptions(this.tree);
|
this.prepareChartOptions(this.tree);
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
@@ -107,10 +108,10 @@ export class TaprootAddressScriptsComponent implements OnChanges {
|
|||||||
} else {
|
} else {
|
||||||
this.prepareChartOptions(this.croppedTree);
|
this.prepareChartOptions(this.croppedTree);
|
||||||
if (!delay) {
|
if (!delay) {
|
||||||
this.height = (this.depthShown + 1) * 40;
|
this.height = (this.depthShown + 1) * this.levelHeight;
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.height = (this.depthShown + 1) * 40;
|
this.height = (this.depthShown + 1) * this.levelHeight;
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
@@ -150,16 +151,20 @@ export class TaprootAddressScriptsComponent implements OnChanges {
|
|||||||
const isFirstChild = left === k;
|
const isFirstChild = left === k;
|
||||||
const children: [TaprootTree, TaprootTree] = isFirstChild ? [node, { name: e }] : [{ name: e }, node];
|
const children: [TaprootTree, TaprootTree] = isFirstChild ? [node, { name: e }] : [{ name: e }, node];
|
||||||
|
|
||||||
if (this.mergeBranchAtDepth(masterTree, parentHash, children, isFirstChild, merklePath.length - i - 1)) {
|
// Try to merge the branch to the tree at current level
|
||||||
|
if (masterTree && this.mergeBranchAtDepth(masterTree, parentHash, children, isFirstChild, merklePath.length - i - 1)) {
|
||||||
return masterTree;
|
return masterTree;
|
||||||
}
|
}
|
||||||
|
// If no merge is possible, go up one level and try again
|
||||||
k = parentHash;
|
k = parentHash;
|
||||||
node = { name: k, children };
|
node = { name: k, children };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
if (!masterTree) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
// We only end up here if we could not merge the script in masterTree due to malformed merkle path
|
||||||
|
console.error('Could not merge script in Taptree');
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeBranchAtDepth(tree: TaprootTree, target: string, children: [TaprootTree, TaprootTree], first: boolean, targetDepth: number, currentDepth = 0): boolean {
|
mergeBranchAtDepth(tree: TaprootTree, target: string, children: [TaprootTree, TaprootTree], first: boolean, targetDepth: number, currentDepth = 0): boolean {
|
||||||
@@ -353,7 +358,7 @@ export class TaprootAddressScriptsComponent implements OnChanges {
|
|||||||
bottom: '20',
|
bottom: '20',
|
||||||
right: 0,
|
right: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
height: Math.max(140, (this.depthShown) * 40),
|
height: Math.max(140, this.depthShown * this.levelHeight),
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
curveness: 0.9,
|
curveness: 0.9,
|
||||||
width: 2,
|
width: 2,
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
// Import tree-shakeable echarts
|
// Import tree-shakeable echarts
|
||||||
import * as echarts from 'echarts/core';
|
import * as echarts from 'echarts/core';
|
||||||
|
|
||||||
import { LineChart, LinesChart, BarChart, TreemapChart, PieChart, ScatterChart, GaugeChart, CustomChart, TreeChart } from 'echarts/charts';
|
import { LineChart, LinesChart, BarChart, TreemapChart, PieChart, ScatterChart, GaugeChart, CustomChart, TreeChart } from 'echarts/charts';
|
||||||
import { TitleComponent, TooltipComponent, GridComponent, LegendComponent, GeoComponent, DataZoomComponent, VisualMapComponent, MarkLineComponent, GraphicComponent } from 'echarts/components';
|
import { TitleComponent, TooltipComponent, GridComponent, LegendComponent, GeoComponent, DataZoomComponent, VisualMapComponent, MarkLineComponent, GraphicComponent } from 'echarts/components';
|
||||||
import { SVGRenderer, CanvasRenderer } from 'echarts/renderers';
|
import { SVGRenderer, CanvasRenderer } from 'echarts/renderers';
|
||||||
|
Reference in New Issue
Block a user