Documentation
¶
Index ¶
- Constants
- func NewBlock(txs []*models.TransactionModel, prev *models.BlockModel) *models.BlockModel
- func NewCoinBaseTX(to, data string) *models.TransactionModel
- func NewGenesisBlock(db *gorm.DB, odb *gorm.DB, address string) *models.BlockModel
- func NewTransaction(from, to string, amount int, bc *Blockchain, ws *models.Wallets) *models.TransactionModel
- type Blockchain
- func (b *Blockchain) AddBlock(txs []*models.TransactionModel)
- func (b *Blockchain) DisplayBlockChain()
- func (b *Blockchain) FindOutputs(PubKeyHash []byte, amount int) (int, map[string][]int)
- func (b *Blockchain) FindTransaction(Txid string) (*models.TransactionModel, error)
- func (b *Blockchain) GetUnspentOutputs(PubKeyHash []byte) []models.TXOutput
- func (b *Blockchain) GetUnspentTransactions(PubKeyHash []byte) []models.TransactionModel
- func (b *Blockchain) MineBlock(transactions []*models.TransactionModel)
- func (b *Blockchain) SetOutputsDB(db *gorm.DB)
- func (b *Blockchain) SignTransaction(transaction *models.TransactionModel, privKey *ecdsa.PrivateKey)
- func (b *Blockchain) UpdateBlocks()
- func (b *Blockchain) VerifyTransaction(transaction *models.TransactionModel) bool
- type ProofOfWork
Constants ¶
View Source
const TargetBits = 16
Variables ¶
This section is empty.
Functions ¶
func NewBlock ¶
func NewBlock(txs []*models.TransactionModel, prev *models.BlockModel) *models.BlockModel
func NewCoinBaseTX ¶
func NewCoinBaseTX(to, data string) *models.TransactionModel
func NewGenesisBlock ¶
func NewTransaction ¶
func NewTransaction(from, to string, amount int, bc *Blockchain, ws *models.Wallets) *models.TransactionModel
Types ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
func GetBlockChainFromGenesis ¶
func GetBlockChainFromGenesis(db *gorm.DB, odb *gorm.DB) *Blockchain
func NewBlockChain ¶
func (*Blockchain) AddBlock ¶
func (b *Blockchain) AddBlock(txs []*models.TransactionModel)
func (*Blockchain) DisplayBlockChain ¶
func (b *Blockchain) DisplayBlockChain()
func (*Blockchain) FindOutputs ¶
func (*Blockchain) FindTransaction ¶
func (b *Blockchain) FindTransaction(Txid string) (*models.TransactionModel, error)
func (*Blockchain) GetUnspentOutputs ¶
func (b *Blockchain) GetUnspentOutputs(PubKeyHash []byte) []models.TXOutput
func (*Blockchain) GetUnspentTransactions ¶
func (b *Blockchain) GetUnspentTransactions(PubKeyHash []byte) []models.TransactionModel
func (*Blockchain) MineBlock ¶
func (b *Blockchain) MineBlock(transactions []*models.TransactionModel)
func (*Blockchain) SetOutputsDB ¶
func (b *Blockchain) SetOutputsDB(db *gorm.DB)
func (*Blockchain) SignTransaction ¶
func (b *Blockchain) SignTransaction(transaction *models.TransactionModel, privKey *ecdsa.PrivateKey)
func (*Blockchain) UpdateBlocks ¶
func (b *Blockchain) UpdateBlocks()
func (*Blockchain) VerifyTransaction ¶
func (b *Blockchain) VerifyTransaction(transaction *models.TransactionModel) bool
type ProofOfWork ¶
type ProofOfWork struct {
// contains filtered or unexported fields
}
func NewProofOfWork ¶
func NewProofOfWork(b *models.BlockModel) *ProofOfWork
func (*ProofOfWork) Run ¶
func (pow *ProofOfWork) Run() (int, [32]byte)
func (*ProofOfWork) Validate ¶
func (pow *ProofOfWork) Validate() bool
Click to show internal directories.
Click to hide internal directories.