pub struct AgentConsensusVoting { /* private fields */ }Expand description
Agentic consensus for response voting
Agents submit responses and vote. Majority wins.
Implementations§
Source§impl AgentConsensusVoting
impl AgentConsensusVoting
Sourcepub fn new(
threshold: f64,
min_responses: usize,
min_votes: usize,
) -> AgentConsensusVoting
pub fn new( threshold: f64, min_responses: usize, min_votes: usize, ) -> AgentConsensusVoting
Create new consensus instance
§Arguments
threshold- Fraction of votes needed (0.5 = majority)min_responses- Minimum responses before checking consensusmin_votes- Minimum votes before checking consensus
Sourcepub async fn submit_query(&self, query: Query) -> [u8; 32]
pub async fn submit_query(&self, query: Query) -> [u8; 32]
Submit a new query
Sourcepub async fn submit_response(
&self,
response: Response,
) -> Result<[u8; 32], Error>
pub async fn submit_response( &self, response: Response, ) -> Result<[u8; 32], Error>
Submit a response to a query
Sourcepub async fn vote(
&self,
query_id: [u8; 32],
response_id: [u8; 32],
voter: Did,
) -> Result<(), Error>
pub async fn vote( &self, query_id: [u8; 32], response_id: [u8; 32], voter: Did, ) -> Result<(), Error>
Vote for a response
Each agent can only vote once per query (across all responses)
Sourcepub async fn get_result(&self, query_id: [u8; 32]) -> Option<ConsensusResult>
pub async fn get_result(&self, query_id: [u8; 32]) -> Option<ConsensusResult>
Get the consensus result for a query
Sourcepub async fn is_finalized(&self, query_id: [u8; 32]) -> bool
pub async fn is_finalized(&self, query_id: [u8; 32]) -> bool
Check if a query has reached consensus
Auto Trait Implementations§
impl Freeze for AgentConsensusVoting
impl !RefUnwindSafe for AgentConsensusVoting
impl Send for AgentConsensusVoting
impl Sync for AgentConsensusVoting
impl Unpin for AgentConsensusVoting
impl !UnwindSafe for AgentConsensusVoting
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more