Giter Site home page Giter Site logo

chainstack / web3quorum Goto Github PK

View Code? Open in Web Editor NEW
3.0 21.0 1.0 133 KB

A web3py extension that supports Quorum APIs: Raft and Istanbul

Home Page: https://chainstack.com/quorum/

License: Apache License 2.0

Python 100.00%
quorum blockchain python-library web3py

web3quorum's Introduction

web3quorum โ›“

A web3py extension that supports Quorum APIs: Raft and Istanbul.

Quick start

pip install web3quorum

Usage examples

from web3 import HTTPProvider
from web3quorum import Web3Quorum

w3 = Web3Quorum(HTTPProvider('http://foo.bar'))

# retrieve cluster info
>>> w3.raft.cluster
({'hostname': '31.247.117.573',
'nodeId': 'db207d418bbbfcb0639f303259f62bf1da3c95aceb051f32cac8361a1c08276f4296f8e3f57833caac9c2aaa28a90158bf6eaf3f8ad602ac27a3e0ed6c8c765c',
'p2pPort': 30303,
'raftId': 2,
'raftPort': 50400},
{'hostname': '54.84.81.417',
'nodeId': 'c9391a893f9d3e44d820419259f2e441f209c0e4e1957ca3df35473f20f529c3c94fecb1e1c37e3bb0f15b74defd0db3c72a1b83d5f2d65d34dd7d255efdba0c',
'p2pPort': 30303,
'raftId': 1,
'raftPort': 50400})

# add new learner peer
>>> w3.raft.add_learner('enode://db207d418bbbfcb0639f303259f62bf1da3c95aceb051f32cac8361a1c08276f4296f8e3f57833caac9c2aaa28a90158bf6eaf3f8ad602ac27a3e0ed6c8c765c@1.1.1.1:30303?discport=0&raftport=50400')
2

# promote learner peer to verifier
>>> w3.raft.promote_to_peer(2)
True

# delete verifier peer
>>> w3.raft.remove_peer(2)

Resolve enode or hostname to raft Id

from web3quorum import enode_to_raft_id

>>> enode_to_raft_id(api, 'enode://db207d418bbbfcb0639f303259f62bf1da3c95aceb051f32cac8361a1c08276f4296f8e3f57833caac9c2aaa28a90158bf6eaf3f8ad602ac27a3e0ed6c8c765c@1.1.1.1:30303')
2

Use mock object in tests

from web3quorum import Web3QuorumMock

>>> w3 = Web3QuorumMock()
>>> w3.raft.role
verifier

web3quorum's People

Contributors

easeev avatar hayorov avatar maxitosh avatar sozinm avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

kenman79

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.