Giter Club home page Giter Club logo

chainsync's Introduction

ChainSync

PyPI GitHub issues Build Status

A simple library to stream blocks and operations for digesting into other mediums.

Install

pip install chainsync

Requirements

pip install -r requirements.txt

Example - streaming blocks

from chainsync import ChainSync
from chainsync.adapters.steemv2 import SteemV2Adapter

adapter = SteemV2Adapter(endpoints=['https://api.steemit.com'])
chainsync = ChainSync(adapter)

for dataType, data in chainsync.stream(['blocks']):
    print("{} - {}".format(data['block_num'], data['witness']))

Example - streaming operations

from chainsync import ChainSync
from chainsync.adapters.steemv2 import SteemV2Adapter

adapter = SteemV2Adapter(endpoints=['https://api.steemit.com'])
chainsync = ChainSync(adapter)

for dataType, data in chainsync.stream(['ops']):
    print("{} - {}".format(data['block_num'], data['operation_type']))

Example - streaming operations with a whitelist

from chainsync import ChainSync
from chainsync.adapters.steemv2 import SteemV2Adapter

adapter = SteemV2Adapter(endpoints=['https://api.steemit.com'])
chainsync = ChainSync(adapter)

for dataType, op in chainsync.stream(['ops'], whitelist=['vote']):
    print("{} - {} by {}".format(op['block_num'], op['operation_type'], op['voter']))

Example - custom adapters

A custom adapter can be supplied to allow parsing of a specific blockchain

from chainsync import ChainSync
from chainsync.adapters.decent import DecentAdapter

adapter = DecentAdapter(endpoints=['http://api.decent-db.com:8090'])
chainsync = ChainSync(adapter)

for block in chainsync.stream(['blocks']):
    print("{} - {}".format(block['block_num'], block['witness']))

Adapters

Adapters can be added and configured to allow access to other similar blockchains.

A current list of adapters can be found in the ./chainsync/adapters folder.

chainsync's People

Contributors

aaroncox avatar caleblogan avatar

Watchers

James Cloos avatar Bobinson K B 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.