Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
bxq2011hust committed Dec 20, 2018
1 parent 0804077 commit 272d2cf
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 21 deletions.
7 changes: 2 additions & 5 deletions CODING_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Use clang-format tool to format your changes, see [CONTRIBUTING](CONTRIBUTING.md
## Preprocessor
1. File comment is always at top, and includes:
- Copyright.
- License.
- Copyright.
- License.
2. Never use `#ifdef`/`#define`/`#endif` file guards. Prefer `#pragma once` as first line below file comment.
3. Prefer static const variable to value macros.
Expand All @@ -48,7 +48,6 @@ GOLDEN RULE: Preprocessor: ALL_CAPS; C++: camelCase.
All other entities' first alpha is lower case.
## Variable prefixes
1. Leading underscore `_` to parameter names.
Expand All @@ -60,8 +59,6 @@ All other entities' first alpha is lower case.
3. Leading `g_` to global (non-const) variables.
4. Leading `s_` to static (non-const, non-global) variables.
## Error reporting
Prefer exception to bool/int return type.
Expand Down
3 changes: 2 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ coverage:
status:
project:
app:
target: 70
target: 73
threshold: 0.05
paths: "!test/"
default:
Expand All @@ -19,6 +19,7 @@ coverage:
patch:
default:
target: 10
enabled: no
changes:
default:
enabled: no
Expand Down
8 changes: 7 additions & 1 deletion libinitializer/P2PInitializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ class P2PInitializer : public std::enable_shared_from_this<P2PInitializer>
public:
typedef std::shared_ptr<P2PInitializer> Ptr;

~P2PInitializer() {}
~P2PInitializer()
{
if (m_p2pService)
{
m_p2pService->stop();
}
}

void initConfig(boost::property_tree::ptree const& _pt);

Expand Down
1 change: 1 addition & 0 deletions libnetwork/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ void Host::start()
m_run = true;
m_asioInterface->init(m_listenHost, m_listenPort);
m_hostThread = std::make_shared<std::thread>([&] {
dev::pthread_setThreadName("io_service");
while (haveNetwork())
{
try
Expand Down
5 changes: 2 additions & 3 deletions libnetwork/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,9 @@ void Session::drop(DisconnectReason _reason)
/// if get Host object failed, close the socket directly
auto socket = m_socket;
auto server = m_server.lock();
if (server || !server->asioInterface() || !server->asioInterface()->ioService())
if (server && socket->isConnected())
{
if (socket->isConnected())
socket->close();
socket->close();
}
auto shutdown_timer =
std::make_shared<boost::asio::deadline_timer>(*server->asioInterface()->ioService(),
Expand Down
2 changes: 1 addition & 1 deletion libnetwork/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Session : public SessionFace, public std::enable_shared_from_this<Session>
std::shared_ptr<std::unordered_map<uint32_t, ResponseCallback::Ptr>> m_seq2Callback;

std::function<void(NetworkException, SessionFace::Ptr, Message::Ptr)> m_messageHandler;
uint64_t m_shutDownTimeThres = 30000;
uint64_t m_shutDownTimeThres = 3000;
};

class SessionFactory
Expand Down
20 changes: 10 additions & 10 deletions tools/build_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ LOG_INFO "Start Port : $port_start"
LOG_INFO "Server IP : ${ip_array[@]}"
LOG_INFO "State Type : ${state_type}"
LOG_INFO "RPC listen IP : ${listen_ip}"
LOG_INFO "SDK PKCS12 Passwd : ${pkcs12_passwd}"
[ ! -z ${pkcs12_passwd} ] && LOG_INFO "SDK PKCS12 Passwd : ${pkcs12_passwd}"
LOG_INFO "Output Dir : $output_dir"
LOG_INFO "CA Key Path : $ca_file"
echo "=============================================================="
Expand Down Expand Up @@ -189,7 +189,7 @@ gen_chain_cert() {
gen_agency_cert() {
chain="$2"
agencypath="$3"
name=`getname "$agencypath"`
name=$(getname "$agencypath")

dir_must_exists "$chain"
file_must_exists "$chain/ca.key"
Expand Down Expand Up @@ -233,9 +233,9 @@ gen_node_cert() {
fi

agpath="$2"
agency=`getname "$agpath"`
agency=$(getname "$agpath")
ndpath="$3"
node=`getname "$ndpath"`
node=$(getname "$ndpath")
dir_must_exists "$agpath"
file_must_exists "$agpath/agency.key"
check_name agency "$agency"
Expand All @@ -250,8 +250,8 @@ gen_node_cert() {
cp $agpath/ca.crt $agpath/agency.crt $ndpath

cd $ndpath
nodeid=`cat node.nodeid | head`
serial=`cat node.serial | head`
nodeid=$(cat node.nodeid | head)
serial=$(cat node.serial | head)
cat >node.json <<EOF
{
"id":"$nodeid",
Expand Down Expand Up @@ -290,7 +290,7 @@ read_password() {
gen_sdk_cert() {
agency="$2"
sdkpath="$3"
sdk=`getname "$sdkpath"`
sdk=$(getname "$sdkpath")
dir_must_exists "$agency"
file_must_exists "$agency/agency.key"
dir_must_not_exists "$sdkpath"
Expand Down Expand Up @@ -661,7 +661,7 @@ for line in ${ip_array[*]};do
rm node.json node.param node.private node.ca node.pubkey
mv *.* ${conf_path}/
cd $output_dir
privateKey=`openssl ec -in "$node_dir/${conf_path}/node.key" -text 2> /dev/null| sed -n '3,5p' | sed 's/://g'| tr "\n" " "|sed 's/ //g'`
privateKey=$(openssl ec -in "$node_dir/${conf_path}/node.key" -text 2> /dev/null| sed -n '3,5p' | sed 's/://g'| tr "\n" " "|sed 's/ //g')
len=${#privateKey}
head2=${privateKey:0:2}
if [ "64" == "${len}" ] && [ "00" != "$head2" ];then
Expand All @@ -687,14 +687,14 @@ for line in ${ip_array[*]};do
echo "groups_count[${j}]=${groups_count[${j}]}" >> $output_dir/${logfile}
groups[${j}]=$"${groups[${j}]}node.${groups_count[${j}]}=${nodeid}
"
((++groups_count[${j}]))
((++groups_count[j]))
done
else
nodeid_list=$"${nodeid_list}node.${count}=${nodeid}
"
fi

ip_list=$"${ip_list}node.${count}="${ip}:$(( port_start + ${i} * 3 ))"
ip_list=$"${ip_list}node.${count}="${ip}:$(( port_start + i * 3 ))"
"
((++count))
done
Expand Down

0 comments on commit 272d2cf

Please sign in to comment.