Feature/migrate hidden delegations (#786)

* Remove migration code

* Added function to iterate over delegation of variable type

* Add unit tests

* Refactored some naming and reused mix/gateway functionality

* Borrow bucket instead of move

* Linked with existing delegations function

* Migration of left-over delegations

* Remove unused imports

* Put a gateway test as well, next to the mix one

* Expose queries for all delegations

* Change break point

* Added client side calls to the new queries

* Fix clippy

* Added pagination and read check tests

* Fix gateway test from the last commit

* Test functions for (de)serialization of identity and owner (in)to storage keys

* Add delegation function unit test

* Feature guard import

* Changed UnpackedDelegation from type to struct

* Remove mutable parameter and put start_after in returned value

* Made all delegations into iterator for OOM safety

* Fix clippy

* Add test for delegations iterator size in memory

* Change map with if let for ease of read

* Use DENOM instead of hardcoded value
This commit is contained in:
Bogdan-Ștefan Neacşu
2021-09-30 15:04:33 +03:00
committed by GitHub
parent 12637d93ff
commit 2a98f7482d
13 changed files with 995 additions and 124 deletions
+17 -4
View File
@@ -3,14 +3,20 @@ use rocket::serde::json::Json;
use rocket::{Route, State};
use serde::Serialize;
use mixnet_contract::{Addr, Coin, Layer, MixNode};
use mixnet_contract::{Addr, Coin, Layer, MixNode, RawDelegationData};
use crate::mix_node::models::{NodeDescription, NodeStats};
use crate::mix_nodes::{get_mixnode_delegations, Location};
use crate::mix_nodes::{get_mixnode_delegations, get_single_mixnode_delegations, Location};
use crate::state::ExplorerApiStateContext;
pub fn mix_node_make_default_routes() -> Vec<Route> {
routes_with_openapi![get_delegations, get_description, get_stats, list]
routes_with_openapi![
get_delegations,
get_all_delegations,
get_description,
get_stats,
list
]
}
#[derive(Clone, Debug, Serialize, JsonSchema)]
@@ -54,7 +60,14 @@ pub(crate) async fn list(
#[openapi(tag = "mix_node")]
#[get("/<pubkey>/delegations")]
pub(crate) async fn get_delegations(pubkey: &str) -> Json<Vec<mixnet_contract::Delegation>> {
Json(get_mixnode_delegations(pubkey).await)
Json(get_single_mixnode_delegations(pubkey).await)
}
#[openapi(tag = "mix_node")]
#[get("/all_mix_delegations")]
pub(crate) async fn get_all_delegations(
) -> Json<Vec<mixnet_contract::UnpackedDelegation<RawDelegationData>>> {
Json(get_mixnode_delegations().await)
}
#[openapi(tag = "mix_node")]