Skip to content

Commit

Permalink
all: upgrade coreutils
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Mar 14, 2024
1 parent 7f2a8d7 commit e3ce6e4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 129 deletions.
38 changes: 1 addition & 37 deletions bus/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ func (b *bus) walletPrepareFormHandler(jc jape.Context) {
return
}

b.w.SignTransaction(&txn, toSign, ExplicitCoveredFields(txn))
b.w.SignTransaction(&txn, toSign, wallet.ExplicitCoveredFields(txn))

jc.Encode(append(b.cm.UnconfirmedParents(txn), txn))
}
Expand Down Expand Up @@ -2387,42 +2387,6 @@ func (b *bus) multipartHandlerListPartsPOST(jc jape.Context) {
jc.Encode(resp)
}

// ExplicitCoveredFields returns a CoveredFields that covers all elements
// present in txn.
func ExplicitCoveredFields(txn types.Transaction) (cf types.CoveredFields) {
for i := range txn.SiacoinInputs {
cf.SiacoinInputs = append(cf.SiacoinInputs, uint64(i))
}
for i := range txn.SiacoinOutputs {
cf.SiacoinOutputs = append(cf.SiacoinOutputs, uint64(i))
}
for i := range txn.FileContracts {
cf.FileContracts = append(cf.FileContracts, uint64(i))
}
for i := range txn.FileContractRevisions {
cf.FileContractRevisions = append(cf.FileContractRevisions, uint64(i))
}
for i := range txn.StorageProofs {
cf.StorageProofs = append(cf.StorageProofs, uint64(i))
}
for i := range txn.SiafundInputs {
cf.SiafundInputs = append(cf.SiafundInputs, uint64(i))
}
for i := range txn.SiafundOutputs {
cf.SiafundOutputs = append(cf.SiafundOutputs, uint64(i))
}
for i := range txn.MinerFees {
cf.MinerFees = append(cf.MinerFees, uint64(i))
}
for i := range txn.ArbitraryData {
cf.ArbitraryData = append(cf.ArbitraryData, uint64(i))
}
for i := range txn.Signatures {
cf.Signatures = append(cf.Signatures, uint64(i))
}
return
}

// New returns a new Bus.
func New(am alerts.Alerter, hm WebhookManager, cm ChainManager, s Syncer, w Wallet, hdb HostDB, as AutopilotStore, ms MetadataStore, ss SettingStore, eas EphemeralAccountStore, mtrcs MetricsStore, l *zap.Logger) (*bus, error) {
b := &bus{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/montanaflynn/stats v0.7.1
gitlab.com/NebulousLabs/encoding v0.0.0-20200604091946-456c3dc907fe
go.sia.tech/core v0.2.1
go.sia.tech/coreutils v0.0.4-0.20240307153935-66de052e7ef7
go.sia.tech/coreutils v0.0.4-0.20240313143809-01b5d444a630
go.sia.tech/gofakes3 v0.0.0-20231109151325-e0d47c10dce2
go.sia.tech/hostd v1.0.2
go.sia.tech/jape v0.11.2-0.20240124024603-93559895d640
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ go.sia.tech/coreutils v0.0.4-0.20240306153355-9185ee5bb346 h1:HeZRhx0JEWLYZ9TZMA
go.sia.tech/coreutils v0.0.4-0.20240306153355-9185ee5bb346/go.mod h1:UBFc77wXiE//eyilO5HLOncIEj7F69j0Nv2OkFujtP0=
go.sia.tech/coreutils v0.0.4-0.20240307153935-66de052e7ef7 h1:XXIMhtB9mcR1PlwdkPT78gWaCMSTJ/xDwrOm+qJJBY4=
go.sia.tech/coreutils v0.0.4-0.20240307153935-66de052e7ef7/go.mod h1:OTMMLucKVcpMDCIwGQlvbi4QNgc3O2Y291xMheYrpOQ=
go.sia.tech/coreutils v0.0.4-0.20240313143809-01b5d444a630 h1:KpVSI9ijpyyjwXvxV0tSWK9ukFyTupibg9OrlvjiKDk=
go.sia.tech/coreutils v0.0.4-0.20240313143809-01b5d444a630/go.mod h1:QvsXghS4wqhJosQq3AkMjA2mJ6pbDB7PgG+w5b09/z0=
go.sia.tech/gofakes3 v0.0.0-20231109151325-e0d47c10dce2 h1:ulzfJNjxN5DjXHClkW2pTiDk+eJ+0NQhX87lFDZ03t0=
go.sia.tech/gofakes3 v0.0.0-20231109151325-e0d47c10dce2/go.mod h1:PlsiVCn6+wssrR7bsOIlZm0DahsVrDydrlbjY4F14sg=
go.sia.tech/hostd v1.0.2-beta.2.0.20240131203318-9d84aad6ef13 h1:JcyVUtJfzeMh+zJAW20BMVhBYekg+h0T8dMeF7GzAFs=
Expand Down
19 changes: 18 additions & 1 deletion internal/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,24 @@ func NewBus(cfg BusConfig, dir string, seed types.PrivateKey, logger *zap.Logger
if cfg.Network == nil {
return nil, nil, nil, errors.New("cannot bootstrap without a network")
}
bootstrap(*cfg.Network, sqlStore)

var bootstrapPeers []string
switch cfg.Network.Name {
case "mainnet":
bootstrapPeers = syncer.MainnetBootstrapPeers
case "zen":
bootstrapPeers = syncer.ZenBootstrapPeers
case "anagami":
bootstrapPeers = syncer.AnagamiBootstrapPeers
default:
return nil, nil, nil, fmt.Errorf("no available bootstrap peers for unknown network '%s'", cfg.Network.Name)
}

for _, addr := range bootstrapPeers {
if err := sqlStore.AddPeer(addr); err != nil {
return nil, nil, nil, fmt.Errorf("%w: failed to add bootstrap peer '%s'", err, addr)
}
}
}

// start the syncer
Expand Down
90 changes: 0 additions & 90 deletions internal/node/syncer.go

This file was deleted.

16 changes: 16 additions & 0 deletions stores/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ func (s *SQLStore) Peers() ([]syncer.PeerInfo, error) {
return infos, nil
}

// PeerInfo returns the metadata for the specified peer or ErrPeerNotFound
// if the peer wasn't found in the store.
func (s *SQLStore) PeerInfo(addr string) (syncer.PeerInfo, error) {
var peer dbSyncerPeer
err := s.db.
Where("address = ?", addr).
Take(&peer).
Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return syncer.PeerInfo{}, syncer.ErrPeerNotFound
} else if err != nil {
return syncer.PeerInfo{}, err
}
return peer.info(), nil
}

// UpdatePeerInfo updates the metadata for the specified peer. If the peer
// is not found, the error should be ErrPeerNotFound.
func (s *SQLStore) UpdatePeerInfo(addr string, fn func(*syncer.PeerInfo)) error {
Expand Down

0 comments on commit e3ce6e4

Please sign in to comment.