Permalink
Browse files

Inflation changes compiling

  • Loading branch information...
jedmccaleb committed May 4, 2014
1 parent dec80f9 commit b17a8174d9f3dba46a602b3bc7f87e09fc03effe
@@ -1322,6 +1322,7 @@
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\transactors\InflationTransactor.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\transactors\OfferCancelTransactor.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
@@ -340,22 +340,6 @@ AccountState::pointer Ledger::getAccountState (const RippleAddress& accountID)
return boost::make_shared<AccountState> (sle, accountID);
}
NicknameState::pointer Ledger::getNicknameState (uint256 const& uNickname)
{
SHAMapItem::pointer item = mAccountStateMap->peekItem (Ledger::getNicknameIndex (uNickname));
if (!item)
{
return NicknameState::pointer ();
}
SerializedLedgerEntry::pointer sle =
boost::make_shared<SerializedLedgerEntry> (item->peekSerializer (), item->getTag ());
if (sle->getType () != ltNICKNAME) return NicknameState::pointer ();
return boost::make_shared<NicknameState> (sle);
}
bool Ledger::addTransaction (uint256 const& txID, const Serializer& txn)
{
@@ -1420,15 +1404,6 @@ SLE::pointer Ledger::getGenerator (const uint160& uGeneratorID)
return getASNodeI (getGeneratorIndex (uGeneratorID), ltGENERATOR_MAP);
}
//
// Nickname
//
SLE::pointer Ledger::getNickname (uint256 const& uNickname)
{
return getASNodeI (uNickname, ltNICKNAME);
}
//
// Offer
//
@@ -1713,18 +1688,6 @@ uint256 Ledger::getGeneratorIndex (const uint160& uGeneratorID)
return s.getSHA512Half ();
}
// What is important:
// --> uNickname: is a Sha256
// <-- SHA512/2: for consistency and speed in generating indexes.
uint256 Ledger::getNicknameIndex (uint256 const& uNickname)
{
Serializer s (34);
s.add16 (spaceNickname); // 2
s.add256 (uNickname); // 32
return s.getSHA512Half ();
}
uint256 Ledger::getOfferIndex (const uint160& uAccountID, uint32 uSequence)
{
@@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define INFLATION_RATE (1.01/12.0) // 1% a year
#define INFLATION_NUM_WINNERS 5
#define INFLATION_WIN_MIN_PERCENT .1
#define MIN(x,y) ((x)<(y) ? (x) : (y))
/*
What about when an account that wins a dole is now gone?
*/
@@ -48,14 +48,14 @@ namespace ripple {
uint32 seq = mTxn.getFieldU32(sfSequence);
if (seq != mEngine->getLedger().getInflationSeq())
if (seq != mEngine->getLedger()->getInflationSeq())
{
WriteLog(lsINFO, InflationTransactor) << "doInflation: Invalid Seq number.";
return telNOT_TIME;
}
uint32 closeTime=mEngine->getLedger().getParentCloseTimeNC();
uint32 closeTime=mEngine->getLedger()->getParentCloseTimeNC();
if (closeTime > seq*INFLATION_FREQUENCY)
{
WriteLog(lsINFO, InflationTransactor) << "doInflation: Too early.";
@@ -66,19 +66,19 @@ namespace ripple {
// check previous ledger if this should be applied now
// loop through all accounts and tally votes
// dole out the inflation amount to the winners
uint256 parentHash=mEngine->getLedger().getParentHash();
uint256 parentHash=mEngine->getLedger()->getParentHash();
Ledger::pointer votingLedger=getApp().getLedgerMaster().getLedgerByHash(parentHash);
if (votingLedger)
{
std::map< uint160, uint64 > voteTally;
// TODO: is there a better way to do this than walk every element in the ledger?
SHAMap votingLedgerItems = votingLedger->peekAccountStateMap();
SHAMapItem::pointer item = votingLedgerItems.peekFirstItem();
const SHAMap::pointer votingLedgerItems = votingLedger->peekAccountStateMap();
SHAMapItem::pointer item = votingLedgerItems->peekFirstItem();
while (item)
{
SLE::pointer s=boost::make_shared<SLE>(item->peekSerializer(), node->getTag());
SLE::pointer s=boost::make_shared<SLE>(item->peekSerializer(), item->getTag());
if (s->getType() == ltACCOUNT_ROOT)
{
@@ -92,17 +92,17 @@ namespace ripple {
}
item = votingLedgerItems.peekNextItem(item->getTag());
item = votingLedgerItems->peekNextItem(item->getTag());
}
// sort the votes
std::vector< std::pair<uint160, uint64> > sortedVotes;
copy(voteTally.begin(), voteTally.end(), back_inserter(sortedVotes));
sort(sortedVotes.begin(), sortedVotes.end(), voteSorter);
uint64 minBalance = mEngine->getLedger().getTotalCoins()*INFLATION_WIN_MIN_PERCENT;
uint64 minBalance = mEngine->getLedger()->getTotalCoins()*INFLATION_WIN_MIN_PERCENT;
uint64 totalVoted = 0;
int maxIndex = min(INFLATION_NUM_WINNERS, sortedVotes.size());
int maxIndex = MIN(INFLATION_NUM_WINNERS, sortedVotes.size());
for (int n = 0; n < maxIndex; n++)
{
if (sortedVotes[n].second > minBalance)
@@ -123,14 +123,14 @@ namespace ripple {
}
}
uint64 coinsToDole = mEngine->getLedger().getFeePool() + INFLATION_RATE*mEngine->getLedger().getTotalCoins();
uint64 coinsToDole = mEngine->getLedger()->getFeePool() + INFLATION_RATE*mEngine->getLedger()->getTotalCoins();
//uint64 coinsLeft = coinsToDole;
for (int n = 0; n < maxIndex; n++)
{
double share=sortedVotes[n].second/totalVoted;
uint64 coinsDoled = share*coinsToDole;
//coinsLeft -= coinsDoled;
SLE::pointer account=mEngine->getLedger().getAccountRoot(sortedVotes[n].first);
SLE::pointer account=mEngine->getLedger()->getAccountRoot(sortedVotes[n].first);
if (account)
{
mEngine->entryModify(account);

0 comments on commit b17a817

Please sign in to comment.