impl

package
v0.0.0-...-7b2e207 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlockTableName = "blocks"

BlockTableName is the name of the transaction block table

View Source
var ChainTableName = "chains"

ChainTableName is the name of the table holding all chain information

Functions

func MakeGenesisBlockHash

func MakeGenesisBlockHash(chainName string) string

MakeGenesisBlockHash creates the standard hash for the first block of a chain which is a sha256 hash of a concatenated chain name and 64 chars of `0`.

func MakeTxsHash

func MakeTxsHash(txs []*types.Transaction) string

MakeTxsHash takes a slice of transactions and returns a SHA256 hash of the transactions

func VerifyTxs

func VerifyTxs(txs []*types.Transaction) (*types.Transaction, bool)

VerifyTxs checks whether the hash of a transactions are valid hashes based on the hash algorithm defined by Transaction.MakeHash.

Types

type PostgresBlockchain

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

PostgresBlockchain implements the Blockchain interface

func (*PostgresBlockchain) Close

func (b *PostgresBlockchain) Close() error

Close the database

func (*PostgresBlockchain) Connect

func (b *PostgresBlockchain) Connect(dbAddr string) (interface{}, error)

Connect connects to a postgres server and returns a client or error if connection failed.

func (*PostgresBlockchain) CreateBlock

func (b *PostgresBlockchain) CreateBlock(id, chainName string, transactions []*types.Transaction) (*types.Block, error)

CreateBlock creates a new block. It creates a chained structure by setting the new block's previous hash value to the hash of the last block of the chain specified. The new block's hash is calculated from the hash of all the contained transaction hashes.

func (*PostgresBlockchain) CreateChain

func (b *PostgresBlockchain) CreateChain(name string, public bool) (*types.Chain, error)

CreateChain creates a new chain

func (*PostgresBlockchain) GetBlock

func (b *PostgresBlockchain) GetBlock(chainName, id string) (*types.Block, error)

GetBlock fetches a block by its chain name and id

func (*PostgresBlockchain) GetChain

func (b *PostgresBlockchain) GetChain(name string) (*types.Chain, error)

GetChain gets a chain

func (*PostgresBlockchain) GetImplementationName

func (b *PostgresBlockchain) GetImplementationName() string

GetImplementationName returns th

func (*PostgresBlockchain) Init

func (b *PostgresBlockchain) Init() error

Init creates the chain and block tables

func (*PostgresBlockchain) MakeChainName

func (b *PostgresBlockchain) MakeChainName(namespace, name string) string

MakeChainName returns a new chain name prefixed with a namespace

Jump to

Keyboard shortcuts

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