Giter Club home page Giter Club logo

Comments (4)

vkomenda avatar vkomenda commented on May 26, 2024 1

Here is the way I think we should change the API. Please feel free to comment. I propose to keep the DistAlgorithm interface in a modified form for internal purposes, making it more automaton-like. At the moment DistAlgorithm already has semantics close to that of an automaton - with Input and Output but without state. I believe that the interface should only have

  1. a step function from inputs (and states, internally) to outputs and states,

  2. types of input value, output value and state.

An input is an incoming message and an optional input value.

An output is a list of outgoing messages, a list of log entries and an optional output value. The caller #[must_use] the output.

The usual type of state will be the set of four values:

a. not initialized (accepting incoming messages and input values),

b. initialized (accepting incoming messages and discarding input values),

c. terminated (discarding everything),

d. error.

The state value is a field in the algorithm struct and is output at each step, so there is no need to have an is_terminated function to check for termination.

I think that keeping errors separate from state as in Result<OutputAndState, Error> would only follow the requirements of external crates such as error_chain and is not a necessity.

That was the easy part. So, what does it mean for the user of the library? If you use any of the algorithm structs directly, you must know the types of its input values, output values, messages and states. The top level API can provide an interface call to the step function, so that using the DistAlgorithm trait is not needed in user code.

from hbbft.

afck avatar afck commented on May 26, 2024 1

I agree with the plan for the outputs, and I like the idea of replacing multiple booleans (like terminated) with a single state enum, where possible.

An input is an incoming message and an optional input value.

I think we would end up only ever calling input(None, Some(input)) or input(Some(msg), None), so maybe it should be two separate functions.

from hbbft.

afck avatar afck commented on May 26, 2024 1

Let's also keep in mind the Rust API guidelines whenever we make changes to the API.

from hbbft.

vkomenda avatar vkomenda commented on May 26, 2024 1

I created an issue for that: #108.

from hbbft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.