arthurgervais / Bitcoin-Simulator

Bitcoin and Blockchain Simulator
http://arthurgervais.github.io/Bitcoin-Simulator/
186 stars 75 forks source link

Fixed deprecated Mean Attribute Warning. #6

Closed tnull closed 2 years ago

tnull commented 6 years ago

From ns-3.27 onwards, the ns3::ParetoRandomVariable class deprecates the use of the "Mean" attribute (see RELEASE_NOTES), leading to a lot of warning messages: Attribute 'Mean' is deprecated: Not anymore used. Use 'Scale' instead - changing this attribute has no effect.

This pull request fixes this by calculating and scale parameter from the mean value and supplying it to the "Scale" attribute.

elvisyjlin commented 6 years ago

Hi @tnull,

I'm using Bitcoin-Simulator with ns-3.28. I encountered the deprecated mean attribute warning and thanks for your fixing.

However, after revising src/applications/helper/bitcoin-topology-helper.cc as your modification, I got the following error when compiling via ./waf.

../../src/applications/helper/bitcoin-topology-helper.cc: In constructor 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)':
../../src/applications/helper/bitcoin-topology-helper.cc:1120:78: error: 'node' was not declared in this scope
           double shape = m_regionLatencies[m_bitcoinNodesRegion[(m_nodes.at (node.first).Get (0))->GetId()]] [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]] / m_latencyParetoShapeDivider;
                                                                              ^
../../src/applications/helper/bitcoin-topology-helper.cc:1126:84: error: capture of non-variable 'ns3::BitcoinTopologyHelper::m_bitcoinNodesRegion' 
                                                                                   [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]]));
                                                                                    ^
In file included from ../../src/applications/helper/bitcoin-topology-helper.cc:19:0:
./ns3/bitcoin-topology-helper.h:164:51: note: 'uint32_t* ns3::BitcoinTopologyHelper::m_bitcoinNodesRegion' declared here
   uint32_t                                       *m_bitcoinNodesRegion;      //!< The region in which the bitcoin nodes are located
                                                   ^
../../src/applications/helper/bitcoin-topology-helper.cc:1126:104: error: expected ',' before '[' token
                                                                                   [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]]));
                                                                                                        ^
../../src/applications/helper/bitcoin-topology-helper.cc:1126:104: error: expected identifier before '[' token
../../src/applications/helper/bitcoin-topology-helper.cc: In lambda function:
../../src/applications/helper/bitcoin-topology-helper.cc:1126:142: error: expected '{' before ')' token
                                                                                   [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]]));
                                                                                                                                              ^
../../src/applications/helper/bitcoin-topology-helper.cc: In constructor 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)':
../../src/applications/helper/bitcoin-topology-helper.cc:1126:142: error: expected ';' before ')' token
../../src/applications/helper/bitcoin-topology-helper.cc:1128:85: error: capture of non-variable 'ns3::BitcoinTopologyHelper::m_bitcoinNodesRegion' 
                                                                                    [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]] / m_latencyParetoShapeDivider));
                                                                                     ^
In file included from ../../src/applications/helper/bitcoin-topology-helper.cc:19:0:
./ns3/bitcoin-topology-helper.h:164:51: note: 'uint32_t* ns3::BitcoinTopologyHelper::m_bitcoinNodesRegion' declared here
   uint32_t                                       *m_bitcoinNodesRegion;      //!< The region in which the bitcoin nodes are located
                                                   ^
../../src/applications/helper/bitcoin-topology-helper.cc:1128:105: error: expected ',' before '[' token
                                                                                    [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]] / m_latencyParetoShapeDivider));
                                                                                                         ^
../../src/applications/helper/bitcoin-topology-helper.cc:1128:105: error: expected identifier before '[' token
../../src/applications/helper/bitcoin-topology-helper.cc: In lambda function:
../../src/applications/helper/bitcoin-topology-helper.cc:1128:144: error: expected '{' before '/' token
                                                                                    [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]] / m_latencyParetoShapeDivider));
                                                                                                                                                ^
../../src/applications/helper/bitcoin-topology-helper.cc: In constructor 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)':
../../src/applications/helper/bitcoin-topology-helper.cc:1128:144: error: no match for 'operator/' (operand types are 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)::<lambda()>' and 'double')
In file included from ./ns3/nstime.h:26:0,
                 from ./ns3/ipv4-routing-protocol.h:29,
                 from ./ns3/ipv4-l3-protocol.h:34,
                 from ./ns3/internet-stack-helper.h:29,
                 from ./ns3/bitcoin-topology-helper.h:24,
                 from ../../src/applications/helper/bitcoin-topology-helper.cc:19:
./ns3/int64x64.h:119:12: note: candidate: ns3::int64x64_t ns3::operator/(const ns3::int64x64_t&, const ns3::int64x64_t&)
 int64x64_t operator / (const int64x64_t & lhs, const int64x64_t & rhs)
            ^
./ns3/int64x64.h:119:12: note:   no known conversion for argument 1 from 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)::<lambda()>' to 'const ns3::int64x64_t&'
In file included from ./ns3/ipv4-routing-protocol.h:29:0,
                 from ./ns3/ipv4-l3-protocol.h:34,
                 from ./ns3/internet-stack-helper.h:29,
                 from ./ns3/bitcoin-topology-helper.h:24,
                 from ../../src/applications/helper/bitcoin-topology-helper.cc:19:
./ns3/nstime.h:870:1: note: candidate: int64_t ns3::operator/(const ns3::Time&, const ns3::Time&)
 operator / (const Time & lhs, const Time & rhs)
 ^
./ns3/nstime.h:870:1: note:   no known conversion for argument 1 from 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)::<lambda()>' to 'const ns3::Time&'
./ns3/nstime.h:883:1: note: candidate: ns3::Time ns3::operator/(const ns3::Time&, const int64_t&)
 operator / (const Time & lhs, const int64_t & rhs)
 ^
./ns3/nstime.h:883:1: note:   no known conversion for argument 1 from 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)::<lambda()>' to 'const ns3::Time&'
../../src/applications/helper/bitcoin-topology-helper.cc:1183:79: error: 'miner' was not declared in this scope
           double shape = m_regionLatencies[m_bitcoinNodesRegion[(m_nodes.at (*miner).Get (0))->GetId()]] [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]] / m_latencyParetoShapeDivider;
                                                                               ^
../../src/applications/helper/bitcoin-topology-helper.cc:1190:84: error: capture of non-variable 'ns3::BitcoinTopologyHelper::m_bitcoinNodesRegion' 
                                                                                   [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]]));
                                                                                    ^
In file included from ../../src/applications/helper/bitcoin-topology-helper.cc:19:0:
./ns3/bitcoin-topology-helper.h:164:51: note: 'uint32_t* ns3::BitcoinTopologyHelper::m_bitcoinNodesRegion' declared here
   uint32_t                                       *m_bitcoinNodesRegion;      //!< The region in which the bitcoin nodes are located
                                                   ^
../../src/applications/helper/bitcoin-topology-helper.cc:1190:104: error: expected ',' before '[' token
                                                                                   [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]]));
                                                                                                        ^
../../src/applications/helper/bitcoin-topology-helper.cc:1190:104: error: expected identifier before '[' token
../../src/applications/helper/bitcoin-topology-helper.cc: In lambda function:
../../src/applications/helper/bitcoin-topology-helper.cc:1190:142: error: expected '{' before ')' token
                                                                                   [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]]));
                                                                                                                                              ^
../../src/applications/helper/bitcoin-topology-helper.cc: In constructor 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)':
../../src/applications/helper/bitcoin-topology-helper.cc:1190:142: error: expected ';' before ')' token
../../src/applications/helper/bitcoin-topology-helper.cc:1192:85: error: capture of non-variable 'ns3::BitcoinTopologyHelper::m_bitcoinNodesRegion' 
                                                                                    [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]] / m_latencyParetoShapeDivider));
                                                                                     ^
In file included from ../../src/applications/helper/bitcoin-topology-helper.cc:19:0:
./ns3/bitcoin-topology-helper.h:164:51: note: 'uint32_t* ns3::BitcoinTopologyHelper::m_bitcoinNodesRegion' declared here
   uint32_t                                       *m_bitcoinNodesRegion;      //!< The region in which the bitcoin nodes are located
                                                   ^
../../src/applications/helper/bitcoin-topology-helper.cc:1192:105: error: expected ',' before '[' token
                                                                                    [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]] / m_latencyParetoShapeDivider));
                                                                                                         ^
../../src/applications/helper/bitcoin-topology-helper.cc:1192:105: error: expected identifier before '[' token
../../src/applications/helper/bitcoin-topology-helper.cc: In lambda function:
../../src/applications/helper/bitcoin-topology-helper.cc:1192:144: error: expected '{' before '/' token
                                                                                    [m_bitcoinNodesRegion[(m_nodes.at (*it).Get (0))->GetId()]] / m_latencyParetoShapeDivider));
                                                                                                                                                ^
../../src/applications/helper/bitcoin-topology-helper.cc: In constructor 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)':
../../src/applications/helper/bitcoin-topology-helper.cc:1192:144: error: no match for 'operator/' (operand types are 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)::<lambda()>' and 'double')
In file included from ./ns3/nstime.h:26:0,
                 from ./ns3/ipv4-routing-protocol.h:29,
                 from ./ns3/ipv4-l3-protocol.h:34,
                 from ./ns3/internet-stack-helper.h:29,
                 from ./ns3/bitcoin-topology-helper.h:24,
                 from ../../src/applications/helper/bitcoin-topology-helper.cc:19:
./ns3/int64x64.h:119:12: note: candidate: ns3::int64x64_t ns3::operator/(const ns3::int64x64_t&, const ns3::int64x64_t&)
 int64x64_t operator / (const int64x64_t & lhs, const int64x64_t & rhs)
            ^
./ns3/int64x64.h:119:12: note:   no known conversion for argument 1 from 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)::<lambda()>' to 'const ns3::int64x64_t&'
In file included from ./ns3/ipv4-routing-protocol.h:29:0,
                 from ./ns3/ipv4-l3-protocol.h:34,
                 from ./ns3/internet-stack-helper.h:29,
                 from ./ns3/bitcoin-topology-helper.h:24,
                 from ../../src/applications/helper/bitcoin-topology-helper.cc:19:
./ns3/nstime.h:870:1: note: candidate: int64_t ns3::operator/(const ns3::Time&, const ns3::Time&)
 operator / (const Time & lhs, const Time & rhs)
 ^
./ns3/nstime.h:870:1: note:   no known conversion for argument 1 from 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)::<lambda()>' to 'const ns3::Time&'
./ns3/nstime.h:883:1: note: candidate: ns3::Time ns3::operator/(const ns3::Time&, const int64_t&)
 operator / (const Time & lhs, const int64_t & rhs)
 ^
./ns3/nstime.h:883:1: note:   no known conversion for argument 1 from 'ns3::BitcoinTopologyHelper::BitcoinTopologyHelper(uint32_t, uint32_t, uint32_t, ns3::BitcoinRegion*, ns3::Cryptocurrency, int, int, double, uint32_t)::<lambda()>' to 'const ns3::Time&'

Build failed
 -> task in 'ns3-applications' failed (exit status 1): 
    {task 139734521468688: cxx bitcoin-topology-helper.cc -> bitcoin-topology-helper.cc.1.o}
['/usr/bin/g++', '-std=c++11', '-march=native', '-fstrict-overflow', '-Wstrict-overflow=2', '-std=c++11', '-pthread', '-pthread', '-I.', '-I../..', '-I/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent', '-I/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include', '-I/usr/lib/openmpi/include', '-I/usr/lib/openmpi/include/openmpi', '-DNS3_BUILD_PROFILE_OPTIMIZED', '-DHAVE_SYS_IOCTL_H=1', '-DHAVE_IF_NETS_H=1', '-DHAVE_NET_ETHERNET_H=1', '-DHAVE_PACKET_H=1', '-DHAVE_IF_TUN_H=1', '-DHAVE_MPI=1', '-DNS3_OPENMPI', '-DNS3_MPI', '../../src/applications/helper/bitcoin-topology-helper.cc', '-c', '-o', '$USER/workspace/ns-allinone-3.28/ns-3.28/build/optimized/src/applications/helper/bitcoin-topology-helper.cc.1.o']
tnull commented 6 years ago

@elvisyjlin How did you apply the patch? It seems odd that this would result in such a number of error messages. Could it be that you messed up your scopes, i.e. added/removed a superfluous/needed opening/closing brace?

elvisyjlin commented 6 years ago

@tnull You're right. I reexamined the code I revised and found two lines which should be removed remained there. I'm so sorry about this bug. Now it works! Thank you so much!