PoS

package
v0.0.0-...-3c37bd4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(publKey ecdsa.PublicKey) string

func GenPublicKey

func GenPublicKey() string

func GetAddress

func GetAddress(publicKey string) string

func Hash160

func Hash160(inputByte []byte) []byte

func Hash256

func Hash256(inputByte []byte) []byte

func IntToHex

func IntToHex(num int64) []byte

IntToHex converts an int64 to a byte array

func ReverseBytes

func ReverseBytes(data []byte)

ReverseBytes reverses a byte array

func Ripemd160Once

func Ripemd160Once(inputByte []byte) []byte

func Serialize

func Serialize(obj any) []byte

func SetHashAndAddress

func SetHashAndAddress(b *Block, mp *MinerPool)

func Sha256Once

func Sha256Once(inputByte []byte) []byte

Types

type Block

type Block struct {
	Timestamp int64
	PrevHash  []byte
	Hash      []byte
	Data      []byte
	Height    int64
	DiffNum   uint
	Nonce     int64
	Address   string
}

func DeserializeBlock

func DeserializeBlock(d []byte) *Block

func NewBlock

func NewBlock(data string, prevHash []byte, height int64, mp *MinerPool) *Block

func NewGenesisBlock

func NewGenesisBlock(mp *MinerPool) *Block

type Blockchain

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

func NewBlockchain

func NewBlockchain(mp *MinerPool) *Blockchain

func (*Blockchain) AddBlock

func (bc *Blockchain) AddBlock(data string)

func (*Blockchain) BlockChainIteration

func (bc *Blockchain) BlockChainIteration()

func (*Blockchain) NewIterator

func (bc *Blockchain) NewIterator() *BlockchainIterator

func (*Blockchain) ShowBlocksOfMiner

func (bc *Blockchain) ShowBlocksOfMiner(address string)

type BlockchainIterator

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

func (*BlockchainIterator) Next

func (bci *BlockchainIterator) Next() *Block

type Miner

type Miner struct {
	Tokens  int64
	Days    int64
	Address string
}

func DeserializeMiner

func DeserializeMiner(d []byte) *Miner

func NewMiner

func NewMiner(tokens, days int64) *Miner

type MinerPool

type MinerPool struct {
	DiffNum     uint
	Target      big.Int
	Addresses   []string
	Probability []string
	// contains filtered or unexported fields
}

func NewMinerPool

func NewMinerPool(addressesJson, dbFile string) *MinerPool

func (*MinerPool) AddMiner

func (mp *MinerPool) AddMiner(tokens, days int64)

func (*MinerPool) Adjust

func (mp *MinerPool) Adjust(NewDiffNum uint)

func (*MinerPool) Mine

func (mp *MinerPool) Mine(b *Block) (int64, []byte, string)

func (*MinerPool) PrepareData

func (mp *MinerPool) PrepareData(b *Block, nonce int64) []byte

func (*MinerPool) ShowAllMiners

func (mp *MinerPool) ShowAllMiners()

func (*MinerPool) Validate

func (mp *MinerPool) Validate(b *Block) bool

Jump to

Keyboard shortcuts

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