Skip to content

Commit

Permalink
Merge #4324
Browse files Browse the repository at this point in the history
4324: Add Search methods to gRPC API r=damip a=aoudiamoncef

* [x] document all added functions
* [ ] try in sandbox /simulation/labnet
  * [ ] if part of node-launch, checked using the `resync_check` flag
* [x] unit tests on the added/changed features
  * [x] make tests compile
  * [x] make tests pass 
* [x] add logs allowing easy debugging in case the changes caused problems
* [x] if the API has changed, update the API specification

closes #4271 #4272 #4274

Co-authored-by: Moncef AOUDIA <[email protected]>
  • Loading branch information
bors[bot] and aoudiamoncef authored Aug 15, 2023
2 parents 89d65cb + d9c2deb commit 0f80b95
Show file tree
Hide file tree
Showing 17 changed files with 800 additions and 254 deletions.
102 changes: 56 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ massa_versioning = { path = "./massa-versioning" }
massa_wallet = { path = "./massa-wallet" }

# Massa projects dependencies
massa-proto-rs = {git = "https://github.com/massalabs/massa-proto-rs", "rev" = "32179e2"}
massa-proto-rs = {git = "https://github.com/massalabs/massa-proto-rs", "rev" = "09870a9d6590e5e67e9b16dd427efef3c5bbe4a6"}
massa-sc-runtime = {git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "main"}
peernet = { git = "https://github.com/massalabs/PeerNet", "branch" = "main" }

Expand Down
9 changes: 4 additions & 5 deletions massa-api/src/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,10 @@ impl MassaRpcServer for API<Public> {
/// only active blocks are returned
async fn get_blocks(&self, ids: Vec<BlockId>) -> RpcResult<Vec<BlockInfo>> {
let consensus_controller = self.0.consensus_controller.clone();
let storage = self.0.storage.clone_without_refs();
let blocks = ids
.into_iter()
.filter_map(|id| {
let content = if let Some(wrapped_block) = storage.read_blocks().get(&id) {
let content = if let Some(wrapped_block) = self.0.storage.read_blocks().get(&id) {
wrapped_block.content.clone()
} else {
return None;
Expand Down Expand Up @@ -687,16 +686,16 @@ impl MassaRpcServer for API<Public> {

async fn get_blockclique_block_by_slot(&self, slot: Slot) -> RpcResult<Option<Block>> {
let consensus_controller = self.0.consensus_controller.clone();
let storage = self.0.storage.clone_without_refs();

let block_id_option = consensus_controller.get_blockclique_block_at_slot(slot);

let block_id = match block_id_option {
Some(id) => id,
None => return Ok(None),
};

let res = storage
let res = self
.0
.storage
.read_blocks()
.get(&block_id)
.map(|b| b.content.clone());
Expand Down
2 changes: 1 addition & 1 deletion massa-async-pool/src/mapping_grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl From<AsyncMessage> for grpc_model::AsyncMessage {
sender: value.sender.to_string(),
destination: value.destination.to_string(),
handler: value.handler.to_string(),
max_gas: value.max_gas,
used_gas: value.max_gas,
fee: Some(value.fee.into()),
coins: Some(value.coins.into()),
validity_start: Some(value.validity_start.into()),
Expand Down
1 change: 1 addition & 0 deletions massa-grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ tokio-stream = {workspace = true} # BOM UPGRADE Revert to "0.1.12" if prob
tracing = {workspace = true}
parking_lot = {workspace = true, "features" = ["deadlock_detection"]}
h2 = {workspace = true}
itertools = {workspace = true}

massa_consensus_exports = {workspace = true}
massa_hash = {workspace = true}
Expand Down
Loading

0 comments on commit 0f80b95

Please sign in to comment.