Skip to content

Commit

Permalink
vTorrent-Client 0.7.2 Beta
Browse files Browse the repository at this point in the history
Major beta release
  • Loading branch information
vtorrent committed Apr 12, 2015
1 parent 344c9ef commit 6fabfae
Show file tree
Hide file tree
Showing 596 changed files with 199,388 additions and 136,507 deletions.
73,137 changes: 0 additions & 73,137 deletions Makefile

This file was deleted.

Empty file modified contrib/macdeploy/app-icon-550x550.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified contrib/macdeploy/background.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified contrib/macdeploy/background.psd
100644 → 100755
Empty file.
Binary file renamed src/qt/res/icons/wall.png → linux-release/vTorrent-32.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions linux-release/vTorrent.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Name=vTorrent
Comment=vTorrent Client
Exec=/home/ubuntu/vTorrent-qt/release/vTorrent-client %u
Terminal=false
Type=Application
Icon=/home/ubuntu/vTorrent-qt/release/vTorrent-32.png
MimeType=x-scheme-handler/vtorrent;
Categories=Office;Finance;
41 changes: 22 additions & 19 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ bool CAddrInfo::IsTerrible(int64_t nNow) const
if (nTime > nNow + 10*60) // came in a flying DeLorean
return true;

if (nTime==0 || nNow-nTime > ADDRMAN_HORIZON_DAYS*86400) // not seen in over a month
if (nTime==0 || nNow-nTime > ADDRMAN_HORIZON_DAYS*24*60*60) // not seen in recent history
return true;

if (nLastSuccess==0 && nAttempts>=ADDRMAN_RETRIES) // tried three times and never a success
if (nLastSuccess==0 && nAttempts>=ADDRMAN_RETRIES) // tried N times and never a success
return true;

if (nNow-nLastSuccess > ADDRMAN_MIN_FAIL_DAYS*86400 && nAttempts>=ADDRMAN_MAX_FAILURES) // 10 successive failures in the last week
if (nNow-nLastSuccess > ADDRMAN_MIN_FAIL_DAYS*24*60*60 && nAttempts>=ADDRMAN_MAX_FAILURES) // N successive failures in the last week
return true;

return false;
Expand Down Expand Up @@ -347,13 +347,14 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimeP
nFactor *= 2;
if (nFactor > 1 && (GetRandInt(nFactor) != 0))
return false;
} else {
} else
{
pinfo = Create(addr, source, &nId);
pinfo->nTime = max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty);
// printf("Added %s [nTime=%fhr]\n", pinfo->ToString().c_str(), (GetAdjustedTime() - pinfo->nTime) / 3600.0);
nNew++;
fNew = true;
}
};

int nUBucket = pinfo->GetNewBucket(nKey, source);
std::set<int> &vNew = vvNew[nUBucket];
Expand All @@ -363,7 +364,7 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimeP
if (vNew.size() == ADDRMAN_NEW_BUCKET_SIZE)
ShrinkNew(nUBucket);
vvNew[nUBucket].insert(nId);
}
};
return fNew;
}

Expand Down Expand Up @@ -408,8 +409,9 @@ CAddress CAddrMan::Select_(int nUnkBias)
if (GetRandInt(1<<30) < fChanceFactor*info.GetChance()*(1<<30))
return info;
fChanceFactor *= 1.2;
}
} else {
};
} else
{
// use a new node
double fChanceFactor = 1.0;
while(1)
Expand All @@ -426,8 +428,8 @@ CAddress CAddrMan::Select_(int nUnkBias)
if (GetRandInt(1<<30) < fChanceFactor*info.GetChance()*(1<<30))
return info;
fChanceFactor *= 1.2;
}
}
};
};
}

#ifdef DEBUG_ADDRMAN
Expand All @@ -448,16 +450,17 @@ int CAddrMan::Check_()
if (!info.nLastSuccess) return -1;
if (info.nRefCount) return -2;
setTried.insert(n);
} else {
} else
{
if (info.nRefCount < 0 || info.nRefCount > ADDRMAN_NEW_BUCKETS_PER_ADDRESS) return -3;
if (!info.nRefCount) return -4;
mapNew[n] = info.nRefCount;
}
};
if (mapAddr[info] != n) return -5;
if (info.nRandomPos<0 || info.nRandomPos>=vRandom.size() || vRandom[info.nRandomPos] != n) return -14;
if (info.nLastTry < 0) return -6;
if (info.nLastSuccess < 0) return -8;
}
};

if (setTried.size() != nTried) return -9;
if (mapNew.size() != nNew) return -10;
Expand All @@ -469,8 +472,8 @@ int CAddrMan::Check_()
{
if (!setTried.count(*it)) return -11;
setTried.erase(*it);
}
}
};
};

for (int n=0; n<vvNew.size(); n++)
{
Expand All @@ -480,8 +483,8 @@ int CAddrMan::Check_()
if (!mapNew.count(*it)) return -12;
if (--mapNew[*it] == 0)
mapNew.erase(*it);
}
}
};
};

if (setTried.size()) return -13;
if (mapNew.size()) return -15;
Expand All @@ -492,12 +495,12 @@ int CAddrMan::Check_()

void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr)
{
int nNodes = ADDRMAN_GETADDR_MAX_PCT*vRandom.size()/100;
unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100;
if (nNodes > ADDRMAN_GETADDR_MAX)
nNodes = ADDRMAN_GETADDR_MAX;

// perform a random shuffle over the first nNodes elements of vRandom (selecting from all)
for (int n = 0; n<nNodes; n++)
for (unsigned int n = 0; n < nNodes; n++)
{
int nRndPos = GetRandInt(vRandom.size() - n) + n;
SwapRandom(n, nRndPos);
Expand Down
13 changes: 6 additions & 7 deletions src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ bool CAlert::RelayTo(CNode* pnode) const

bool CAlert::CheckSignature() const
{
CKey key;
if (!key.SetPubKey(ParseHex(fTestNet ? pszTestKey : pszMainKey)))
return error("CAlert::CheckSignature() : SetPubKey failed");
CPubKey key(ParseHex(fTestNet ? pszTestKey : pszMainKey));
if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig))
return error("CAlert::CheckSignature() : verify signature failed");

Expand Down Expand Up @@ -211,15 +209,16 @@ bool CAlert::ProcessAlert(bool fThread)
printf("cancelling alert %d\n", alert.nID);
uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
mapAlerts.erase(mi++);
}
else if (!alert.IsInEffect())
} else
if (!alert.IsInEffect())
{
printf("expiring alert %d\n", alert.nID);
uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
mapAlerts.erase(mi++);
}
else
} else
{
mi++;
}
}

// Check if this alert has been cancelled
Expand Down
18 changes: 16 additions & 2 deletions src/allocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include <boost/thread/mutex.hpp>
#include <map>
#include <openssl/crypto.h> // for OPENSSL_cleanse()

#ifdef WIN32
#ifdef _WIN32_WINNT
Expand Down Expand Up @@ -175,6 +176,19 @@ class LockedPageManager: public LockedPageManagerBase<MemoryPageLocker>
{}
};

//
// Functions for directly locking/unlocking memory objects.
// Intended for non-dynamically allocated structures.
//
template<typename T> void LockObject(const T &t) {
LockedPageManager::instance.LockRange((void*)(&t), sizeof(T));
}

template<typename T> void UnlockObject(const T &t) {
OPENSSL_cleanse((void*)(&t), sizeof(T));
LockedPageManager::instance.UnlockRange((void*)(&t), sizeof(T));
}

//
// Allocator that locks its contents from being paged
// out of memory and clears its contents before deletion.
Expand Down Expand Up @@ -212,7 +226,7 @@ struct secure_allocator : public std::allocator<T>
{
if (p != NULL)
{
memset(p, 0, sizeof(T) * n);
OPENSSL_cleanse(p, sizeof(T) * n);
LockedPageManager::instance.UnlockRange(p, sizeof(T) * n);
}
std::allocator<T>::deallocate(p, n);
Expand Down Expand Up @@ -246,7 +260,7 @@ struct zero_after_free_allocator : public std::allocator<T>
void deallocate(T* p, std::size_t n)
{
if (p != NULL)
memset(p, 0, sizeof(T) * n);
OPENSSL_cleanse(p, sizeof(T) * n);
std::allocator<T>::deallocate(p, n);
}
};
Expand Down
23 changes: 11 additions & 12 deletions src/base58.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <string>
#include <vector>
#include "state.h"
#include "bignum.h"
#include "key.h"
#include "script.h"
Expand Down Expand Up @@ -404,21 +405,19 @@ bool inline CBitcoinAddressVisitor::operator()(const CNoDestination &id) const {
class CBitcoinSecret : public CBase58Data
{
public:
void SetSecret(const CSecret& vchSecret, bool fCompressed)
void SetKey(const CKey& vchSecret)
{
assert(vchSecret.size() == 32);
SetData(128 + (fTestNet ? CBitcoinAddress::PUBKEY_ADDRESS_TEST : CBitcoinAddress::PUBKEY_ADDRESS), &vchSecret[0], vchSecret.size());
if (fCompressed)
assert(vchSecret.IsValid());
SetData((fTestNet ? CBitcoinAddress::PUBKEY_ADDRESS_TEST : CBitcoinAddress::PUBKEY_ADDRESS), vchSecret.begin(), vchSecret.size()); //128+?
if (vchSecret.IsCompressed())
vchData.push_back(1);
}

CSecret GetSecret(bool &fCompressedOut)
CKey GetKey()
{
CSecret vchSecret;
vchSecret.resize(32);
memcpy(&vchSecret[0], &vchData[0], 32);
fCompressedOut = vchData.size() == 33;
return vchSecret;
CKey ret;
ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1);
return ret;
}

bool IsValid() const
Expand Down Expand Up @@ -449,9 +448,9 @@ class CBitcoinSecret : public CBase58Data
return SetString(strSecret.c_str());
}

CBitcoinSecret(const CSecret& vchSecret, bool fCompressed)
CBitcoinSecret(const CKey& vchSecret)
{
SetSecret(vchSecret, fCompressed);
SetKey(vchSecret);
}

CBitcoinSecret()
Expand Down
16 changes: 11 additions & 5 deletions src/bignum.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class CBigNum : public BIGNUM
* @param range The upper bound on the number.
* @return
*/
static CBigNum randBignum(const CBigNum& range) {
static CBigNum randBignum(const CBigNum& range)
{
CBigNum ret;
if(!BN_rand_range(&ret, &range)){
throw bignum_error("CBigNum:rand element : BN_rand_range failed");
Expand All @@ -120,9 +121,11 @@ class CBigNum : public BIGNUM
* @param k The bit length of the number.
* @return
*/
static CBigNum RandKBitBigum(const uint32_t k){
static CBigNum RandKBitBigum(const uint32_t k)
{
CBigNum ret;
if(!BN_rand(&ret, k, -1, 0)){
if(!BN_rand(&ret, k, -1, 0))
{
throw bignum_error("CBigNum:rand element : BN_rand failed");
}
return ret;
Expand Down Expand Up @@ -175,7 +178,8 @@ class CBigNum : public BIGNUM
n = -(sn + 1);
++n;
fNegative = true;
} else {
} else
{
n = sn;
fNegative = false;
}
Expand Down Expand Up @@ -393,6 +397,7 @@ class CBigNum : public BIGNUM
unsigned int c = rem.getulong();
str += "0123456789abcdef"[c];
}

if (BN_is_negative(this))
str += "-";
reverse(str.begin(), str.end());
Expand Down Expand Up @@ -500,7 +505,8 @@ class CBigNum : public BIGNUM
* @param safe true for a safe prime
* @return the prime
*/
static CBigNum generatePrime(const unsigned int numBits, bool safe = false) {
static CBigNum generatePrime(const unsigned int numBits, bool safe = false)
{
CBigNum ret;
if(!BN_generate_prime_ex(&ret, numBits, (safe == true), NULL, NULL, NULL))
throw bignum_error("CBigNum::generatePrime*= :BN_generate_prime_ex");
Expand Down
Loading

0 comments on commit 6fabfae

Please sign in to comment.