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 2 updates #169

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
2 changes: 1 addition & 1 deletion cmd/explored/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func runRootCmd(ctx context.Context, log *zap.Logger) error {
}
s := syncer.New(syncerListener, cm, ps, header, syncer.WithLogger(log.Named("syncer")), syncer.WithMaxInboundPeers(256))
defer s.Close()
go s.Run(ctx)
go s.Run()

e, err := explorer.NewExplorer(cm, store, cfg.Index.BatchSize, cfg.Scanner, log.Named("explorer"))
if err != nil {
Expand Down
28 changes: 16 additions & 12 deletions explorer/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ func (e *Event) UnmarshalJSON(b []byte) error {

// A ChainUpdate is a set of changes to the consensus state.
type ChainUpdate interface {
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))
SiacoinElementDiffs() []consensus.SiacoinElementDiff
SiafundElementDiffs() []consensus.SiafundElementDiff
FileContractElementDiffs() []consensus.FileContractElementDiff
V2FileContractElementDiffs() []consensus.V2FileContractElementDiff
}

// RelevantAddressesV1 returns all the relevant addresses to a V1 transaction.
Expand Down Expand Up @@ -428,14 +428,16 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) (events []
// collect all elements
sces := make(map[types.SiacoinOutputID]types.SiacoinElement)
sfes := make(map[types.SiafundOutputID]types.SiafundElement)
cu.ForEachSiacoinElement(func(sce types.SiacoinElement, _, _ bool) {
for _, diff := range cu.SiacoinElementDiffs() {
sce := diff.SiacoinElement
sce.StateElement.MerkleProof = nil
sces[types.SiacoinOutputID(sce.ID)] = sce
})
cu.ForEachSiafundElement(func(sfe types.SiafundElement, _, _ bool) {
}
for _, diff := range cu.SiafundElementDiffs() {
sfe := diff.SiafundElement
sfe.StateElement.MerkleProof = nil
sfes[types.SiafundOutputID(sfe.ID)] = sfe
})
}

// handle v1 transactions
for _, txn := range b.Transactions {
Expand Down Expand Up @@ -471,7 +473,8 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) (events []
}

// handle contracts
cu.ForEachFileContractElement(func(fce types.FileContractElement, _ bool, rev *types.FileContractElement, resolved, valid bool) {
for _, diff := range cu.FileContractElementDiffs() {
fce, resolved, valid := diff.FileContractElement, diff.Resolved, diff.Valid
if !resolved {
return
}
Expand Down Expand Up @@ -521,9 +524,10 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) (events []
}, []types.Address{address})
}
}
})
}

cu.ForEachV2FileContractElement(func(fce types.V2FileContractElement, _ bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) {
for _, diff := range cu.V2FileContractElementDiffs() {
fce, res := diff.V2FileContractElement, diff.Resolution
if res == nil {
return
}
Expand Down Expand Up @@ -561,7 +565,7 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) (events []
}
addV2Resolution(sces[types.FileContractID(fce.ID).V2RenterOutputID()])
addV2Resolution(sces[types.FileContractID(fce.ID).V2HostOutputID()])
})
}

// handle block rewards
for i := range b.MinerPayouts {
Expand Down
88 changes: 54 additions & 34 deletions explorer/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate) error {
// add new siacoin elements to the store
var newSiacoinElements, spentSiacoinElements []SiacoinOutput
var ephemeralSiacoinElements []SiacoinOutput
cau.ForEachSiacoinElement(func(se types.SiacoinElement, created, spent bool) {
for _, diff := range cau.SiacoinElementDiffs() {
created, spent, se := diff.Created, diff.Spent, diff.SiacoinElement
if created && spent {
ephemeralSiacoinElements = append(ephemeralSiacoinElements, SiacoinOutput{
SiacoinElement: se,
Source: sources[se.ID],
})
return
continue
}

if spent {
Expand All @@ -123,32 +124,37 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate) error {
Source: sources[se.ID],
})
}
})
}

var newSiafundElements, spentSiafundElements []types.SiafundElement
var ephemeralSiafundElements []types.SiafundElement
cau.ForEachSiafundElement(func(se types.SiafundElement, created, spent bool) {
for _, diff := range cau.SiafundElementDiffs() {
created, spent, se := diff.Created, diff.Spent, diff.SiafundElement
if created && spent {
ephemeralSiafundElements = append(ephemeralSiafundElements, se)
return
continue
}

if spent {
spentSiafundElements = append(spentSiafundElements, se)
} else {
newSiafundElements = append(newSiafundElements, se)
}
})
}

fceMap := make(map[types.FileContractID]FileContractUpdate)
cau.ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool) {
fceMap[fce.ID] = FileContractUpdate{
FileContractElement: fce,
for _, diff := range cau.FileContractElementDiffs() {
var rev *types.FileContractElement
if revision, ok := diff.RevisionElement(); ok {
rev = &revision
}
fceMap[diff.FileContractElement.ID] = FileContractUpdate{
FileContractElement: diff.FileContractElement,
Revision: rev,
Resolved: resolved,
Valid: valid,
Resolved: diff.Resolved,
Valid: diff.Valid,
}
})
}
for _, txn := range cau.Block.Transactions {
txnID := txn.ID()
for i := range txn.FileContracts {
Expand All @@ -173,13 +179,17 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate) error {
}

v2FceMap := make(map[types.FileContractID]V2FileContractUpdate)
cau.ForEachV2FileContractElement(func(fce types.V2FileContractElement, created bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) {
v2FceMap[types.FileContractID(fce.ID)] = V2FileContractUpdate{
FileContractElement: fce,
for _, diff := range cau.V2FileContractElementDiffs() {
var rev *types.V2FileContractElement
if revision, ok := diff.V2RevisionElement(); ok {
rev = &revision
}
v2FceMap[types.FileContractID(diff.V2FileContractElement.ID)] = V2FileContractUpdate{
FileContractElement: diff.V2FileContractElement,
Revision: rev,
Resolution: res,
Resolution: diff.Resolution,
}
})
}
for _, txn := range cau.Block.V2Transactions() {
txnID := txn.ID()
for i := range txn.FileContracts {
Expand Down Expand Up @@ -290,12 +300,13 @@ func revertChainUpdate(tx UpdateTx, cru chain.RevertUpdate, revertedIndex types.
// add new siacoin elements to the store
var newSiacoinElements, spentSiacoinElements []SiacoinOutput
var ephemeralSiacoinElements []SiacoinOutput
cru.ForEachSiacoinElement(func(se types.SiacoinElement, created, spent bool) {
for _, diff := range cru.SiacoinElementDiffs() {
created, spent, se := diff.Created, diff.Spent, diff.SiacoinElement
if created && spent {
ephemeralSiacoinElements = append(ephemeralSiacoinElements, SiacoinOutput{
SiacoinElement: se,
})
return
continue
}

if spent {
Expand All @@ -307,32 +318,37 @@ func revertChainUpdate(tx UpdateTx, cru chain.RevertUpdate, revertedIndex types.
SiacoinElement: se,
})
}
})
}

var newSiafundElements, spentSiafundElements []types.SiafundElement
var ephemeralSiafundElements []types.SiafundElement
cru.ForEachSiafundElement(func(se types.SiafundElement, created, spent bool) {
for _, diff := range cru.SiafundElementDiffs() {
created, spent, se := diff.Created, diff.Spent, diff.SiafundElement
if created && spent {
ephemeralSiafundElements = append(ephemeralSiafundElements, se)
return
continue
}

if spent {
newSiafundElements = append(newSiafundElements, se)
} else {
spentSiafundElements = append(spentSiafundElements, se)
}
})
}

fceMap := make(map[types.FileContractID]FileContractUpdate)
cru.ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool) {
fceMap[fce.ID] = FileContractUpdate{
FileContractElement: fce,
for _, diff := range cru.FileContractElementDiffs() {
var rev *types.FileContractElement
if revision, ok := diff.RevisionElement(); ok {
rev = &revision
}
fceMap[diff.FileContractElement.ID] = FileContractUpdate{
FileContractElement: diff.FileContractElement,
Revision: rev,
Resolved: resolved,
Valid: valid,
Resolved: diff.Resolved,
Valid: diff.Valid,
}
})
}
for _, txn := range cru.Block.Transactions {
txnID := txn.ID()
for i := range txn.FileContracts {
Expand All @@ -357,13 +373,17 @@ func revertChainUpdate(tx UpdateTx, cru chain.RevertUpdate, revertedIndex types.
}

v2FceMap := make(map[types.FileContractID]V2FileContractUpdate)
cru.ForEachV2FileContractElement(func(fce types.V2FileContractElement, created bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) {
v2FceMap[types.FileContractID(fce.ID)] = V2FileContractUpdate{
FileContractElement: fce,
for _, diff := range cru.V2FileContractElementDiffs() {
var rev *types.V2FileContractElement
if revision, ok := diff.V2RevisionElement(); ok {
rev = &revision
}
v2FceMap[types.FileContractID(diff.V2FileContractElement.ID)] = V2FileContractUpdate{
FileContractElement: diff.V2FileContractElement,
Revision: rev,
Resolution: res,
Resolution: diff.Resolution,
}
})
}
for _, txn := range cru.Block.V2Transactions() {
txnID := txn.ID()
for i := range txn.FileContracts {
Expand Down
28 changes: 18 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/google/go-cmp v0.6.0
github.com/ip2location/ip2location-go v8.3.0+incompatible
github.com/mattn/go-sqlite3 v1.14.24
go.sia.tech/core v0.9.1
go.sia.tech/coreutils v0.10.1
go.sia.tech/core v0.10.2-0.20250211180922-261f960c1315
go.sia.tech/coreutils v0.11.1
go.sia.tech/jape v0.12.1
go.uber.org/zap v1.27.0
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -18,15 +18,23 @@ require (
)

require (
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/stretchr/testify v1.8.3 // indirect
go.etcd.io/bbolt v1.3.11 // indirect
github.com/onsi/ginkgo/v2 v2.12.0 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.49.0 // indirect
github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66 // indirect
go.etcd.io/bbolt v1.4.0 // indirect
go.sia.tech/mux v1.3.0 // indirect
go.uber.org/mock v0.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/tools v0.20.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/tools v0.22.0 // indirect
)
Loading