-
Notifications
You must be signed in to change notification settings - Fork 0
/
mining.go
86 lines (69 loc) · 2.74 KB
/
mining.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) 2014-2016 The btcsuite developers
// Copyright (c) 2016-2019 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/Eacred/eacrd/blockchain/stake"
"github.com/Eacred/eacrd/chaincfg/chainhash"
"github.com/Eacred/eacrd/dcrutil"
)
const (
// MinHighPriority is the minimum priority value that allows a
// transaction to be considered high priority.
MinHighPriority = dcrutil.AtomsPerCoin * 144.0 / 250
)
// TxDesc is a descriptor about a transaction in a transaction source along with
// additional metadata.
type TxDesc struct {
// Tx is the transaction associated with the entry.
Tx *dcrutil.Tx
// Type is the type of the transaction associated with the entry.
Type stake.TxType
// Added is the time when the entry was added to the source pool.
Added time.Time
// Height is the block height when the entry was added to the source
// pool.
Height int64
// Fee is the total fee the transaction associated with the entry pays.
Fee int64
}
// VoteDesc is a descriptor about a vote transaction in a transaction source
// along with additional metadata.
type VoteDesc struct {
VoteHash chainhash.Hash
TicketHash chainhash.Hash
ApprovesParent 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
// MiningDescs returns a slice of mining descriptors for all the
// transactions in the source pool.
MiningDescs() []*TxDesc
// 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
}