forked from NebulousLabs/Sia
/
transactionpool.go
76 lines (61 loc) · 2.79 KB
/
transactionpool.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
package modules
import (
"errors"
"github.com/NebulousLabs/Sia/types"
)
const (
TransactionSizeLimit = 16e3
TransactionSetSizeLimit = 100e3
)
var (
ErrDuplicateTransactionSet = errors.New("transaction is a duplicate")
ErrLargeTransaction = errors.New("transaction is too large for this transaction pool")
ErrLargeTransactionSet = errors.New("transaction set is too large for this transaction pool")
ErrInvalidArbPrefix = errors.New("transaction contains non-standard arbitrary data")
PrefixNonSia = types.Specifier{'N', 'o', 'n', 'S', 'i', 'a'}
PrefixStrNonSia = "NonSia" // COMPATv0.3.3.3
TransactionPoolDir = "transactionpool"
)
// A TransactionPoolSubscriber receives updates about the confirmed and
// unconfirmed set from the transaction pool. Generally, there is no need to
// subscribe to both the consensus set and the transaction pool.
type TransactionPoolSubscriber interface {
// All transaction pool subscribers must also be able to receive consensus
// set updates.
ConsensusSetSubscriber
// ReceiveTransactionPoolUpdate notifies subscribers of a change to the
// consensus set and/or unconfirmed set, and includes the consensus change
// that would result if all of the transactions made it into a block.
ReceiveUpdatedUnconfirmedTransactions([]types.Transaction, ConsensusChange)
}
// A TransactionPool manages unconfirmed transactions.
type TransactionPool interface {
// AcceptTransactionSet accepts a set of potentially interdependent
// transactions.
AcceptTransactionSet([]types.Transaction) error
// COMPAT v0.3.3.3
//
// RelayTransaction is an RPC that accepts a transaction set from a
// peer.
RelayTransaction(PeerConn) error
// RelayTransactionSet is an RPC that accepts a transaction set from a
// peer.
RelayTransactionSet(PeerConn) error
// IsStandardTransaction returns `err = nil` if the transaction is
// standard, otherwise it returns an error explaining what is not standard.
IsStandardTransaction(types.Transaction) error
// PurgeTransactionPool is a temporary function available to the miner. In
// the event that a miner mines an unacceptable block, the transaction pool
// will be purged to clear out the transaction pool and get rid of the
// illegal transaction. This should never happen, however there are bugs
// that make this condition necessary.
PurgeTransactionPool()
// TransactionList returns a list of all transactions in the transaction
// pool. The transactions are provided in an order that can acceptably be
// put into a block.
TransactionList() []types.Transaction
// TransactionPoolSubscribe adds a subscriber to the transaction pool.
// Subscribers will receive all consensus set changes as well as
// transaction pool changes, and should not subscribe to both.
TransactionPoolSubscribe(TransactionPoolSubscriber)
}