Documentation ¶
Index ¶
- type Block
- type Blockchain
- func (bc *Blockchain) AddTransaction(sender, recepient string, value float32)
- func (bc *Blockchain) CalculateTotalAmount(addr string) float32
- func (bc Blockchain) CopyTransactionPool() []*Transaction
- func (bc *Blockchain) CreateBlock(nonce int, prevHash [32]byte) *Block
- func (bc Blockchain) LastBlock() *Block
- func (bc *Blockchain) Mining() bool
- func (bc Blockchain) Print()
- func (bc Blockchain) ProofOfWork() int
- func (bc Blockchain) ValidProof(nonce int, prevHash [32]byte, txns []*Transaction, difficulty int) bool
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func (Block) MarshalJSON ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
func NewBlockchain ¶
func NewBlockchain(addr string) *Blockchain
func (*Blockchain) AddTransaction ¶
func (bc *Blockchain) AddTransaction(sender, recepient string, value float32)
func (*Blockchain) CalculateTotalAmount ¶
func (bc *Blockchain) CalculateTotalAmount(addr string) float32
func (Blockchain) CopyTransactionPool ¶
func (bc Blockchain) CopyTransactionPool() []*Transaction
func (*Blockchain) CreateBlock ¶
func (bc *Blockchain) CreateBlock(nonce int, prevHash [32]byte) *Block
func (Blockchain) LastBlock ¶
func (bc Blockchain) LastBlock() *Block
func (*Blockchain) Mining ¶
func (bc *Blockchain) Mining() bool
Mining accepts a receiver pointer even though there is no mutation done in this method. However, it calls other mutating methods like Add Transaction to which reference needs to be passed so that the mutation is successful
func (Blockchain) Print ¶
func (bc Blockchain) Print()
func (Blockchain) ProofOfWork ¶
func (bc Blockchain) ProofOfWork() int
func (Blockchain) ValidProof ¶
func (bc Blockchain) ValidProof(nonce int, prevHash [32]byte, txns []*Transaction, difficulty int) bool
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func NewTransaction ¶
func NewTransaction(sender, recepient string, value float32) *Transaction
func (Transaction) MarshalJSON ¶
func (t Transaction) MarshalJSON() ([]byte, error)
func (Transaction) Print ¶
func (t Transaction) Print()
Click to show internal directories.
Click to hide internal directories.