Interest Rate while creating a new asset should be increased by 2 when creates a entry in blockchain. Interface should also show the same.
For example, while creating a new asset if you provide interest rate as 10 then it should save as 12.
~/securitization_blockchain/chaincode/src
has lib.go
, securitization.go
, read_ledger.go
and write_ledger.go
.
- which file you need to modify
- which function
- what code changes are required
echo $GOROOT
/usr/local/go
echo $GOPATH
# Set GOPATH
export GOPATH=/home/student/fabric1.2
# Navigate to chincode directory ~/securitization_blockchain/chaincode/src
go build ## It will be helpful to check for any errors in chaincode
OR
go build -o <output binary name>
IBP Dashboard -> Channels -> Choose your channel -> Switch to Chaincode -> Install Chaincode -> Choose Peer -> Install Chaincode
- Provide same Chaincode ID as before.
- Chaincode Version should be different say v2.
- Choose all chaincode files.
- Click on
Submit
.
Choose Update
action for your installed chaincode as shown.
-
Clean up the previous connection related details.
cd ~/securitization_blockchain/sc-ui rm -f chaincode_info.json rm -f connection_profile.json rm -rf hfc-key-store
-
Re-launch your application.
-
Configure HF Client - with new version of chaincode.
-
The previous entries will be shown on Application as-is.
-
Now create a new asset and verify your updated chaincode.
Original Code
asset.InterestRate = args[2]
Updated Code
interest_rate, _ := strconv.ParseFloat(args[2], 32)
interest_rate = interest_rate + 0.02
asset.InterestRate = strconv.FormatFloat(interest_rate, 'f', -1, 32)