@@ -46,20 +46,6 @@ type Config struct {
4646 // mempool eviction policies in the caller.
4747 MaxNodes int
4848
49- // MaxEdges limits the total number of parent-child relationships. This
50- // provides defense against attacks that try to create extremely
51- // connected transaction graphs to degrade performance.
52- MaxEdges int
53-
54- // EnableCaching enables memoization of expensive computations like
55- // ancestor/descendant counts. This trades memory for speed, which is
56- // beneficial in production but may complicate debugging.
57- EnableCaching bool
58-
59- // CacheTimeout defines how long cached computation results remain
60- // valid. Shorter timeouts trade freshness for computation cost.
61- CacheTimeout time.Duration
62-
6349 // MaxPackageSize limits the number of transactions in a package.
6450 // Bitcoin Core uses 101 (25 ancestors + 25 descendants + 1 root),
6551 // enforced here to prevent package relay DoS attacks.
@@ -75,9 +61,6 @@ type Config struct {
7561func DefaultConfig () * Config {
7662 return & Config {
7763 MaxNodes : 100000 ,
78- MaxEdges : 200000 ,
79- EnableCaching : true ,
80- CacheTimeout : 5 * time .Second ,
8164 MaxPackageSize : 101 ,
8265 }
8366}
@@ -444,61 +427,6 @@ func (g *TxGraph) HasTransaction(hash chainhash.Hash) bool {
444427 return exists
445428}
446429
447- // AddEdge adds an edge between two nodes.
448- func (g * TxGraph ) AddEdge (parentHash , childHash chainhash.Hash ) error {
449- g .mu .Lock ()
450- defer g .mu .Unlock ()
451-
452- parent , parentExists := g .nodes [parentHash ]
453- child , childExists := g .nodes [childHash ]
454-
455- if ! parentExists || ! childExists {
456- return ErrNodeNotFound
457- }
458-
459- // Check if edge already exists.
460- if _ , exists := parent .Children [childHash ]; exists {
461- return nil // Already connected
462- }
463-
464- // Check for cycles.
465- if g .wouldCreateCycle (parent , child ) {
466- return ErrCycleDetected
467- }
468-
469- // Add edge.
470- parent .Children [childHash ] = child
471- child .Parents [parentHash ] = parent
472- atomic .AddInt32 (& g .metrics .edgeCount , 1 )
473-
474- // Update clusters.
475- g .mergeNodeClusters (parent , child )
476-
477- return nil
478- }
479-
480- // RemoveEdge removes an edge between two nodes.
481- func (g * TxGraph ) RemoveEdge (parentHash , childHash chainhash.Hash ) error {
482- g .mu .Lock ()
483- defer g .mu .Unlock ()
484-
485- parent , parentExists := g .nodes [parentHash ]
486- child , childExists := g .nodes [childHash ]
487-
488- if ! parentExists || ! childExists {
489- return ErrNodeNotFound
490- }
491-
492- // Remove edge if it exists.
493- if _ , exists := parent .Children [childHash ]; exists {
494- delete (parent .Children , childHash )
495- delete (child .Parents , parentHash )
496- atomic .AddInt32 (& g .metrics .edgeCount , - 1 )
497- }
498-
499- return nil
500- }
501-
502430// GetAncestors returns all ancestors of a transaction up to maxDepth.
503431func (g * TxGraph ) GetAncestors (hash chainhash.Hash ,
504432 maxDepth int ) map [chainhash.Hash ]* TxGraphNode {
@@ -511,13 +439,6 @@ func (g *TxGraph) GetAncestors(hash chainhash.Hash,
511439 return nil
512440 }
513441
514- // Check cache if enabled.
515- if g .config .EnableCaching &&
516- time .Since (node .cachedMetrics .LastUpdated ) < g .config .CacheTimeout {
517- // For now, skip cache and compute directly.
518- // TODO: Implement proper caching.
519- }
520-
521442 ancestors := make (map [chainhash.Hash ]* TxGraphNode )
522443 visited := make (map [chainhash.Hash ]bool )
523444 g .collectAncestorsRecursive (node , ancestors , visited , 0 , maxDepth )
@@ -798,8 +719,6 @@ func (g *TxGraph) createNewCluster(node *TxGraphNode) {
798719 }
799720
800721 cluster .Nodes [node .TxHash ] = node
801- cluster .Roots = []* TxGraphNode {node }
802- cluster .Leaves = []* TxGraphNode {node }
803722
804723 g .indexes .clusters [clusterID ] = cluster
805724 g .indexes .nodeToCluster [node .TxHash ] = clusterID
@@ -822,9 +741,6 @@ func (g *TxGraph) addToCluster(node *TxGraphNode, clusterID ClusterID) {
822741 g .indexes .nodeToCluster [node .TxHash ] = clusterID
823742
824743 node .Metadata .ClusterID = clusterID
825-
826- // Update roots and leaves.
827- g .updateClusterBoundaries (cluster )
828744}
829745
830746// mergeClusters merges multiple clusters into one.
@@ -878,7 +794,6 @@ func (g *TxGraph) mergeClusters(
878794 }
879795
880796 targetCluster .Size = len (targetCluster .Nodes )
881- g .updateClusterBoundaries (targetCluster )
882797}
883798
884799// mergeNodeClusters merges clusters when adding an edge.
@@ -897,18 +812,3 @@ func (g *TxGraph) mergeNodeClusters(parent, child *TxGraphNode) {
897812 g .mergeClusters (parent , clusters )
898813}
899814
900- // updateClusterBoundaries updates roots and leaves of a cluster.
901- func (g * TxGraph ) updateClusterBoundaries (cluster * TxCluster ) {
902- cluster .Roots = nil
903- cluster .Leaves = nil
904-
905- for _ , node := range cluster .Nodes {
906- if len (node .Parents ) == 0 {
907- cluster .Roots = append (cluster .Roots , node )
908- }
909- if len (node .Children ) == 0 {
910- cluster .Leaves = append (cluster .Leaves , node )
911- }
912- }
913- }
914-
0 commit comments