types

package
v0.0.0-...-7cc22e0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add2PKH

func Add2PKH(address Address) []byte

func Hash

func Hash(s serializer) []byte

TODO: for sign interface

func Int2Hex

func Int2Hex(n int64) []byte

func NodeID

func NodeID(config config.Config) string

func PK2Add

func PK2Add(pk []byte, isHash bool) string

Types

type Account

type Account string

Account address in string

type Address

type Address []byte

account address in byte

type Block

type Block struct {
	BH           *BlockHeader
	Transactions []*Transaction
}

func NewBlock

func NewBlock() *Block

func (*Block) Hash

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

func (*Block) SnapShot

func (b *Block) SnapShot() *Block

a deep copy of Block

func (*Block) Validate_hash

func (b *Block) Validate_hash() bool

type BlockHeader

type BlockHeader struct {
	Timestamp  int64
	PrevHash   []byte
	BlockIndex uint64
	BlockHash  []byte
	Miner      Address
	Nonce      uint64
	Difficulty uint64
}

type Chainid

type Chainid int

type Node

type Node struct {
	ID string
	// Node full address
	FullAdd     string
	Port        string
	GenesisHash []byte
	LastHash    []byte
	NodeHeight  uint64
}

func NewNode

func NewNode(config config.Config, port int, last_hash []byte, height uint64) *Node

type Transaction

type Transaction struct {
	Timestamp time.Duration
	TxID      []byte
	TxInputs  []*TxIn
	TxOutputs []*TxOut
}

func CoinbaseTx

func CoinbaseTx(to Address, amount int) *Transaction

func (*Transaction) CheckHash

func (tx *Transaction) CheckHash() bool

func (Transaction) Checksig

func (tx Transaction) Checksig() bool

OP_CHECKSIG

func (*Transaction) IsCoinbase

func (tx *Transaction) IsCoinbase() bool

func (*Transaction) IsValid

func (tx *Transaction) IsValid(u []*UTXO) bool

func (*Transaction) SnapShot

func (tx *Transaction) SnapShot() *Transaction

deep copy of transaction

func (Transaction) TrimmeTX

func (tx Transaction) TrimmeTX() *Transaction

type TxIn

type TxIn struct {
	OutPoint  []byte
	Vout      uint
	Value     int
	PublicKey []byte // serialized compressed public key
	Signature []byte
}

type TxOut

type TxOut struct {
	PublicKeyHash []byte
	Value         int
}

type UTXO

type UTXO struct {
	Txid  []byte
	Index uint
	Txout *TxOut
}

func (*UTXO) SnapShot

func (u *UTXO) SnapShot() *UTXO

type UtxoSet

type UtxoSet struct {
	Mu     *sync.Mutex
	Tokens map[Account][]*UTXO
}

func NewUtxoSet

func NewUtxoSet() *UtxoSet

func (*UtxoSet) SnapShot

func (u *UtxoSet) SnapShot() *UtxoSet

func (*UtxoSet) UpdateUtxoSet

func (u *UtxoSet) UpdateUtxoSet(tx *Transaction)

Jump to

Keyboard shortcuts

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