{"action":"created","issue":{"url":"https://api.github.com/repos/zathras-crypto/mastercore/issues/26","labels_url":"https://api.github.com/repos/zathras-crypto/mastercore/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/zathras-crypto/mastercore/issues/26/comments","events_url":"https://api.github.com/repos/zathras-crypto/mastercore/issues/26/events","html_url":"https://github.com/zathras-crypto/mastercore/issues/26","id":57760785,"number":26,"title":"UI: incoming transactions out of order","user":{"login":"dexX7","id":5836089,"avatar_url":"https://avatars.githubusercontent.com/u/5836089?v=3","gravatar_id":"","url":"https://api.github.com/users/dexX7","html_url":"https://github.com/dexX7","followers_url":"https://api.github.com/users/dexX7/followers","following_url":"https://api.github.com/users/dexX7/following{/other_user}","gists_url":"https://api.github.com/users/dexX7/gists{/gist_id}","starred_url":"https://api.github.com/users/dexX7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dexX7/subscriptions","organizations_url":"https://api.github.com/users/dexX7/orgs","repos_url":"https://api.github.com/users/dexX7/repos","events_url":"https://api.github.com/users/dexX7/events{/privacy}","received_events_url":"https://api.github.com/users/dexX7/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/zathras-crypto/mastercore/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/zathras-crypto/mastercore/labels/critical","name":"critical","color":"d11d11"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-02-16T03:10:10Z","updated_at":"2015-02-25T07:55:04Z","closed_at":null,"body":"Restarted the client inbetween a few times and the transaction history is out of order, see \"Date\":\r\n\r\n![cjxdqor](https://cloud.githubusercontent.com/assets/5836089/6206737/5633b19c-b591-11e4-9bc4-fa2f42b1c6bf.png)\r\n\r\nThis is actually intersting, because I tested\r\n```c++\r\nui->txHistoryTable->setSortingEnabled(true);\r\n```\r\n... earlier, which worked for all fields, except the date field, so it looks like there is something slightly off. But might as well be unrelated, didn't look further into it at that point."},"comment":{"url":"https://api.github.com/repos/zathras-crypto/mastercore/issues/comments/75919519","html_url":"https://github.com/zathras-crypto/mastercore/issues/26#issuecomment-75919519","issue_url":"https://api.github.com/repos/zathras-crypto/mastercore/issues/26","id":75919519,"user":{"login":"zathras-crypto","id":5633351,"avatar_url":"https://avatars.githubusercontent.com/u/5633351?v=3","gravatar_id":"","url":"https://api.github.com/users/zathras-crypto","html_url":"https://github.com/zathras-crypto","followers_url":"https://api.github.com/users/zathras-crypto/followers","following_url":"https://api.github.com/users/zathras-crypto/following{/other_user}","gists_url":"https://api.github.com/users/zathras-crypto/gists{/gist_id}","starred_url":"https://api.github.com/users/zathras-crypto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zathras-crypto/subscriptions","organizations_url":"https://api.github.com/users/zathras-crypto/orgs","repos_url":"https://api.github.com/users/zathras-crypto/repos","events_url":"https://api.github.com/users/zathras-crypto/events{/privacy}","received_events_url":"https://api.github.com/users/zathras-crypto/received_events","type":"User","site_admin":false},"created_at":"2015-02-25T07:55:04Z","updated_at":"2015-02-25T07:55:04Z","body":"@dexX7 alrighty, this still isn't perfectly finished I have some work to do on the byte offset stuff and providing a sort key for that first visible column (the status icon), but other than that this should be working now.  Sort order is currently defaulted to date while I work the status/confirmations icon sortkey stuff - it's worth noting a lot of blocks on testnet ```come in a DeLorean``` which means you can have for example a transaction with 2 confirmations that has a timestamp earlier than a transaction with say 3 or 4 confirmations.\r\n\r\n\r\nIt's a pretty substantial rewrite of the history methodology; I've created an in memory map that will hold a bunch of transaction objects for each transaction in history (including outbound pending transactions) and this serves in effect as a cache for the history table.  In a nutshell:\r\n\r\nPopulateHistoryMap() goes through all pending and wallet transactions with a first step of checking if they are already in the history map - if they are not found we parse and add the transaction to the map, otherwise we know we already have it so just move on to the next transaction (this should solve repeatedly reparsing transactions).  PopulateHistoryMap() can thus be called frequently and only result in parsing if the transaction is not already in the map.\r\n\r\nUpdateHistory() (this is what the signals connect to) first calls PopulateHistoryMap() to make sure the map is up to date, and then iterates through the map checking if each transaction is in the history table.  If it is, again we don't need to do anything and just move on (otherwise we add it with a new row).  This should solve the repeated re-population of the history table since we only add rows when we spot new transactions via PopulateHistoryMap() and those rows are simply appended and left to the sortorder to organize.\r\n\r\nLastly UpdateHistory() will loop through all rows in the history table, checking just the time of the block they're in vs current chain height so it can update the confirmations icon.\r\n\r\nTL:DR; this should result in a far more efficient methodology for transaction history and require far less compute since we should only ever parse once for each transaction, and the cache and fixes to sorting allow us to maintain the same history table without repopulating it top to bottom over and over.\r\n\r\nExtremely limited testing, I'll continue to work trying to add a sort key using [block height] [byte offset] for that 1st visible column with the status icons, but excluding that it should be in workable for you to test if you have the time :)\r\n\r\nThanks\r\nZ\r\n\r\nhttps://github.com/zathras-crypto/mastercore/commit/03151b62aed4f43e6aa04ca68e345d32e6c96a06"}}