Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Nov 4, 2024
1 parent 9bfd8c7 commit 05b3cc2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions explorer/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,19 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) []Event {
fces := make(map[types.FileContractID]types.FileContractElement)
v2fces := make(map[types.FileContractID]types.V2FileContractElement)
cu.ForEachSiacoinElement(func(sce types.SiacoinElement, created, spent bool) {
sce.MerkleProof = nil
sce.StateElement.MerkleProof = nil
sces[types.SiacoinOutputID(sce.ID)] = sce
})
cu.ForEachSiafundElement(func(sfe types.SiafundElement, created, spent bool) {
sfe.MerkleProof = nil
sfe.StateElement.MerkleProof = nil
sfes[types.SiafundOutputID(sfe.ID)] = sfe
})
cu.ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool) {
fce.MerkleProof = nil
fce.StateElement.MerkleProof = nil
fces[types.FileContractID(fce.ID)] = fce
})
cu.ForEachV2FileContractElement(func(fce types.V2FileContractElement, created bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) {
fce.MerkleProof = nil
fce.StateElement.MerkleProof = nil
v2fces[types.FileContractID(fce.ID)] = fce
})

Expand Down Expand Up @@ -220,7 +220,7 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) []Event {
var e EventV2Transaction
for _, a := range txn.Attestations {
var ha chain.HostAnnouncement
if ha.FromAttestation(a) {
if ha.FromArbitraryData(a.Value) {
e.HostAnnouncements = append(e.HostAnnouncements, ha)
}
}
Expand Down
6 changes: 3 additions & 3 deletions explorer/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate) error {
if created && spent {
ephemeralSiacoinElements = append(ephemeralSiacoinElements, SiacoinOutput{
SiacoinElement: se,
Source: sources[types.SiacoinOutputID(se.StateElement.ID)],
Source: sources[types.SiacoinOutputID(se.ID)],
})
return
}

if spent {
spentSiacoinElements = append(spentSiacoinElements, SiacoinOutput{
SiacoinElement: se,
Source: sources[types.SiacoinOutputID(se.StateElement.ID)],
Source: sources[types.SiacoinOutputID(se.ID)],
})
} else {
newSiacoinElements = append(newSiacoinElements, SiacoinOutput{
SiacoinElement: se,
Source: sources[types.SiacoinOutputID(se.StateElement.ID)],
Source: sources[types.SiacoinOutputID(se.ID)],
})
}
})
Expand Down
10 changes: 5 additions & 5 deletions persist/sqlite/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ func scanEvent(tx *txn, s scanner) (ev explorer.Event, eventID int64, err error)
FROM contract_payout_events ev
JOIN siacoin_elements sce ON ev.output_id = sce.id
JOIN file_contract_elements fce ON ev.contract_id = fce.id
WHERE ev.event_id = ?`, eventID).Scan(decode(&m.SiacoinOutput.StateElement.ID), decode(&m.SiacoinOutput.StateElement.LeafIndex), &m.SiacoinOutput.MaturityHeight, decode(&m.SiacoinOutput.SiacoinOutput.Address), decode(&m.SiacoinOutput.SiacoinOutput.Value), decode(&m.FileContract.StateElement.ID), decode(&m.FileContract.StateElement.LeafIndex), decode(&m.FileContract.FileContract.Filesize), decode(&m.FileContract.FileContract.FileMerkleRoot), decode(&m.FileContract.FileContract.WindowStart), decode(&m.FileContract.FileContract.WindowEnd), decode(&m.FileContract.FileContract.Payout), decode(&m.FileContract.FileContract.UnlockHash), decode(&m.FileContract.FileContract.RevisionNumber), &m.Missed)
WHERE ev.event_id = ?`, eventID).Scan(decode(&m.SiacoinOutput.ID), decode(&m.SiacoinOutput.StateElement.LeafIndex), &m.SiacoinOutput.MaturityHeight, decode(&m.SiacoinOutput.SiacoinOutput.Address), decode(&m.SiacoinOutput.SiacoinOutput.Value), decode(&m.FileContract.ID), decode(&m.FileContract.StateElement.LeafIndex), decode(&m.FileContract.FileContract.Filesize), decode(&m.FileContract.FileContract.FileMerkleRoot), decode(&m.FileContract.FileContract.WindowStart), decode(&m.FileContract.FileContract.WindowEnd), decode(&m.FileContract.FileContract.Payout), decode(&m.FileContract.FileContract.UnlockHash), decode(&m.FileContract.FileContract.RevisionNumber), &m.Missed)
ev.Data = &m
case explorer.EventTypeMinerPayout:
var m explorer.EventMinerPayout
err = tx.QueryRow(`SELECT sc.output_id, sc.leaf_index, sc.maturity_height, sc.address, sc.value
FROM siacoin_elements sc
INNER JOIN miner_payout_events ev ON (ev.output_id = sc.id)
WHERE ev.event_id = ?`, eventID).Scan(decode(&m.SiacoinOutput.StateElement.ID), decode(&m.SiacoinOutput.StateElement.LeafIndex), decode(&m.SiacoinOutput.MaturityHeight), decode(&m.SiacoinOutput.SiacoinOutput.Address), decode(&m.SiacoinOutput.SiacoinOutput.Value))
WHERE ev.event_id = ?`, eventID).Scan(decode(&m.SiacoinOutput.ID), decode(&m.SiacoinOutput.StateElement.LeafIndex), decode(&m.SiacoinOutput.MaturityHeight), decode(&m.SiacoinOutput.SiacoinOutput.Address), decode(&m.SiacoinOutput.SiacoinOutput.Value))
if err != nil {
return explorer.Event{}, 0, fmt.Errorf("failed to fetch miner payout event data: %w", err)
}
Expand All @@ -86,7 +86,7 @@ WHERE ev.event_id = ?`, eventID).Scan(decode(&m.SiacoinOutput.StateElement.ID),
err = tx.QueryRow(`SELECT sc.output_id, sc.leaf_index, sc.maturity_height, sc.address, sc.value
FROM siacoin_elements sc
INNER JOIN foundation_subsidy_events ev ON (ev.output_id = sc.id)
WHERE ev.event_id = ?`, eventID).Scan(decode(&m.SiacoinOutput.StateElement.ID), decode(&m.SiacoinOutput.StateElement.LeafIndex), decode(&m.SiacoinOutput.MaturityHeight), decode(&m.SiacoinOutput.SiacoinOutput.Address), decode(&m.SiacoinOutput.SiacoinOutput.Value))
WHERE ev.event_id = ?`, eventID).Scan(decode(&m.SiacoinOutput.ID), decode(&m.SiacoinOutput.StateElement.LeafIndex), decode(&m.SiacoinOutput.MaturityHeight), decode(&m.SiacoinOutput.SiacoinOutput.Address), decode(&m.SiacoinOutput.SiacoinOutput.Value))
ev.Data = &m
default:
return explorer.Event{}, 0, fmt.Errorf("unknown event type: %s", eventType)
Expand Down Expand Up @@ -180,7 +180,7 @@ func (s *Store) AddressEvents(address types.Address, offset, limit uint64) (even

func scanSiacoinOutput(s scanner) (sco explorer.SiacoinOutput, err error) {
var spentIndex types.ChainIndex
err = s.Scan(decode(&sco.StateElement.ID), decode(&sco.StateElement.LeafIndex), &sco.Source, decodeNull(&spentIndex), &sco.MaturityHeight, decode(&sco.SiacoinOutput.Address), decode(&sco.SiacoinOutput.Value))
err = s.Scan(decode(&sco.ID), decode(&sco.StateElement.LeafIndex), &sco.Source, decodeNull(&spentIndex), &sco.MaturityHeight, decode(&sco.SiacoinOutput.Address), decode(&sco.SiacoinOutput.Value))
if spentIndex != (types.ChainIndex{}) {
sco.SpentIndex = &spentIndex
}
Expand All @@ -189,7 +189,7 @@ func scanSiacoinOutput(s scanner) (sco explorer.SiacoinOutput, err error) {

func scanSiafundOutput(s scanner) (sfo explorer.SiafundOutput, err error) {
var spentIndex types.ChainIndex
err = s.Scan(decode(&sfo.StateElement.ID), decode(&sfo.StateElement.LeafIndex), decodeNull(&spentIndex), decode(&sfo.ClaimStart), decode(&sfo.SiafundOutput.Address), decode(&sfo.SiafundOutput.Value))
err = s.Scan(decode(&sfo.ID), decode(&sfo.StateElement.LeafIndex), decodeNull(&spentIndex), decode(&sfo.ClaimStart), decode(&sfo.SiafundOutput.Address), decode(&sfo.SiafundOutput.Value))
if spentIndex != (types.ChainIndex{}) {
sfo.SpentIndex = &spentIndex
}
Expand Down
20 changes: 10 additions & 10 deletions persist/sqlite/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ func addSiacoinElements(tx *txn, index types.ChainIndex, spentElements, newEleme
defer stmt.Close()

for _, sce := range newElements {
result, err := stmt.Exec(encode(sce.StateElement.ID), encode(index.ID), encode(sce.StateElement.LeafIndex), int(sce.Source), sce.MaturityHeight, encode(sce.SiacoinOutput.Address), encode(sce.SiacoinOutput.Value), encode(sce.StateElement.LeafIndex))
result, err := stmt.Exec(encode(sce.ID), encode(index.ID), encode(sce.StateElement.LeafIndex), int(sce.Source), sce.MaturityHeight, encode(sce.SiacoinOutput.Address), encode(sce.SiacoinOutput.Value), encode(sce.StateElement.LeafIndex))
if err != nil {
return nil, fmt.Errorf("addSiacoinElements: failed to execute siacoin_elements statement: %w", err)
}
Expand All @@ -517,7 +517,7 @@ func addSiacoinElements(tx *txn, index types.ChainIndex, spentElements, newEleme
return nil, fmt.Errorf("addSiacoinElements: failed to get last insert ID: %w", err)
}

scDBIds[types.SiacoinOutputID(sce.StateElement.ID)] = dbID
scDBIds[types.SiacoinOutputID(sce.ID)] = dbID
}
}
if len(spentElements) > 0 {
Expand All @@ -531,7 +531,7 @@ func addSiacoinElements(tx *txn, index types.ChainIndex, spentElements, newEleme
defer stmt.Close()

for _, sce := range spentElements {
result, err := stmt.Exec(encode(sce.StateElement.ID), encode(index.ID), encode(sce.StateElement.LeafIndex), encode(index), int(sce.Source), sce.MaturityHeight, encode(sce.SiacoinOutput.Address), encode(sce.SiacoinOutput.Value), encode(index), encode(sce.StateElement.LeafIndex))
result, err := stmt.Exec(encode(sce.ID), encode(index.ID), encode(sce.StateElement.LeafIndex), encode(index), int(sce.Source), sce.MaturityHeight, encode(sce.SiacoinOutput.Address), encode(sce.SiacoinOutput.Value), encode(index), encode(sce.StateElement.LeafIndex))
if err != nil {
return nil, fmt.Errorf("addSiacoinElements: failed to execute siacoin_elements statement: %w", err)
}
Expand All @@ -541,7 +541,7 @@ func addSiacoinElements(tx *txn, index types.ChainIndex, spentElements, newEleme
return nil, fmt.Errorf("addSiacoinElements: failed to get last insert ID: %w", err)
}

scDBIds[types.SiacoinOutputID(sce.StateElement.ID)] = dbID
scDBIds[types.SiacoinOutputID(sce.ID)] = dbID
}
}

Expand All @@ -561,7 +561,7 @@ func addSiafundElements(tx *txn, index types.ChainIndex, spentElements, newEleme
defer stmt.Close()

for _, sfe := range newElements {
result, err := stmt.Exec(encode(sfe.StateElement.ID), encode(index.ID), encode(sfe.StateElement.LeafIndex), encode(sfe.ClaimStart), encode(sfe.SiafundOutput.Address), encode(sfe.SiafundOutput.Value), encode(sfe.StateElement.LeafIndex))
result, err := stmt.Exec(encode(sfe.ID), encode(index.ID), encode(sfe.StateElement.LeafIndex), encode(sfe.ClaimStart), encode(sfe.SiafundOutput.Address), encode(sfe.SiafundOutput.Value), encode(sfe.StateElement.LeafIndex))
if err != nil {
return nil, fmt.Errorf("addSiafundElements: failed to execute siafund_elements statement: %w", err)
}
Expand All @@ -571,7 +571,7 @@ func addSiafundElements(tx *txn, index types.ChainIndex, spentElements, newEleme
return nil, fmt.Errorf("addSiafundElements: failed to get last insert ID: %w", err)
}

sfDBIds[types.SiafundOutputID(sfe.StateElement.ID)] = dbID
sfDBIds[types.SiafundOutputID(sfe.ID)] = dbID
}
}
if len(spentElements) > 0 {
Expand All @@ -585,7 +585,7 @@ func addSiafundElements(tx *txn, index types.ChainIndex, spentElements, newEleme
defer stmt.Close()

for _, sfe := range spentElements {
result, err := stmt.Exec(encode(sfe.StateElement.ID), encode(index.ID), encode(sfe.StateElement.LeafIndex), encode(index), encode(sfe.ClaimStart), encode(sfe.SiafundOutput.Address), encode(sfe.SiafundOutput.Value), encode(sfe.StateElement.LeafIndex), encode(index))
result, err := stmt.Exec(encode(sfe.ID), encode(index.ID), encode(sfe.StateElement.LeafIndex), encode(index), encode(sfe.ClaimStart), encode(sfe.SiafundOutput.Address), encode(sfe.SiafundOutput.Value), encode(sfe.StateElement.LeafIndex), encode(index))
if err != nil {
return nil, fmt.Errorf("addSiafundElements: failed to execute siafund_elements statement: %w", err)
}
Expand All @@ -595,7 +595,7 @@ func addSiafundElements(tx *txn, index types.ChainIndex, spentElements, newEleme
return nil, fmt.Errorf("addSiafundElements: failed to get last insert ID: %w", err)
}

sfDBIds[types.SiafundOutputID(sfe.StateElement.ID)] = dbID
sfDBIds[types.SiafundOutputID(sfe.ID)] = dbID
}
}
return sfDBIds, nil
Expand Down Expand Up @@ -732,7 +732,7 @@ func addEvents(tx *txn, scDBIds map[types.SiacoinOutputID]int64, fcDBIds map[exp
case *explorer.EventMinerPayout:
_, err = minerPayoutEventStmt.Exec(eventID, scDBIds[types.SiacoinOutputID(event.ID)])
case *explorer.EventContractPayout:
_, err = contractPayoutEventStmt.Exec(eventID, scDBIds[types.SiacoinOutputID(v.SiacoinOutput.StateElement.ID)], fcDBIds[explorer.DBFileContract{ID: types.FileContractID(v.FileContract.StateElement.ID), RevisionNumber: v.FileContract.FileContract.RevisionNumber}], v.Missed)
_, err = contractPayoutEventStmt.Exec(eventID, scDBIds[types.SiacoinOutputID(v.SiacoinOutput.ID)], fcDBIds[explorer.DBFileContract{ID: types.FileContractID(v.FileContract.ID), RevisionNumber: v.FileContract.FileContract.RevisionNumber}], v.Missed)
case *explorer.EventFoundationSubsidy:
_, err = foundationSubsidyEventStmt.Exec(eventID, scDBIds[types.SiacoinOutputID(event.ID)])
default:
Expand Down Expand Up @@ -917,7 +917,7 @@ func updateFileContractElements(tx *txn, revert bool, b types.Block, fces []expl
}

if err := addFC(
types.FileContractID(fce.StateElement.ID),
types.FileContractID(fce.ID),
fce.StateElement.LeafIndex,
fce.FileContract,
update.Resolved,
Expand Down
4 changes: 2 additions & 2 deletions persist/sqlite/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func TestSendTransactions(t *testing.T) {
}

testutil.SignTransaction(cm.TipState(), pk1, &parentTxn)
scOutputID = types.Hash256(parentTxn.SiacoinOutputID(2))
scOutputID = types.SiacoinOutputID(parentTxn.SiacoinOutputID(2))
sfOutputID = parentTxn.SiafundOutputID(2)

// Mine a block with the above transaction
Expand Down Expand Up @@ -1438,7 +1438,7 @@ func TestRevertSendTransactions(t *testing.T) {
}

testutil.SignTransaction(cm.TipState(), pk1, &parentTxn)
scOutputID = types.Hash256(parentTxn.SiacoinOutputID(2))
scOutputID = types.SiacoinOutputID(parentTxn.SiacoinOutputID(2))
sfOutputID = parentTxn.SiafundOutputID(2)

// Mine a block with the above transaction
Expand Down
2 changes: 1 addition & 1 deletion persist/sqlite/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func encodedIDs(ids []types.FileContractID) []any {
func scanFileContract(s scanner) (contractID int64, fc explorer.FileContract, err error) {
var confirmationIndex, proofIndex types.ChainIndex
var confirmationTransactionID, proofTransactionID types.TransactionID
err = s.Scan(&contractID, decode(&fc.StateElement.ID), decode(&fc.StateElement.LeafIndex), &fc.Resolved, &fc.Valid, decode(&fc.TransactionID), decodeNull(&confirmationIndex), decodeNull(&confirmationTransactionID), decodeNull(&proofIndex), decodeNull(&proofTransactionID), decode(&fc.FileContract.Filesize), decode(&fc.FileContract.FileMerkleRoot), decode(&fc.FileContract.WindowStart), decode(&fc.FileContract.WindowEnd), decode(&fc.FileContract.Payout), decode(&fc.FileContract.UnlockHash), decode(&fc.FileContract.RevisionNumber))
err = s.Scan(&contractID, decode(&fc.ID), decode(&fc.StateElement.LeafIndex), &fc.Resolved, &fc.Valid, decode(&fc.TransactionID), decodeNull(&confirmationIndex), decodeNull(&confirmationTransactionID), decodeNull(&proofIndex), decodeNull(&proofTransactionID), decode(&fc.FileContract.Filesize), decode(&fc.FileContract.FileMerkleRoot), decode(&fc.FileContract.WindowStart), decode(&fc.FileContract.WindowEnd), decode(&fc.FileContract.Payout), decode(&fc.FileContract.UnlockHash), decode(&fc.FileContract.RevisionNumber))

if confirmationIndex != (types.ChainIndex{}) {
fc.ConfirmationIndex = &confirmationIndex
Expand Down
Loading

0 comments on commit 05b3cc2

Please sign in to comment.