model

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: ISC Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VirtualBlockHash = hash.MustBytesToHash([]byte{
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
})

VirtualBlockHash is a marker hash for the virtual block

View Source
var VirtualGenesisBlockHash = hash.MustBytesToHash([]byte{
	0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
	0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
	0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
	0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
})

VirtualGenesisBlockHash is a marker hash for the virtual genesis block

Functions

This section is empty.

Types

type BlockGHOSTDAGData

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

BlockGHOSTDAGData represents GHOSTDAG data for some block

func NewBlockGHOSTDAGData

func NewBlockGHOSTDAGData(
	blueScore uint64,
	blueWork *big.Int,
	selectedParent *hash.Hash,
	mergeSetBlues []*hash.Hash,
	mergeSetReds []*hash.Hash,
	bluesAnticoneSizes map[hash.Hash]KType) *BlockGHOSTDAGData

NewBlockGHOSTDAGData creates a new instance of BlockGHOSTDAGData

func (*BlockGHOSTDAGData) AddBlueWork

func (bgd *BlockGHOSTDAGData) AddBlueWork(x, y *big.Int)

func (*BlockGHOSTDAGData) AppendMergeSetBlue

func (bgd *BlockGHOSTDAGData) AppendMergeSetBlue(h *hash.Hash)

func (*BlockGHOSTDAGData) AppendMergeSetRed

func (bgd *BlockGHOSTDAGData) AppendMergeSetRed(h *hash.Hash)

func (*BlockGHOSTDAGData) BlueScore

func (bgd *BlockGHOSTDAGData) BlueScore() uint64

BlueScore returns the BlueScore of the block

func (*BlockGHOSTDAGData) BlueWork

func (bgd *BlockGHOSTDAGData) BlueWork() *big.Int

BlueWork returns the BlueWork of the block

func (*BlockGHOSTDAGData) BluesAnticoneSizes

func (bgd *BlockGHOSTDAGData) BluesAnticoneSizes() map[hash.Hash]KType

BluesAnticoneSizes returns a map between the blocks in its MergeSetBlues and the size of their anticone

func (*BlockGHOSTDAGData) Clone

func (bgd *BlockGHOSTDAGData) Clone() *BlockGHOSTDAGData

func (*BlockGHOSTDAGData) MergeSetBlues

func (bgd *BlockGHOSTDAGData) MergeSetBlues() []*hash.Hash

MergeSetBlues returns the MergeSetBlues of the block (not a copy)

func (*BlockGHOSTDAGData) MergeSetBluesLen

func (bgd *BlockGHOSTDAGData) MergeSetBluesLen() int

func (*BlockGHOSTDAGData) MergeSetReds

func (bgd *BlockGHOSTDAGData) MergeSetReds() []*hash.Hash

MergeSetReds returns the MergeSetReds of the block (not a copy)

func (*BlockGHOSTDAGData) SelectedParent

func (bgd *BlockGHOSTDAGData) SelectedParent() *hash.Hash

SelectedParent returns the SelectedParent of the block

func (*BlockGHOSTDAGData) SetBlueScore

func (bgd *BlockGHOSTDAGData) SetBlueScore(score uint64)

func (*BlockGHOSTDAGData) SetBlueWork

func (bgd *BlockGHOSTDAGData) SetBlueWork(work *big.Int)

func (*BlockGHOSTDAGData) SetBlueWorkUint64

func (bgd *BlockGHOSTDAGData) SetBlueWorkUint64(work uint64)

func (*BlockGHOSTDAGData) SetBluesAnticoneSize

func (bgd *BlockGHOSTDAGData) SetBluesAnticoneSize(h *hash.Hash, value KType)

func (*BlockGHOSTDAGData) SetSelectedParent

func (bgd *BlockGHOSTDAGData) SetSelectedParent(sp *hash.Hash)

type BlockHeader

type BlockHeader interface {
	Bits() uint32
	Pow() pow.IPow
}

type BlockHeaderStore

type BlockHeaderStore interface {
	model.Store
	BlockHeader(dbContext DBReader, stagingArea *model.StagingArea, blockHash *hash.Hash) (BlockHeader, error)
	HasBlockHeader(dbContext DBReader, stagingArea *model.StagingArea, blockHash *hash.Hash) (bool, error)
	BlockHeaders(dbContext DBReader, stagingArea *model.StagingArea, blockHashes []*hash.Hash) ([]BlockHeader, error)
	Delete(stagingArea *model.StagingArea, blockHash *hash.Hash)
	Count(stagingArea *model.StagingArea) uint64
}

BlockHeaderStore represents a store of block headers

type DAGTopologyManager

type DAGTopologyManager interface {
	Parents(stagingArea *model.StagingArea, blockHash *hash.Hash) ([]*hash.Hash, error)
	Children(stagingArea *model.StagingArea, blockHash *hash.Hash) ([]*hash.Hash, error)
	IsParentOf(stagingArea *model.StagingArea, blockHashA *hash.Hash, blockHashB *hash.Hash) (bool, error)
	IsChildOf(stagingArea *model.StagingArea, blockHashA *hash.Hash, blockHashB *hash.Hash) (bool, error)
	IsAncestorOf(stagingArea *model.StagingArea, blockHashA *hash.Hash, blockHashB *hash.Hash) (bool, error)
	IsAncestorOfAny(stagingArea *model.StagingArea, blockHash *hash.Hash, potentialDescendants []*hash.Hash) (bool, error)
	IsAnyAncestorOf(stagingArea *model.StagingArea, potentialAncestors []*hash.Hash, blockHash *hash.Hash) (bool, error)
	IsInSelectedParentChainOf(stagingArea *model.StagingArea, blockHashA *hash.Hash, blockHashB *hash.Hash) (bool, error)
	ChildInSelectedParentChainOf(stagingArea *model.StagingArea, lowHash, highHash *hash.Hash) (*hash.Hash, error)

	SetParents(stagingArea *model.StagingArea, blockHash *hash.Hash, parentHashes []*hash.Hash) error
}

DAGTopologyManager exposes methods for querying relationships between blocks in the DAG

type DBBucket

type DBBucket interface {
	Bucket(bucketBytes []byte) DBBucket
	Key(suffix []byte) DBKey
	Path() []byte
}

DBBucket is an interface for a database bucket

type DBCursor

type DBCursor interface {
	// Next moves the iterator to the next key/value pair. It returns whether the
	// iterator is exhausted. Panics if the cursor is closed.
	Next() bool

	// First moves the iterator to the first key/value pair. It returns false if
	// such a pair does not exist. Panics if the cursor is closed.
	First() bool

	// Seek moves the iterator to the first key/value pair whose key is greater
	// than or equal to the given key. It returns ErrNotFound if such pair does not
	// exist.
	Seek(key DBKey) error

	// Key returns the key of the current key/value pair, or ErrNotFound if done.
	// The caller should not modify the contents of the returned key, and
	// its contents may change on the next call to Next.
	Key() (DBKey, error)

	// Value returns the value of the current key/value pair, or ErrNotFound if done.
	// The caller should not modify the contents of the returned slice, and its
	// contents may change on the next call to Next.
	Value() ([]byte, error)

	// Close releases associated resources.
	Close() error
}

DBCursor iterates over database entries given some bucket.

type DBKey

type DBKey interface {
	Bytes() []byte
	Bucket() DBBucket
	Suffix() []byte
}

DBKey is an interface for a database key

type DBManager

type DBManager interface {
	DBWriter

	// Begin begins a new database transaction.
	Begin() (DBTransaction, error)
}

DBManager defines the interface of a database that can begin transactions and read data.

type DBReader

type DBReader interface {
	// Get gets the value for the given key. It returns
	// ErrNotFound if the given key does not exist.
	Get(key DBKey) ([]byte, error)

	// Has returns true if the database does contains the
	// given key.
	Has(key DBKey) (bool, error)

	// Cursor begins a new cursor over the given bucket.
	Cursor(bucket DBBucket) (DBCursor, error)
}

DBReader defines a proxy over domain data access

type DBTransaction

type DBTransaction interface {
	DBWriter

	// Rollback rolls back whatever changes were made to the
	// database within this transaction.
	Rollback() error

	// Commit commits whatever changes were made to the database
	// within this transaction.
	Commit() error

	// RollbackUnlessClosed rolls back changes that were made to
	// the database within the transaction, unless the transaction
	// had already been closed using either Rollback or Commit.
	RollbackUnlessClosed() error
}

DBTransaction is a proxy over domain data access that requires an open database transaction

type DBWriter

type DBWriter interface {
	DBReader

	// Put sets the value for the given key. It overwrites
	// any previous value for that key.
	Put(key DBKey, value []byte) error

	// Delete deletes the value for the given key. Will not
	// return an error if the key doesn't exist.
	Delete(key DBKey) error
}

DBWriter is an interface to write to the database

type GHOSTDAGDataStore

type GHOSTDAGDataStore interface {
	model.Store
	Stage(stagingArea *model.StagingArea, blockHash *hash.Hash, blockGHOSTDAGData *BlockGHOSTDAGData, isTrustedData bool)
	IsStaged(stagingArea *model.StagingArea) bool
	Get(dbContext DBReader, stagingArea *model.StagingArea, blockHash *hash.Hash, isTrustedData bool) (*BlockGHOSTDAGData, error)
	UnstageAll(stagingArea *model.StagingArea)
}

GHOSTDAGDataStore represents a store of BlockGHOSTDAGData

type KType

type KType byte

KType defines the size of GHOSTDAG consensus algorithm K parameter.

Jump to

Keyboard shortcuts

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