Documentation ¶
Index ¶
- Constants
- func GetReward(usdPrice int) int
- func NewTransactionList(transactions []wallet.Transaction) ([]byte, error)
- func SumDexmHashVOne(nonce, block []byte) (*big.Int, error)
- func VerifyTransactionSignature(transaction wallet.Transaction) (bool, error)
- type Block
- type BlockChain
- func (bc *BlockChain) GenerateBalanceDB()
- func (bc *BlockChain) GetBalance(wallet string) (int, int, int)
- func (bc *BlockChain) GetBlock(index int64) (*Block, error)
- func (bc *BlockChain) GetLen() int64
- func (bc *BlockChain) GetPoBWallets(nodes int) []string
- func (bc *BlockChain) NewBlock(transactionList, contractList []byte)
- func (bc *BlockChain) ProcessBlock(curr *Block) error
- func (bc *BlockChain) SetBalance(wallet string, amount, nonce, burn int) error
- func (bc *BlockChain) VerifyNewBlockValidity(minedBlock *PoWBlock) (bool, error)
- type PoWBlock
- type SegwitTransaction
- type WalletInfo
Constants ¶
const ( GENESIS_DIFF = 20000000000000 USD_REWARD = 250 )
Variables ¶
This section is empty.
Functions ¶
func GetReward ¶
Finds reward for a usd price Each block has a fixed reward in USD. usdPrice is found by using schelling. We do this to keep the price of the coin somewhat stable. There is one huge flaw however: you will get a good hash about 2**256/difficulty times, thus with a higher difficulty the reward should grow.
func NewTransactionList ¶
func NewTransactionList(transactions []wallet.Transaction) ([]byte, error)
Function that generates a Segwit list of transactions.
func SumDexmHashVOne ¶
First version of the PoW hash. Uses lyra2rev2
func VerifyTransactionSignature ¶
func VerifyTransactionSignature(transaction wallet.Transaction) (bool, error)
Verify if a transaction has a valid signature
Types ¶
type Block ¶
type Block struct { Index int64 `bson:"i"` Timestamp int64 `bson:"t"` Hash string `bson:"h"` PreviousBlockHash string `bson:"p"` TransactionList []byte `bson:"l,omitempty"` ContractList []byte `bson:"c,omitempty"` Miner string `bson:"m"` }
func (*Block) CalculateHash ¶
func (*Block) GetDifficulty ¶
func (b *Block) GetDifficulty(bc *BlockChain) *big.Int
Returns difficulty for a given block This function assumes the block is valid. TODO Implement adjustments based on Shelling results and hashing power
type BlockChain ¶
func NewBlockChain ¶
func NewBlockChain() *BlockChain
Generates a new blockchain with only the genesis block
func (*BlockChain) GenerateBalanceDB ¶
func (bc *BlockChain) GenerateBalanceDB()
Generates database of all balances in the blockchain
func (*BlockChain) GetBalance ¶
func (bc *BlockChain) GetBalance(wallet string) (int, int, int)
Given a wallet returns balance and nonce
func (*BlockChain) GetBlock ¶
func (bc *BlockChain) GetBlock(index int64) (*Block, error)
Returns a block at index i
func (*BlockChain) GetLen ¶
func (bc *BlockChain) GetLen() int64
Returns how many blocks are in the chain
func (*BlockChain) GetPoBWallets ¶
func (bc *BlockChain) GetPoBWallets(nodes int) []string
Returns random wallets based on their burn. TODO Add PoB decay
func (*BlockChain) NewBlock ¶
func (bc *BlockChain) NewBlock(transactionList, contractList []byte)
Turns transactions and contracts into a block without the proof of work. Then stores it in the DB TODO Only PoW blocks shold be on the DB
func (*BlockChain) ProcessBlock ¶
func (bc *BlockChain) ProcessBlock(curr *Block) error
Takes in a block and then updates all balances
func (*BlockChain) SetBalance ¶
func (bc *BlockChain) SetBalance(wallet string, amount, nonce, burn int) error
Stores amount, nonce, and burn for a given wallet
func (*BlockChain) VerifyNewBlockValidity ¶
func (bc *BlockChain) VerifyNewBlockValidity(minedBlock *PoWBlock) (bool, error)
Verify that a PoW block is valid