Пример #1
0
void
NameIterationTester::update (const std::string& n)
{
  const valtype& name = ValtypeFromString (n);
  const CNameData testData = getNextData ();

  assert (data.count (name) == 1);
  data[name] = testData;
  hybrid.SetName (name, testData, false);
  cache.SetName (name, testData, false);
  verify ();
}
Пример #2
0
void
CNameTxUndo::apply (CCoinsViewCache& view) const
{
  if (isNew)
    view.DeleteName (name);
  else
    view.SetName (name, oldData, true);
}
Пример #3
0
void
ApplyGameTransactions (const std::vector<CTransaction>& vGameTx,
                       const StepResult& stepResult, unsigned nHeight,
                       CValidationState& state, CCoinsViewCache& view,
                       CBlockUndo& undo)
{
  for (unsigned i = 0; i < vGameTx.size (); ++i)
    {
      undo.vtxundo.push_back (CTxUndo ());
      UpdateCoins (vGameTx[i], state, view, undo.vtxundo.back (), nHeight);
    }

  /* Update name db for killed players.  */
  const PlayerSet& victims = stepResult.GetKilledPlayers ();
  if (!victims.empty ())
    {
      assert (!vGameTx.empty ());
      const CTransaction& txKills = vGameTx.front ();
      assert (txKills.vout.empty ());
      assert (txKills.vin.size () == victims.size ());

      BOOST_FOREACH(const PlayerID& name, victims)
        {
          const valtype& vchName = ValtypeFromString (name);
          LogPrint ("names", "Killing player at height %d: %s\n",
                    nHeight, name.c_str ());

          CNameTxUndo opUndo;
          opUndo.fromOldState (vchName, view);
          undo.vnameundo.push_back (opUndo);

          CNameData data;
          data.setDead (nHeight, txKills.GetHash ());
          view.SetName (vchName, data, false);
        }
    }