Dereplicode send_transaction and request_airdrop RPC handlers
(cherry picked from commit a7079e4dde
)
This commit is contained in:
committed by
Trent Nelson
parent
e8e74ee009
commit
1b2fdcd3a2
@ -1132,6 +1132,18 @@ pub trait RpcSol {
|
||||
) -> Result<RpcStakeActivation>;
|
||||
}
|
||||
|
||||
fn _send_transaction(
|
||||
meta: JsonRpcRequestProcessor,
|
||||
transaction: Transaction,
|
||||
wire_transaction: Vec<u8>,
|
||||
last_valid_slot: Slot,
|
||||
) -> Result<String> {
|
||||
let signature = transaction.signatures[0];
|
||||
meta.send_transaction_service
|
||||
.send(signature, wire_transaction, last_valid_slot);
|
||||
Ok(signature.to_string())
|
||||
}
|
||||
|
||||
pub struct RpcSolImpl;
|
||||
impl RpcSol for RpcSolImpl {
|
||||
type Metadata = JsonRpcRequestProcessor;
|
||||
@ -1477,17 +1489,13 @@ impl RpcSol for RpcSolImpl {
|
||||
info!("request_airdrop_transaction failed: {:?}", err);
|
||||
Error::internal_error()
|
||||
})?;
|
||||
let signature = transaction.signatures[0];
|
||||
|
||||
let wire_transaction = serialize(&transaction).map_err(|err| {
|
||||
info!("request_airdrop: serialize error: {:?}", err);
|
||||
Error::internal_error()
|
||||
})?;
|
||||
|
||||
meta.send_transaction_service
|
||||
.send(signature, wire_transaction, last_valid_slot);
|
||||
|
||||
Ok(signature.to_string())
|
||||
_send_transaction(meta, transaction, wire_transaction, last_valid_slot)
|
||||
}
|
||||
|
||||
fn send_transaction(
|
||||
@ -1499,7 +1507,6 @@ impl RpcSol for RpcSolImpl {
|
||||
debug!("send_transaction rpc request received");
|
||||
let config = config.unwrap_or_default();
|
||||
let (wire_transaction, transaction) = deserialize_bs58_transaction(data)?;
|
||||
let signature = transaction.signatures[0];
|
||||
let bank = &*meta.bank(None)?;
|
||||
let last_valid_slot = bank
|
||||
.get_blockhash_last_valid_slot(&transaction.message.recent_blockhash)
|
||||
@ -1520,7 +1527,8 @@ impl RpcSol for RpcSolImpl {
|
||||
.into());
|
||||
}
|
||||
|
||||
if let (Err(err), _log_output) = run_transaction_simulation(&bank, transaction) {
|
||||
if let (Err(err), _log_output) = run_transaction_simulation(&bank, transaction.clone())
|
||||
{
|
||||
// Note: it's possible that the transaction simulation failed but the actual
|
||||
// transaction would succeed, such as when a transaction depends on an earlier
|
||||
// transaction that has yet to reach max confirmations. In these cases the user
|
||||
@ -1533,9 +1541,7 @@ impl RpcSol for RpcSolImpl {
|
||||
}
|
||||
}
|
||||
|
||||
meta.send_transaction_service
|
||||
.send(signature, wire_transaction, last_valid_slot);
|
||||
Ok(signature.to_string())
|
||||
_send_transaction(meta, transaction, wire_transaction, last_valid_slot)
|
||||
}
|
||||
|
||||
fn simulate_transaction(
|
||||
|
Reference in New Issue
Block a user