-
Notifications
You must be signed in to change notification settings - Fork 387
Give clients on the wallet a way to get pending transactions #65
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,7 +138,7 @@ contract multiowned { | |
| uint ownerIndexBit = 2**ownerIndex; | ||
| return !(pending.ownersDone & ownerIndexBit == 0); | ||
| } | ||
|
|
||
| // INTERNAL METHODS | ||
|
|
||
| function confirmAndCheck(bytes32 _operation) internal returns (bool) { | ||
|
|
@@ -363,16 +363,55 @@ contract Wallet is multisig, multiowned, daylimit { | |
| return true; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // Gets the number of pending transactions | ||
| function numPendingTransactions() constant returns (uint _pendingTransactionsCount) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel the extra line was for visibility. Check line 50 above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| _pendingTransactionsCount = 0; | ||
| // Use m_pendingIndex.length to get all hashes, then count how many of the | ||
| // operations are transactions, because we don't want to store hashes twice | ||
| // and this is a local call anyway | ||
| for (uint i = 0; i < m_pendingIndex.length; i++) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If I haven't looked through all the dapp, but can it be guaranteed that this won't end in always-OOG? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a uint |
||
| if (isPendingTransaction(i)) { | ||
| _pendingTransactionsCount++; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Gets the pending operation at a specified index | ||
| // Will return a tuple [bytes32 operationHash, uint confirmationsNeeded, address toAddress, uint transactionValue, bytes data] | ||
| function getPendingTransaction(uint _index) constant returns (bytes32 _operationHash, uint _confirmationsNeeded, address _toAddress, uint _transactionValue, bytes _data) { | ||
| uint pendingTransactionsCount = 0; | ||
| // Seek through all of m_pendingIndex (used in the multiowned contract) | ||
| // But only count transactions | ||
| for (uint i = 0; i < m_pendingIndex.length; i++) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as in |
||
| if (isPendingTransaction(i)) { | ||
| if (_index == pendingTransactionsCount) { | ||
| // Found the pending transaction, return it. | ||
| var operationHash = m_pendingIndex[i]; | ||
| return (operationHash, m_pending[operationHash].yetNeeded, address(m_txs[operationHash].to), m_txs[operationHash].value, m_txs[operationHash].data); | ||
| } | ||
| pendingTransactionsCount++; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as in |
||
| } | ||
| } | ||
| } | ||
|
|
||
| // INTERNAL METHODS | ||
|
|
||
| function clearPending() internal { | ||
| uint length = m_pendingIndex.length; | ||
| for (uint i = 0; i < length; ++i) | ||
| delete m_txs[m_pendingIndex[i]]; | ||
| super.clearPending(); | ||
| } | ||
|
|
||
| // Determine if a pending operation index is a pending transaction | ||
| function isPendingTransaction(uint _index) constant internal returns (bool) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Future refactoring: Group operations on "pending transaction" into a library. |
||
| if (m_txs[m_pendingIndex[_index]].to != 0 || m_txs[m_pendingIndex[_index]].data.length != 0) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| // FIELDS | ||
|
|
||
| // pending transactions we have at present. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the extra line was for visibility. Check line 50 above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, i'll leave it in