Congestion tree validation (#84)

* add common/pkg/tree validation

* update noah go.mod

* cleaning and fixes

* fix builder_test.go

* Fix deferred func

* fix even number of vtxos in congestion tree

---------

Co-authored-by: altafan <18440657+altafan@users.noreply.github.com>
This commit is contained in:
Louis Singer
2024-01-23 15:38:43 +01:00
committed by GitHub
parent 3407fd277a
commit 5dba216a98
25 changed files with 1127 additions and 395 deletions

View File

@@ -7,6 +7,7 @@ import (
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/tree"
"github.com/ark-network/ark/internal/core/application"
"github.com/ark-network/ark/internal/core/domain"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
@@ -280,10 +281,10 @@ func (v vtxoList) toProto(hrp string, aspKey *secp256k1.PublicKey) []*arkv1.Vtxo
return list
}
// castCongestionTree converts a domain.CongestionTree to a repeated arkv1.TreeLevel
func castCongestionTree(tree domain.CongestionTree) *arkv1.Tree {
levels := make([]*arkv1.TreeLevel, 0, len(tree))
for _, level := range tree {
// castCongestionTree converts a tree.CongestionTree to a repeated arkv1.TreeLevel
func castCongestionTree(congestionTree tree.CongestionTree) *arkv1.Tree {
levels := make([]*arkv1.TreeLevel, 0, len(congestionTree))
for _, level := range congestionTree {
levelProto := &arkv1.TreeLevel{
Nodes: make([]*arkv1.Node, 0, len(level)),
}

View File

@@ -18,7 +18,7 @@ func parseTxs(txs []string) ([]string, error) {
}
for _, tx := range txs {
if _, err := psetv2.NewPsetFromBase64(tx); err != nil {
return nil, fmt.Errorf("invalid tx format %s", err)
return nil, fmt.Errorf("invalid tx format")
}
}
return txs, nil