Skip to content

Commit 9bf0d83

Browse files
committed
generate idempotency key with x-forward-host
1 parent 1597306 commit 9bf0d83

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/ic-solana/src/rpc_client.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@ use serde::{de::DeserializeOwned, Serialize};
1414
use serde_json::{json, Value};
1515

1616
use crate::{
17-
add_metric_entry, constants::*, eddsa::hash_with_sha256, request::RpcRequest, rpc_client::multi_call::{MultiCallError, MultiCallResults}, types::{
17+
add_metric_entry,
18+
constants::*,
19+
eddsa::hash_with_sha256,
20+
request::RpcRequest,
21+
rpc_client::multi_call::{MultiCallError, MultiCallResults},
22+
types::{
1823
CommitmentConfig, EncodedConfirmedTransactionWithStatusMeta, Epoch, EpochInfo, EpochSchedule, Pubkey,
1924
RpcAccountInfoConfig, RpcBlockConfig, RpcBlockProductionConfig, RpcContextConfig, RpcEpochConfig,
2025
RpcGetVoteAccountsConfig, RpcLargestAccountsConfig, RpcLeaderScheduleConfig, RpcProgramAccountsConfig,
2126
RpcSendTransactionConfig, RpcSignatureStatusConfig, RpcSignaturesForAddressConfig,
2227
RpcSimulateTransactionConfig, RpcSupplyConfig, RpcTokenAccountsFilter, RpcTransactionConfig, Signature, Slot,
2328
Transaction, TransactionStatus, UiAccount, UiConfirmedBlock, UiTokenAmount, UiTransactionEncoding,
2429
UnixTimestamp,
25-
}
30+
},
2631
};
2732

2833
mod compression;
@@ -133,9 +138,14 @@ impl RpcClient {
133138
});
134139
}
135140

136-
let idempotency_key = hash_with_sha256(&format!("{}{}", provider.network, payload));
141+
let forward_host = headers
142+
.iter()
143+
.find(|header| header.name == "x-forward-host")
144+
.map_or(String::default(), |header| header.value.clone());
145+
146+
let idempotency_key = hash_with_sha256(&format!("{}{}", forward_host, payload));
137147
headers.push(HttpHeader {
138-
name: "X-Idempotency".to_string(),
148+
name: "idempotency-key".to_string(),
139149
value: idempotency_key,
140150
});
141151

0 commit comments

Comments
 (0)