Skip to main content
https://travis-ci.org/zshvvhm/tinyblock.svg?branch=master https://coveralls.io/repos/github/zshvvhm/tinyblock/badge.svg https://img.shields.io/pypi/v/tinyblock.svg https://img.shields.io/pypi/l/tinyblock.svg https://img.shields.io/pypi/pyversions/tinyblock.svg

Installation

Install and update using pip:

$ pip install tinyblock

Block

dict({'previous_hash'(str): '...',
      'timestamp'(int): '...',
      'data'(any): '...',
      'nonce'(int): '...',
      'next_hash'(str): '...'})

Usage

  • Define a simple blockchain:

    from tinyblock import tinyblock
    #The initial variable should be a list of blocks. If not set it, the default chain would be an empty list.
    my_blockchain = tinyblock()
  • Add a block to the chain:

    #The parameter is the data of this block
    my_blockchain.add('This is a block.')
  • Find a block with statement:

    #Find the blocks with features below. The return elements will content the index in origin chain list.
    #Completely match: previous_hash, nonce, next_hash.
    #Partly match: data. (Currently support str, int, float, list, dict, bool and tuple)
    #Range match: timestamp.(Could be an int, list or tuple)
    my_blockchain.find(previous_hash='', timestamp='', data='', nonce='', next_hash='')
  • Pop the last block of the chain:

    my_blockchain.pop()
  • Check wether the blockchain is anything correct:

    my_blockchain.chainCheck(print_option=True)
  • Fix the blockchain(with start and stop index):

    my_blockchain.chainFix(start=0, stop=4)
  • Get the block list:

    my_blockchain.getChain()
  • Customise the rule for mining new block:

    #The default rule is hash start with '0000'.
    #To change the rule, you can override the mineRule function.
    def newRule(hash):
        if hash[0:5] == '0'*5:
            return True
        return False
    
    my_blockchain.mineRule = newRule

Metadata

Release files for tinyblock 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tinyblock 0.2.0
File Size Uploaded
tinyblock-0.2.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tinyblock 0.2.0
File Interpreter ABI Platform
tinyblock-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 10.1 kB

Release files / tinyblock-0.2.0.tar.gz

Download URL tinyblock-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ebfc13d44d3b56560bc2c2e869e05e8319f61c010f2789d22863a12a0d7b9f17
BLAKE2b-256 checksum
How to use checksums
f605e9ba7fca7e2886d3841f7d54b635c571b237f31e3e0488c5b6f6c0b22921
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / tinyblock-0.2.0-py2.py3-none-any.whl

Download URL tinyblock-0.2.0-py2.py3-none-any.whl
Size 6.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d90da78a1aade97e05cf675f08c32b5f671dc433a095eea14f3283cf8b29837c
BLAKE2b-256 checksum
How to use checksums
a1fcfa11420d5bd4199c66b6ead1ff6bc37329a673237a8017485964943c1837
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page