Documentation ¶
Index ¶
- func HashBlock(previousBlockHash string, currentBlockData BlockData, nonce int) string
- func ProofOfWork(previousBlockHash string, currentBlockData BlockData) int
- type Block
- type BlockData
- type Blockchain
- func (b *Blockchain) AddMinedBlockToChain(newBlock Block)
- func (b *Blockchain) AddTransactionToPendingTransactions(transaction Transaction) int
- func (b *Blockchain) GetLastBlock() Block
- func (b *Blockchain) MineBlock() Block
- func (b *Blockchain) NewBlock(nonce int, previousBlockHash string, hash string) Block
- func (b *Blockchain) PublishChain(replyQueue string)
- func (b *Blockchain) RequestChain()
- func (b *Blockchain) SynchroniseChain(chain Blockchain)
- type ChainRequest
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashBlock ¶
HashBlock - sha256 hash of block Ref: https://github.com/openblockchains/awesome-sha256/blob/master/hash.go
func ProofOfWork ¶
ProofOfWork Algorithm
Types ¶
type Block ¶
type Block struct { Hash string Index int Nonce int PreviousBlockHash string Timestamp int64 Transactions []Transaction }
Block structure
type Blockchain ¶
type Blockchain struct { Chain []Block PendingTransactions []Transaction }
Blockchain structure
var B Blockchain
B - The Blockchain
func CreateNewBlockchain ¶
func CreateNewBlockchain() Blockchain
CreateNewBlockchain - Function to create new chain
func (*Blockchain) AddMinedBlockToChain ¶
func (b *Blockchain) AddMinedBlockToChain(newBlock Block)
AddMinedBlockToChain add block
func (*Blockchain) AddTransactionToPendingTransactions ¶
func (b *Blockchain) AddTransactionToPendingTransactions(transaction Transaction) int
AddTransactionToPendingTransactions to add transaction to chain
func (*Blockchain) GetLastBlock ¶
func (b *Blockchain) GetLastBlock() Block
GetLastBlock of blockchain
func (*Blockchain) NewBlock ¶
func (b *Blockchain) NewBlock(nonce int, previousBlockHash string, hash string) Block
NewBlock - To create new block
func (*Blockchain) PublishChain ¶
func (b *Blockchain) PublishChain(replyQueue string)
PublishChain for peer nodes to sync
func (*Blockchain) SynchroniseChain ¶
func (b *Blockchain) SynchroniseChain(chain Blockchain)
SynchroniseChain Method
type Transaction ¶
type Transaction struct { Checksum string Data string DataCategory string Recipient string Sender string TransactionID string }
Transaction structure
func NewTransaction ¶
func NewTransaction(data string, dataCategory string, sender string, recipient string) Transaction
NewTransaction to create new transaction
Click to show internal directories.
Click to hide internal directories.