Merge branch 'master' of ssh://github.com/novacoin-project/novacoin
author0xDEADFACE <masmfan@gmail.com>
Sun, 14 Feb 2016 03:23:21 +0000 (19:23 -0800)
committer0xDEADFACE <masmfan@gmail.com>
Sun, 14 Feb 2016 03:23:21 +0000 (19:23 -0800)
src/ecies.cpp
src/key.cpp
src/main.cpp
src/rpcrawtransaction.cpp
src/txdb-bdb.cpp
src/txdb-leveldb.cpp
src/util.cpp

index 215d390..39fe2d7 100644 (file)
@@ -11,7 +11,6 @@
 #include "ies.h"
 #include <iostream>
 #include <vector>
-#include <openssl/ecdh.h>
 
 #define SET_ERROR(string) \
     sprintf(error, "%s %s:%d", (string), __FILE__, __LINE__)
@@ -273,16 +272,16 @@ static int store_mac_tag(const ies_ctx_t *ctx, const unsigned char *envelope_key
 
 cryptogram_t * ecies_encrypt(const ies_ctx_t *ctx, const unsigned char *data, size_t length, char *error) {
 
-    const size_t block_length = EVP_CIPHER_block_size(ctx->cipher);
-    const size_t mac_length = EVP_MD_size(ctx->md);
-    cryptogram_t *cryptogram = NULL;
-    unsigned char *envelope_key = NULL;
-
     if (!ctx || !data || !length) {
         SET_ERROR("Invalid arguments");
         return NULL;
     }
 
+    const size_t block_length = EVP_CIPHER_block_size(ctx->cipher);
+    const size_t mac_length = EVP_MD_size(ctx->md);
+    cryptogram_t *cryptogram = NULL;
+    unsigned char *envelope_key = NULL;
+
     if (block_length == 0 || block_length > EVP_MAX_BLOCK_LENGTH) {
         SET_ERROR("Derived block size is incorrect");
         return NULL;
index c37b102..bf0f99d 100644 (file)
@@ -6,12 +6,9 @@
 
 #include <openssl/ecdsa.h>
 #include <openssl/obj_mac.h>
-#include <openssl/ssl.h>
-#include <openssl/ecdh.h>
 
 #include "key.h"
 #include "base58.h"
-#include "ies.h"
 
 // Generate a private key from just the secret parameter
 int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key)
index befcfaa..68ae6a2 100644 (file)
@@ -1189,11 +1189,11 @@ const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfSta
 
 unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake)
 {
-    CBigNum bnTargetLimit = !fProofOfStake ? bnProofOfWorkLimit : GetProofOfStakeLimit(pindexLast->nHeight, pindexLast->nTime);
-
     if (pindexLast == NULL)
         return bnTargetLimit.GetCompact(); // genesis block
 
+    CBigNum bnTargetLimit = !fProofOfStake ? bnProofOfWorkLimit : GetProofOfStakeLimit(pindexLast->nHeight, pindexLast->nTime);
+
     const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake);
     if (pindexPrev->pprev == NULL)
         return bnTargetLimit.GetCompact(); // first block
@@ -2137,7 +2137,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
         return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str());
 
     // Construct new block index object
-    CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this);
+    CBlockIndex* pindexNew = new(nothrow) CBlockIndex(nFile, nBlockPos, *this);
     if (!pindexNew)
         return error("AddToBlockIndex() : new CBlockIndex failed");
     pindexNew->phashBlock = &hash;
index 5bec8b4..fd40d5f 100644 (file)
@@ -12,8 +12,6 @@
 #include "main.h"
 #include "net.h"
 #include "wallet.h"
-#include "script.h"
-#include "util.h"
 
 using namespace std;
 using namespace boost;
index bbfb656..5ce59b5 100644 (file)
@@ -160,7 +160,7 @@ CBlockIndex static * InsertBlockIndex(uint256 hash)
         return (*mi).second;
 
     // Create new
-    CBlockIndex* pindexNew = new CBlockIndex();
+    CBlockIndex* pindexNew = new(nothrow) CBlockIndex();
     if (!pindexNew)
         throw runtime_error("LoadBlockIndex() : new CBlockIndex failed");
     mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
index 4a7a3cf..97bf88c 100644 (file)
@@ -325,7 +325,7 @@ static CBlockIndex *InsertBlockIndex(uint256 hash)
         return (*mi).second;
 
     // Create new
-    CBlockIndex* pindexNew = new CBlockIndex();
+    CBlockIndex* pindexNew = new(nothrow) CBlockIndex();
     if (!pindexNew)
         throw runtime_error("LoadBlockIndex() : new CBlockIndex failed");
     mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
index f6d80f7..7fb43bc 100644 (file)
@@ -331,7 +331,7 @@ string vstrprintf(const char *format, va_list ap)
         if (p != buffer)
             delete[] p;
         limit *= 2;
-        p = new char[limit];
+        p = new(nothrow) char[limit];
         if (p == NULL)
             throw std::bad_alloc();
     }