Changeset View
Changeset View
Standalone View
Standalone View
src/coins.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | public: | ||||
void Clear() { | void Clear() { | ||||
out.SetNull(); | out.SetNull(); | ||||
nHeightAndIsCoinBase = 0; | nHeightAndIsCoinBase = 0; | ||||
} | } | ||||
template <typename Stream> void Serialize(Stream &s) const { | template <typename Stream> void Serialize(Stream &s) const { | ||||
assert(!IsSpent()); | assert(!IsSpent()); | ||||
::Serialize(s, VARINT(nHeightAndIsCoinBase)); | ::Serialize(s, VARINT(nHeightAndIsCoinBase)); | ||||
// only compress for disk format | |||||
if (s.GetType() & SER_DISK) { | |||||
matiu: Could you explain the consequences of this? Before this PR, are there any cases in which `s. | |||||
tomtomtom7Unsubmitted Not Done Inline ActionsCurrently Coins are only serialized to LevelDB using SER_DISK. There is no network level serialization of Coins. Therefore I can safely use the same method with SER_NETWORK to create a new, slightly different serialization for the commitment. It is slightly different because we don't want compression here, it is already compressed to a single multiset variable. tomtomtom7: Currently Coins are only serialized to LevelDB using SER_DISK. There is no network level… | |||||
::Serialize(s, CTxOutCompressor(REF(out))); | ::Serialize(s, CTxOutCompressor(REF(out))); | ||||
} else { | |||||
::Serialize(s, REF(out)); | |||||
} | |||||
} | } | ||||
template <typename Stream> void Unserialize(Stream &s) { | template <typename Stream> void Unserialize(Stream &s) { | ||||
::Unserialize(s, VARINT(nHeightAndIsCoinBase)); | ::Unserialize(s, VARINT(nHeightAndIsCoinBase)); | ||||
if (s.GetType() & SER_DISK) { | |||||
::Unserialize(s, REF(CTxOutCompressor(out))); | ::Unserialize(s, REF(CTxOutCompressor(out))); | ||||
} else { | |||||
::Unserialize(s, REF(out)); | |||||
} | |||||
} | } | ||||
size_t DynamicMemoryUsage() const { | size_t DynamicMemoryUsage() const { | ||||
return memusage::DynamicUsage(out.scriptPubKey); | return memusage::DynamicUsage(out.scriptPubKey); | ||||
} | } | ||||
}; | }; | ||||
class SaltedOutpointHasher { | class SaltedOutpointHasher { | ||||
▲ Show 20 Lines • Show All 237 Lines • Show Last 20 Lines |
Could you explain the consequences of this? Before this PR, are there any cases in which s.GetType()&SER_DISK is false?