Page MenuHomePhabricator

Avoid double copy when emplacing into DisconnectedBlockTransactons::txInfo
ClosedPublic

Authored by Fabien on Feb 27 2023, 15:05.

Details

Summary
MR !1128 introduced this code but on second reading I realized the
double-copy from this MR can be remove by using `try_emplace` and also by actually giving the `TxInfo` type a real constructor.

This commit is just a minor code quality commit to reduce the creation of a temporary.  In most cases the optimizer will elide this temporary anyway, but for debug builds it may not, and also it's of higher code quality to just avoid creating it.

Port of bchn#1191.
Depends on D13171.

Test Plan
ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Feb 27 2023, 15:05

Failed tests logs:

====== Bitcoin ABC functional tests with the next upgrade activated: rpc_deprecated.py ======

------- Stdout: -------
2023-02-27T15:17:46.030000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_151555/rpc_deprecated_28
2023-02-27T15:17:46.495000Z TestFramework (INFO): Check isfinaltransaction returns false when looking for unknown transactions
2023-02-27T15:17:46.499000Z TestFramework (INFO): Check isfinalblock and isfinaltransaction returns false when the quorum is not established
2023-02-27T15:17:51.376000Z TestFramework (INFO): Check the getblocktemplate output with and without -deprecatedrpc=getblocktemplate_sigops
2023-02-27T15:17:56.864000Z TestFramework (INFO): Check the getblockchaininfo output with and without -deprecatedrpc=softforks
2023-02-27T15:17:56.893000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/rpc_deprecated.py", line 151, in run_test
    assert 'ancestorcount' in utxo
AssertionError
2023-02-27T15:17:56.943000Z TestFramework (INFO): Stopping nodes
2023-02-27T15:17:57.045000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_151555/rpc_deprecated_28
2023-02-27T15:17:57.045000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_151555/rpc_deprecated_28/test_framework.log
2023-02-27T15:17:57.045000Z TestFramework (ERROR): 
2023-02-27T15:17:57.045000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_151555/rpc_deprecated_28' to consolidate all logs
2023-02-27T15:17:57.045000Z TestFramework (ERROR): 
2023-02-27T15:17:57.045000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2023-02-27T15:17:57.045000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2023-02-27T15:17:57.045000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests with the next upgrade activated: rpc_deprecated.py

PiRK added a subscriber: PiRK.

OK, the code is trivially good so the CI failure is surely unrelated to this.

This revision is now accepted and ready to land.Feb 27 2023, 16:10