This reworks the mining template generator slightly to remove the leftover unexported block manager facade interface that was used as part of originally separating the code in a separate internal package. The following is a high level overview of the changes: - Introduces BgBlkTmplConfig for the background block template generator to mirror the standard approach used throughout the code - Removes local fields that are now in the new config struct - Removes blockManagerFacade interface which included: - IsCurrent - ForceReorganization - Adds IsCurrent function to new BgBlkTmplConfig struct - Adds ForceReorganizion to Config - Updates all code to account for the changes
61 lines
2.3 KiB
Go
61 lines
2.3 KiB
Go
// Copyright (c) 2014-2016 The btcsuite developers
|
|
// Copyright (c) 2015-2020 The Decred developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package mining
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/decred/dcrd/chaincfg/chainhash"
|
|
"github.com/decred/dcrd/wire"
|
|
)
|
|
|
|
// PriorityInputser defines an interface that provides access to information
|
|
// about an transaction output needed to calculate a priority based on the input
|
|
// age of a transaction. It is used within this package as a generic means to
|
|
// provide the block heights and amounts referenced by all of the inputs to a
|
|
// transaction that are needed to calculate an input age. The boolean return
|
|
// indicates whether or not the information for the provided outpoint was found.
|
|
type PriorityInputser interface {
|
|
PriorityInput(prevOut *wire.OutPoint) (blockHeight int64, amount int64, ok bool)
|
|
}
|
|
|
|
// TxSource represents a source of transactions to consider for inclusion in
|
|
// new blocks.
|
|
//
|
|
// The interface contract requires that all of these methods are safe for
|
|
// concurrent access with respect to the source.
|
|
type TxSource interface {
|
|
// LastUpdated returns the last time a transaction was added to or
|
|
// removed from the source pool.
|
|
LastUpdated() time.Time
|
|
|
|
// HaveTransaction returns whether or not the passed transaction hash
|
|
// exists in the source pool.
|
|
HaveTransaction(hash *chainhash.Hash) bool
|
|
|
|
// HaveAllTransactions returns whether or not all of the passed
|
|
// transaction hashes exist in the source pool.
|
|
HaveAllTransactions(hashes []chainhash.Hash) bool
|
|
|
|
// VoteHashesForBlock returns the hashes for all votes on the provided
|
|
// block hash that are currently available in the source pool.
|
|
VoteHashesForBlock(hash *chainhash.Hash) []chainhash.Hash
|
|
|
|
// VotesForBlocks returns a slice of vote descriptors for all votes on
|
|
// the provided block hashes that are currently available in the source
|
|
// pool.
|
|
VotesForBlocks(hashes []chainhash.Hash) [][]VoteDesc
|
|
|
|
// IsRegTxTreeKnownDisapproved returns whether or not the regular
|
|
// transaction tree of the block represented by the provided hash is
|
|
// known to be disapproved according to the votes currently in the
|
|
// source pool.
|
|
IsRegTxTreeKnownDisapproved(hash *chainhash.Hash) bool
|
|
|
|
// MiningView returns a snapshot of the underlying TxSource.
|
|
MiningView() *TxMiningView
|
|
}
|