Skip to content

Commit fd50b16

Browse files
committed
fix http request creation
1 parent f6880ac commit fd50b16

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

market/mk12/cidgravity.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,6 @@ const cidGravityMinerCheckUrl = "https://service.cidgravity.com/private/v1/miner
133133
const cidGravityMinerCheckLabel = "cidg-miner-status-check"
134134
const agentName = "curio"
135135

136-
var commonHeaders = http.Header{
137-
"X-CIDgravity-Agent": []string{"CIDgravity-storage-Connector"},
138-
"X-CIDgravity-Version": []string{"1.0"},
139-
"Content-Type": []string{"application/json"},
140-
}
141-
142136
func (m *MK12) cidGravityCheck(ctx context.Context, deal *ProviderDealState) (bool, string, error) {
143137

144138
data, err := m.prepareCidGravityPayload(ctx, deal)
@@ -150,7 +144,11 @@ func (m *MK12) cidGravityCheck(ctx context.Context, deal *ProviderDealState) (bo
150144
client := &http.Client{}
151145

152146
// Create the new request
153-
var req *http.Request
147+
req, err := http.NewRequest("POST", cidGravityDealCheckUrl, bytes.NewBuffer(data))
148+
if err != nil {
149+
return false, "", xerrors.Errorf("Error creating request: %w", err)
150+
}
151+
154152
if deal.ClientDealProposal.Proposal.Label.IsString() {
155153
lableStr, err := deal.ClientDealProposal.Proposal.Label.ToString()
156154
if err != nil {
@@ -162,15 +160,15 @@ func (m *MK12) cidGravityCheck(ctx context.Context, deal *ProviderDealState) (bo
162160
return false, "", xerrors.Errorf("Error creating request: %w", err)
163161
}
164162
}
165-
} else {
166-
req, err = http.NewRequest("POST", cidGravityDealCheckUrl, bytes.NewBuffer(data))
167-
if err != nil {
168-
return false, "", xerrors.Errorf("Error creating request: %w", err)
169-
}
170163
}
171164

172165
// Add necessary headers
173-
req.Header = commonHeaders
166+
req.Header = http.Header{
167+
"X-CIDgravity-Agent": []string{"CIDgravity-storage-Connector"},
168+
"X-CIDgravity-Version": []string{"1.0"},
169+
"Content-Type": []string{"application/json"},
170+
}
171+
174172
req.Header.Set("X-API-KEY", m.cfg.Market.StorageMarketConfig.MK12.CIDGravityToken)
175173
req.Header.Set("X-Address-ID", deal.ClientDealProposal.Proposal.Provider.String())
176174
req.Header.Set("Authorization", m.cfg.Market.StorageMarketConfig.MK12.CIDGravityToken)

0 commit comments

Comments
 (0)