blockchain

package
v0.0.0-...-9bf9bed Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

blockchain.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAddress

func FormatAddress(publicKey *ecdsa.PublicKey) string

func InitializeRedis

func InitializeRedis()

InitializeRedis initializes the Redis client.

Types

type Block

type Block struct {
	Index        int
	PrevHash     string
	Hash         string
	TimeStamp    string
	Data         string
	Transactions []*Transaction
}

func CreateGenesisBlock

func CreateGenesisBlock() *Block

type Blockchain

type Blockchain struct {
	Blocks []*Block
}

func NewBlockchain

func NewBlockchain() *Blockchain

func NewBlockchainWithGenesis

func NewBlockchainWithGenesis(genesis *Block) *Blockchain

func (*Blockchain) AddBlock

func (bc *Blockchain) AddBlock(data string, sender *Wallet, receiver *Wallet, amount int)

func (*Blockchain) PrintBlockchain

func (bc *Blockchain) PrintBlockchain()

type Transaction

type Transaction struct {
	From   *ecdsa.PublicKey
	To     *ecdsa.PublicKey
	Amount int
}

type Wallet

type Wallet struct {
	PrivateKey *ecdsa.PrivateKey
	PublicKey  *ecdsa.PublicKey
}

func CreateWallet

func CreateWallet() (*Wallet, error)

Jump to

Keyboard shortcuts

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