init (#9)
This commit is contained in:
+9
-3
@@ -19,17 +19,19 @@ type (
|
||||
txDecoder sdk.TxDecoder
|
||||
prepareLanesHandler block.PrepareLanesHandler
|
||||
processLanesHandler block.ProcessLanesHandler
|
||||
mempool block.Mempool
|
||||
}
|
||||
)
|
||||
|
||||
// NewProposalHandler returns a new abci++ proposal handler. This proposal handler will
|
||||
// iteratively call each of the lanes in the chain to prepare and process the proposal.
|
||||
func NewProposalHandler(logger log.Logger, txDecoder sdk.TxDecoder, lanes []block.Lane) *ProposalHandler {
|
||||
func NewProposalHandler(logger log.Logger, txDecoder sdk.TxDecoder, mempool block.Mempool) *ProposalHandler {
|
||||
return &ProposalHandler{
|
||||
logger: logger,
|
||||
txDecoder: txDecoder,
|
||||
prepareLanesHandler: ChainPrepareLanes(lanes...),
|
||||
processLanesHandler: ChainProcessLanes(lanes...),
|
||||
prepareLanesHandler: ChainPrepareLanes(mempool.Registry()...),
|
||||
processLanesHandler: ChainProcessLanes(mempool.Registry()...),
|
||||
mempool: mempool,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +50,8 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
|
||||
}
|
||||
}()
|
||||
|
||||
h.logger.Info("mempool distribution before proposal creation", "distribution", h.mempool.GetTxDistribution())
|
||||
|
||||
proposal, err := h.prepareLanesHandler(ctx, block.NewProposal(req.MaxTxBytes))
|
||||
if err != nil {
|
||||
h.logger.Error("failed to prepare proposal", "err", err)
|
||||
@@ -61,6 +65,8 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
|
||||
"height", req.Height,
|
||||
)
|
||||
|
||||
h.logger.Info("mempool distribution after proposal creation", "distribution", h.mempool.GetTxDistribution())
|
||||
|
||||
return &abci.ResponsePrepareProposal{
|
||||
Txs: proposal.GetProposal(),
|
||||
}, nil
|
||||
|
||||
+13
-5
@@ -450,10 +450,12 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
mempool := block.NewLanedMempool(log.NewTestLogger(s.T()), false, panicLane, defaultLane)
|
||||
|
||||
proposalHandler := abci.NewProposalHandler(
|
||||
log.NewTestLogger(s.T()),
|
||||
s.encodingConfig.TxConfig.TxDecoder(),
|
||||
[]block.Lane{panicLane, defaultLane},
|
||||
mempool,
|
||||
).PrepareProposalHandler()
|
||||
|
||||
resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{MaxTxBytes: 1000000})
|
||||
@@ -483,10 +485,12 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
mempool := block.NewLanedMempool(log.NewTestLogger(s.T()), false, defaultLane, panicLane)
|
||||
|
||||
proposalHandler := abci.NewProposalHandler(
|
||||
log.NewTestLogger(s.T()),
|
||||
s.encodingConfig.TxConfig.TxDecoder(),
|
||||
[]block.Lane{defaultLane, panicLane},
|
||||
mempool,
|
||||
).PrepareProposalHandler()
|
||||
|
||||
resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{MaxTxBytes: 1000000})
|
||||
@@ -517,10 +521,12 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
mempool := block.NewLanedMempool(log.NewTestLogger(s.T()), false, panicLane, panicLane2, defaultLane)
|
||||
|
||||
proposalHandler := abci.NewProposalHandler(
|
||||
log.NewTestLogger(s.T()),
|
||||
s.encodingConfig.TxConfig.TxDecoder(),
|
||||
[]block.Lane{panicLane, panicLane2, defaultLane},
|
||||
mempool,
|
||||
).PrepareProposalHandler()
|
||||
|
||||
resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{MaxTxBytes: 1000000})
|
||||
@@ -551,10 +557,12 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
mempool := block.NewLanedMempool(log.NewTestLogger(s.T()), false, defaultLane, panicLane, panicLane2)
|
||||
|
||||
proposalHandler := abci.NewProposalHandler(
|
||||
log.NewTestLogger(s.T()),
|
||||
s.encodingConfig.TxConfig.TxDecoder(),
|
||||
[]block.Lane{defaultLane, panicLane, panicLane2},
|
||||
mempool,
|
||||
).PrepareProposalHandler()
|
||||
|
||||
resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{MaxTxBytes: 1000000})
|
||||
@@ -787,7 +795,7 @@ func (s *ProposalsTestSuite) setUpProposalHandlers(lanes []block.Lane) *abci.Pro
|
||||
return abci.NewProposalHandler(
|
||||
log.NewTestLogger(s.T()),
|
||||
s.encodingConfig.TxConfig.TxDecoder(),
|
||||
mempool.Registry(),
|
||||
mempool,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user