This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
Asynchronous transactions (polling based for now). #1652
Merged
Merged
Conversation
This file contains 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
- Alter eth_sendTransaction to be async, returning one of: - Transaction hash (signed and submitted). - Transaction promise ID (< 32 bytes). - Zero hash (will never be signed). - Introduce new JSONRPC eth_checkTransaction. The new API call takes a single argument - a promise ID. It returns either: - Transaction hash (signed and submitted). - null (still pending, call again later), - Zero hash (will never be signed).
- Restore previous semantics of sendTransaction. - Introduce eth_postTransaction. - Some refactoring.
Additional web3.js code required to make this work: web3._extend({
property: 'eth',
methods: [
new web3._extend.Method({
name: 'postTransaction',
call: 'eth_postTransaction',
params: 1,
inputFormatter: [web3._extend.formatters.inputCallFormatter]
})
]
});
web3._extend({
property: 'eth',
methods: [
new web3._extend.Method({
name: 'checkTransaction',
call: 'eth_checkTransaction',
params: 1
})
]
});
{
var postTransaction = web3.eth.postTransaction.bind(web3.eth);
var sendTransaction = web3.eth.sendTransaction.bind(web3.eth);
web3.eth.sendTransaction = function(options, f) {
// No callback - use compatibility sync API.
if (typeof f != "function")
return sendTransaction(options);
// Callback - use async API.
var id = postTransaction(options);
var timer_id = window.setInterval(check, 500);
function check() {
let r = web3.eth.checkTransaction(id);
if (typeof r == 'string') {
clearInterval(timer_id);
if (r == "0x0000000000000000000000000000000000000000000000000000000000000000")
f("Rejected", r);
else
f(null, r);
}
}
}
} |
@@ -59,6 +61,7 @@ impl<C, M> EthSigningQueueClient<C, M> where C: MiningBlockChainClient, M: Miner | |||
accounts: Arc::downgrade(accounts), | |||
client: Arc::downgrade(client), | |||
miner: Arc::downgrade(miner), | |||
pending: Mutex::new(HashMap::new()), |
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.
It can leak (when check
is not called), maybe TransientHashMap
(the same one is used for filters) could be used here?
JS code is invalid in general case - The code should be applied only if signer is enabled. Minor things:
|
tomusdrw
added
A5-grumble 🔥
Pull request has minor issues that must be addressed before merging.
and removed
A0-pleasereview 🤓
Pull request needs code review.
labels
Jul 18, 2016
signer should always be used with UI and in any case JS code is not part of this PR. |
tomusdrw
added
A8-looksgood 🦄
Pull request is reviewed well.
and removed
A5-grumble 🔥
Pull request has minor issues that must be addressed before merging.
labels
Jul 18, 2016
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
eth_postTransaction
as an async alternative toeth_sendTransaction
. Returns a Confirmation promise ID.eth_checkTransaction
, takes a single argument - a Confirmation promise ID and returnsone of:
null
(still pending, call again later),