Simplify the way we handle validations. Include a signing time instead of a

closing time. Keep only the validation with the most recent signing time.
Sign using network time. This eliminates the ValidationPair nightmare and
makes the logic must easier to understand, increasing confidence that it
does what it's supposed to do.
This commit is contained in:
JoelKatz
2012-09-03 20:13:57 -07:00
parent 0862ed2957
commit 4930ebb945
9 changed files with 57 additions and 89 deletions

View File

@@ -6,7 +6,7 @@
SOElement SerializedValidation::sValidationFormat[] = {
{ sfFlags, "Flags", STI_UINT32, SOE_FLAGS, 0 },
{ sfLedgerHash, "LedgerHash", STI_HASH256, SOE_REQUIRED, 0 },
{ sfCloseTime, "CloseTime", STI_UINT32, SOE_REQUIRED, 0 },
{ sfSigningTime, "SignTime", STI_UINT32, SOE_REQUIRED, 0 },
{ sfSigningKey, "SigningKey", STI_VL, SOE_REQUIRED, 0 },
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 },
};
@@ -19,12 +19,12 @@ SerializedValidation::SerializedValidation(SerializerIterator& sit, bool checkSi
if (checkSignature && !isValid()) throw std::runtime_error("Invalid validation");
}
SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint32 closeTime,
SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint32 signTime,
const NewcoinAddress& naSeed, bool isFull)
: STObject(sValidationFormat), mSignature("Signature"), mTrusted(false)
{
setValueFieldH256(sfLedgerHash, ledgerHash);
setValueFieldU32(sfCloseTime, closeTime);
setValueFieldU32(sfSigningTime, signTime);
if (naSeed.isValid())
setValueFieldVL(sfSigningKey, NewcoinAddress::createNodePublic(naSeed).getNodePublic());
if (!isFull) setFlag(sFullFlag);
@@ -50,9 +50,9 @@ uint256 SerializedValidation::getLedgerHash() const
return getValueFieldH256(sfLedgerHash);
}
uint32 SerializedValidation::getCloseTime() const
uint32 SerializedValidation::getSignTime() const
{
return getValueFieldU32(sfCloseTime);
return getValueFieldU32(sfSigningTime);
}
uint32 SerializedValidation::getFlags() const