Network decentralizatoin and bug fixes
This commit is contained in:
@@ -33,6 +33,9 @@ struct CCcontract_info CCinfos[0x100];
|
||||
|
||||
bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn)
|
||||
{
|
||||
// DISABLE CRYPTO CONDITIONS FOR NOW
|
||||
return false;
|
||||
|
||||
EvalRef eval;
|
||||
bool out = eval->Dispatch(cond, tx, nIn);
|
||||
//fprintf(stderr,"out %d vs %d isValid\n",(int32_t)out,(int32_t)eval->state.IsValid());
|
||||
|
||||
@@ -165,6 +165,7 @@ public:
|
||||
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
||||
vFixedSeeds.clear();
|
||||
vSeeds.clear();
|
||||
vSeeds.push_back(CDNSSeedData("veruscoin.io", "seeds.veruscoin.io")); // @kolo - old static dns seeds
|
||||
vSeeds.push_back(CDNSSeedData("komodoplatform.com", "seeds.komodoplatform.com")); // @kolo - old static dns seeds
|
||||
vSeeds.push_back(CDNSSeedData("kolo.supernet.org", "static.kolo.supernet.org")); // @kolo - new static dns seeds ToDo
|
||||
vSeeds.push_back(CDNSSeedData("kolo.supernet.org", "dynamic.kolo.supernet.org")); // @kolo - crawler seeds ToDo
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
* IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly.
|
||||
*/
|
||||
static SeedSpec6 pnSeed6_main[] = {
|
||||
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x19,0x30,0xec}, 27485},
|
||||
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x19,0x30,0xec}, 27487},
|
||||
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x40,0x69,0x6f}, 27485},
|
||||
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x40,0x69,0x6f}, 27487},
|
||||
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x19,0x30,0x48}, 27485},
|
||||
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x19,0x30,0x48}, 27487}
|
||||
};
|
||||
|
||||
static SeedSpec6 pnSeed6_test[] = {
|
||||
|
||||
28
src/main.cpp
28
src/main.cpp
@@ -1932,6 +1932,30 @@ bool IsInitialBlockDownload()
|
||||
return state;
|
||||
}
|
||||
|
||||
// determine if we are in sync with the best chain
|
||||
bool IsInSync()
|
||||
{
|
||||
const CChainParams& chainParams = Params();
|
||||
LOCK(cs_main);
|
||||
if (fImporting || fReindex)
|
||||
{
|
||||
//fprintf(stderr,"IsInitialBlockDownload: fImporting %d || %d fReindex\n",(int32_t)fImporting,(int32_t)fReindex);
|
||||
return false;
|
||||
}
|
||||
if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints()))
|
||||
{
|
||||
//fprintf(stderr,"IsInitialBlockDownload: checkpoint -> initialdownload\n");
|
||||
return false;
|
||||
}
|
||||
CBlockIndex *ptr = chainActive.Tip();
|
||||
if ( !ptr )
|
||||
return false;
|
||||
else if ( pindexBestHeader != 0 && (pindexBestHeader->nHeight - 1) > ptr->nHeight )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool fLargeWorkForkFound = false;
|
||||
bool fLargeWorkInvalidChainFound = false;
|
||||
CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL;
|
||||
@@ -3388,7 +3412,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
||||
list<CTransaction> removed;
|
||||
CValidationState stateDummy;
|
||||
// don't keep staking or invalid transactions
|
||||
if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (block.IsVerusPOSBlock() || komodo_isPoS((CBlock *)&block) != 0)) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
||||
if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (block.IsVerusPOSBlock() || (komodo_isPoS((CBlock *)&block) != 0))) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
||||
{
|
||||
mempool.remove(tx, removed, true);
|
||||
}
|
||||
@@ -3412,7 +3436,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
||||
for (int i = 0; i < block.vtx.size(); i++)
|
||||
{
|
||||
CTransaction &tx = block.vtx[i];
|
||||
if ((i == (block.vtx.size() - 1) && (block.IsVerusPOSBlock() || komodo_isPoS((CBlock *)&block) != 0)))
|
||||
if ((i == (block.vtx.size() - 1) && (block.IsVerusPOSBlock() || (komodo_isPoS((CBlock *)&block) != 0))))
|
||||
{
|
||||
EraseFromWallets(tx.GetHash());
|
||||
}
|
||||
|
||||
@@ -224,6 +224,8 @@ void ThreadScriptCheck();
|
||||
void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const CBlockIndex *const &bestHeader, int64_t nPowTargetSpacing);
|
||||
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
||||
bool IsInitialBlockDownload();
|
||||
/** Check if the daemon is in sync */
|
||||
bool IsInSync();
|
||||
/** Format a string that describes several potential problems detected by the core */
|
||||
std::string GetWarnings(const std::string& strFor);
|
||||
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
|
||||
|
||||
@@ -796,16 +796,16 @@ int32_t waitForPeers(const CChainParams &chainparams)
|
||||
LOCK(cs_vNodes);
|
||||
fvNodesEmpty = vNodes.empty();
|
||||
}
|
||||
if (fvNodesEmpty)
|
||||
if (!IsInSync() || fvNodesEmpty)
|
||||
{
|
||||
do {
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
MilliSleep(100 + rand() % 400);
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
fvNodesEmpty = vNodes.empty();
|
||||
}
|
||||
} while (fvNodesEmpty);
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
} while (!IsInSync() || fvNodesEmpty);
|
||||
MilliSleep(100 + rand() % 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -813,6 +813,7 @@ int32_t waitForPeers(const CChainParams &chainparams)
|
||||
#ifdef ENABLE_WALLET
|
||||
CBlockIndex *get_chainactive(int32_t height)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if ( chainActive.Tip() != 0 )
|
||||
{
|
||||
if ( height <= chainActive.Tip()->nHeight )
|
||||
|
||||
45
src/net.cpp
45
src/net.cpp
@@ -48,7 +48,8 @@
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
const int MAX_OUTBOUND_CONNECTIONS = 8;
|
||||
const int MAX_OUTBOUND_CONNECTIONS = 4;
|
||||
const int MAX_INBOUND_FROMIP = 3;
|
||||
|
||||
struct ListenSocket {
|
||||
SOCKET socket;
|
||||
@@ -61,6 +62,8 @@ namespace {
|
||||
//
|
||||
// Global state variables
|
||||
//
|
||||
extern uint16_t ASSETCHAINS_P2PPORT;
|
||||
|
||||
bool fDiscover = true;
|
||||
bool fListen = true;
|
||||
uint64_t nLocalServices = NODE_NETWORK;
|
||||
@@ -907,11 +910,21 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
|
||||
LogPrintf("Warning: Unknown socket family\n");
|
||||
|
||||
bool whitelisted = hListenSocket.whitelisted || CNode::IsWhitelistedRange(addr);
|
||||
int nInboundThisIP = 0;
|
||||
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
struct sockaddr_storage tmpsockaddr;
|
||||
socklen_t tmplen = sizeof(sockaddr);
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
{
|
||||
if (pnode->fInbound)
|
||||
{
|
||||
nInbound++;
|
||||
if (pnode->addr.GetSockAddr((struct sockaddr*)&tmpsockaddr, &tmplen) && (tmplen == len) && (memcmp(&sockaddr, &tmpsockaddr, tmplen) == 0))
|
||||
nInboundThisIP++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hSocket == INVALID_SOCKET)
|
||||
@@ -946,6 +959,14 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
|
||||
}
|
||||
}
|
||||
|
||||
if (nInboundThisIP >= MAX_INBOUND_FROMIP)
|
||||
{
|
||||
// No connection to evict, disconnect the new connection
|
||||
LogPrint("net", "too many connections from %s, connection refused\n", addr.ToString());
|
||||
CloseSocket(hSocket);
|
||||
return;
|
||||
}
|
||||
|
||||
// According to the internet TCP_NODELAY is not carried into accepted sockets
|
||||
// on all platforms. Set it again here just to be sure.
|
||||
int set = 1;
|
||||
@@ -1267,8 +1288,12 @@ void ThreadDNSAddressSeed()
|
||||
int nOneDay = 24*3600;
|
||||
CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()));
|
||||
addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old
|
||||
vAdd.push_back(addr);
|
||||
found++;
|
||||
// only add seeds with the right port
|
||||
if (addr.GetPort() == ASSETCHAINS_P2PPORT)
|
||||
{
|
||||
vAdd.push_back(addr);
|
||||
found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
addrman.Add(vAdd, CNetAddr(seed.name, true));
|
||||
@@ -1279,16 +1304,6 @@ void ThreadDNSAddressSeed()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DumpAddresses()
|
||||
{
|
||||
int64_t nStart = GetTimeMillis();
|
||||
@@ -1587,10 +1602,6 @@ void ThreadMessageHandler()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool BindListenPort(const CService &addrBind, string& strError, bool fWhitelisted)
|
||||
{
|
||||
strError = "";
|
||||
|
||||
@@ -56,7 +56,7 @@ static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
|
||||
/** The maximum number of entries in setAskFor (larger due to getdata latency)*/
|
||||
static const size_t SETASKFOR_MAX_SZ = 2 * MAX_INV_SZ;
|
||||
/** The maximum number of peer connections to maintain. */
|
||||
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;
|
||||
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 384;
|
||||
/** The period before a network upgrade activates, where connections to upgrading peers are preferred (in blocks). */
|
||||
static const int NETWORK_UPGRADE_PEER_PREFERENCE_BLOCK_PERIOD = 24 * 24 * 3;
|
||||
|
||||
|
||||
@@ -573,8 +573,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
if (strMode != "template")
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
||||
|
||||
if (vNodes.empty())
|
||||
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!");
|
||||
if (Params().MiningRequiresPeers() && (!IsInSync() || vNodes.empty()))
|
||||
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Cannot get a block template while no peers are connected or chain not in sync!");
|
||||
|
||||
//if (IsInitialBlockDownload())
|
||||
// throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
|
||||
|
||||
@@ -56,6 +56,7 @@ uint32_t komodo_segid32(char *coinaddr);
|
||||
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height);
|
||||
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
|
||||
#define KOMODO_VERSION "0.1.1"
|
||||
#define VERUS_VERSION "0.3.12"
|
||||
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||
extern uint32_t ASSETCHAINS_CC;
|
||||
extern uint32_t ASSETCHAINS_MAGIC;
|
||||
@@ -108,6 +109,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
|
||||
obj.push_back(Pair("version", CLIENT_VERSION));
|
||||
obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
|
||||
obj.push_back(Pair("KMDversion", KOMODO_VERSION));
|
||||
obj.push_back(Pair("VRSCversion", VERUS_VERSION));
|
||||
obj.push_back(Pair("notarized", notarized_height));
|
||||
obj.push_back(Pair("prevMoMheight", prevMoMheight));
|
||||
obj.push_back(Pair("notarizedhash", notarized_hash.ToString()));
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
#set working directory to the location of this script
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd $DIR
|
||||
./komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -addnode=185.25.48.72 -addnode=185.25.48.236 -addnode=185.64.105.111 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -ac_veruspos=50 -gen -genproclimit=0 "$@"
|
||||
./komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -ac_veruspos=50 -gen -genproclimit=0 "$@"
|
||||
|
||||
Reference in New Issue
Block a user