Browse Source

concurrency: fix STM example to add to balance

Worked by coincidence; the txn would always retry and there
was a 1/10 chance it would pass by selecting the same to/from keys.
Anthony Romano 8 years ago
parent
commit
b206afc4a7
1 changed files with 1 additions and 1 deletions
  1. 1 1
      clientv3/concurrency/example_stm_test.go

+ 1 - 1
clientv3/concurrency/example_stm_test.go

@@ -58,7 +58,7 @@ func ExampleSTM_apply() {
 
 
 		// transfer amount
 		// transfer amount
 		xfer := fromInt / 2
 		xfer := fromInt / 2
-		fromInt, toInt = fromInt-xfer, toInt-xfer
+		fromInt, toInt = fromInt-xfer, toInt+xfer
 
 
 		// writeback
 		// writeback
 		stm.Put(fromK, fmt.Sprintf("%d", fromInt))
 		stm.Put(fromK, fmt.Sprintf("%d", fromInt))