Skip to content

Commit

Permalink
[FAB-6292] Fix spelling error
Browse files Browse the repository at this point in the history
[FAB_6292] fix spelling error in high-throughput.

Change-Id: I6f0d3a8ccdbd3b5b0762e3f346292340862354ac
Signed-off-by: Zhangjiong Xuan <xuanzhangjiong@hyperchain.cn>
  • Loading branch information
Zhangjiong Xuan committed Sep 26, 2017
1 parent 56af764 commit c9b0c62
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion high-throughput/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ frequently added to or removed from. For example, with a bank or credit card acc
of money in the account is the result of all of these additions and subtractions aggregated together. A typical person's bank account may not be
used frequently enough to require highly-parallel throughput, but an organizational account used to store the money collected from customers on an
e-commerce platform may very well receive a very high number of transactions from all over the world all at once. In fact, this use case is the only
use case for cryptocurrencies like Bitcoin: a user's unspent transaction output (UTXO) is the result of all transactions he or she has been a part of
use case for crypto currencies like Bitcoin: a user's unspent transaction output (UTXO) is the result of all transactions he or she has been a part of
since joining the blockchain. Other use cases that can employ this technique might be IOT sensors which frequently update their sensed value in the
cloud.

Expand Down
32 changes: 16 additions & 16 deletions high-throughput/chaincode/high-throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* of millions of rows of data.
*
* @author Alexandre Pauwels for IBM
* @created 17 Aug 2017
* @created 17 Aug 2017
*/

package main
Expand All @@ -22,8 +22,8 @@ package main
* 2 specific Hyperledger Fabric specific libraries for Smart Contracts
*/
import (
"strconv"
"fmt"
"strconv"

"github.com/hyperledger/fabric/core/chaincode/shim"
sc "github.com/hyperledger/fabric/protos/peer"
Expand All @@ -35,8 +35,8 @@ type SmartContract struct {

// Define Status codes for the response
const (
OK = 200
ERROR = 500
OK = 200
ERROR = 500
)

// Init is called when the smart contract is instantiated
Expand Down Expand Up @@ -76,7 +76,7 @@ func (s *SmartContract) Invoke(APIstub shim.ChaincodeStubInterface) sc.Response
}

/**
* Updates the ledger to include a new delta for a particluar variable. If this is the first time
* Updates the ledger to include a new delta for a particular variable. If this is the first time
* this variable is being added to the ledger, then its initial value is assumed to be 0. The arguments
* to give in the args array are as follows:
* - args[0] -> name of the variable
Expand Down Expand Up @@ -110,7 +110,7 @@ func (s *SmartContract) update(APIstub shim.ChaincodeStubInterface, args []strin
// Retrieve info needed for the update procedure
txid := APIstub.GetTxID()
compositeIndexName := "varName~op~value~txID"

// Create the composite key that will allow us to query for all deltas on a particular variable
compositeKey, compositeErr := APIstub.CreateCompositeKey(compositeIndexName, []string{name, op, args[1], txid})
if compositeErr != nil {
Expand All @@ -122,7 +122,7 @@ func (s *SmartContract) update(APIstub shim.ChaincodeStubInterface, args []strin
if compositePutErr != nil {
return shim.Error(fmt.Sprintf("Could not put operation for %s in the ledger: %s", name, compositePutErr.Error()))
}

return shim.Success([]byte(fmt.Sprintf("Successfully added %s%s to %s", op, args[1], name)))
}

Expand Down Expand Up @@ -175,7 +175,7 @@ func (s *SmartContract) get(APIstub shim.ChaincodeStubInterface, args []string)
// Retrieve the delta value and operation
operation := keyParts[1]
valueStr := keyParts[2]

// Convert the value string and perform the operation
value, convErr := strconv.ParseFloat(valueStr, 64)
if convErr != nil {
Expand All @@ -190,7 +190,7 @@ func (s *SmartContract) get(APIstub shim.ChaincodeStubInterface, args []string)
default:
return shim.Error(fmt.Sprintf("Unrecognized operation %s", operation))
}
}
}

return shim.Success([]byte(strconv.FormatFloat(finalVal, 'f', -1, 64)))
}
Expand Down Expand Up @@ -248,7 +248,7 @@ func (s *SmartContract) pruneFast(APIstub shim.ChaincodeStubInterface, args []st
// Retrieve the operation and value
operation := keyParts[1]
valueStr := keyParts[2]

// Convert the value to a float
value, convErr := strconv.ParseFloat(valueStr, 64)
if convErr != nil {
Expand All @@ -270,8 +270,8 @@ func (s *SmartContract) pruneFast(APIstub shim.ChaincodeStubInterface, args []st
default:
return shim.Error(fmt.Sprintf("Unrecognized operation %s", operation))
}
}
}

// Update the ledger with the final value and return
updateResp := s.update(APIstub, []string{name, strconv.FormatFloat(finalVal, 'f', -1, 64), "+"})
if updateResp.Status == OK {
Expand Down Expand Up @@ -339,8 +339,8 @@ func (s *SmartContract) pruneSafe(APIstub shim.ChaincodeStubInterface, args []st
if deltaRowDelErr != nil {
return shim.Error(fmt.Sprintf("Could not delete delta row: %s", deltaRowDelErr.Error()))
}
}
}

// Insert new row for the final value
updateResp := s.update(APIstub, []string{name, valueStr, "+"})
if updateResp.Status == ERROR {
Expand Down Expand Up @@ -427,7 +427,7 @@ func main() {
}
}

/**
/**
* All functions below this are for testing traditional editing of a single row
*/
func (s *SmartContract) putStandard(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {
Expand All @@ -443,7 +443,7 @@ func (s *SmartContract) putStandard(APIstub shim.ChaincodeStubInterface, args []
if putErr != nil {
return shim.Error(fmt.Sprintf("Failed to put state: %s", putErr.Error()))
}

return shim.Success(nil)
}

Expand Down

0 comments on commit c9b0c62

Please sign in to comment.