Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the all-dependencies group with 3 updates #48

Merged
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
18 changes: 9 additions & 9 deletions explorer/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ type EventContractPayout struct {

// A ChainUpdate is a set of changes to the consensus state.
type ChainUpdate interface {
ForEachSiacoinElement(func(sce types.SiacoinElement, spent bool))
ForEachSiafundElement(func(sfe types.SiafundElement, spent bool))
ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool))
ForEachV2FileContractElement(func(fce types.V2FileContractElement, rev *types.V2FileContractElement, res types.V2FileContractResolutionType))
ForEachSiacoinElement(func(sce types.SiacoinElement, created, spent bool))
ForEachSiafundElement(func(sfe types.SiafundElement, created, spent bool))
ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool))
ForEachV2FileContractElement(func(fce types.V2FileContractElement, created bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType))
}

// AppliedEvents extracts a list of relevant events from a chain update.
Expand Down Expand Up @@ -139,19 +139,19 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) []Event {
sfes := make(map[types.SiafundOutputID]types.SiafundElement)
fces := make(map[types.FileContractID]types.FileContractElement)
v2fces := make(map[types.FileContractID]types.V2FileContractElement)
cu.ForEachSiacoinElement(func(sce types.SiacoinElement, spent bool) {
cu.ForEachSiacoinElement(func(sce types.SiacoinElement, created, spent bool) {
sce.MerkleProof = nil
sces[types.SiacoinOutputID(sce.ID)] = sce
})
cu.ForEachSiafundElement(func(sfe types.SiafundElement, spent bool) {
cu.ForEachSiafundElement(func(sfe types.SiafundElement, created, spent bool) {
sfe.MerkleProof = nil
sfes[types.SiafundOutputID(sfe.ID)] = sfe
})
cu.ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool) {
cu.ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool) {
fce.MerkleProof = nil
fces[types.FileContractID(fce.ID)] = fce
})
cu.ForEachV2FileContractElement(func(fce types.V2FileContractElement, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) {
cu.ForEachV2FileContractElement(func(fce types.V2FileContractElement, created bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) {
fce.MerkleProof = nil
v2fces[types.FileContractID(fce.ID)] = fce
})
Expand Down Expand Up @@ -232,7 +232,7 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) []Event {
}

// handle missed contracts
cu.ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool) {
cu.ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool) {
if !resolved {
return
}
Expand Down
54 changes: 10 additions & 44 deletions explorer/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,11 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate) error {
}
}

created := make(map[types.Hash256]bool)
ephemeral := make(map[types.Hash256]bool)
for _, txn := range cau.Block.Transactions {
for i := range txn.SiacoinOutputs {
created[types.Hash256(txn.SiacoinOutputID(i))] = true
}
for _, input := range txn.SiacoinInputs {
ephemeral[types.Hash256(input.ParentID)] = created[types.Hash256(input.ParentID)]
}
for i := range txn.SiafundOutputs {
created[types.Hash256(txn.SiafundOutputID(i))] = true
}
for _, input := range txn.SiafundInputs {
ephemeral[types.Hash256(input.ParentID)] = created[types.Hash256(input.ParentID)]
}
}

// add new siacoin elements to the store
var newSiacoinElements, spentSiacoinElements []SiacoinOutput
var ephemeralSiacoinElements []SiacoinOutput
cau.ForEachSiacoinElement(func(se types.SiacoinElement, spent bool) {
if ephemeral[se.ID] {
cau.ForEachSiacoinElement(func(se types.SiacoinElement, created, spent bool) {
if created && spent {
ephemeralSiacoinElements = append(ephemeralSiacoinElements, SiacoinOutput{
SiacoinElement: se,
Source: sources[types.SiacoinOutputID(se.StateElement.ID)],
Expand All @@ -124,8 +107,8 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate) error {

var newSiafundElements, spentSiafundElements []types.SiafundElement
var ephemeralSiafundElements []types.SiafundElement
cau.ForEachSiafundElement(func(se types.SiafundElement, spent bool) {
if ephemeral[se.ID] {
cau.ForEachSiafundElement(func(se types.SiafundElement, created, spent bool) {
if created && spent {
ephemeralSiafundElements = append(ephemeralSiafundElements, se)
return
}
Expand All @@ -138,7 +121,7 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate) error {
})

var fces []FileContractUpdate
cau.ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool) {
cau.ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool) {
fces = append(fces, FileContractUpdate{
FileContractElement: fce,
Revision: rev,
Expand Down Expand Up @@ -180,28 +163,11 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate) error {

// revertChainUpdate atomically reverts a chain update from a store
func revertChainUpdate(tx UpdateTx, cru chain.RevertUpdate, revertedIndex types.ChainIndex) error {
created := make(map[types.Hash256]bool)
ephemeral := make(map[types.Hash256]bool)
for _, txn := range cru.Block.Transactions {
for i := range txn.SiacoinOutputs {
created[types.Hash256(txn.SiacoinOutputID(i))] = true
}
for _, input := range txn.SiacoinInputs {
ephemeral[types.Hash256(input.ParentID)] = created[types.Hash256(input.ParentID)]
}
for i := range txn.SiafundOutputs {
created[types.Hash256(txn.SiafundOutputID(i))] = true
}
for _, input := range txn.SiafundInputs {
ephemeral[types.Hash256(input.ParentID)] = created[types.Hash256(input.ParentID)]
}
}

// add new siacoin elements to the store
var newSiacoinElements, spentSiacoinElements []SiacoinOutput
var ephemeralSiacoinElements []SiacoinOutput
cru.ForEachSiacoinElement(func(se types.SiacoinElement, spent bool) {
if ephemeral[se.ID] {
cru.ForEachSiacoinElement(func(se types.SiacoinElement, created, spent bool) {
if created && spent {
ephemeralSiacoinElements = append(ephemeralSiacoinElements, SiacoinOutput{
SiacoinElement: se,
})
Expand All @@ -221,8 +187,8 @@ func revertChainUpdate(tx UpdateTx, cru chain.RevertUpdate, revertedIndex types.

var newSiafundElements, spentSiafundElements []types.SiafundElement
var ephemeralSiafundElements []types.SiafundElement
cru.ForEachSiafundElement(func(se types.SiafundElement, spent bool) {
if ephemeral[se.ID] {
cru.ForEachSiafundElement(func(se types.SiafundElement, created, spent bool) {
if created && spent {
ephemeralSiafundElements = append(ephemeralSiafundElements, se)
return
}
Expand All @@ -235,7 +201,7 @@ func revertChainUpdate(tx UpdateTx, cru chain.RevertUpdate, revertedIndex types.
})

var fces []FileContractUpdate
cru.ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool) {
cru.ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool) {
fces = append(fces, FileContractUpdate{
FileContractElement: fce,
Revision: rev,
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ toolchain go1.22.4
require (
github.com/mattn/go-sqlite3 v1.14.22
go.etcd.io/bbolt v1.3.10
go.sia.tech/core v0.2.7
go.sia.tech/coreutils v0.0.6
go.sia.tech/jape v0.11.1
go.sia.tech/core v0.3.0
go.sia.tech/coreutils v0.1.0
go.sia.tech/jape v0.12.0
go.uber.org/zap v1.27.0
lukechampine.com/frand v1.4.2
lukechampine.com/upnp v0.3.0
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0=
go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ=
go.sia.tech/core v0.2.7 h1:9Q/3BHL6ziAMPeiko863hhTD/Zs2s7OqEUiPKouDny8=
go.sia.tech/core v0.2.7/go.mod h1:BMgT/reXtgv6XbDgUYTCPY7wSMbspDRDs7KMi1vL6Iw=
go.sia.tech/coreutils v0.0.6 h1:xLpv3JyvbOoXcX3gC6a6Y3zQ/MZn/fyFvuPIzv/e/Eg=
go.sia.tech/coreutils v0.0.6/go.mod h1:EiDcQk2qLuP32Qoj/XphY9fbjTXphJhJZMERoC4LF0c=
go.sia.tech/jape v0.11.1 h1:M7IP+byXL7xOqzxcHUQuXW+q3sYMkYzmMlMw+q8ZZw0=
go.sia.tech/jape v0.11.1/go.mod h1:4QqmBB+t3W7cNplXPj++ZqpoUb2PeiS66RLpXmEGap4=
go.sia.tech/core v0.3.0 h1:PDfAQh9z8PYD+oeVS7rS9SEnTMOZzwwFfAH45yktmko=
go.sia.tech/core v0.3.0/go.mod h1:BMgT/reXtgv6XbDgUYTCPY7wSMbspDRDs7KMi1vL6Iw=
go.sia.tech/coreutils v0.1.0 h1:WQL7iT+jK1BiMx87bASXrZJZf4N2fbQkIOW8rS7wkh4=
go.sia.tech/coreutils v0.1.0/go.mod h1:ybaFgewKXrlxFW71LqsyQlxjG6yWL6BSePrbZYnrprU=
go.sia.tech/jape v0.12.0 h1:13fBi7c5X8zxTQ05Cd9ZsIfRJgdvGoZqbEzH861z7BU=
go.sia.tech/jape v0.12.0/go.mod h1:wU+h6Wh5olDjkPXjF0tbZ1GDgoZ6VTi4naFw91yyWC4=
go.sia.tech/mux v1.2.0 h1:ofa1Us9mdymBbGMY2XH/lSpY8itFsKIo/Aq8zwe+GHU=
go.sia.tech/mux v1.2.0/go.mod h1:Yyo6wZelOYTyvrHmJZ6aQfRoer3o4xyKQ4NmQLJrBSo=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
Expand Down