Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of bids #453

Closed
randomlogin opened this issue May 15, 2020 · 5 comments
Closed

Order of bids #453

randomlogin opened this issue May 15, 2020 · 5 comments

Comments

@randomlogin
Copy link

randomlogin commented May 15, 2020

Reproduce: call /auction/name or /bid/name for the name with several bids. Observe the order of bids in the output.

The problem is that bids are sorted not by the block height in which they occurred, but by their hash (or hash of their block), which is quite useless.

The same may stand for some other transaction lists (reveals?).

And explicitly including the block height of transaction in the output would be also nice.

@pinheadmz
Copy link
Member

Related: bcoin-org/bcoin#605

We need wallet pagination anyway. It is a major overhaul and never merged into bcoin.

@pinheadmz
Copy link
Member

A simple way to do this is to add height to the serialized BlindBid object here:

https://github.com/handshake-org/hsd/blob/master/lib/wallet/txdb.js#L3776-L3824

and then insert it connectNames() here:

https://github.com/handshake-org/hsd/blob/master/lib/wallet/txdb.js#L1883-L1903

height is a local variable in that function so it should be possible.

This would require a wallet database migration for all users if the upgrade is pushed, and then the getBids function would also need to sort by the height.

I don't personally see the use case for this. Can you elaborate? Bids are bids. They are locked in, their order does not matter.

@tynes
Copy link
Contributor

tynes commented May 15, 2020

The BlindBid object has an outpoint which can be used to fetch the Coin object, which represents a UTXO along with some additional metadata (including the height). For each bid, you can query for the coin and then use it's height to sort. Both the chain and wallet should be indexing the Coin objects. The chain indexes all of them and the wallet indexes the ones that you own.

https://github.com/handshake-org/hsd/blob/master/lib/blockchain/chain.js#L2535
https://github.com/handshake-org/hsd/blob/master/lib/wallet/txdb.js#L2931

https://hsd-dev.org/api-docs/#get-coin-by-outpoint
https://hsd-dev.org/api-docs/#get-wallet-coin

Changing the wallet indexes in a way that requires a migration is risky and we should try to make sure that its only done if absolutely necessary.

@randomlogin
Copy link
Author

randomlogin commented May 28, 2020

I don't personally see the use case for this. Can you elaborate? Bids are bids. They are locked in, their order does not matter.

For example to see what happens after I make a bid, i.e. the behaviour of other bidders. So I need to see the order of past and upcoming bids.

@tynes
Copy link
Contributor

tynes commented May 28, 2020

So I need to see the order of past and upcoming bids.

The Coin object includes a height field, see #453 (comment)

@tynes tynes closed this as completed Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants