dag

package
v0.1.7-0...-7628261 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DagBlocksRejected = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "casanova_dag_blocks_rejected_total",
		Help: "Number of blocks rejected.",
	})

	DagMicroVec = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "dag_usec_total",
		Help: "Total microseconds spent in DAG subprocesses.",
	},
		[]string{"function"},
	)
	TotalBytesWritten = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "consensus_bytes_total",
		Help: "Total bytes written to disk for various objects.",
	},
		[]string{"object"},
	)
)
View Source
var (
	SaveMicroVec = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "save_usec_total",
		Help: "Total microseconds spent writing to disk for various objects.",
	},
		[]string{"object"},
	)
)

Functions

This section is empty.

Types

type BlockCache

type BlockCache struct {
	// contains filtered or unexported fields
}

func LoadBlockCache

func LoadBlockCache() (*BlockCache, error)

func NewBlockCache

func NewBlockCache(genesis block.Block) (*BlockCache, error)

func (BlockCache) Get

func (bc BlockCache) Get(bid ids.BlockId) (block.Block, bool)

TODO(chuck): We'll probably want separate functions for loading Blocks/Parents. There will be distinct instances where we'll want the parent info (e.g. a validator came back online and is talking about a block we haven't needed in a while) and when we won't need parent info (e.g. when someone requests an old block for catchup). For now, always loading both is the more comprehensive but inefficient choice

func (BlockCache) GetTxn

func (BlockCache) Has

func (bc BlockCache) Has(bid ids.BlockId) bool

func (BlockCache) Load

func (bc BlockCache) Load(bid ids.BlockId) (block.Block, error)

func (BlockCache) LoadBlock

func (bc BlockCache) LoadBlock(bid ids.BlockId) (block.Block, error)

func (BlockCache) LoadParents

func (bc BlockCache) LoadParents(bid ids.BlockId) (block.Heights, error)

func (BlockCache) Range

func (bc BlockCache) Range(vid uint16, f func(block.Block) bool)

func (BlockCache) Save

func (bc BlockCache) Save(blk block.Block) error

func (BlockCache) Seen

func (bc BlockCache) Seen(bid ids.BlockId) bool

func (BlockCache) Set

func (bc BlockCache) Set(bid ids.BlockId, blk block.Block)

func (BlockCache) Size

func (bc BlockCache) Size() uint64

func (BlockCache) Tip

func (bc BlockCache) Tip(vid uint16) block.Block

type Dag

type Dag interface {
	Blocks() *BlockCache
	Roots() block.Heights
	Tip(uint16) ids.BlockId

	Add(block.Block) bool
	Get(ids.BlockId) (block.Block, bool)
	Has(ids.BlockId) bool
	Size() uint64

	Pending() *pendingQueue

	InterpretDeltas(block.Block) bool

	CatchUpChannel() chan block.Block

	GetDot() string
}

type LinearHashTable

type LinearHashTable struct {
	// contains filtered or unexported fields
}

func NewLHT

func NewLHT(keybits uint16) (*LinearHashTable, error)

func (*LinearHashTable) Get

func (*LinearHashTable) GetDups

Gets all dups of txn

func (*LinearHashTable) GetTxn

func (*LinearHashTable) Insert

func (tbl *LinearHashTable) Insert(txn transaction.Transaction) (bool, error)

Inserts the value into the table. Returns a bool indicating whether there was another (duplicate) element with the same value. If successfully inserted, error is nil.

func (*LinearHashTable) Key

func (tbl *LinearHashTable) Key(value uint64) uint64

func (LinearHashTable) Print

func (tbl LinearHashTable) Print()

func (*LinearHashTable) Reset

func (tbl *LinearHashTable) Reset()

type SilvermintDag

type SilvermintDag struct {
	// contains filtered or unexported fields
}

func Build

func Build(genesis block.Block, roots [validator.N_MAX_VALIDATORS]block.Block, bcache *BlockCache) *SilvermintDag

func (*SilvermintDag) Add

func (dag *SilvermintDag) Add(blk block.Block) bool

Adds a block to this dag, mutating it. Adds each transaction to the given map from hashes to transactions Returns true if the block is no longer pending (added or duplicate), false otherwise.

func (*SilvermintDag) Blocks

func (dag *SilvermintDag) Blocks() *BlockCache

func (*SilvermintDag) CatchUpChannel

func (dag *SilvermintDag) CatchUpChannel() chan block.Block

func (*SilvermintDag) Get

func (dag *SilvermintDag) Get(bid ids.BlockId) (block.Block, bool)

func (*SilvermintDag) GetDot

func (dag *SilvermintDag) GetDot() string

func (*SilvermintDag) Has

func (dag *SilvermintDag) Has(bid ids.BlockId) bool

func (*SilvermintDag) InterpretDeltas

func (dag *SilvermintDag) InterpretDeltas(blk block.Block) bool

Interprets and assigns block Parents from block's HeightDeltas, mutating it. Returns true if successful or false if there were missing parents.

func (*SilvermintDag) LeastUndeletableHeights

func (dag *SilvermintDag) LeastUndeletableHeights(
	regs map[validator.Validator]bool,
) block.Heights

TODO(chuck): This function isn't being used currently, but it can be used for getting the blocks needed for a snapshot to send to another validator. Determines the minimum, non-deletable height for each validator. The parents of tips can be built on still, so they aren't deletable.

func (*SilvermintDag) Pending

func (dag *SilvermintDag) Pending() *pendingQueue

func (*SilvermintDag) PrintChildMap

func (dag *SilvermintDag) PrintChildMap(indent int)

func (*SilvermintDag) PrintChildren

func (dag *SilvermintDag) PrintChildren(indent int, bid ids.BlockId)

func (*SilvermintDag) PrintDag

func (dag *SilvermintDag) PrintDag()

func (*SilvermintDag) PrintTips

func (dag *SilvermintDag) PrintTips()

func (*SilvermintDag) Roots

func (dag *SilvermintDag) Roots() block.Heights

func (*SilvermintDag) Size

func (dag *SilvermintDag) Size() uint64

func (*SilvermintDag) Tip

func (dag *SilvermintDag) Tip(vid uint16) ids.BlockId

Jump to

Keyboard shortcuts

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