@@ -34,86 +34,9 @@ import Ouroboros.Network.DeltaQ (PeerGSV (..), defaultGSV,
34
34
import Ouroboros.Network.Protocol.TxSubmission2.Type
35
35
import Ouroboros.Network.TxSubmission.Inbound.Policy
36
36
import Ouroboros.Network.TxSubmission.Inbound.State
37
+ import Ouroboros.Network.TxSubmission.Inbound.Types
37
38
38
39
39
- -- | Decision made by the decision logic. Each peer will receive a 'Decision'.
40
- --
41
- -- /note:/ it is rather non-standard to represent a choice between requesting
42
- -- `txid`s and `tx`'s as a product rather than a sum type. The client will
43
- -- need to download `tx`s first and then send a request for more txids (and
44
- -- acknowledge some `txid`s). Due to pipelining each client will request
45
- -- decision from the decision logic quite often (every two pipelined requests),
46
- -- but with this design a decision once taken will make the peer non-active
47
- -- (e.g. it won't be returned by `filterActivePeers`) for longer, and thus the
48
- -- expensive `makeDecision` computation will not need to take that peer into
49
- -- account.
50
- --
51
- data TxDecision txid tx = TxDecision {
52
- txdTxIdsToAcknowledge :: ! NumTxIdsToAck ,
53
- -- ^ txid's to acknowledge
54
-
55
- txdTxIdsToRequest :: ! NumTxIdsToReq ,
56
- -- ^ number of txid's to request
57
-
58
- txdPipelineTxIds :: ! Bool ,
59
- -- ^ the tx-submission protocol only allows to pipeline `txid`'s requests
60
- -- if we have non-acknowledged `txid`s.
61
-
62
- txdTxsToRequest :: ! (Set txid ),
63
- -- ^ txid's to download.
64
-
65
- txdTxsToMempool :: ! [tx ]
66
- -- ^ list of `tx`s to submit to the mempool.
67
- }
68
- deriving (Show , Eq )
69
-
70
- -- | A non-commutative semigroup instance.
71
- --
72
- -- /note:/ this instance must be consistent with `pickTxsToDownload` and how
73
- -- `PeerTxState` is updated. It is designed to work with `TMergeVar`s.
74
- --
75
- instance Ord txid => Semigroup (TxDecision txid tx ) where
76
- TxDecision { txdTxIdsToAcknowledge,
77
- txdTxIdsToRequest,
78
- txdPipelineTxIds = _ignored,
79
- txdTxsToRequest,
80
- txdTxsToMempool }
81
- <>
82
- TxDecision { txdTxIdsToAcknowledge = txdTxIdsToAcknowledge',
83
- txdTxIdsToRequest = txdTxIdsToRequest',
84
- txdPipelineTxIds = txdPipelineTxIds',
85
- txdTxsToRequest = txdTxsToRequest',
86
- txdTxsToMempool = txdTxsToMempool' }
87
- =
88
- TxDecision { txdTxIdsToAcknowledge = txdTxIdsToAcknowledge + txdTxIdsToAcknowledge',
89
- txdTxIdsToRequest = txdTxIdsToRequest + txdTxIdsToRequest',
90
- txdPipelineTxIds = txdPipelineTxIds',
91
- txdTxsToRequest = txdTxsToRequest <> txdTxsToRequest',
92
- txdTxsToMempool = txdTxsToMempool ++ txdTxsToMempool'
93
- }
94
-
95
- -- | A no-op decision.
96
- emptyTxDecision :: TxDecision txid tx
97
- emptyTxDecision = TxDecision {
98
- txdTxIdsToAcknowledge = 0 ,
99
- txdTxIdsToRequest = 0 ,
100
- txdPipelineTxIds = False ,
101
- txdTxsToRequest = Set. empty,
102
- txdTxsToMempool = []
103
- }
104
-
105
- data SharedDecisionContext peeraddr txid tx = SharedDecisionContext {
106
- -- TODO: check how to access it.
107
- sdcPeerGSV :: ! (Map peeraddr PeerGSV ),
108
-
109
- sdcSharedTxState :: ! (SharedTxState peeraddr txid tx )
110
- }
111
- deriving Show
112
-
113
- --
114
- -- Decision Logic
115
- --
116
-
117
40
-- | Make download decisions.
118
41
--
119
42
makeDecisions
0 commit comments