return only one array with necessary hashes for each index in order. Element's hash and root are not included eg. registered indexes are 1, 2, each needs 2 hashes then the function return an array of 4 hashes [a1, a2, b1, b2] where a1, a2 are proof branch for element at index 1 b1, b2 are proof bran
()
| 74 | // where a1, a2 are proof branch for element at index 1 |
| 75 | // b1, b2 are proof branch for element at index 2 |
| 76 | func (dt DagTree) AllBranchesArray() []smartpool.BranchElement { |
| 77 | if dt.finalized { |
| 78 | result := []smartpool.BranchElement{} |
| 79 | branches := dt.Branches() |
| 80 | for _, k := range dt.Indices() { |
| 81 | // p := proofs[k] |
| 82 | // fmt.Printf("Index: %d\nRawData: %s\nHashedData: %s\n", k, hex.EncodeToString(p.RawData[:]), proofs[k].HashedData.Hex()) |
| 83 | hashes := branches[k].ToNodeArray()[1:] |
| 84 | // fmt.Printf("Len proofs: %s\n", len(pfs)) |
| 85 | for i := 0; i*2 < len(hashes); i++ { |
| 86 | // for anyone who is courious why i*2 + 1 comes before i * 2 |
| 87 | // it's agreement between client side and contract side |
| 88 | if i*2+1 >= len(hashes) { |
| 89 | result = append(result, |
| 90 | smartpool.BranchElementFromHash( |
| 91 | smartpool.SPHash(DagData{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}), |
| 92 | smartpool.SPHash(hashes[i*2].(DagData)))) |
| 93 | } else { |
| 94 | result = append(result, |
| 95 | smartpool.BranchElementFromHash( |
| 96 | smartpool.SPHash(hashes[i*2+1].(DagData)), |
| 97 | smartpool.SPHash(hashes[i*2].(DagData)))) |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | return result |
| 102 | } |
| 103 | panic("SP Merkle tree needs to be finalized by calling mt.Finalize()") |
| 104 | } |
| 105 | |
| 106 | func (dt DagTree) AllDAGElements() []smartpool.Word { |
| 107 | if dt.finalized { |
no test coverage detected