chain

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ChainStorageFile = "data/chain.json"
View Source
const GenblockStorageFile = "data/genesis.json"
View Source
const (
	//Treasury_Address string = "P0614579c42f2"
	Treasury_Address string = "P2e2bfb58c9db"
)

Variables

This section is empty.

Functions

func EmptyPool

func EmptyPool(mgr *ChainManager)

empty the tx pool

func GenesisKeys

func GenesisKeys() crypto.Keypair

TODO

func GenesisTx

func GenesisTx() block.Tx

func HandleTx

func HandleTx(mgr *ChainManager, tx block.Tx) string

func MakeBlock

func MakeBlock(mgr *ChainManager)

function to create blocks, called periodically currently assumes we can create blocks at will and we don't sync

func MakeBlockLoop

func MakeBlockLoop(mgr *ChainManager, blocktime time.Duration)

func MakeGenesisBlock

func MakeGenesisBlock() block.Block

func ReadGenBlock

func ReadGenBlock() block.Block

func ReadState

func ReadState()

func ShowAccount

func ShowAccount(mgr *ChainManager, account string)

func TxValid

func TxValid(mgr *ChainManager, tx block.Tx) bool

valid cash transaction instead of needing to evluate bytecode like Bitcoin or Ethereum this is hardcoded cash transaction, no multisig, no timelocks * sufficient balance of sender (the sender has the cash, no credit as of now) * the sender is who he says he is (authorized access to funds) speed of evaluation should be way less than 1 msec TODO check nonce

func WriteGenBlock

func WriteGenBlock(block block.Block)

func WriteState

func WriteState()

Types

type ChainManager

type ChainManager struct {
	Tx_pool  []block.Tx
	Blocks   []block.Block
	Accounts map[string]int
}

func CreateManager

func CreateManager() ChainManager

func (*ChainManager) AppendBlock

func (mgr *ChainManager) AppendBlock(new_block block.Block)

append block to chain of blocks

func (*ChainManager) ApplyBlock

func (mgr *ChainManager) ApplyBlock(block block.Block)

apply block to the state

func (*ChainManager) ApplyBlocks

func (mgr *ChainManager) ApplyBlocks(blocks []block.Block)

func (*ChainManager) BlockHeight

func (mgr *ChainManager) BlockHeight() int

func (*ChainManager) InitAccounts

func (mgr *ChainManager) InitAccounts()

init genesis account

func (*ChainManager) IsTreasury

func (mgr *ChainManager) IsTreasury(account block.Account) bool

func (*ChainManager) LastBlock

func (mgr *ChainManager) LastBlock() block.Block

func (*ChainManager) RandomAccount

func (mgr *ChainManager) RandomAccount() string

func (*ChainManager) ReadChain

func (mgr *ChainManager) ReadChain() bool

TODO error

func (*ChainManager) ResetBlocks

func (mgr *ChainManager) ResetBlocks()

reset blocks to 0

func (*ChainManager) SetAccount

func (mgr *ChainManager) SetAccount(account string, balance int)

func (*ChainManager) WriteChain

func (mgr *ChainManager) WriteChain()

trivial json storage

Jump to

Keyboard shortcuts

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