write blocks to database every once in a while instead of every time a block is written