Suggested fix to issue 192 (market - execution timestamp) + docs fixes#229
Open
AkstonCap wants to merge 2 commits intoNexusoft:merging-6.0from
Open
Suggested fix to issue 192 (market - execution timestamp) + docs fixes#229AkstonCap wants to merge 2 commits intoNexusoft:merging-6.0from
AkstonCap wants to merge 2 commits intoNexusoft:merging-6.0from
Conversation
added 2 commits
January 16, 2026 18:43
correct executed order timestamps Previously, executed orders in market/list/executed and market/user/executed APIs would display the original order creation timestamp instead of the actual execution timestamp. This made it impossible to accurately determine when trades occurred, breaking functionality for last price fetching and price charting. Root Cause: ----------- The ContractDB only stored the hashCaller (genesis hash of who executed the order) when an order was fulfilled. There was no link to the execution transaction, so when displaying executed orders, the API had no way to retrieve the execution timestamp and fell back to the order's creation time. Solution: --------- 1. Database Schema (LLD/types/contract.h): - Added ContractData struct to store both hashCaller and hashExecution - Updated ContractTransaction::mapContracts to use ContractData - Extended WriteContract() to accept execution tx hash parameter - Extended ReadContract() to return execution tx hash via output param 2. Validation Layer (TAO/Operation/validate.cpp): - Modified Validate::Commit() to accept and store execution tx hash - Passes contract.Hash() (executing transaction's hash) to WriteContract 3. Execution Layer (TAO/Operation/execute.cpp): - OP::VALIDATE case now passes contract.Hash() to Validate::Commit() 4. Market API (TAO/API/commands/market/): - OrderToJSON() now accepts optional nExecutionTimestamp parameter - When provided (> 0), uses execution time instead of creation time - list.cpp and user.cpp fetch execution tx via ReadContract() - Retrieve timestamp from execution transaction for executed orders Backward Compatibility: ----------------------- Orders executed before this fix have hashExecution = 0 in the database. ReadTx(0) fails gracefully, leaving nExecutionTimestamp = 0, which causes OrderToJSON to fall back to the original creation timestamp. New orders will correctly display execution timestamps. Files Changed: - src/LLD/types/contract.h - ContractData struct, updated interfaces - src/LLD/contract.cpp - Store/retrieve ContractData with execution hash - src/TAO/Operation/include/validate.h - Updated Commit() signature - src/TAO/Operation/validate.cpp - Pass execution hash to WriteContract - src/TAO/Operation/execute.cpp - Pass contract.Hash() to Commit() - src/LLP/lookup.cpp - Updated WriteContract call - src/TAO/API/types/commands/market.h - Added timestamp param to OrderToJSON - src/TAO/API/commands/market/json.cpp - Use execution timestamp if provided - src/TAO/API/commands/market/list.cpp - Fetch execution timestamp - src/TAO/API/commands/market/user.cpp - Fetch execution timestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suggestion for fix to issue 192: #192 (market/list/executed/timestamp seem to be inherited from order creation time, not execution time).
See commits for detailed explanation where transaction hash is added. Please validate if this inclusion fits the "bigger picture", this fix was only done with this specific issue in mind.
Feel free to edit or decline.