index

package module
v0.0.0-...-71c2772 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 29 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// InclusionOrphan orphan (was not included in-verified-chain)
	InclusionOrphan = BlockInclusion(iota)
	// InclusionInVerifiedChain in-verified-chain (uncle or main)
	InclusionInVerifiedChain
	// InclusionAlternateInVerifiedChain alternate in-verified-chain (uncle or main), for example when duplicate nonce happens
	InclusionAlternateInVerifiedChain

	InclusionCount
)
View Source
const MainBlockSelectFields = "id, height, timestamp, reward, coinbase_id, difficulty, metadata, side_template_id, coinbase_private_key"
View Source
const MainCoinbaseOutputSelectFields = "id, index, global_output_index, miner, value"
View Source
const MainLikelySweepTransactionSelectFields = "" /* 260-byte string literal not displayed */
View Source
const MinerSelectFields = "id, alias, spend_public_key, view_public_key"
View Source
const SideBlockSelectFields = "" /* 284-byte string literal not displayed */

Variables

This section is empty.

Functions

func BlocksInPPLNSWindow

func BlocksInPPLNSWindow(tip *SideBlock, consensus *sidechain.Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, getUnclesByTemplateId GetUnclesByTemplateIdFunc, addWeightFunc SideBlockWindowAddWeightFunc) (bottomHeight uint64, err error)

BlocksInPPLNSWindow Copy of sidechain.BlocksInPPLNSWindow

func BlocksInPPLNSWindowFast

func BlocksInPPLNSWindowFast(indexDb *Index, tip *SideBlock, difficultyByHeight block.GetDifficultyByHeightFunc, addWeightFunc SideBlockWindowAddWeightFunc) (bottomHeight uint64, err error)

func CalculateOutputs

func CalculateOutputs(indexDb *Index, block *SideBlock, transactionOutputType uint8, totalReward uint64, coinbasePrivateKey crypto.PrivateKey, coinbasePrivateKeySeed types.Hash, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, getUnclesByTemplateId GetUnclesByTemplateIdFunc, derivationCache sidechain.DerivationCacheInterface, preAllocatedShares sidechain.Shares, preAllocatedRewards []uint64) (outputs transaction.Outputs, bottomHeight uint64)

CalculateOutputs Copy of sidechain.CalculateOutputs

func ChanConsume

func ChanConsume[T any](c <-chan T)

func ChanIterate

func ChanIterate[T any](c <-chan T, f IterateFunction[int, T]) (complete bool)

func ChanToSlice

func ChanToSlice[S ~[]T, T any](c <-chan T) (s S)

func GetShares

func GetShares(indexDb *Index, tip *SideBlock, coinbasePrivateKeySeed types.Hash, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, getUnclesByTemplateId GetUnclesByTemplateIdFunc, preAllocatedShares sidechain.Shares) (shares sidechain.Shares, bottomHeight uint64)

GetShares Copy of sidechain.GetShares

func GetSharesOrdered

func GetSharesOrdered(indexDb *Index, tip *SideBlock, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, getUnclesByTemplateId GetUnclesByTemplateIdFunc, preAllocatedShares sidechain.Shares) (shares sidechain.Shares, bottomHeight uint64)

GetSharesOrdered Copy of sidechain.GetSharesOrdered

func HashRatioSideBlocks

func HashRatioSideBlocks(shares []*SideBlock, latest *SideBlock, consensusUnclePenalty uint64) (hashrate uint64, ratio float64, weight, total types.Difficulty)

func IterateSideBlocksInPPLNSWindow

func IterateSideBlocksInPPLNSWindow(tip *SideBlock, consensus *sidechain.Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, getUnclesByTemplateId GetUnclesByTemplateIdFunc, addWeightFunc SideBlockWindowAddWeightFunc, slotFunc func(slot SideBlockWindowSlot)) error

IterateSideBlocksInPPLNSWindow Copy of sidechain.IterateBlocksInPPLNSWindow

func IterateSideBlocksInPPLNSWindowFast

func IterateSideBlocksInPPLNSWindowFast(indexDb *Index, tip *SideBlock, difficultyByHeight block.GetDifficultyByHeightFunc, addWeightFunc SideBlockWindowAddWeightFunc, slotFunc func(slot SideBlockWindowSlot)) error

func IterateToSlice

func IterateToSlice[T any](i Iterator[int, T], _ ...error) (s []T)

func IterateToSliceWithoutPointer

func IterateToSliceWithoutPointer[T any](i Iterator[int, *T], _ ...error) (s []T)

func QueryFirstResult

func QueryFirstResult[T any](i QueryIterator[T], err ...error) (v *T)

func QueryHasResults

func QueryHasResults[T any](i QueryIterator[T], err ...error) bool

func QueryIterate

func QueryIterate[V any](i QueryIterator[V], f IterateFunction[int, *V])

func QueryIterateToSlice

func QueryIterateToSlice[T any](i QueryIterator[T], err ...error) (s []*T)

func SliceIterate

func SliceIterate[S ~[]T, T any](s S, f IterateFunction[int, T]) (complete bool)

func SortSideBlock

func SortSideBlock(a, b *SideBlock) int

Types

type BlockInclusion

type BlockInclusion int

type FakeQueryResult

type FakeQueryResult[V any] struct {
	NextFunction func() (int, *V)
}

func (*FakeQueryResult[V]) All

func (r *FakeQueryResult[V]) All(f IterateFunction[int, *V]) (complete bool)

func (*FakeQueryResult[V]) Close

func (r *FakeQueryResult[V]) Close()

func (*FakeQueryResult[V]) Err

func (r *FakeQueryResult[V]) Err() error

func (*FakeQueryResult[V]) Next

func (r *FakeQueryResult[V]) Next() (int, *V)

type FoundBlock

type FoundBlock struct {
	MainBlock MainBlock `json:"main_block"`

	SideHeight           uint64           `json:"side_height"`
	Miner                uint64           `json:"miner"`
	UncleOf              types.Hash       `json:"uncle_of,omitempty"`
	EffectiveHeight      uint64           `json:"effective_height"`
	WindowDepth          uint32           `json:"window_depth"`
	WindowOutputs        uint32           `json:"window_outputs"`
	TransactionCount     uint32           `json:"transaction_count"`
	Difficulty           uint64           `json:"difficulty"`
	CumulativeDifficulty types.Difficulty `json:"cumulative_difficulty"`
	Inclusion            BlockInclusion   `json:"inclusion"`

	// Extra information filled just for JSON purposes
	MinerAddress *address.Address `json:"miner_address,omitempty"`
	MinerAlias   string           `json:"miner_alias,omitempty"`
}

func (*FoundBlock) ScanFromRow

func (b *FoundBlock) ScanFromRow(_ *sidechain.Consensus, row RowScanInterface) error

type GetByTemplateIdFunc

type GetByTemplateIdFunc func(h types.Hash) *SideBlock

type GetUnclesByTemplateIdFunc

type GetUnclesByTemplateIdFunc func(h types.Hash) QueryIterator[SideBlock]

type Index

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

func OpenIndex

func OpenIndex(connStr string, consensus *sidechain.Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getSeedByHeight block.GetSeedByHeightFunc, getByTemplateId sidechain.GetByTemplateIdFunc) (index *Index, err error)

func (*Index) CachePoolBlock

func (i *Index) CachePoolBlock(b *sidechain.PoolBlock)

func (*Index) Close

func (i *Index) Close() error

func (*Index) Consensus

func (i *Index) Consensus() *sidechain.Consensus

func (*Index) DeleteMinerWebHook

func (i *Index) DeleteMinerWebHook(minerId uint64, hookType WebHookType) error

func (*Index) DerivationCache

func (i *Index) DerivationCache() sidechain.DerivationCacheInterface

func (*Index) GetByTemplateId

func (i *Index) GetByTemplateId(id types.Hash) *sidechain.PoolBlock

func (*Index) GetDifficultyByHeight

func (i *Index) GetDifficultyByHeight(height uint64) types.Difficulty

func (*Index) GetFoundBlocks

func (i *Index) GetFoundBlocks(where string, limit uint64, params ...any) (QueryIterator[FoundBlock], error)

func (*Index) GetMainBlockByCoinbaseId

func (i *Index) GetMainBlockByCoinbaseId(id types.Hash) (b *MainBlock)

func (*Index) GetMainBlockByGlobalOutputIndex

func (i *Index) GetMainBlockByGlobalOutputIndex(globalOutputIndex uint64) (b *MainBlock)

func (*Index) GetMainBlockByHeight

func (i *Index) GetMainBlockByHeight(height uint64) (b *MainBlock)

func (*Index) GetMainBlockById

func (i *Index) GetMainBlockById(id types.Hash) (b *MainBlock)

func (*Index) GetMainBlockTip

func (i *Index) GetMainBlockTip() (b *MainBlock)

func (*Index) GetMainBlocksByQuery

func (i *Index) GetMainBlocksByQuery(where string, params ...any) (QueryIterator[MainBlock], error)

func (*Index) GetMainBlocksByQueryStatement

func (i *Index) GetMainBlocksByQueryStatement(stmt *sql.Stmt, params ...any) (QueryIterator[MainBlock], error)

func (*Index) GetMainCoinbaseOutputByGlobalOutputIndex

func (i *Index) GetMainCoinbaseOutputByGlobalOutputIndex(globalOutputIndex uint64) (o *MainCoinbaseOutput)

func (*Index) GetMainCoinbaseOutputByIndex

func (i *Index) GetMainCoinbaseOutputByIndex(coinbaseId types.Hash, index uint64) (o *MainCoinbaseOutput)

func (*Index) GetMainCoinbaseOutputByMinerId

func (i *Index) GetMainCoinbaseOutputByMinerId(coinbaseId types.Hash, minerId uint64) *MainCoinbaseOutput

func (*Index) GetMainCoinbaseOutputs

func (i *Index) GetMainCoinbaseOutputs(coinbaseId types.Hash) (QueryIterator[MainCoinbaseOutput], error)

func (*Index) GetMainLikelySweepTransactionByGlobalOutputIndices

func (i *Index) GetMainLikelySweepTransactionByGlobalOutputIndices(globalOutputIndices ...uint64) []*MainLikelySweepTransaction

func (*Index) GetMainLikelySweepTransactionBySpendingGlobalOutputIndices

func (i *Index) GetMainLikelySweepTransactionBySpendingGlobalOutputIndices(globalOutputIndices ...uint64) [][]*MainLikelySweepTransaction

func (*Index) GetMainLikelySweepTransactions

func (i *Index) GetMainLikelySweepTransactions(limit uint64) (r QueryIterator[MainLikelySweepTransaction], err error)

func (*Index) GetMainLikelySweepTransactionsByAddress

func (i *Index) GetMainLikelySweepTransactionsByAddress(addr *address.Address, limit uint64) (r QueryIterator[MainLikelySweepTransaction], err error)

func (*Index) GetMiner

func (i *Index) GetMiner(miner uint64) *Miner

func (*Index) GetMinerByAddress

func (i *Index) GetMinerByAddress(addr *address.Address) *Miner

func (*Index) GetMinerByAlias

func (i *Index) GetMinerByAlias(alias string) *Miner

func (*Index) GetMinerByPackedAddress

func (i *Index) GetMinerByPackedAddress(addr address.PackedAddress) *Miner

func (*Index) GetMinerByStringAddress

func (i *Index) GetMinerByStringAddress(addr string) *Miner

func (*Index) GetMinerWebHooks

func (i *Index) GetMinerWebHooks(minerId uint64) (QueryIterator[MinerWebHook], error)

func (*Index) GetOrCreateMinerByAddress

func (i *Index) GetOrCreateMinerByAddress(addr *address.Address) *Miner

func (*Index) GetOrCreateMinerPackedAddress

func (i *Index) GetOrCreateMinerPackedAddress(addr address.PackedAddress) *Miner

func (*Index) GetPayoutsByMinerId

func (i *Index) GetPayoutsByMinerId(minerId uint64, limit uint64) (r QueryIterator[Payout], err error)

func (*Index) GetPayoutsByMinerIdFromHeight

func (i *Index) GetPayoutsByMinerIdFromHeight(minerId uint64, height uint64) (QueryIterator[Payout], error)

func (*Index) GetPayoutsByMinerIdFromTimestamp

func (i *Index) GetPayoutsByMinerIdFromTimestamp(minerId uint64, timestamp uint64) (QueryIterator[Payout], error)

func (*Index) GetPayoutsBySideBlock

func (i *Index) GetPayoutsBySideBlock(b *SideBlock) (QueryIterator[Payout], error)

func (*Index) GetSeedByHeight

func (i *Index) GetSeedByHeight(height uint64) types.Hash

func (*Index) GetShares

func (i *Index) GetShares(limit, minerId uint64, onlyBlocks bool, inclusion BlockInclusion) (QueryIterator[SideBlock], error)

func (*Index) GetSideBlockByMainId

func (i *Index) GetSideBlockByMainId(id types.Hash) (b *SideBlock)

func (*Index) GetSideBlockFromPoolBlock

func (i *Index) GetSideBlockFromPoolBlock(b *sidechain.PoolBlock, inclusion BlockInclusion) (tip *SideBlock, uncles []*SideBlock, err error)

func (*Index) GetSideBlockTip

func (i *Index) GetSideBlockTip() (b *SideBlock)

func (*Index) GetSideBlocksByHeight

func (i *Index) GetSideBlocksByHeight(height uint64) QueryIterator[SideBlock]

func (*Index) GetSideBlocksByMainHeight

func (i *Index) GetSideBlocksByMainHeight(height uint64) QueryIterator[SideBlock]

func (*Index) GetSideBlocksByMinerIdInWindow

func (i *Index) GetSideBlocksByMinerIdInWindow(minerId, startHeight, windowSize uint64) QueryIterator[SideBlock]

func (*Index) GetSideBlocksByQuery

func (i *Index) GetSideBlocksByQuery(where string, params ...any) (QueryIterator[SideBlock], error)

func (*Index) GetSideBlocksByQueryStatement

func (i *Index) GetSideBlocksByQueryStatement(stmt *sql.Stmt, params ...any) (QueryIterator[SideBlock], error)

func (*Index) GetSideBlocksByTemplateId

func (i *Index) GetSideBlocksByTemplateId(id types.Hash) QueryIterator[SideBlock]

func (*Index) GetSideBlocksByUncleOfId

func (i *Index) GetSideBlocksByUncleOfId(id types.Hash) QueryIterator[SideBlock]

func (*Index) GetSideBlocksInPPLNSWindow

func (i *Index) GetSideBlocksInPPLNSWindow(tip *SideBlock) QueryIterator[SideBlock]

func (*Index) GetSideBlocksInWindow

func (i *Index) GetSideBlocksInWindow(startHeight, windowSize uint64) QueryIterator[SideBlock]

func (*Index) GetTipSideBlockByHeight

func (i *Index) GetTipSideBlockByHeight(height uint64) (b *SideBlock)

func (*Index) GetTipSideBlockByTemplateId

func (i *Index) GetTipSideBlockByTemplateId(id types.Hash) (b *SideBlock)

func (*Index) GetView

func (i *Index) GetView(k string) string

func (*Index) InsertOrUpdateMainBlock

func (i *Index) InsertOrUpdateMainBlock(b *MainBlock) error

func (*Index) InsertOrUpdateMainCoinbaseOutputs

func (i *Index) InsertOrUpdateMainCoinbaseOutputs(outputs MainCoinbaseOutputs) error

func (*Index) InsertOrUpdateMainLikelySweepTransaction

func (i *Index) InsertOrUpdateMainLikelySweepTransaction(t *MainLikelySweepTransaction) error

func (*Index) InsertOrUpdateMinerWebHook

func (i *Index) InsertOrUpdateMinerWebHook(w *MinerWebHook) error

func (*Index) InsertOrUpdatePoolBlock

func (i *Index) InsertOrUpdatePoolBlock(b *sidechain.PoolBlock, inclusion BlockInclusion) error

func (*Index) InsertOrUpdateSideBlock

func (i *Index) InsertOrUpdateSideBlock(b *SideBlock) error

func (*Index) PrepareMainBlocksByQueryStatement

func (i *Index) PrepareMainBlocksByQueryStatement(where string) (stmt *sql.Stmt, err error)

func (*Index) PrepareSideBlocksByQueryStatement

func (i *Index) PrepareSideBlocksByQueryStatement(where string) (stmt *sql.Stmt, err error)

func (*Index) Query

func (i *Index) Query(query string, callback func(row RowScanInterface) error, params ...any) error

func (*Index) QueryGlobalOutputIndices

func (i *Index) QueryGlobalOutputIndices(indices []uint64) []*MatchedOutput

func (*Index) QueryStatement

func (i *Index) QueryStatement(stmt *sql.Stmt, callback func(row RowScanInterface) error, params ...any) error

func (*Index) QueryTransactionInputs

func (i *Index) QueryTransactionInputs(inputs []client.TransactionInput) TransactionInputQueryResults

func (*Index) SetMinerAlias

func (i *Index) SetMinerAlias(minerId uint64, alias string) error

type IterateFunction

type IterateFunction[K, V any] func(key K, value V) (stop bool)

type Iterator

type Iterator[K, V any] interface {
	All(f IterateFunction[K, V]) (complete bool)
}

func IteratorToIterator

func IteratorToIterator[K, V any](i Iterator[K, V], _ ...error) Iterator[K, V]

type IteratorFunction

type IteratorFunction[K, V any] func(f IterateFunction[K, V]) (complete bool)

type MainBlock

type MainBlock struct {
	Id         types.Hash `json:"id"`
	Height     uint64     `json:"height"`
	Timestamp  uint64     `json:"timestamp"`
	Reward     uint64     `json:"reward"`
	CoinbaseId types.Hash `json:"coinbase_id"`
	Difficulty uint64     `json:"difficulty"`

	// Metadata should be jsonb blob, can be NULL. metadata such as pool ownership, links to other p2pool networks, and other interesting data
	Metadata map[string]any `json:"metadata,omitempty"`

	// sidechain data for blocks we own
	// SideTemplateId can be NULL
	SideTemplateId types.Hash `json:"side_template_id,omitempty"`
	// CoinbasePrivateKey private key for coinbase outputs we own (all 0x00 = not known, but should have one)
	CoinbasePrivateKey crypto.PrivateKeyBytes `json:"coinbase_private_key,omitempty"`
}

func (*MainBlock) GetMetadata

func (b *MainBlock) GetMetadata(key string) any

func (*MainBlock) ScanFromRow

func (b *MainBlock) ScanFromRow(_ *sidechain.Consensus, row RowScanInterface) error

func (*MainBlock) SetMetadata

func (b *MainBlock) SetMetadata(key string, v any)

type MainCoinbaseOutput

type MainCoinbaseOutput struct {
	// Id coinbase id
	Id types.Hash `json:"id"`
	// Index transaction output index
	Index uint32 `json:"index"`
	// Monero global output idx
	GlobalOutputIndex uint64 `json:"global_output_index"`

	// Miner owner of the output
	Miner uint64 `json:"miner"`

	Value uint64 `json:"value"`

	MinerAddress *address.Address `json:"miner_address,omitempty"`
	MinerAlias   string           `json:"miner_alias,omitempty"`
}

func (*MainCoinbaseOutput) ScanFromRow

type MainCoinbaseOutputs

type MainCoinbaseOutputs []MainCoinbaseOutput

type MainLikelySweepTransaction

type MainLikelySweepTransaction struct {
	// Id coinbase id
	Id                    types.Hash                          `json:"id"`
	Timestamp             uint64                              `json:"timestamp"`
	Result                MinimalTransactionInputQueryResults `json:"result"`
	Match                 []TransactionInputQueryResultsMatch `json:"match"`
	Value                 uint64                              `json:"value"`
	SpendingOutputIndices []uint64                            `json:"spending_output_indices"`
	GlobalOutputIndices   []uint64                            `json:"global_output_indices"`

	InputCount      int `json:"input_count"`
	InputDecoyCount int `json:"input_decoy_count"`

	MinerCount       int `json:"miner_count"`
	OtherMinersCount int `json:"other_miners_count"`
	NoMinerCount     int `json:"no_miner_count"`

	MinerRatio       float32 `json:"miner_ratio"`
	OtherMinersRatio float32 `json:"other_miners_ratio"`
	NoMinerRatio     float32 `json:"no_miner_ratio"`

	Address *address.Address `json:"address"`
}

func (*MainLikelySweepTransaction) ScanFromRow

func (t *MainLikelySweepTransaction) ScanFromRow(consensus *sidechain.Consensus, row RowScanInterface) error

type MatchedOutput

type MatchedOutput struct {
	Coinbase          *MainCoinbaseOutput         `json:"coinbase,omitempty"`
	Sweep             *MainLikelySweepTransaction `json:"sweep,omitempty"`
	GlobalOutputIndex uint64                      `json:"global_output_index"`
	Timestamp         uint64                      `json:"timestamp"`
	Address           *address.Address            `json:"address"`
}

type Miner

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

func (*Miner) Address

func (m *Miner) Address() *address.Address

func (*Miner) Alias

func (m *Miner) Alias() string

func (*Miner) Id

func (m *Miner) Id() uint64

func (*Miner) ScanFromRow

func (m *Miner) ScanFromRow(consensus *sidechain.Consensus, row RowScanInterface) error

type MinerWebHook

type MinerWebHook struct {
	Miner     uint64               `json:"miner"`
	Type      WebHookType          `json:"type"`
	Url       string               `json:"url"`
	Settings  map[string]string    `json:"settings"`
	Consensus *sidechain.Consensus `json:"-"`
}

func (*MinerWebHook) ScanFromRow

func (w *MinerWebHook) ScanFromRow(consensus *sidechain.Consensus, row RowScanInterface) error

func (*MinerWebHook) Verify

func (w *MinerWebHook) Verify() error

type MinimalMatchedOutput

type MinimalMatchedOutput struct {
	Coinbase          types.Hash       `json:"coinbase,omitempty"`
	Sweep             types.Hash       `json:"sweep,omitempty"`
	GlobalOutputIndex uint64           `json:"global_output_index"`
	Address           *address.Address `json:"address"`
}

type MinimalTransactionInputQueryResult

type MinimalTransactionInputQueryResult struct {
	Input          client.TransactionInput `json:"input"`
	MatchedOutputs []*MinimalMatchedOutput `json:"matched_outputs"`
}

type MinimalTransactionInputQueryResults

type MinimalTransactionInputQueryResults []MinimalTransactionInputQueryResult

type Payout

type Payout struct {
	Miner             uint64                 `json:"miner"`
	TemplateId        types.Hash             `json:"template_id"`
	SideHeight        uint64                 `json:"side_height"`
	UncleOf           types.Hash             `json:"uncle_of,omitempty"`
	MainId            types.Hash             `json:"main_id"`
	MainHeight        uint64                 `json:"main_height"`
	Timestamp         uint64                 `json:"timestamp"`
	CoinbaseId        types.Hash             `json:"coinbase_id"`
	Reward            uint64                 `json:"coinbase_reward"`
	PrivateKey        crypto.PrivateKeyBytes `json:"coinbase_private_key"`
	Index             uint64                 `json:"coinbase_output_index"`
	GlobalOutputIndex uint64                 `json:"global_output_index"`
	IncludingHeight   uint64                 `json:"including_height"`
}

func (*Payout) ScanFromRow

func (p *Payout) ScanFromRow(_ *sidechain.Consensus, row RowScanInterface) error

type QueryIterator

type QueryIterator[V any] interface {
	All(f IterateFunction[int, *V]) (complete bool)
	Next() (int, *V)
	Close()
	Err() error
}

type QueryResult

type QueryResult[V any] struct {
	// contains filtered or unexported fields
}

func (*QueryResult[V]) All

func (r *QueryResult[V]) All(f IterateFunction[int, *V]) (complete bool)

func (*QueryResult[V]) Close

func (r *QueryResult[V]) Close()

func (*QueryResult[V]) Err

func (r *QueryResult[V]) Err() error

func (*QueryResult[V]) Next

func (r *QueryResult[V]) Next() (int, *V)

type RowScanInterface

type RowScanInterface interface {
	Scan(dest ...any) error
}

type Scannable

type Scannable interface {
	ScanFromRow(consensus *sidechain.Consensus, row RowScanInterface) error
}

type SideBlock

type SideBlock struct {
	// MainId mainchain id, on Monero network
	MainId     types.Hash `json:"main_id"`
	MainHeight uint64     `json:"main_height"`

	// TemplateId -- sidechain template id. Note multiple blocks can exist per template id, see Inclusion
	TemplateId types.Hash `json:"template_id"`
	SideHeight uint64     `json:"side_height"`
	// ParentTemplateId previous sidechain template id
	ParentTemplateId types.Hash `json:"parent_template_id"`

	// Miner internal id of the miner who contributed the block
	Miner uint64 `json:"miner"`

	// UncleOf has been included under this parent block TemplateId as an uncle
	UncleOf types.Hash `json:"uncle_of,omitempty"`
	// EffectiveHeight has been included under this parent block height as an uncle, or is this height
	EffectiveHeight uint64 `json:"effective_height"`

	// Nonce data
	Nonce      uint32 `json:"nonce"`
	ExtraNonce uint32 `json:"extra_nonce"`

	Timestamp       uint64                      `json:"timestamp"`
	SoftwareId      p2pooltypes.SoftwareId      `json:"software_id"`
	SoftwareVersion p2pooltypes.SoftwareVersion `json:"software_version"`
	// WindowDepth PPLNS window depth, in blocks including this one
	WindowDepth   uint32 `json:"window_depth"`
	WindowOutputs uint32 `json:"window_outputs"`

	// Difficulty sidechain difficulty at height
	Difficulty           uint64           `json:"difficulty"`
	CumulativeDifficulty types.Difficulty `json:"cumulative_difficulty"`
	PowDifficulty        uint64           `json:"pow_difficulty"`
	// PowHash result of PoW function as a hash (all 0x00 = not known)
	PowHash types.Hash `json:"pow_hash"`

	Inclusion BlockInclusion `json:"inclusion"`

	TransactionCount uint32 `json:"transaction_count"`

	MinedMainAtHeight bool                  `json:"mined_main_at_height,omitempty"`
	MinerAddress      *address.Address      `json:"miner_address,omitempty"`
	MinerAlias        string                `json:"miner_alias,omitempty"`
	Uncles            []SideBlockUncleEntry `json:"uncles,omitempty"`
	MainDifficulty    uint64                `json:"main_difficulty,omitempty"`
}

func (*SideBlock) FromPoolBlock

func (b *SideBlock) FromPoolBlock(i *Index, block *sidechain.PoolBlock, getSeedByHeight mainblock.GetSeedByHeightFunc) error

FromPoolBlock block needs to be pre-processed for ids to be correct These fields need to be filled by caller to match needs: SideBlock.UncleOf SideBlock.EffectiveHeight SideBlock.WindowDepth SideBlock.Inclusion

func (*SideBlock) FullId

func (b *SideBlock) FullId() sidechain.FullId

func (*SideBlock) IsOrphan

func (b *SideBlock) IsOrphan() bool

func (*SideBlock) IsTipOfHeight

func (b *SideBlock) IsTipOfHeight() bool

IsTipOfHeight whether this block is considered to be the "main" block within this height, not an uncle, or alternate

func (*SideBlock) IsUncle

func (b *SideBlock) IsUncle() bool

func (*SideBlock) ScanFromRow

func (b *SideBlock) ScanFromRow(_ *sidechain.Consensus, row RowScanInterface) error

func (*SideBlock) SetUncleOf

func (b *SideBlock) SetUncleOf(block *SideBlock) error

func (*SideBlock) Weight

func (b *SideBlock) Weight(tipHeight, windowSize, consensusUnclePenalty uint64) (weight, parentWeight uint64)

type SideBlockUncleEntry

type SideBlockUncleEntry struct {
	TemplateId types.Hash `json:"template_id"`
	Miner      uint64     `json:"miner"`
	SideHeight uint64     `json:"side_height"`
	Difficulty uint64     `json:"difficulty"`
}

type SideBlockWindowAddWeightFunc

type SideBlockWindowAddWeightFunc func(b *SideBlock, weight types.Difficulty)

type SideBlockWindowSlot

type SideBlockWindowSlot struct {
	Block *SideBlock
	// Uncles that count for the window weight
	Uncles []*SideBlock
}

type TransactionInputQueryResult

type TransactionInputQueryResult struct {
	Input          client.TransactionInput `json:"input"`
	MatchedOutputs []*MatchedOutput        `json:"matched_outputs"`
}

type TransactionInputQueryResults

type TransactionInputQueryResults []TransactionInputQueryResult

func (TransactionInputQueryResults) Match

type TransactionInputQueryResultsMatch

type TransactionInputQueryResultsMatch struct {
	Address        *address.Address `json:"address"`
	Count          uint64           `json:"count"`
	SweepCount     uint64           `json:"sweep_count"`
	CoinbaseCount  uint64           `json:"coinbase_count"`
	CoinbaseAmount uint64           `json:"coinbase_amount"`
}

type TransactionInputQueryResultsMatches

type TransactionInputQueryResultsMatches []TransactionInputQueryResultsMatch

type WebHookType

type WebHookType string
const (
	WebHookSlack          WebHookType = "slack"
	WebHookDiscord        WebHookType = "discord"
	WebHookTelegram       WebHookType = "telegram"
	WebHookMatrixHookshot WebHookType = "matrix-hookshot"
	WebHookCustom         WebHookType = "custom"
)

Jump to

Keyboard shortcuts

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