Exemple #1
0
static UniValue generatetoaddress(const JSONRPCRequest& request)
{
    if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
        throw std::runtime_error(
            "generatetoaddress nblocks address (maxtries)\n"
            "\nMine blocks immediately to a specified address (before the RPC call returns)\n"
            "\nArguments:\n"
            "1. nblocks      (numeric, required) How many blocks are generated immediately.\n"
            "2. address      (string, required) The address to send the newly generated bitcoin to.\n"
            "3. maxtries     (numeric, optional) How many iterations to try (default = 1000000).\n"
            "\nResult:\n"
            "[ blockhashes ]     (array) hashes of blocks generated\n"
            "\nExamples:\n"
            "\nGenerate 11 blocks to myaddress\n"
            + HelpExampleCli("generatetoaddress", "11 \"myaddress\"")
            + "If you are running the bitcoin core wallet, you can get a new address to send the newly generated bitcoin to with:\n"
            + HelpExampleCli("getnewaddress", "")
        );

    int nGenerate = request.params[0].get_int();
    uint64_t nMaxTries = 1000000;
    if (!request.params[2].isNull()) {
        nMaxTries = request.params[2].get_int();
    }

    CTxDestination destination = DecodeDestination(request.params[1].get_str());
    if (!IsValidDestination(destination)) {
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
    }

    std::shared_ptr<CReserveScript> coinbaseScript = std::make_shared<CReserveScript>();
    coinbaseScript->reserveScript = GetScriptForDestination(destination);

    return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);
}
UniValue generate(const JSONRPCRequest& request)
{
    if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
        throw std::runtime_error(
            "generate nblocks ( maxtries )\n"
            "\nMine up to nblocks blocks immediately (before the RPC call returns)\n"
            "\nArguments:\n"
            "1. nblocks      (numeric, required) How many blocks are generated immediately.\n"
            "2. maxtries     (numeric, optional) How many iterations to try (default = 1000000).\n"
            "\nResult:\n"
            "[ blockhashes ]     (array) hashes of blocks generated\n"
            "\nExamples:\n"
            "\nGenerate 11 blocks\n"
            + HelpExampleCli("generate", "11")
        );

    int nGenerate = request.params[0].get_int();
    uint64_t nMaxTries = 1000000;
    if (request.params.size() > 1) {
        nMaxTries = request.params[1].get_int();
    }

    boost::shared_ptr<CReserveScript> coinbaseScript;
    GetMainSignals().ScriptForMining(coinbaseScript);

    // If the keypool is exhausted, no script is returned at all.  Catch this.
    if (!coinbaseScript)
        throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");

    //throw an error if no script was provided
    if (coinbaseScript->reserveScript.empty())
        throw JSONRPCError(RPC_INTERNAL_ERROR, "No coinbase script available (mining requires a wallet)");

    return generateBlocks(coinbaseScript, nGenerate, nMaxTries, true);
}
Exemple #3
0
UniValue generatetoaddress(const JSONRPCRequest& request)
{
    if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
        throw std::runtime_error(
            "generatetoaddress nblocks address (maxtries)\n"
            "\nMine blocks immediately to a specified address (before the RPC call returns)\n"
            "\nArguments:\n"
            "1. nblocks      (numeric, required) How many blocks are generated immediately.\n"
            "2. address      (string, required) The address to send the newly generated Dash to.\n"
            "3. maxtries     (numeric, optional) How many iterations to try (default = 1000000).\n"
            "\nResult:\n"
            "[ blockhashes ]     (array) hashes of blocks generated\n"
            "\nExamples:\n"
            "\nGenerate 11 blocks to myaddress\n"
            + HelpExampleCli("generatetoaddress", "11 \"myaddress\"")
        );

    int nGenerate = request.params[0].get_int();
    uint64_t nMaxTries = 1000000;
    if (request.params.size() > 2) {
        nMaxTries = request.params[2].get_int();
    }

    CBitcoinAddress address(request.params[1].get_str());
    if (!address.IsValid())
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");

    boost::shared_ptr<CReserveScript> coinbaseScript(new CReserveScript());
    coinbaseScript->reserveScript = GetScriptForDestination(address.Get());

    return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);
}
Block* Aggregator::getNextValBlock(int colIndex_) {
  Log::writeToLog("Aggregator", 1, "getNextValBlock with colIndex", colIndex_);

  // note: if NO_GROUP, then the colIndex_ will be 0, which is GROUP_COL_INDEX in the code
  assert(!(m_aggType == NO_GROUP && colIndex_ != 0));

  // check if we have initialized input and output blocks yet
  if (!m_areBlocksInitialized) {
    initInputBlocks();
    // if no input agg blocks, the aggregator has no output
    if (m_aggBlockIn == NULL) {
      return NULL;
    }
    initOutputBlocks();

    m_areBlocksInitialized = true;
  }

  // check if we need to generate new output blocks
  if (m_isAggBlockConsumed && m_isGroupBlockConsumed) {
    m_isAggBlockConsumed = m_isGroupBlockConsumed = false;
    
    generateBlocks();
  }

  if (m_aggType == NO_GROUP) {
    m_isAggBlockConsumed = m_isGroupBlockConsumed = true;
    return m_aggBlockOut;
  } else if (colIndex_ == AGG_COL_INDEX && !m_isAggBlockConsumed) {

    m_isAggBlockConsumed = true;
    Log::writeToLog("Aggregator", 1, "Returning Aggregate Block");
    return m_aggBlockOut;

  } else if (colIndex_ == GROUP_COL_INDEX && !m_isGroupBlockConsumed) {

    m_isGroupBlockConsumed = true;
    Log::writeToLog("Aggregator", 1, "Returning Group By Block");
    return m_groupBlockOut;

  } else {
    // operator above is reading a block without having read other block
    if (m_isAggBlockConsumed) {

      throw new UnexpectedException("Aggregator: already read AggBlock but haven't read GroupBlock");

    } else {

      throw new UnexpectedException("Aggregator: already read GroupBlock but haven't read AggBlock");

    }
  }
}
Exemple #5
0
Chunk::Chunk(Vec2i chunkCoords, Chunk* northChunk,Chunk* southChunk,Chunk* eastChunk,Chunk* westChunk) 
	:	m_chunkCoords(chunkCoords),
		m_northChunk(northChunk),
		m_southChunk(southChunk),
		m_eastChunk(eastChunk),
		m_westChunk(westChunk)
{
	m_enableCulling = true;
	m_vertexes.reserve(20000);
	m_lightDirtyIndex.reserve(5000);
	m_vboID = 0;
	m_block = new Block[BLOCKS_IN_A_CHUNK];
	m_pumpkinCount = 0;

	if(m_northChunk != nullptr)
	{
		m_northChunk->m_southChunk = this;
		m_northChunk->m_isDirty = true;
		m_northChunk->checkBoundary();
	}

	if(m_southChunk != nullptr)
	{
		m_southChunk->m_northChunk = this;
		m_southChunk->m_isDirty = true;
		m_southChunk->checkBoundary();
	}

	if(m_westChunk != nullptr)
	{
		m_westChunk->m_eastChunk = this;
		m_westChunk->m_isDirty = true;
		m_westChunk->checkBoundary();
	}

	if(m_eastChunk != nullptr)
	{
		m_eastChunk->m_westChunk = this;
		m_eastChunk->m_isDirty = true;
		m_eastChunk->checkBoundary();
	}

	if(!loadFromDisk())
		generateBlocks();
	
	initialLightLevel();
	sendList(BLOCKS_IN_A_CHUNK);

	m_timeSinceLastUpdate = 0.1f;
}
Exemple #6
0
static UniValue generatetoaddress(const JSONRPCRequest& request)
{
    if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
        throw std::runtime_error(
            RPCHelpMan{"generatetoaddress",
                "\nMine blocks immediately to a specified address (before the RPC call returns)\n",
                {
                    {"nblocks", RPCArg::Type::NUM, RPCArg::Optional::NO, "How many blocks are generated immediately."},
                    {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address to send the newly generated bitcoin to."},
                    {"maxtries", RPCArg::Type::NUM, /* default */ "1000000", "How many iterations to try."},
                },
                RPCResult{
            "[ blockhashes ]     (array) hashes of blocks generated\n"
                },
                RPCExamples{
            "\nGenerate 11 blocks to myaddress\n"
            + HelpExampleCli("generatetoaddress", "11 \"myaddress\"")
            + "If you are running the bitcoin core wallet, you can get a new address to send the newly generated bitcoin to with:\n"
            + HelpExampleCli("getnewaddress", "")
                },
            }.ToString());

    int nGenerate = request.params[0].get_int();
    uint64_t nMaxTries = 1000000;
    if (!request.params[2].isNull()) {
        nMaxTries = request.params[2].get_int();
    }

    CTxDestination destination = DecodeDestination(request.params[1].get_str());
    if (!IsValidDestination(destination)) {
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
    }

    std::shared_ptr<CReserveScript> coinbaseScript = std::make_shared<CReserveScript>();
    coinbaseScript->reserveScript = GetScriptForDestination(destination);

    return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);
}