Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Dec 18, 2024
1 parent ed2d909 commit 511c4c7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions autopilot/contractor/contractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ func (c *Contractor) refreshContract(ctx *mCtx, contract contract, host api.Host
}

func (c *Contractor) renewContract(ctx *mCtx, contract contract, host api.Host, logger *zap.SugaredLogger) (cm api.ContractMetadata, proceed bool, err error) {
fmt.Println("contractor: renew")
if contract.Revision == nil {
return api.ContractMetadata{}, true, errors.New("can't renew contract without a revision")
}
Expand Down
2 changes: 2 additions & 0 deletions autopilot/contractor/hostfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ func (c *Contractor) isUsableContract(cfg api.AutopilotConfig, contract contract
usable = usable && contract.IsGood() && c.shouldForgiveFailedRefresh(contract.ID)
refresh = true
renew = false
fmt.Println("refresh, out of collateral", contract.RemainingCollateral(), MinCollateral, contract.ContractPrice, contract.Revision.MissedHostValue)
}
if contract.IsOutOfFunds() {
reasons = append(reasons, errContractOutOfFunds.Error())
usable = usable && contract.IsGood() && c.shouldForgiveFailedRefresh(contract.ID)
refresh = true
renew = false
fmt.Println("refresh, out of funds")
}
if shouldRenew, secondHalf := isUpForRenewal(cfg, contract.EndHeight(), bh); shouldRenew {
reasons = append(reasons, fmt.Errorf("%w; second half: %t", errContractUpForRenewal, secondHalf).Error())
Expand Down
1 change: 1 addition & 0 deletions bus/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ func (b *Bus) contractIDRenewHandlerPOST(jc jape.Context) {
}

// add the renewal
fmt.Println("renew handler")
metadata, err := b.addRenewal(ctx, contract)
if jc.Check("couldn't add renewal", err) == nil {
jc.Encode(metadata)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/montanaflynn/stats v0.7.1
github.com/shopspring/decimal v1.4.0
go.sia.tech/core v0.8.1-0.20241217152409-7950a7ca324b
go.sia.tech/coreutils v0.8.1-0.20241218134231-af7c48b09fd7
go.sia.tech/coreutils v0.8.1-0.20241218140128-03c2825e135b
go.sia.tech/gofakes3 v0.0.5
go.sia.tech/hostd v1.1.3-0.20241218083322-ae9c8a971fe0
go.sia.tech/jape v0.12.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
go.sia.tech/core v0.8.1-0.20241217152409-7950a7ca324b h1:VRkb6OOX1KawLQwuqOEHLcjha8gxVX0tAyu2Dyoq8Ek=
go.sia.tech/core v0.8.1-0.20241217152409-7950a7ca324b/go.mod h1:Wj1qzvpMM2rqEQjwWJEbCBbe9VWX/mSJUu2Y2ABl1QA=
go.sia.tech/coreutils v0.8.1-0.20241218134231-af7c48b09fd7 h1:slR3kyySkOXpOC9cslU8jPgs8FXrapaCad80QyCx8UY=
go.sia.tech/coreutils v0.8.1-0.20241218134231-af7c48b09fd7/go.mod h1:xhIbFjjkzmCF8Dt73ZvquaBQCT2Dje7AKYBRAesn93w=
go.sia.tech/coreutils v0.8.1-0.20241218140128-03c2825e135b h1:DIprjP9Q+8LCpW927i4AgMed717e8nHILj+yjFJ2Nv4=
go.sia.tech/coreutils v0.8.1-0.20241218140128-03c2825e135b/go.mod h1:xhIbFjjkzmCF8Dt73ZvquaBQCT2Dje7AKYBRAesn93w=
go.sia.tech/gofakes3 v0.0.5 h1:vFhVBUFbKE9ZplvLE2w4TQxFMQyF8qvgxV4TaTph+Vw=
go.sia.tech/gofakes3 v0.0.5/go.mod h1:LXEzwGw+OHysWLmagleCttX93cJZlT9rBu/icOZjQ54=
go.sia.tech/hostd v1.1.3-0.20241218083322-ae9c8a971fe0 h1:QtF8l+pHZq6gPyDyuQoMv8GdwU6lvz39y4I34S3cuvo=
Expand Down
1 change: 1 addition & 0 deletions stores/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (s *SQLStore) AddRenewal(ctx context.Context, c api.ContractMetadata) error
}

// reinsert renewed contract
fmt.Println("add renewal")
renewed.ArchivalReason = api.ContractArchivalReasonRenewed
renewed.RenewedTo = c.ID
renewed.Usability = api.ContractUsabilityBad
Expand Down

0 comments on commit 511c4c7

Please sign in to comment.