Documentation ¶
Index ¶
- Constants
- type AmountResponse
- type Block
- type Blockchain
- func (bc *Blockchain) AddTransaction(sender string, recipient string, value float32, ...) bool
- func (bc *Blockchain) CalculateTotalAmount(blockchainAddress string) float32
- func (bc *Blockchain) CopyTransactionPool() []*Transaction
- func (bc *Blockchain) CreateBlock(nonce int, previousHash [32]byte) *Block
- func (bc *Blockchain) CreateTransaction(sender string, recipient string, value float32, ...) bool
- func (bc *Blockchain) LastBlock() *Block
- func (bc *Blockchain) MarshalJSON() ([]byte, error)
- func (bc *Blockchain) Mining() bool
- func (bc *Blockchain) Print()
- func (bc *Blockchain) ProofOfWork() int
- func (bc *Blockchain) StartMining()
- func (bc *Blockchain) TransactionPool() []*Transaction
- func (bc *Blockchain) ValidProof(nonce int, previousHash [32]byte, transactions []*Transaction, difficulty int) bool
- func (bc *Blockchain) VerifyTransactionSignature(senderPublicKey *ecdsa.PublicKey, s *utils.Signature, t *Transaction) bool
- type Transaction
- type TransactionRequest
Constants ¶
View Source
const ( MINING_DIFFICULTY = 3 MINING_SENDER = "THE BLOCKCHAIN" MINING_REWARD = 1.0 MINING_TIMER_SEC = 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AmountResponse ¶
type AmountResponse struct {
Amount float32 `json:"amount"`
}
func (*AmountResponse) MarshalJSON ¶
func (ar *AmountResponse) MarshalJSON() ([]byte, error)
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(blockchainAddress string, port uint16) *Blockchain
func (*Blockchain) AddTransaction ¶
func (*Blockchain) CalculateTotalAmount ¶
func (bc *Blockchain) CalculateTotalAmount(blockchainAddress string) float32
func (*Blockchain) CopyTransactionPool ¶
func (bc *Blockchain) CopyTransactionPool() []*Transaction
func (*Blockchain) CreateBlock ¶
func (bc *Blockchain) CreateBlock(nonce int, previousHash [32]byte) *Block
func (*Blockchain) CreateTransaction ¶
func (*Blockchain) LastBlock ¶
func (bc *Blockchain) LastBlock() *Block
func (*Blockchain) MarshalJSON ¶
func (bc *Blockchain) MarshalJSON() ([]byte, error)
func (*Blockchain) Mining ¶
func (bc *Blockchain) Mining() bool
func (*Blockchain) Print ¶
func (bc *Blockchain) Print()
func (*Blockchain) ProofOfWork ¶
func (bc *Blockchain) ProofOfWork() int
func (*Blockchain) StartMining ¶
func (bc *Blockchain) StartMining()
func (*Blockchain) TransactionPool ¶
func (bc *Blockchain) TransactionPool() []*Transaction
func (*Blockchain) ValidProof ¶
func (bc *Blockchain) ValidProof(nonce int, previousHash [32]byte, transactions []*Transaction, difficulty int) bool
func (*Blockchain) VerifyTransactionSignature ¶
func (bc *Blockchain) VerifyTransactionSignature( senderPublicKey *ecdsa.PublicKey, s *utils.Signature, t *Transaction) bool
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func NewTransaction ¶
func NewTransaction(sender string, recipient string, value float32) *Transaction
func (*Transaction) MarshalJSON ¶
func (t *Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) Print ¶
func (t *Transaction) Print()
type TransactionRequest ¶
type TransactionRequest struct { SenderBlockchainAddress *string `json:"sender_blockchain_address"` RecipientBlockchainAddress *string `json:"recipient_blockchain_address"` SenderPublicKey *string `json:"sender_public_key"` Value *float32 `json:"value"` Signature *string `json:"signature"` }
func (*TransactionRequest) Validate ¶
func (tr *TransactionRequest) Validate() bool
Click to show internal directories.
Click to hide internal directories.