I built a blockchain network Every time I query the ledger via chaincode in which query is implemented by GetState (key), it always returns empty value, even if I can get the key/value pair by invoking GetStateByRange("","") which returns all the key/value pairs.
These are the logs I inspected from the peer where the chaincode was installed on:
2018-01-17 09:01:26.670 UTC [chaincode] processStream -> DEBU 961 [43697748]Received message GET_STATE from shim
2018-01-17 09:01:26.670 UTC [chaincode] handleMessage -> DEBU 962 [43697748]Fabric side Handling ChaincodeMessage of type: GET_STATE in state rea
2018-01-17 09:01:26.670 UTC [chaincode] afterGetState -> DEBU 963 [43697748]Received GET_STATE, invoking get state from ledger
2018-01-17 09:01:26.670 UTC [chaincode] filterError -> DEBU 964 Ignoring NoTransitionError: no transition
2018-01-17 09:01:26.670 UTC [chaincode] func1 -> DEBU 965 [43697748] getting state for chaincode test, key , channel chainplaza
2018-01-17 09:01:26.671 UTC [stateleveldb] GetState -> DEBU 966 GetState(). ns=test, key=
2018-01-17 09:01:26.671 UTC [chaincode] func1 -> DEBU 967 [43697748]No state associated with key: a. Sending RESPONSE with an empty payload
2018-01-17 09:01:26.671 UTC [chaincode] 1 -> DEBU 968 [43697748]handleGetState serial send RESPONSE
2018-01-17 09:01:26.671 UTC [chaincode] processStream -> DEBU 969 [43697748]Received message COMPLETED from shim
2018-01-17 09:01:26.671 UTC [chaincode] handleMessage -> DEBU 96a [43697748]Fabric side Handling ChaincodeMessage of type: COMPLETED in state rea
2018-01-17 09:01:26.671 UTC [chaincode] handleMessage -> DEBU 96b [43697748e1ea4c6f0f6af336f6c413583716c8ec1d59c10118ecfd49bf581509]HandleMessage
2018-01-17 09:01:26.671 UTC [chaincode] notify -> DEBU 96c notifying Txid:43697748e1ea4c6f0f6af336f6c413583716c8ec1d59c10118ecfd49bf581509
2018-01-17 09:01:26.671 UTC [chaincode] Execute -> DEBU 96d Exit
Here, [stateleveldb] GetState -> DEBU 966 GetState(). ns=test, key=, the key part is empty. If I am not wrong, in a blockchain working properly, the value of the key should be the parameter of GetState(key).
The chaincode I used is this : https://github.com/hyperledger/fabric-samples/tree/release/chaincode/chaincode_example02