Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions persist/sqlite/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ func (s *Store) SiacoinElements(ids []types.SiacoinOutputID) (result []explorer.
if err != nil {
return fmt.Errorf("failed to scan siacoin output: %w", err)
}
sco.StateElement.MerkleProof, err = s.MerkleProof(sco.StateElement.LeafIndex)
if err != nil {
return fmt.Errorf("failed to get output merkle proof: %w", err)
}

result = append(result, sco)
}
return nil
Expand All @@ -199,6 +204,10 @@ func (s *Store) SiafundElements(ids []types.SiafundOutputID) (result []explorer.
if err != nil {
return fmt.Errorf("failed to scan siafund output: %w", err)
}
sfo.StateElement.MerkleProof, err = s.MerkleProof(sfo.StateElement.LeafIndex)
if err != nil {
return fmt.Errorf("failed to get output merkle proof: %w", err)
}
result = append(result, sfo)
}
return nil
Expand Down
27 changes: 3 additions & 24 deletions persist/sqlite/v2consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@ func getSCE(t *testing.T, db explorer.Store, scid types.SiacoinOutputID) types.S
} else if len(sces) == 0 {
t.Fatal("can't find sce")
}
sce := sces[0]

sce.SiacoinElement.StateElement.MerkleProof, err = db.MerkleProof(sce.StateElement.LeafIndex)
if err != nil {
t.Fatal(err)
}

return sce.SiacoinElement
return sces[0].SiacoinElement
}

func getSFE(t *testing.T, db explorer.Store, sfid types.SiafundOutputID) types.SiafundElement {
Expand All @@ -42,14 +35,7 @@ func getSFE(t *testing.T, db explorer.Store, sfid types.SiafundOutputID) types.S
} else if len(sfes) == 0 {
t.Fatal("can't find sfe")
}
sfe := sfes[0]

sfe.SiafundElement.StateElement.MerkleProof, err = db.MerkleProof(sfe.StateElement.LeafIndex)
if err != nil {
t.Fatal(err)
}

return sfe.SiafundElement
return sfes[0].SiafundElement
}

func getFCE(t *testing.T, db explorer.Store, fcid types.FileContractID) types.V2FileContractElement {
Expand All @@ -61,14 +47,7 @@ func getFCE(t *testing.T, db explorer.Store, fcid types.FileContractID) types.V2
} else if len(fces) == 0 {
t.Fatal("can't find fces")
}
fce := fces[0]

fce.V2FileContractElement.StateElement.MerkleProof, err = db.MerkleProof(fce.V2FileContractElement.StateElement.LeafIndex)
if err != nil {
t.Fatal(err)
}

return fce.V2FileContractElement
return fces[0].V2FileContractElement
}

func getCIE(t *testing.T, db explorer.Store, bid types.BlockID) types.ChainIndexElement {
Expand Down
4 changes: 4 additions & 0 deletions persist/sqlite/v2contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ WHERE rev.contract_id = ?
if err != nil && !errors.Is(err, sql.ErrNoRows) {
return fmt.Errorf("failed to scan file contract: %w", err)
} else if err == nil {
fc.V2FileContractElement.StateElement.MerkleProof, err = s.MerkleProof(fc.V2FileContractElement.StateElement.LeafIndex)
if err != nil {
return fmt.Errorf("failed to get contract merkle proof: %w", err)
}
result = append(result, fc)
}
}
Expand Down
Loading