chug

package module
v0.0.0-...-ad20016 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 15 Imported by: 0

README

crypto-hug

Blockchain implementation for assets named "hugs"

By v-braun - viktor-braun.de.

Build Status codecov Go Report Card Documentation PR welcome

Description

Installation

go get github.com/crypto-hug/crypto-hug

Usage

use crypto-hug

Configuration

configure crypto-hug

Authors

image
v-braun

Contributing

Make sure to read these guides before getting started:

License

crypto-hug is available under the MIT License. See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GiveHugTransactionType = TransactionType("HUG")
View Source
var SpawnGenesisHugTransactionType = TransactionType("GHUG")

Functions

func ConfigExists

func ConfigExists(fs *fs.FileSystem) bool

func NewAddress

func NewAddress(data []byte) (string, error)

Types

type Block

type Block struct {
	Version      Version
	Hash         []byte
	PrevHash     []byte
	Timestamp    int64
	Transactions Transactions
}

func NewBlock

func NewBlock() *Block

func NewGenesisBlock

func NewGenesisBlock(config *Config, genesisTx *Transaction) *Block

func (*Block) HashBlock

func (b *Block) HashBlock()

type Blockchain

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

func NewBlockchain

func NewBlockchain(fs *fs.FileSystem, config *Config) *Blockchain

func (*Blockchain) CreateGenesisBlockIfNotExists

func (bc *Blockchain) CreateGenesisBlockIfNotExists()

func (*Blockchain) ProcessTransaction

func (bc *Blockchain) ProcessTransaction(tx *Transaction) error

func (*Blockchain) States

func (bc *Blockchain) States() *StateStore

func (*Blockchain) Store

func (bc *Blockchain) Store() *TxStore

type Config

type Config struct {
	GenesisTx struct {
		Version   string
		Timestamp int64
		Hash      string
		PubKey    string
		Address   string
		Lock      string
		Data      string
	}
	Paths struct {
		BlockDir    string
		StatesDir   string
		HugsDir     string
		TxStagePath string
	}
	Blocks struct {
		Size int
	}
}

func NewConfigFromFile

func NewConfigFromFile(fs *fs.FileSystem) (*Config, error)

func NewConfigFromFileOrDefault

func NewConfigFromFileOrDefault(fs *fs.FileSystem) (*Config, error)

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) WriteToFile

func (c *Config) WriteToFile(fs *fs.FileSystem) error

type DB

type DB struct {
	*bbolt.DB
}

func NewDB

func NewDB(path string) *DB

func (*DB) NewWritableTx

func (db *DB) NewWritableTx() (*dbTx, error)

type NodeHost

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

func NewNodeHost

func NewNodeHost(fs *fs.FileSystem, config *Config) *NodeHost

func (*NodeHost) GetHugEtag

func (nh *NodeHost) GetHugEtag(address string) (string, error)

func (*NodeHost) ProcessTransaction

func (nh *NodeHost) ProcessTransaction(tx *Transaction) error

func (*NodeHost) Start

func (nh *NodeHost) Start()

type StateStore

type StateStore struct {
	// contains filtered or unexported fields
}
func (sm *StateStore) HugAddLinks(ctx *txProcessCtx) error

func (*StateStore) HugCreateIfNotExists

func (sm *StateStore) HugCreateIfNotExists(address string) error

func (*StateStore) HugExists

func (sm *StateStore) HugExists(address string) bool

func (*StateStore) HugGetEtag

func (sm *StateStore) HugGetEtag(address string) (string, error)

func (*StateStore) HugSetEtag

func (sm *StateStore) HugSetEtag(address string, etag string) error

type Transaction

type Transaction struct {
	Version   Version
	Type      TransactionType
	Timestamp int64

	Hash *utils.Base58JsonVal

	IssuerPubKey *utils.Base58JsonVal
	IssuerLock   *utils.Base58JsonVal
	IssuerEtag   string

	ValidatorPubKey *utils.Base58JsonVal
	ValidatorLock   *utils.Base58JsonVal
	ValidatorEtag   string

	Data *utils.Base58JsonVal
}

func NewGenesisTransaction

func NewGenesisTransaction(config *Config) *Transaction

func NewTransaction

func NewTransaction(t TransactionType) *Transaction

func (*Transaction) Address

func (tx *Transaction) Address() (string, error)

func (*Transaction) Check

func (tx *Transaction) Check() error

func (*Transaction) CheckHash

func (tx *Transaction) CheckHash() error

func (*Transaction) CheckLockIssuer

func (tx *Transaction) CheckLockIssuer() bool

func (*Transaction) CheckLockValidator

func (tx *Transaction) CheckLockValidator() bool

func (*Transaction) HashTx

func (tx *Transaction) HashTx()

func (*Transaction) IsGenesisTx

func (tx *Transaction) IsGenesisTx(conf *Config) bool

func (*Transaction) IssuerAddress

func (tx *Transaction) IssuerAddress() (string, error)

func (*Transaction) LockIssuer

func (tx *Transaction) LockIssuer(privKey []byte, pubKey []byte) error

func (*Transaction) LockValidator

func (tx *Transaction) LockValidator(privKey []byte, pubKey []byte) error

func (*Transaction) ValidatorAddress

func (tx *Transaction) ValidatorAddress() (string, error)

type TransactionType

type TransactionType string

type Transactions

type Transactions []*Transaction

type TxProcessor

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

func NewTxProcessor

func NewTxProcessor(fs *fs.FileSystem, config *Config) *TxProcessor

func (*TxProcessor) Process

func (proc *TxProcessor) Process(tx *Transaction) error

type TxStore

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

func (*TxStore) BlockCount

func (s *TxStore) BlockCount() int

func (*TxStore) CommitStagedTx

func (s *TxStore) CommitStagedTx() *Block

func (*TxStore) StageTx

func (s *TxStore) StageTx(ctx *txProcessCtx) error

func (*TxStore) StagedTxCount

func (s *TxStore) StagedTxCount() int

type Version

type Version string
const (
	TxVersion         Version = defaultVersion
	AddressVersion    Version = defaultVersion
	BlockVersion      Version = defaultVersion
	HugVersion        Version = defaultVersion
	BlockchainVersion Version = defaultVersion
)

type Wallet

type Wallet struct {
	PrivK []byte
	PubK  []byte
	Addr  string
}

func NewWallet

func NewWallet() *Wallet

func NewWalletFromKeys

func NewWalletFromKeys(priv, pub []byte) *Wallet

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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