Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid assigning shared ptr dereference to reference. #440

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ libbitcoin-network.pc

bin
obj
build
.*.swp
*~
/*.kdev4
Expand Down
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/obj/nix-gnu-debug-static/libbitcoin-network-test",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/obj/nix-gnu-debug-static",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"cmake.sourceDirectory": "/home/nixmini/Repository/Source/libbitcoin-network/builds/cmake",
"cmake.useCMakePresets": "always"
}
34 changes: 34 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cmake",
"label": "CMake: build",
"command": "build",
"targets": [
"bitcoin-network",
"libbitcoin-network-test"
],
"preset": "${command:cmake.activeBuildPresetName}",
"group": "build",
"problemMatcher": [],
"detail": "CMake template build task"
},
{
"type": "cmake",
"label": "CMake: clean",
"command": "clean",
"preset": "${command:cmake.activeBuildPresetName}",
"problemMatcher": [],
"detail": "CMake template clean task"
},
{
"type": "cmake",
"label": "CMake: install",
"command": "install",
"preset": "${command:cmake.activeBuildPresetName}",
"problemMatcher": [],
"detail": "CMake template install task"
}
]
}
6 changes: 3 additions & 3 deletions builds/cmake/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "nix-base",
"description": "Factored base settings for non-windows *nix based platforms.",
"hidden": true,
"installDir": "${sourceParentDir}/../../prefix/${presetName}",
"installDir": "${sourceParentDir}/../../../prefix/${presetName}",
"binaryDir": "${sourceParentDir}/../obj/${presetName}",
"condition": {
"type": "inList",
Expand All @@ -18,11 +18,11 @@
"cacheVariables": {
"CMAKE_PREFIX_PATH": {
"type": "PATH",
"value": "${sourceParentDir}/../../prefix/${presetName}"
"value": "${sourceParentDir}/../../../prefix/${presetName}"
},
"CMAKE_LIBRARY_PATH": {
"type": "PATH",
"value": "${sourceParentDir}/../../prefix/${presetName}/lib:$env{CMAKE_LIBRARY_PATH}"
"value": "${sourceParentDir}/../../../prefix/${presetName}/lib:$env{CMAKE_LIBRARY_PATH}"
}
}
},
Expand Down
11 changes: 11 additions & 0 deletions builds/vscode/network.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"folders": [
{
"path": "../../../libbitcoin-system"
},
{
"path": "../../../libbitcoin-network"
}
],
"settings": {}
}
16 changes: 8 additions & 8 deletions src/messages/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ typename transaction::cptr transaction::deserialize(uint32_t version,
if (!reader)
return nullptr;

const auto& tx = *message->transaction_ptr;
const auto& tx = message->transaction_ptr;

// Cache transaction hashes.
// If !witness then wire txs cannot have been segregated.
if (tx.is_segregated())
if (tx->is_segregated())
{
const auto true_size = tx.serialized_size(true);
const auto false_size = tx.serialized_size(false);
tx.set_witness_hash(bitcoin_hash(true_size, data.data()));
tx.set_nominal_hash(chain::transaction::desegregated_hash(
const auto true_size = tx->serialized_size(true);
const auto false_size = tx->serialized_size(false);
tx->set_witness_hash(bitcoin_hash(true_size, data.data()));
tx->set_nominal_hash(chain::transaction::desegregated_hash(
true_size, false_size, data.data()));
}
else
{
const auto false_size = tx.serialized_size(false);
tx.set_nominal_hash(bitcoin_hash(false_size, data.data()));
const auto false_size = tx->serialized_size(false);
tx->set_nominal_hash(bitcoin_hash(false_size, data.data()));
}

return message;
Expand Down
Loading