Documentation ¶
Index ¶
- type CLI
- func (cc *CLI) AppendBlock(bk *block.BlockType)
- func (cc *CLI) AppendTxToBlock(bk *block.BlockType, tx *transactions.TransactionType)
- func (cc *CLI) BuildBlockFileName(hashStr string) (fnBlockPath string)
- func (cc *CLI) BuildIndexFileName() (fnIndexPath string)
- func (cc *CLI) CreateGenesis(args []string)
- func (cc *CLI) GetNonZeroForAccount(acct addr.AddressType) (rv []*transactions.TxOutputType)
- func (cc *CLI) GetTotalValueForAccount(acct addr.AddressType) (sum int)
- func (cc *CLI) ListAccounts(args []string)
- func (cc *CLI) ListAccountsJSON() string
- func (cc *CLI) NewEmptyBlock() (bk *block.BlockType)
- func (cc *CLI) ReadGlobalConfig()
- func (cc *CLI) ReadGlobalData(args []string)
- func (cc *CLI) SendFundsJSON(fromStr, toStr, amountStr, addrStr, signature, msg, memo string) (jsonData string)
- func (cc *CLI) SendFundsTransaction(from addr.AddressType, sig lib.SignatureType, message string, ...) (tx *transactions.TransactionType, err error)
- func (cc *CLI) ShowBalance(args []string)
- func (cc *CLI) ShowBalanceJSON(acctStr string) string
- func (cc *CLI) TestReadBlock(args []string)
- func (cc *CLI) TestSendFunds(args []string)
- func (cc *CLI) TestWriteBlock(args []string)
- func (cc *CLI) Usage()
- func (cc *CLI) ValidateSignature(addrStr, signature, msg string) (isValid bool, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLI ¶
type CLI struct { GCfg config.GlobalConfigData AllBlocks []*block.BlockType BlockIndex index.BlockIndex }
func (*CLI) AppendBlock ¶
AppendBlock appends a new block to the set of blocks in the blockchain. The block mining reward will be added as the last transaction in the block. Mining will be performed to seal the block. The block will be written out to the file system and the index of blocks is updated. Verification occures that the block has produced a unique hash. (Hash Collisions are possible but very rare - It would be simple to add a fix so that if you get a collision it fixes it. This has not been done).
func (*CLI) AppendTxToBlock ¶
func (cc *CLI) AppendTxToBlock(bk *block.BlockType, tx *transactions.TransactionType)
AppendTxToBlock takes a transaction and appends it to the set of transactions in the block. TxOffset values for transaction outputs have to be set. The BlockNo is also set to the current blocks. If the list of addresses, cc.BLockIndex.FindValue.AddrIndex is nil then the map is allocated.
func (*CLI) BuildBlockFileName ¶
BuildBlockFileName takes a hashStr that is the name of the JSON file withouth the path and `.json` and combines to make a full file name.
func (*CLI) BuildIndexFileName ¶
BuildIndexFileName returns the name of the index.json file with the correct path from the configuration.
func (*CLI) CreateGenesis ¶
CreateGenesis creates and writes out the genesis block and the initial index.json files. Theis is the ""genesis"" of the blockchain.
func (*CLI) GetNonZeroForAccount ¶
func (cc *CLI) GetNonZeroForAccount(acct addr.AddressType) (rv []*transactions.TxOutputType)
GetNonZeroForAccount returns a slice of tranactions that have a positive (Non-Zero) balance. This is the set of output tranactions that will need to be turned into input tranactions to make a funds transfer occure.
func (*CLI) GetTotalValueForAccount ¶
func (cc *CLI) GetTotalValueForAccount(acct addr.AddressType) (sum int)
GetTotalValueForAccount walks the index finding all the non-zero tranactions for an account and adds up the total value for the account.
func (*CLI) ListAccounts ¶
ListAccounts will walk through the index and find all the accounts, construct a non-dup list the accounts and print it out.
Improvement - this could be split into a library function to get the accoutns and then just print.
func (*CLI) ListAccountsJSON ¶
ListAccounts will walk through the index and find all the accounts, construct a non-dup list the accounts and print it out.
Improvement - this could be split into a library function to get the accoutns and then just print.
func (*CLI) NewEmptyBlock ¶
func (*CLI) ReadGlobalConfig ¶
func (cc *CLI) ReadGlobalConfig()
ReadGlobalConfig reads in the index and all of the blocks.
func (*CLI) ReadGlobalData ¶
ReadGlobalData is an intialization function to read the locally stored set of blocks and index from ./data.
func (*CLI) SendFundsJSON ¶
func (cc *CLI) SendFundsJSON(fromStr, toStr, amountStr, addrStr, signature, msg, memo string) (jsonData string)
SendFundsJSON will process command argumetns and walk through the transaction process of sending funds once. This is essentially the transaction process - but driven from the command line.
func (*CLI) SendFundsTransaction ¶
func (cc *CLI) SendFundsTransaction( from addr.AddressType, sig lib.SignatureType, message string, to addr.AddressType, amount int, memo string, ) ( tx *transactions.TransactionType, err error, )
SendFundsTransaction is the core chunk of moving funds from one account to another.
This is your homework. Finish out this function and test.
func (*CLI) ShowBalance ¶
ShowBalance will use the index to find an account, then walk through all the unused outputs (the balance) and add that up. Then it will print out the balance for that account.
func (*CLI) ShowBalanceJSON ¶
ShowBalanceJSON will use the index to find an account, then walk through all the unused outputs (the balance) and add that up. Then it will convert this to a JSON responce and return it.
func (*CLI) TestReadBlock ¶
TestReadBlock Test code for command line.
func (*CLI) TestSendFunds ¶
TestSendFunds will process command argumetns and walk through the transaction process of sending funds once. This is essentially the transaction process - but driven from the command line.
func (*CLI) TestWriteBlock ¶
TestWriteBlock Test code for command line.