Post
Topic
Board Service Discussion
Re: BTC Stolen from Poloniex
by
discobean
on 04/03/2014, 12:29:23 UTC
my few c

1. select for update to lock selects, then update the btc value, in a transaction.

There are many others like hashing and triggers to validate data, and to ensure sql injection if happens can be discovered easily.

Update set new value=old value - difference is more efficient and locks the row with resorting to the lock you mention.  Add a check constraint on table.

Without a select lock validation can't occur properly in the business logic checking they have enough available.  Agree you mentioned the constraint, but select lock is a good practice in many instances in validation (btc transfers between accounts wouldn't work with your method), not just this one.

Depending on which DB you are using, the efficiency is the same, as the row is locked for an update anyway.  And only 1 user will generally be accessing their BTC values at any one time.