Documentation ¶
Index ¶
- Constants
- Variables
- func HashInput(input string) string
- func IsValidHash(hash string) bool
- type Block
- type BlockChain
- type Ledger
- func (l *Ledger) AddTokensTo(user string, amount uint)
- func (l Ledger) GetTokenTotalFrom(user string) (uint, error)
- func (l Ledger) IsValidTransaction(transaction SignedTransaction) bool
- func (l *Ledger) ProcessTransaction(transaction SignedTransaction) error
- func (l *Ledger) RemoveTokensFrom(user string, amount uint) error
- type SignedTransaction
- type Transaction
- type Wallet
Constants ¶
View Source
const ( MiniCoin = 1 DecaCoin = 1_0 HectoCoin = 1_00 KiloCoin = 1_000 MegaCoin = 1_000_000 GigaCoin = 1_000_000_000 TeraCoin = 1_000_000_000_000 )
View Source
const MINING_REWARD = HectoCoin
View Source
const MiningRewardUser = "MINING_REWARD"
Variables ¶
View Source
var HASH_START = "c0ffee"
Functions ¶
func IsValidHash ¶
Types ¶
type Block ¶
type Block struct { // These should not be hashed Index uint Hash string // These should be included in the hash Transactions []SignedTransaction HashOfPreviousBlock string Timestamp time.Time Nonce uint }
func CreateGenesisBlock ¶
func CreateGenesisBlock() Block
func CreateNewBlock ¶
func CreateNewBlock(blockChain *BlockChain, transactions []SignedTransaction) Block
func (*Block) ComputeBlock ¶
func (Block) GetHashableString ¶
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
func CreateNewBlockChain ¶
func CreateNewBlockChain(user *Wallet) (BlockChain, error)
func (*BlockChain) AppendBlockAfterPoW ¶
func (b *BlockChain) AppendBlockAfterPoW(block Block, miner *Wallet) error
func (*BlockChain) UpdateLedgerWithBlock ¶
func (b *BlockChain) UpdateLedgerWithBlock(block *Block) error
func (BlockChain) ValidateChain ¶
func (b BlockChain) ValidateChain() error
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
func CreateNewLedger ¶
func CreateNewLedger() Ledger
func (*Ledger) AddTokensTo ¶
func (Ledger) IsValidTransaction ¶
func (l Ledger) IsValidTransaction(transaction SignedTransaction) bool
func (*Ledger) ProcessTransaction ¶
func (l *Ledger) ProcessTransaction(transaction SignedTransaction) error
type SignedTransaction ¶
type SignedTransaction struct { Signature []byte Transaction }
func CreateMiningReward ¶
func CreateMiningReward(to *Wallet) SignedTransaction
func CreateTransaction ¶
func (SignedTransaction) IsVerified ¶
func (st SignedTransaction) IsVerified() bool
type Transaction ¶
func (Transaction) Hash ¶
func (t Transaction) Hash() []byte
func (Transaction) SignTransaction ¶
func (t Transaction) SignTransaction(wallet *Wallet) SignedTransaction
func (Transaction) String ¶
func (t Transaction) String() string
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
func GenerateWallet ¶
func (*Wallet) GetPublicAddress ¶
Click to show internal directories.
Click to hide internal directories.