block

package
v1.18.0-RC2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Provides the data structures and methods to work with the block data structure. The block data structure is the core data structure in the 0chain protocol. It is used to store the transactions and the state of the system at a given point in time. The block data structure is used to create the blockchain, which is a chain of blocks that are linked together using the hash of the previous block.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Header *Header `json:"-"`

	MinerID           common.Key `json:"miner_id"`
	Round             int64      `json:"round"`
	RoundRandomSeed   int64      `json:"round_random_seed"`
	RoundTimeoutCount int        `json:"round_timeout_count"`

	Hash            common.Key `json:"hash"`
	Signature       string     `json:"signature"`
	ChainID         common.Key `json:"chain_id"`
	ChainWeight     float64    `json:"chain_weight"`
	RunningTxnCount int64      `json:"running_txn_count"`

	Version      string           `json:"version"`
	CreationDate common.Timestamp `json:"creation_date"`

	MagicBlockHash string `json:"magic_block_hash"`
	PrevHash       string `json:"prev_hash"`

	ClientStateHash Key                        `json:"state_hash"`
	Txns            []*transaction.Transaction `json:"transactions,omitempty"`
}

Block - data structure that holds the block data

type ChainStats

type ChainStats struct {
	BlockSize            int     `json:"block_size"`
	Count                int     `json:"count"`
	CurrentRound         int     `json:"current_round"`
	Delta                int     `json:"delta"`
	LatestFinalizedRound int     `json:"latest_finalized_round"`
	Max                  float64 `json:"max"`
	Mean                 float64 `json:"mean"`
	Min                  float64 `json:"min"`
	Percentile50         float64 `json:"percentile_50"`
	Percentile90         float64 `json:"percentile_90"`
	Percentile95         float64 `json:"percentile_95"`
	Percentile99         float64 `json:"percentile_99"`
	Rate15Min            float64 `json:"rate_15_min"`
	Rate1Min             float64 `json:"rate_1_min"`
	Rate5Min             float64 `json:"rate_5_min"`
	RateMean             float64 `json:"rate_mean"`
	StdDev               float64 `json:"std_dev"`
	TotalTxns            int     `json:"total_txns"`
}

type DKGKeyShare

type DKGKeyShare struct {
	ID      string `json:"id"`
	Message string `json:"message"`
	Share   string `json:"share"`
	Sign    string `json:"sign"`
}

type FeeStats added in v1.8.16

type FeeStats struct {
	MaxFees  common.Balance `json:"max_fees"`
	MinFees  common.Balance `json:"min_fees"`
	MeanFees common.Balance `json:"mean_fees"`
}

type GroupSharesOrSigns

type GroupSharesOrSigns struct {
	Shares map[string]*ShareOrSigns `json:"shares"`
}
type Header struct {
	Version               string `json:"version,omitempty"`
	CreationDate          int64  `json:"creation_date,omitempty"`
	Hash                  string `json:"hash,omitempty"`
	MinerID               string `json:"miner_id,omitempty"`
	Round                 int64  `json:"round,omitempty"`
	RoundRandomSeed       int64  `json:"round_random_seed,omitempty"`
	MerkleTreeRoot        string `json:"merkle_tree_root,omitempty"`
	StateHash             string `json:"state_hash,omitempty"`
	ReceiptMerkleTreeRoot string `json:"receipt_merkle_tree_root,omitempty"`
	NumTxns               int64  `json:"num_txns,omitempty"`
}

func (*Header) IsBlockExtends

func (h *Header) IsBlockExtends(prevHash string) bool

IsBlockExtends - check if the block extends the previous block

  • prevHash is the hash of the previous block

type Info

type Info struct {
	BuildTag                string        `json:"build_tag"`
	StateMissingNodes       int64         `json:"state_missing_nodes"`
	MinersMedianNetworkTime time.Duration `json:"miners_median_network_time"`
	AvgBlockTxns            int           `json:"avg_block_txns"`
}

type Key

type Key []byte

type MPK

type MPK struct {
	ID  string
	Mpk []string
}

type MagicBlock

type MagicBlock struct {
	Hash                   string              `json:"hash"`
	PreviousMagicBlockHash string              `json:"previous_hash"`
	MagicBlockNumber       int64               `json:"magic_block_number"`
	StartingRound          int64               `json:"starting_round"`
	Miners                 *NodePool           `json:"miners"`   //this is the pool of miners participating in the blockchain
	Sharders               *NodePool           `json:"sharders"` //this is the pool of sharders participaing in the blockchain
	ShareOrSigns           *GroupSharesOrSigns `json:"share_or_signs"`
	Mpks                   *Mpks               `json:"mpks"`
	T                      int                 `json:"t"`
	K                      int                 `json:"k"`
	N                      int                 `json:"n"`
}

type Mpks

type Mpks struct {
	Mpks map[string]*MPK
}

type Node

type Node struct {
	ID           string `yaml:"id" json:"id"`
	Version      string `yaml:"version" json:"version"`
	CreationDate int64  `json:"creation_date"`
	PublicKey    string `yaml:"public_key" json:"public_key"`
	PrivateKey   string `yaml:"private_key" json:"-"`
	N2NHost      string `yaml:"n2n_ip" json:"n2n_host"`
	Host         string `yaml:"public_ip" json:"host"`
	Port         int    `yaml:"port" json:"port"`
	Path         string `yaml:"path" json:"path"`
	Type         int    `json:"type"`
	Description  string `yaml:"description" json:"description"`
	SetIndex     int    `yaml:"set_index" json:"set_index"`
	Status       int    `json:"status"`
	Info         Info   `json:"info"`
}

type NodePool

type NodePool struct {
	Type  int             `json:"type"`
	Nodes map[string]Node `json:"nodes"`
}

type ShareOrSigns

type ShareOrSigns struct {
	ID           string                  `json:"id"`
	ShareOrSigns map[string]*DKGKeyShare `json:"share_or_sign"`
}

Jump to

Keyboard shortcuts

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