state

package
v0.0.0-...-88bd931 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const BlockReward = float32(10)

Variables

This section is empty.

Functions

func ApplyBlock

func ApplyBlock(b Block, s *State) error

func ExpandPath

func ExpandPath(p string) string

func GetEncryptionKeysFilePath

func GetEncryptionKeysFilePath(datadir string) string

func GetKeystoreDirPath

func GetKeystoreDirPath(datadir string) string

func IsBlockHashValid

func IsBlockHashValid(hash Hash) bool

IsBlockHashValid

func NewAddress

func NewAddress(value string) common.Address

func RemoveDir

func RemoveDir(path string) error

func Rename

func Rename(originalPath string, destinationPath string) error

func Unicode

func Unicode(s string) string

func WriteEncryptionKeys

func WriteEncryptionKeys(datadir string, key keystore.CryptoJSON) error

Types

type Block

type Block struct {
	Header BlockHeader
	TXs    []SignedTx
}

func GetBlocksAfter

func GetBlocksAfter(blockHash Hash, dataDir string) ([]Block, error)

Get all blocks in 'datadir' whose parent is a child of the block with the given block hash

func NewBlock

func NewBlock(parent Hash, time uint64, number uint64, txs []SignedTx,
	nonce uint32, miner common.Address, pow int) Block

NewBlock

func (*Block) Hash

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

Hash the block's transactions

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"`
	Number uint64         `json:"number"`
	Nonce  uint32         `json:"nonce"`
	Miner  common.Address `json:"miner"`
	PoW    int            `json:"proof_of_work"`
}

type CurrentNodeState

type CurrentNodeState struct {
	OwnedChannels  [][]byte `json:"channels"`
	Balance        float32  `json:"balance"`
	PendingBalance float32  `json:"pending_balance"`
}

type Genesis

type Genesis struct {
	State map[common.Address]CurrentNodeState `json:"state"`
}

type Hash

type Hash [32]byte

func (Hash) Hex

func (h Hash) Hex() string

func (Hash) IsEmpty

func (h Hash) IsEmpty() bool

func (Hash) MarshalText

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

func (*Hash) UnmarshalText

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

type SignedTx

type SignedTx struct {
	Tx
	Sig []byte `json:"signature"`
}

func NewSignedTx

func NewSignedTx(tx Tx, sig []byte) SignedTx

func (SignedTx) IsAuthentic

func (t SignedTx) IsAuthentic() (bool, error)

type State

type State struct {
	Subscriptions        map[string]chan core.MessageTransport
	Catalog              map[common.Address]CurrentNodeState
	Account2Nonce        map[common.Address]uint
	PendingAccount2Nonce map[common.Address]uint
	// contains filtered or unexported fields
}

func NewStateFromDisk

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

* Loads the current state by replaying all transactions in block.db * on top of the genesis state as defined in genesis.json

func (*State) AddBlock

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

func (*State) Close

func (s *State) Close()

* Close the connection to the file

func (*State) LatestBlock

func (s *State) LatestBlock() Block

* Get the latest block from the current state

func (*State) LatestBlockHash

func (s *State) LatestBlockHash() Hash

* Get the latest block hash from the current state

func (*State) NextBlockNumber

func (s *State) NextBlockNumber() uint64

type Tx

type Tx struct {
	Author common.Address `json:"author"`
	Topic  string         `json:"topic"`
	// GenesisState []byte
	// ValidationRules ???
	Nonce uint   `json:"nonce"`
	Time  uint64 `json:"time"`
}

func NewTx

func NewTx(from common.Address, topic string, nonce uint) Tx

func (Tx) Encode

func (t Tx) Encode() ([]byte, error)

func (Tx) Hash

func (t Tx) Hash() (Hash, error)

Jump to

Keyboard shortcuts

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