block

package
v0.0.0-...-6d37b2d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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 NewBlock

func NewBlock(nonce int, previousHash [32]byte, transactions []*Transaction) *Block

func (*Block) Hash

func (b *Block) Hash() [32]byte

func (*Block) MarshalJSON

func (b *Block) MarshalJSON() ([]byte, error)

func (*Block) Print

func (b *Block) Print()

type Blockchain

type Blockchain struct {
	// contains filtered or unexported fields
}

func NewBlockchain

func NewBlockchain(blockchainAddress string, port uint16) *Blockchain

func (*Blockchain) AddTransaction

func (bc *Blockchain) AddTransaction(sender string, recipient string, value float32,
	senderPublicKey *ecdsa.PublicKey, s *utils.Signature) bool

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 (bc *Blockchain) CreateTransaction(sender string, recipient string, value float32,
	senderPublicKey *ecdsa.PublicKey, s *utils.Signature) bool

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL