Coder Social home page Coder Social logo

axiom-bft's Introduction

Axiom-BFT

======

axiom BFT consensus based on rbft .

Table of Contents

Usage

axiom-bft provides BFT service based on rbft.

You can initialize a RBFT service by:

Node, err := NewNode(conf)

Here, conf is a important structure which contains the config information of RBFT service.

Then you can interact with RBFT core using the methods as below:

To start the RBFT service by _ := Node.Start().

To stop the RBFT service by Node.Stop().

To propose requests to RBFT core by _ := Node.Propose(requests).

To get the current node status of the RBFT state machine by ns := Node.Status().

To receive and produce consensus messages, you can use Node.Step(msg), which msg is the consensus message you will deal with.

To propose the changes of config, you can use _ := Node.ProposeConfChange(cc). Here, cc contains the information of the changes of config. Then application needs to use Node.ApplyConfChange(cc) to apply these changes to the local node.

In addition, Node.ReportExecuted(state) is invoked after application service has actually applied a batch. Node.ReportStateUpdated(State) is invoked after application service finished stateUpdate which must be triggered by RBFT core before.

Note: To use RBFT core, one should implement several service except txPool. Here list the service that need to be provided:

  1. Storage service: to store and restore consensus log.
  2. Network service: to send p2p messages between nodes.
  3. Crypto service: to access the sign/verify methods from the crypto package.
  4. ServiceOutbound service: an application service invoked by RBFT library.

For more information about the service above, you can catch them from file external.go.

API

Node

import ( pb "github.com/axiomesh/axiom-bft/rbftpb" "github.com/axiomesh/axiom-bft/types" )

Instantiate Node func NewNode(conf Config) (Node, error)

Start Node Instance func (n *node) Start() error

Stop Node Instance func (n *node) Stop()

Propose Requests Propose(requests *consensus.RequestSet) error

Propose Config Change ProposeConfChange(cc *types.ConfChange) error

Receive and Process Consensus Messages Step(msg *consensus.ConsensusMessage)

RBFT Core Apply Config Change ApplyConfChange(cc *types.ConfState)

Get Current RBFT Core State Status() NodeStatus

Report Block Executed State to RBFT Core ReportExecuted(state *types.ServiceState)

Report State Updated to RBFT Core ReportStateUpdated(state *types.ServiceState)

Report Config Checkpoint Process Finished to RBFT Core ReportStableCheckpointFinished(height uint64)

Mockgen

Install mockgen : go get github.com/golang/mock/mockgen

Eg.mockgen -destination mock/mock_common.go -package common -source consensus.go

GitCZ

Note: Please use command npm install if you are the first time to use git cz in this repo.

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

Copyright © 2016-2019 Hangzhou Qulian Technology Co., Ltd.

axiom-bft's People

Contributors

duanhaohyperchain avatar zunkk avatar karenlrx avatar ywh254 avatar seveneese avatar

Watchers

Jason Ding avatar levi9311 avatar  avatar  avatar xiaochenl avatar  avatar  avatar

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.