Last active
August 29, 2015 14:07
Revisions
-
curtislinden revised this gist
Oct 9, 2014 . 1 changed file with 29 additions and 83 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,102 +1,48 @@ (still test-set transactional memory semantics) -- I went back to drawing board and asked the question - what if the resource version whas just a transparent mechanism of the resource - IE: model this as direct operations on remote resource... I get the purchase /http?get/my/inventory => { inventory:[{id:1, name:'old boot'}], txn_version: 7 } /http?post/my/inventory <= { inventory:[{id:1, name:'old boot'}, {id:36,name:'new boots'}], txn_version: 7 } => (OK|ERROR) --- OK would bump txn_version such that any successive get would return txn_version:8 I loose 1000 cents for my purchase /http?get/my/wallet => { wallet:{id:1, amount_in_cents: 9000}, txn_version:18} /http?post/my/wallet <= { wallet:{id:1, amount_in_cents: 8000}, txn_version:18} linden gets 5 cents /http?get/linden/wallet => { wallet:{id:1, amount_in_cents: 1000000}, txn_version:1812} /http?post/my/wallet <= { wallet:{id:1, amount_in_cents: 1000005}, txn_version:1812} sue gets 995 Cents /http?get/sue/wallet => { wallet:{id:1, amount_in_cents: 1000}, txn_version:1914} /http?post/my/wallet <= { wallet:{id:1, amount_in_cents: 1995}, txn_version:1914} ROLLBACK ALL STATE: http?post/my/inventory/rollback/txn_version=7 http?post/my/wallet/rollback/txn_version=18 http?post/linden/wallet/rollback/txn_version=1812 http?post/sue/wallet/rollback/txn_version=1914 -
curtislinden created this gist
Oct 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,102 @@ class set /http?store/{resource.atom}/{version}/{value} /http?get/{resource.atom}/{version} /http?next_version/{resource.atom} [200, 400] writing part of a resource /http?store/resource.atom/0/value => OK Increment version of field /http?next_version/resource.atam => 1 /http?store/resource.name/1/ 'the coatsman' => OK /http?next_version/resource.name => 2 /http?get/resource.name/0 => value' /http?get/resource.name/1 => 'the coastman' /http?store/resource.name/2/ 'the coatsman' => OK /http?next_version/resource.name => 3 /http?get/resource.name/1/'the coatsman' => ERROR /http?get/resource.name/2/'the coatsman' => ERROR /http?get/resource.name/3/'the COASTman' => OK --- after here is just me formatting my thoughts. (update{ var, ver, value} -> error ) (update{ var, 0, value} -> store{var,1,value} get{var, 1} ) (store{var,ver,value} -> if db:get{var}.ver == ver + 1 db:put{var.'.version',ver} db:put{var,ver,value} else error{var, ver} ) (get{var,ver} -> db:get{var,ver} ) (next-verion{var} -> db:get{var.'.version'} ) (update{var,value} ver = (next-version var) store{var,ver,value} ) (transaction ; update('adam.name','the coatsman') update('adam.wall.deduct',10) update('eve.wall.credit',7) update('master.wall.credit',3) retry 3, -> error )