Files
ark/asp/internal/core/domain/congestion_tree.go
Louis Singer 51bc673e66 Add covenant-based congestion tree (#62)
* covenant based tx builder

* remove relative time delta

* txbuilder/covenant add leaf boolean in node

* txbuilder/covenant final version

* support covenantType

* add GetLeafOutputScript

* remove printLn

* fix linting

* Update asp/internal/app-config/config.go

Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
Signed-off-by: Louis Singer <41042567+louisinger@users.noreply.github.com>

---------

Signed-off-by: Louis Singer <41042567+louisinger@users.noreply.github.com>
Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
2023-12-14 14:02:37 +01:00

45 lines
733 B
Go

package domain
type Node struct {
Txid string
Tx string
ParentTxid string
Leaf bool
}
type CongestionTree [][]Node
func (c CongestionTree) Leaves() []Node {
leaves := c[len(c)-1]
for _, level := range c[:len(c)-1] {
for _, node := range level {
if node.Leaf {
leaves = append(leaves, node)
}
}
}
return leaves
}
func (c CongestionTree) Children(nodeTxid string) []Node {
var children []Node
for _, level := range c {
for _, node := range level {
if node.ParentTxid == nodeTxid {
children = append(children, node)
}
}
}
return children
}
func (c CongestionTree) NumberOfNodes() int {
var count int
for _, level := range c {
count += len(level)
}
return count
}