Skip to main content

Consensus

Struct Consensus 

Source
pub struct Consensus { /* private fields */ }
Expand description

Сессия GNUnet CONSENSUS: участники вносят элементы и к deadline приходят к общему множеству. Drop уничтожает локальную сессию.

Implementations§

Source§

impl Consensus

Source

pub async fn create( runtime: &GnunetRuntime, config: &Config, peers: &[PeerId], session_id: HashCode, start: SystemTime, deadline: SystemTime, options: ConsensusOptions, ) -> Result<(Self, ConsensusElements), ConsensusError>

Присоединяется к сессии session_id с другими участниками peers; локальный peer сервис добавляет сам. Все участники должны указать те же start и deadline.

Не передавайте в peers идентификатор локального peer, полученный от CORE: сервис 0.29.0 не узнаёт в нём себя, считает его вторым участником, и сессия может не завершиться (BUG-029).

Тип элемента в CONSENSUS 0.29.0 по сети не передаётся, поэтому элементы здесь — просто байты.

Source

pub async fn insert(&self, element: &[u8]) -> Result<(), ConsensusError>

Вносит элемент. Завершается после передачи сообщения сервису; после conclude возвращает Concluding.

Source

pub async fn conclude(&self) -> Result<(), ConsensusError>

Сообщает сервису, что локальных вставок больше не будет, и ждёт завершения сессии. Когда оно наступит, решает сервис: сессия из одного участника завершается сразу, с несколькими — по расписанию раундов до deadline. Элементы согласованного множества приходят в поток до завершения этого вызова.

Source

pub async fn close(self) -> Result<(), ConsensusError>

Дожидается уничтожения локальной сессии.

Trait Implementations§

Source§

impl Drop for Consensus

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.