WIP: Market
-
The market still has a long way to go in terms of features. I am working on the Koolio escrow integration which is simple enough. New users get an address with the escrow service and buyers are told to send money to that address as the end of an auction. The escrow service gets an email informing them of the relevant details.
I have now updated the recaptcha code which was far out of date, the WeBid system used for the market is not really maintained anymore.
Can anyone help me with my shoddy SQL?
[code]$query = "SELECT address FROM " . $DBPrefix . “koolio ORDER BY newid ASC LIMIT 1”;
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
$koolio_addy = $row[‘address’];
mysql_query("DELETE FROM " . $DBPrefix . “koolio WHERE address='” . $koolio_addy . “'”);[/code]This grabs a Koolio address which I use later with $koolio_addy. There is a problem here with concurrency as more than one person could be issued an address before DELETE is run. This works for testing but needs to be tidied up for the live system.
-
Here is what the payment page currently looks like for Koolio escrow.
[img]http://forum.feathercoin.com/index.php?action=dlattach;topic=2065.0;attach=284;image[/img]
[attachment deleted by admin]
-
Maybe I could help you with this. Just to be sure I understand the problem:
there is a table (koolio) that contain all the address for the escrow. So when an auction finish, you want to send the address to the buyer so he can send the FTC. The problem is a buyer can have win multiple items. Then, he should receive multiple e-mail with all a different address. Moreover many auction can finish at almost the same time and you want hem to get a different escrow address . Is it a good sum up of your problem ?
There are several solution and I think the easier one is to have table that link the adress to the item and the buyer. So once the payment is done you can delete it. I’ll be glad to help you with the sql but I need to see the database design and under the hood. -
not sure what you actually want tot do as this delete the first entry in koolio table.
I think there is a link between the transaction and the escrow address in some way here I put a column transaction that should be map to the transaction ID txid. but llocans is true we need to know the context and the table to come to a correct solution
[code]$query = "SELECT address FROM " . $DBPrefix . “koolio where transaction= " $txid " ORDER BY newid ASC LIMIT 1”;
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
$koolio_addy = $row[‘address’];
mysql_query("DELETE FROM " . $DBPrefix . “koolio WHERE address='” . $koolio_addy . “'”);[/code] -
I want an SQL query that gets an address from the koolio table and deletes it before someone else gets the same address. So I need to return an address and delete it from the Koolio table in the same query.
[code]$query = "SELECT address FROM " . $DBPrefix . “koolio where transaction= " $txid " ORDER BY newid ASC LIMIT 1”;
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
$koolio_addy = $row[‘address’];
mysql_query("DELETE FROM " . $DBPrefix . “koolio WHERE address='” . $koolio_addy . “'”);Add $koolio_addy to a new user account[/code]
-
Could you use a stored procedure or a function in mysql.
I do not have mysql so it would be something like
[code]
CREATE PROCEDURE simpleproc (param INT) returns int
BEGIN
SELECT @add=address FROM koolio where transaction= param ORDER BY newid ASC LIMIT 1
Delete from koolio where address = @add
return @add
END
[/code]Another solution would be to lock the table by adding a column status per example that you initialise to 0:
[code]
$query = "UPDATE " . $DBPrefix . "koolio set status = 1 where transaction= " $txid "
mysql_query($query);
$query = "SELECT address FROM " . $DBPrefix . “koolio where transaction= " $txid and status = 1 " ORDER BY newid ASC LIMIT 1”;
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
$koolio_addy = $row[‘address’];
mysql_query("DELETE FROM " . $DBPrefix . “koolio WHERE address='” . $koolio_addy . “’ and status = 1”);
[/code] -
Thanks. I’m not that familiar with MySQL so stored procedures is news to me :)
I really should spend some time on MySQL as I’m sure I could make it do a lot of the work I do in where I am accessing the data from.
-
Not sure if this info will help you…
http://dev.mysql.com/doc/innodb-plugin/1.0/en/innodb-create-index-concurrency.html
-
If you need help to review/optimize code or do implementation, I think I could help you.
-
.
-
[quote name=“wesphily” post=“17454” timestamp=“1372119845”]
sql injection is not too terribly difficult. If we plan to put currency in the mix then we should definitely spend extra time on eliminating the possibility.
[/quote]Before we put a wallet on this site I will get a professional company to look over the code. For now there is a lot to do on the user experience front especially for sellers.
I had no idea how much work this system needed to get it working as you would expect. The site looks like it handles multi buys from a single auction but it barely does and it generates an erroneous auction when the items are all sold. These issues are now resolved in the new release. I thought I was fixing a Buy Now bug but I ended up recoding the Buy Now system.
-
I’m waiting on Koolio to get his site ready. I have not been wasting this time. For the Koolio escrow address we validate the seller’s Feathercoin address so that only valid address will work. I have finished the multi buy system today which gives us all the functionality we presumed was already in the system. The problem with the Buy Now auction system is that on the surface it appeared to be working.
[b]If anyone has to time to work through the site and find bugs please let me know.[/b]
You can access the development site by the link below with the details given below. Registrations from the live system work here. New registrations do not require validation and has recaptcha which we currently do not have!
https://www.feathercoin.com/auction_dev/
Username: admin
Password: Plokij12! -
Anyone that’s used the escrow, please report your experience.
-
.