mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-22 14:44:19 +01:00
* 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>
45 lines
733 B
Go
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
|
|
}
|