Skip to content

Commit

Permalink
settings: don't log announcement warning when validate is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Aug 20, 2024
1 parent 33477e5 commit be52ed2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ type (

RecommendedFee() types.Currency
AddPoolTransactions(txns []types.Transaction) (known bool, err error)
AddV2PoolTransactions(basis types.ChainIndex, txns []types.V2Transaction) (known bool, err error)
UnconfirmedParents(txn types.Transaction) []types.Transaction
AddV2PoolTransactions(basis types.ChainIndex, txns []types.V2Transaction) (known bool, err error)
V2UnconfirmedParents(txn types.V2Transaction) []types.V2Transaction
}

// Webhooks manages webhooks
Expand Down
2 changes: 1 addition & 1 deletion api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (a *api) handlePOSTWalletSend(jc jape.Context) {
return
}
a.wallet.SignV2Inputs(state, &txn, toSign)
txnset := []types.V2Transaction{txn}
txnset := append(a.chain.V2UnconfirmedParents(txn), txn)
// verify the transaction and add it to the transaction pool
if _, err := a.chain.AddV2PoolTransactions(state.Index, txnset); !a.checkServerError(jc, "failed to add v2 transaction set", err) {
a.wallet.ReleaseInputs(nil, []types.V2Transaction{txn})
Expand Down
12 changes: 5 additions & 7 deletions host/settings/announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ func (m *ConfigManager) Announce() error {
// get the current settings
settings := m.Settings()

if err := validateNetAddress(settings.NetAddress); err != nil {
if m.validateNetAddress {
return fmt.Errorf("failed to validate net address: %w", err)
} else {
m.log.Warn("invalid net address", zap.Error(err))
if m.validateNetAddress {
if err := validateNetAddress(settings.NetAddress); err != nil {
return fmt.Errorf("failed to validate net address %q: %w", settings.NetAddress, err)
}
}

Expand Down Expand Up @@ -88,7 +86,7 @@ func (m *ConfigManager) Announce() error {
func validateNetAddress(netaddress string) error {
host, port, err := net.SplitHostPort(netaddress)
if err != nil {
return fmt.Errorf("invalid net address %q: net addresses must contain a host and port: %w", netaddress, err)
return fmt.Errorf("net addresses must contain a host and port: %w", netaddress, err)

Check failure on line 89 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

printf: fmt.Errorf format %w has arg netaddress of wrong type string (govet)

Check failure on line 89 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Build Linux (amd64)

printf: fmt.Errorf format %w has arg netaddress of wrong type string (govet)

Check failure on line 89 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Build macOS (amd64)

printf: fmt.Errorf format %w has arg netaddress of wrong type string (govet)

Check failure on line 89 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Docker

printf: fmt.Errorf format %w has arg netaddress of wrong type string (govet)

Check failure on line 89 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Build Linux (arm64)

printf: fmt.Errorf format %w has arg netaddress of wrong type string (govet)

Check failure on line 89 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Build Windows (amd64)

printf: fmt.Errorf format %w has arg netaddress of wrong type string (govet)

Check failure on line 89 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

printf: fmt.Errorf format %w has arg netaddress of wrong type string (govet)
}

// Check that the host is not empty or localhost.
Expand All @@ -110,7 +108,7 @@ func validateNetAddress(netaddress string) error {
ip := net.ParseIP(host)
if ip != nil {
if ip.IsLoopback() || ip.IsPrivate() || !ip.IsGlobalUnicast() {
return fmt.Errorf("invalid net address %q: only public IP addresses allowed", host)
return fmt.Errorf("only public IP addresses allowed", host)

Check failure on line 111 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

printf: fmt.Errorf call has arguments but no formatting directives (govet)

Check failure on line 111 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Build Linux (amd64)

printf: fmt.Errorf call has arguments but no formatting directives (govet)

Check failure on line 111 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Build macOS (amd64)

printf: fmt.Errorf call has arguments but no formatting directives (govet)

Check failure on line 111 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Docker

printf: fmt.Errorf call has arguments but no formatting directives (govet)

Check failure on line 111 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Build Linux (arm64)

printf: fmt.Errorf call has arguments but no formatting directives (govet)

Check failure on line 111 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / publish / Build Windows (amd64)

printf: fmt.Errorf call has arguments but no formatting directives (govet)

Check failure on line 111 in host/settings/announce.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

printf: fmt.Errorf call has arguments but no formatting directives (govet)
}
return nil
}
Expand Down

0 comments on commit be52ed2

Please sign in to comment.