Skip to content

Commit

Permalink
fix indexer submitting with less than two VN members
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Sep 3, 2024
1 parent 1f7d558 commit 66ff95e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 16 additions & 8 deletions applications/tari_indexer/src/transaction_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ where
async fn try_with_committee<'a, F, T, E, TFut, IShard>(
&self,
substate_addresses: IShard,
mut min_members: usize,
mut num_to_query: usize,
mut callback: F,
) -> Result<T, TransactionManagerError>
where
Expand All @@ -187,14 +187,18 @@ where
return Err(TransactionManagerError::NoCommitteeMembers);
}

let mut num_succeeded = 0;
let mut last_error = None;
let mut last_return = None;
for validator in all_members {
let client = self.client_provider.create_client(&validator);
match callback(client).await {
Ok(ret) => {
min_members = min_members.saturating_sub(1);
if min_members == 0 {
return Ok(ret);
num_to_query = num_to_query.saturating_sub(1);
num_succeeded += 1;
last_return = Some(ret);
if num_to_query == 0 {
break;
}
},
Err(err) => {
Expand All @@ -207,9 +211,13 @@ where
}
}

Err(TransactionManagerError::AllValidatorsFailed {
committee_size,
last_error,
})
if num_succeeded == 0 {
return Err(TransactionManagerError::AllValidatorsFailed {
committee_size,
last_error,
});
}

Ok(last_return.expect("last_return must be Some if num_succeeded > 0"))
}
}
2 changes: 0 additions & 2 deletions applications/tari_swarm_daemon/webui/src/routes/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ export default function Main() {
const [vns, setVns] = useState({});
const [danWallet, setDanWallets] = useState({});
const [indexers, setIndexers] = useState({});
const [node, setNode] = useState<{ grpc: any }>();
const [logs, setLogs] = useState<any | null>({});
const [stdoutLogs, setStdoutLogs] = useState<any | null>({});
const [connectorSample, setConnectorSample] = useState(null);
Expand Down Expand Up @@ -471,7 +470,6 @@ export default function Main() {
jsonRpc("get_stdout", "miner").then((resp) => {
setStdoutLogs((state: any) => ({ ...state, miner: resp }));
});
jsonRpc("grpc_node").then((resp) => setNode({ grpc: resp }));
jsonRpc("list_instances", { by_type: null }).then(({ instances }) => setInstances(instances));
};

Expand Down

0 comments on commit 66ff95e

Please sign in to comment.