Skip to content

Commit

Permalink
optimization of hash.begin() @nmarley thoughts?
Browse files Browse the repository at this point in the history
  • Loading branch information
PastaPastaPasta committed Jul 1, 2018
1 parent 3b2945d commit df879f5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/zmq/zmqpublishnotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
uint256 hash = pindex->GetBlockHash();
LogPrint("zmq", "zmq: Publish hashblock %s\n", hash.GetHex());
char data[32];
auto hashData = hash.begin();
for (unsigned int i = 0; i < 32; i++)
data[31 - i] = hash.begin()[i];
data[31 - i] = hashData[i];
return SendMessage(MSG_HASHBLOCK, data, 32);
}

Expand All @@ -161,8 +162,9 @@ bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &t
uint256 hash = transaction.GetHash();
LogPrint("zmq", "zmq: Publish hashtx %s\n", hash.GetHex());
char data[32];
auto hashData = hash.begin();
for (unsigned int i = 0; i < 32; i++)
data[31 - i] = hash.begin()[i];
data[31 - i] = hashData[i];
return SendMessage(MSG_HASHTX, data, 32);
}

Expand All @@ -171,8 +173,9 @@ bool CZMQPublishHashTransactionLockNotifier::NotifyTransactionLock(const CTransa
uint256 hash = transaction.GetHash();
LogPrint("zmq", "zmq: Publish hashtxlock %s\n", hash.GetHex());
char data[32];
auto hashData = hash.begin();
for (unsigned int i = 0; i < 32; i++)
data[31 - i] = hash.begin()[i];
data[31 - i] = hashData[i];
return SendMessage(MSG_HASHTXLOCK, data, 32);
}

Expand Down Expand Up @@ -220,8 +223,9 @@ bool CZMQPublishHashGovernanceVoteNotifier::NotifyGovernanceVote(const CGovernan
uint256 hash = vote.GetHash();
LogPrint("zmq", "zmq: Publish governancevote %s\n", hash.GetHex());
char data[32];
auto hashData = hash.begin();
for (unsigned int i = 0; i < 32; i++)
data[31 - i] = hash.begin()[i];
data[31 - i] = dashData[i];
return SendMessage(MSG_GVOTE, data, 32);
}

Expand All @@ -230,7 +234,8 @@ bool CZMQPublishHashGovernanceObjectNotifier::NotifyGovernanceObject(const CGove
uint256 hash = object.GetHash();
LogPrint("zmq", "zmq: Publish governanceobject %s\n", hash.GetHex());
char data[32];
auto hashData = hash.begin();
for (unsigned int i = 0; i < 32; i++)
data[31 - i] = hash.begin()[i];
data[31 - i] = hashData[i];
return SendMessage(MSG_GOBJECT, data, 32);
}

0 comments on commit df879f5

Please sign in to comment.