mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -30,27 +30,6 @@ static int initFields()
|
||||
{
|
||||
sfTxnSignature.notSigningField(); sfTxnSignatures.notSigningField();
|
||||
sfSignature.notSigningField();
|
||||
|
||||
sfHighQualityIn.setMeta(SFM_CHANGE); sfHighQualityOut.setMeta(SFM_CHANGE);
|
||||
sfLowQualityIn.setMeta(SFM_CHANGE); sfLowQualityOut.setMeta(SFM_CHANGE);
|
||||
|
||||
sfLowLimit.setMeta(SFM_ALWAYS); sfHighLimit.setMeta(SFM_ALWAYS);
|
||||
sfTakerPays.setMeta(SFM_ALWAYS); sfTakerGets.setMeta(SFM_ALWAYS);
|
||||
sfQualityIn.setMeta(SFM_ALWAYS); sfQualityOut.setMeta(SFM_ALWAYS);
|
||||
|
||||
sfBalance.setMeta(SFM_ALWAYS);
|
||||
|
||||
sfPublicKey.setMeta(SFM_CHANGE); sfMessageKey.setMeta(SFM_CHANGE);
|
||||
sfSigningPubKey.setMeta(SFM_CHANGE); sfAuthorizedKey.setMeta(SFM_CHANGE);
|
||||
sfSigningAccounts.setMeta(SFM_CHANGE);
|
||||
|
||||
sfWalletLocator.setMeta(SFM_ALWAYS);
|
||||
sfWalletSize.setMeta(SFM_ALWAYS);
|
||||
sfNickname.setMeta(SFM_CHANGE);
|
||||
sfAmount.setMeta(SFM_ALWAYS);
|
||||
sfDomain.setMeta(SFM_CHANGE);
|
||||
sfOwner.setMeta(SFM_ALWAYS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static const int f = initFields();
|
||||
@@ -60,6 +39,7 @@ SField::SField(SerializedTypeID tid, int fv) : fieldCode(FIELD_CODE(tid, fv)), f
|
||||
{ // call with the map mutex
|
||||
fieldName = lexical_cast_i(tid) + "/" + lexical_cast_i(fv);
|
||||
codeToField[fieldCode] = this;
|
||||
assert((fv != 1) || ((tid != STI_ARRAY) && (tid!=STI_OBJECT)));
|
||||
}
|
||||
|
||||
SField::ref SField::getField(int code)
|
||||
|
||||
@@ -33,14 +33,6 @@ enum SOE_Flags
|
||||
SOE_OPTIONAL = 1, // optional
|
||||
};
|
||||
|
||||
enum SF_Meta
|
||||
{
|
||||
SFM_NEVER = 0,
|
||||
SFM_CHANGE = 1,
|
||||
SFM_DELETE = 2,
|
||||
SFM_ALWAYS = 3
|
||||
};
|
||||
|
||||
class SField
|
||||
{
|
||||
public:
|
||||
@@ -59,19 +51,17 @@ public:
|
||||
const SerializedTypeID fieldType; // STI_*
|
||||
const int fieldValue; // Code number for protocol
|
||||
std::string fieldName;
|
||||
SF_Meta fieldMeta;
|
||||
bool signingField;
|
||||
|
||||
SField(int fc, SerializedTypeID tid, int fv, const char* fn) :
|
||||
fieldCode(fc), fieldType(tid), fieldValue(fv), fieldName(fn), fieldMeta(SFM_NEVER), signingField(true)
|
||||
fieldCode(fc), fieldType(tid), fieldValue(fv), fieldName(fn), signingField(true)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mapMutex);
|
||||
codeToField[fieldCode] = this;
|
||||
}
|
||||
|
||||
SField(SerializedTypeID tid, int fv, const char *fn) :
|
||||
fieldCode(FIELD_CODE(tid, fv)), fieldType(tid), fieldValue(fv), fieldName(fn),
|
||||
fieldMeta(SFM_NEVER), signingField(true)
|
||||
fieldCode(FIELD_CODE(tid, fv)), fieldType(tid), fieldValue(fv), fieldName(fn), signingField(true)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mapMutex);
|
||||
codeToField[fieldCode] = this;
|
||||
@@ -95,10 +85,6 @@ public:
|
||||
bool isBinary() const { return fieldValue < 256; }
|
||||
bool isDiscardable() const { return fieldValue > 256; }
|
||||
|
||||
SF_Meta getMeta() const { return fieldMeta; }
|
||||
bool shouldMetaDel() const { return (fieldMeta == SFM_DELETE) || (fieldMeta == SFM_ALWAYS); }
|
||||
bool shouldMetaMod() const { return (fieldMeta == SFM_CHANGE) || (fieldMeta == SFM_ALWAYS); }
|
||||
void setMeta(SF_Meta m) { fieldMeta = m; }
|
||||
bool isSigningField() const { return signingField; }
|
||||
void notSigningField() { signingField = false; }
|
||||
|
||||
|
||||
@@ -394,12 +394,10 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
continue;
|
||||
|
||||
SLE::pointer origNode = mLedger->getSLE(it.first);
|
||||
|
||||
if (origNode && (origNode->getType() == ltDIR_NODE)) // No metadata for dir nodes
|
||||
continue;
|
||||
|
||||
SLE::pointer curNode = it.second.mEntry;
|
||||
mSet.setAffectedNode(it.first, *type);
|
||||
uint16 nodeType = curNode ? curNode->getFieldU16(sfLedgerEntry) : origNode->getFieldU16(sfLedgerEntry);
|
||||
|
||||
mSet.setAffectedNode(it.first, *type, nodeType);
|
||||
|
||||
if (type == &sfDeletedNode)
|
||||
{
|
||||
@@ -408,8 +406,8 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
|
||||
STObject finals(sfFinalFields);
|
||||
BOOST_FOREACH(const SerializedType& obj, *curNode)
|
||||
{ // search the deleted node for values saved on delete
|
||||
if (obj.getFName().shouldMetaDel() && !obj.isDefault())
|
||||
{ // save non-default values
|
||||
if (!obj.isDefault() && (obj.getFName() != sfLedgerEntryType))
|
||||
finals.addObject(obj);
|
||||
}
|
||||
if (!finals.empty())
|
||||
@@ -421,7 +419,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
STObject mods(sfPreviousFields);
|
||||
BOOST_FOREACH(const SerializedType& obj, *origNode)
|
||||
{ // search the original node for values saved on modify
|
||||
if (obj.getFName().shouldMetaMod() && !obj.isDefault() && !curNode->hasMatchingEntry(obj))
|
||||
if (!obj.isDefault() && (obj.getFName() != sfLedgerEntryType) && !curNode->hasMatchingEntry(obj))
|
||||
mods.addObject(obj);
|
||||
}
|
||||
if (!mods.empty())
|
||||
@@ -432,6 +430,15 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
{
|
||||
assert(!origNode);
|
||||
threadOwners(curNode, mLedger, newMod);
|
||||
|
||||
STObject news(sfNewFields);
|
||||
BOOST_FOREACH(const SerializedType& obj, *curNode)
|
||||
{ // save non-default values
|
||||
if (!obj.isDefault() && (obj.getFName() != sfLedgerEntryType))
|
||||
news.addObject(obj);
|
||||
}
|
||||
if (!news.empty())
|
||||
mSet.getAffectedNode(it.first, *type).addObject(news);
|
||||
}
|
||||
|
||||
if ((type == &sfCreatedNode) || (type == &sfModifiedNode))
|
||||
|
||||
@@ -792,7 +792,7 @@ void RippleAddress::setSeedRandom()
|
||||
// XXX Maybe we should call MakeNewKey
|
||||
uint128 key;
|
||||
|
||||
RAND_bytes((unsigned char *) &key, sizeof(key));
|
||||
RAND_bytes(key.begin(), key.size());
|
||||
|
||||
RippleAddress::setSeed(key);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,8 @@
|
||||
FIELD(ModifiedNode, OBJECT, 5)
|
||||
FIELD(PreviousFields, OBJECT, 6)
|
||||
FIELD(FinalFields, OBJECT, 7)
|
||||
FIELD(TemplateEntry, OBJECT, 8)
|
||||
FIELD(NewFields, OBJECT, 8)
|
||||
FIELD(TemplateEntry, OBJECT, 9)
|
||||
|
||||
// array of objects
|
||||
// ARRAY/1 is reserved for end of array
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Log.h"
|
||||
extern LogPartition TaggedCachePartition;
|
||||
|
||||
// This class implemented a cache and a map. The cache keeps objects alive
|
||||
// This class implements a cache and a map. The cache keeps objects alive
|
||||
// in the map. The map allows multiple code paths that reference objects
|
||||
// with the same tag to get the same actual object.
|
||||
|
||||
@@ -29,9 +29,10 @@ public:
|
||||
typedef c_Key key_type;
|
||||
typedef c_Data data_type;
|
||||
|
||||
typedef boost::weak_ptr<data_type> weak_data_ptr;
|
||||
typedef boost::shared_ptr<data_type> data_ptr;
|
||||
typedef std::pair<time_t, data_ptr> cache_entry;
|
||||
typedef boost::weak_ptr<data_type> weak_data_ptr;
|
||||
typedef boost::shared_ptr<data_type> data_ptr;
|
||||
typedef std::pair<time_t, weak_data_ptr> cache_entry;
|
||||
typedef std::pair<key_type, cache_entry> cache_pair;
|
||||
|
||||
protected:
|
||||
mutable boost::recursive_mutex mLock;
|
||||
@@ -156,7 +157,7 @@ template<typename c_Key, typename c_Data> bool TaggedCache<c_Key, c_Data>::touch
|
||||
}
|
||||
|
||||
// In map but not cache, put in cache
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), weak_data_ptr(cit->second.second))));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), weak_data_ptr(cit->second.second))));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@ bool TaggedCache<c_Key, c_Data>::canonicalize(const key_type& key, boost::shared
|
||||
typename boost::unordered_map<key_type, weak_data_ptr>::iterator mit = mMap.find(key);
|
||||
if (mit == mMap.end())
|
||||
{ // not in map
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), data)));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), data)));
|
||||
mMap.insert(std::make_pair(key, data));
|
||||
return false;
|
||||
}
|
||||
@@ -189,7 +190,7 @@ bool TaggedCache<c_Key, c_Data>::canonicalize(const key_type& key, boost::shared
|
||||
if (!cachedData)
|
||||
{ // in map, but expired. Update in map, insert in cache
|
||||
mit->second = data;
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), data)));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), data)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,7 +209,7 @@ bool TaggedCache<c_Key, c_Data>::canonicalize(const key_type& key, boost::shared
|
||||
cit->second.second = data;
|
||||
}
|
||||
else // no, add to cache
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), data)));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), data)));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -235,7 +236,7 @@ boost::shared_ptr<c_Data> TaggedCache<c_Key, c_Data>::fetch(const key_type& key)
|
||||
if (cit != mCache.end())
|
||||
cit->second.first = time(NULL); // Yes, refresh
|
||||
else // No, add to cache
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), cachedData)));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), cachedData)));
|
||||
|
||||
return cachedData;
|
||||
}
|
||||
|
||||
@@ -31,13 +31,14 @@ bool TransactionMetaSet::isNodeAffected(const uint256& node) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type)
|
||||
void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type, uint16 nodeType)
|
||||
{ // make sure the node exists and force its type
|
||||
BOOST_FOREACH(STObject& it, mNodes)
|
||||
{
|
||||
if (it.getFieldH256(sfLedgerIndex) == node)
|
||||
{
|
||||
it.setFName(type);
|
||||
it.setFieldU16(sfLedgerEntryType, nodeType);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -47,6 +48,7 @@ void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type)
|
||||
|
||||
assert(obj.getFName() == type);
|
||||
obj.setFieldH256(sfLedgerIndex, node);
|
||||
obj.setFieldU16(sfLedgerEntryType, nodeType);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
uint32 getLgrSeq() { return mLedger; }
|
||||
|
||||
bool isNodeAffected(const uint256&) const;
|
||||
void setAffectedNode(const uint256&, SField::ref type);
|
||||
void setAffectedNode(const uint256&, SField::ref type, uint16 nodeType);
|
||||
STObject& getAffectedNode(const uint256&, SField::ref type);
|
||||
STObject& getAffectedNode(const uint256&);
|
||||
const STObject& peekAffectedNode(const uint256&) const;
|
||||
|
||||
Reference in New Issue
Block a user