Skip to content

Commit

Permalink
Remove a small refactor in runtime/src/lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
ppolewicz authored Sep 26, 2024
1 parent 9614193 commit eacda1e
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,13 @@ impl_runtime_apis! {
}

fn get_delegate(delegate_account_vec: Vec<u8>) -> Vec<u8> {
SubtensorModule::get_delegate(delegate_account_vec).map(|r| r.encode()).unwrap_or_default()
let _result = SubtensorModule::get_delegate(delegate_account_vec);
if _result.is_some() {
let result = _result.expect("Could not get DelegateInfo");
result.encode()
} else {
vec![]
}
}

fn get_delegated(delegatee_account_vec: Vec<u8>) -> Vec<u8> {
Expand All @@ -1385,7 +1391,13 @@ impl_runtime_apis! {
}

fn get_neuron_lite(netuid: u16, uid: u16) -> Vec<u8> {
SubtensorModule::get_neuron_lite(netuid, uid).map(|r| r.encode()).unwrap_or_default()
let _result = SubtensorModule::get_neuron_lite(netuid, uid);
if _result.is_some() {
let result = _result.expect("Could not get NeuronInfoLite");
result.encode()
} else {
vec![]
}
}

fn get_neurons(netuid: u16) -> Vec<u8> {
Expand All @@ -1394,13 +1406,25 @@ impl_runtime_apis! {
}

fn get_neuron(netuid: u16, uid: u16) -> Vec<u8> {
SubtensorModule::get_neuron(netuid, uid).map(|r| r.encode()).unwrap_or_default()
let _result = SubtensorModule::get_neuron(netuid, uid);
if _result.is_some() {
let result = _result.expect("Could not get NeuronInfo");
result.encode()
} else {
vec![]
}
}
}

impl subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block> for Runtime {
fn get_subnet_info(netuid: u16) -> Vec<u8> {
SubtensorModule::get_subnet_info(netuid).map(|r| r.encode()).unwrap_or_default()
let _result = SubtensorModule::get_subnet_info(netuid);
if _result.is_some() {
let result = _result.expect("Could not get SubnetInfo");
result.encode()
} else {
vec![]
}
}

fn get_subnets_info() -> Vec<u8> {
Expand All @@ -1424,7 +1448,13 @@ impl_runtime_apis! {
}

fn get_subnet_hyperparams(netuid: u16) -> Vec<u8> {
SubtensorModule::get_subnet_hyperparams(netuid).map(|r| r.encode()).unwrap_or_default()
let _result = SubtensorModule::get_subnet_hyperparams(netuid);
if _result.is_some() {
let result = _result.expect("Could not get SubnetHyperparams");
result.encode()
} else {
vec![]
}
}
}

Expand Down

0 comments on commit eacda1e

Please sign in to comment.