Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

filter.watch is firing before transaction is on the blockchain #1997

Closed
ethers opened this issue May 21, 2015 · 7 comments
Closed

filter.watch is firing before transaction is on the blockchain #1997

ethers opened this issue May 21, 2015 · 7 comments

Comments

@ethers
Copy link
Member

ethers commented May 21, 2015

develop ce205f3

have code that sets up 1) filter.watch then 2) sendTransaction [sample code below if it helps]

cpp eth cli will fire the filter.watch almost instantly, even though the transaction may never end up on the blockchain. The event should only be fired when the transaction is in a block, as Geth does.
with cpp, the result callback of filter.watch is returning with a blockNumber of 0. Here is an example of the result object from a filter.watch from Geth, non-zero blockNumber:

address: "0xc72369303ce552f5500bb7f398f2a1916c450e7e"args: ObjectblockHash: "0x637828d196cf43fbc33fa407132bc2556fb9c5e71842c50d29493f71491e07f5"blockNumber: 398856event: "rvalReserveTicket"logIndex: 0transactionHash: "0x7c934234617bc3e3d5713c01052eb26be739e3edd8444f19dcc01f411c7fffb3"transactionIndex: 0

Sample code. (The same code was run against both Geth and cpp)

var rvalFilter = contract.rvalReserveTicket({ ticketId: ticketId });
rvalFilter.watch(function(err, res) {
  // res.blockNumber is 0 for cpp eth  <----------------- problem
});

contract.reserveTicket.sendTransaction(ticketId, txHash, objParam, function(err, txHash) {
  console.log('txHash: ', txHash)
});
@gavofyork
Copy link
Contributor

actually, here Go is incorrect - if you're watching for pending transactions, you should get the log filter before it gets mined.

@ethers
Copy link
Member Author

ethers commented Jun 6, 2015

I am using an event, rvalReserveTicket, and don't specify anything in the watch. It isn't clear what is the default in the documentation?
https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-events
https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethfilter

If the default is 'latest', then there's a cpp issue? Does 'pending' make sense for an event? Thanks

(EDIT: In my code I did rename rvalReserveTicket to ticketEvent to be clearer.)

@frozeman
Copy link

frozeman commented Jun 8, 2015

In go the defaults are currently fromBlock: 'latest' and toBlock: 'latest', meaning you would only get the last mined logs.

Pending logs are currently not yet working see ethereum/go-ethereum#852

@frozeman
Copy link

frozeman commented Jun 8, 2015

Pending transactions filter, don't have the filter options, so they are always pending :)

@debris
Copy link
Contributor

debris commented Jun 10, 2015

fixed in #2108. Logs has additional field type. Field can have values "pending" for pending logs, and "block" for mined.

@debris debris closed this as completed Jun 10, 2015
@debris debris reopened this Jun 10, 2015
@frozeman
Copy link

Why not type: 'pending' and type: 'mined'?

type: 'block' sounds odd.

@debris
Copy link
Contributor

debris commented Jun 10, 2015

Why not type: 'pending' and type: 'mined'?
type: 'block' sounds odd.

sure. it will be mined

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants