database

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

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account string

func NewAccount

func NewAccount(value string) Account

type Block

type Block struct {
	Header BlockHeader `json:"header"`
	TXs    []Tx        `json:"payload"`
}

func NewBlock

func NewBlock(parent Hash, time uint64, txs []Tx) Block

func (Block) Hash

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

type BlockFS

type BlockFS struct {
	Key   Hash  `json:"hash"`
	Value Block `json:"block"`
}

type BlockHeader

type BlockHeader struct {
	Parent Hash   `json:"parent"`
	Time   uint64 `json:"time"`
}

type Hash

type Hash [32]byte

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(data []byte) error

type State

type State struct {
	Balances map[Account]uint
	// contains filtered or unexported fields
}

func NewStateFromDisk

func NewStateFromDisk(dataDir string) (*State, error)

func (*State) AddBlock

func (s *State) AddBlock(b Block) error

func (*State) AddTx

func (s *State) AddTx(tx Tx) error

func (*State) Close

func (s *State) Close() error

func (*State) LatestBlockHash

func (s *State) LatestBlockHash() Hash

func (*State) Persist

func (s *State) Persist() (Hash, error)

type Tx

type Tx struct {
	From  Account `json:"from"`
	To    Account `json:"to"`
	Value uint    `json:"value"`
	Data  string  `json:"data"`
}

func NewTx

func NewTx(from Account, to Account, value uint, data string) Tx

func (Tx) IsReward

func (t Tx) IsReward() bool

Jump to

Keyboard shortcuts

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