-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mempool API to Get All Addresses From Parking Lot (#14740)
- Loading branch information
Showing
15 changed files
with
179 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use aptos_logger::info; | ||
use aptos_mempool::{MempoolClientRequest, MempoolClientSender}; | ||
use aptos_system_utils::utils::{reply_with, reply_with_status}; | ||
use aptos_types::account_address::AccountAddress; | ||
use futures_channel::oneshot::Canceled; | ||
use http::{Request, Response, StatusCode}; | ||
use hyper::Body; | ||
|
||
pub async fn mempool_handle_parking_lot_address_request( | ||
_req: Request<Body>, | ||
mempool_client_sender: MempoolClientSender, | ||
) -> hyper::Result<Response<Body>> { | ||
match get_parking_lot_addresses(mempool_client_sender).await { | ||
Ok(addresses) => { | ||
info!("Finished getting parking lot addresses from mempool."); | ||
match bcs::to_bytes(&addresses) { | ||
Ok(addresses) => Ok(reply_with(vec![], addresses)), | ||
Err(e) => { | ||
info!("Failed to bcs serialize parking lot addresses from mempool: {e:?}"); | ||
Ok(reply_with_status( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
e.to_string(), | ||
)) | ||
}, | ||
} | ||
}, | ||
Err(e) => { | ||
info!("Failed to get parking lot addresses from mempool: {e:?}"); | ||
Ok(reply_with_status( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
e.to_string(), | ||
)) | ||
}, | ||
} | ||
} | ||
|
||
async fn get_parking_lot_addresses( | ||
mempool_client_sender: MempoolClientSender, | ||
) -> Result<Vec<(AccountAddress, u64)>, Canceled> { | ||
let (sender, receiver) = futures_channel::oneshot::channel(); | ||
|
||
match mempool_client_sender | ||
.clone() | ||
.try_send(MempoolClientRequest::GetAddressesFromParkingLot(sender)) | ||
{ | ||
Ok(_) => receiver.await, | ||
Err(e) => { | ||
info!("Failed to send request for GetAddressesFromParkingLot: {e:?}"); | ||
Err(Canceled) | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters