models

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

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

Go to latest
Published: May 16, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBlockHashValid

func IsBlockHashValid(hash common.Hash, miningDifficulty uint) bool

Types

type Block

type Block struct {
	Header       BlockHeader         `json:"header"`
	Transactions []SignedTransaction `json:"transactions"`
}

func NewBlock

func NewBlock(parent common.Hash, number uint64, nonce uint64, time time.Time, miner common.Address, txs []SignedTransaction) Block

func (Block) GasReward

func (b Block) GasReward() uint64

func (Block) Hash

func (b Block) Hash() (common.Hash, error)

func (Block) JsonEncode

func (b Block) JsonEncode() ([]byte, error)

func (Block) ToProto

func (b Block) ToProto() *blockchainpb.Block

type BlockHeader

type BlockHeader struct {
	Parent    common.Hash    `json:"parent"`
	Number    uint64         `json:"number"`
	Nonce     uint64         `json:"nonce"`
	Miner     common.Address `json:"address"`
	Timestamp time.Time      `json:"timestamp"`
}

type Genesis

type Genesis struct {
	ChainID     uint32                               `json:"chain_id"`
	ChainName   string                               `json:"chain_name"`
	ChainSymbol string                               `json:"chain_symbol"`
	Timestamp   time.Time                            `json:"timestamp"`
	Coinbase    common.Address                       `json:"coinbase"`
	Allocations map[common.Address]GenesisAllocation `json:"allocs"`
}

func LoadGenesisFromPath

func LoadGenesisFromPath(path string) (*Genesis, error)

type GenesisAllocation

type GenesisAllocation struct {
	Balance uint64 `json:"balance"`
}

type SignedTransaction

type SignedTransaction struct {
	Transaction Transaction `json:"transaction"`
	Signature   []byte      `json:"signature"`
}

func (*SignedTransaction) ToProto

type Transaction

type Transaction struct {
	Sender    common.Address `json:"sender"`
	Recipient common.Address `json:"recipient"`
	Amount    uint64         `json:"amount"`
	Nonce     uint64         `json:"nonce"`
	Gas       uint64         `json:"gas"`
	GasPrice  uint64         `json:"gas_price"`
	Data      string         `json:"data"`
	Timestamp time.Time      `json:"timestamp"`
}

func (Transaction) IsReward

func (t Transaction) IsReward() bool

Jump to

Keyboard shortcuts

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