Skip to content

Commit

Permalink
Merge pull request #190 from SiaFoundation/create-attestations
Browse files Browse the repository at this point in the history
consensus: Mark attestation elements as created
  • Loading branch information
n8maninger authored Aug 14, 2024
2 parents 9dffffb + faa6c86 commit ebc804c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion consensus/merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ func updateLeaves(leaves []elementLeaf) [64][]elementLeaf {
var recompute func(i, j uint64, leaves []elementLeaf) types.Hash256
recompute = func(i, j uint64, leaves []elementLeaf) types.Hash256 {
height := bits.TrailingZeros64(j - i) // equivalent to log2(j-i), as j-i is always a power of two
if len(leaves) == 1 && height == 0 {
if height == 0 {
if len(leaves) > 1 {
panic("consensus: multiple leaves with same accumulator index")
}
return leaves[0].hash()
}
mid := (i + j) / 2
Expand Down
1 change: 1 addition & 0 deletions consensus/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func (ms *MidState) resolveV2FileContractElement(fce types.V2FileContractElement

func (ms *MidState) addAttestationElement(ae types.AttestationElement) {
ms.aes = append(ms.aes, ae)
ms.created[ms.aes[len(ms.aes)-1].ID] = len(ms.aes) - 1
}

// ApplyTransaction applies a transaction to the MidState.
Expand Down

0 comments on commit ebc804c

Please sign in to comment.