chain

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 27 Imported by: 0

README

Chain

Responsibility

  • Given a block, verify whether the block is valid according to the consensus rules
  • Given a transaction, verify whether a transaction is valid

API

  • AcceptBlock(block) Verifies and saves a block
  • VerifyBlock(block) - Verifies a block is valid, including the transactions
  • VerifyTX(tx) - Verifies a tx is valid. For the mempool

Usage

  • AcceptBlock will be used by all nodes, when they recieve a new proposed block, that should be added to the chain

  • VerifyBlock will be used by consensus nodes, to verify that a block is valid without saving it.

  • VerifyTX will be used by the mempool to Verify a TX is valid and can be added to the mempool.

Consensus Rules
  • No double spending, check with utxo database
  • time difference between the last block should not be more than 60 minutes
  • Current blockheader, should reference the previous block header
  • Seed, public key, etc in block should be X Bytes
  • Zkproof should be valid in block
  • Certificates in the block of provisioners, should be valid.
  • Timestamp of previous block should be less than current block
Specification
  • Chain is the only process with a RW copy to the database

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain struct {
	// contains filtered or unexported fields
}

Chain represents the nodes blockchain This struct will be aware of the current state of the node.

func New

func New(eventBus *eventbus.EventBus, rpcBus *rpcbus.RPCBus, counter *chainsync.Counter) (*Chain, error)

New returns a new chain object

func (*Chain) AcceptBlock

func (c *Chain) AcceptBlock(blk block.Block) error

AcceptBlock will accept a block if 1. We have not seen it before 2. All stateless and statefull checks are true Returns nil, if checks passed and block was successfully saved

func (*Chain) Close

func (c *Chain) Close() error

func (*Chain) Listen

func (c *Chain) Listen()

Listen to the collectors

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL