-
senthil authored
When we do a range query on simple keys, it returns composite keys too. This CR make sure that only simple keys are returned by GetStateByRange() API. In order to achieve that, we make the CreateCompositeKey() chaincode API to add a null character (0x00) as a first character in composite key. This creates a separate namespace for composite key. The simpleKey must not be an empty string as it is treated as 0x00 in levelDB which results in collision between simple and compositeKey. Hence, we do not allow empty string as key in PutState(). Further, we need to ensure that a simple key does not start with a null character (0x00). Currently, we cannot impose this constraint on simpleKey as PutState() is being used for storing both <simpleKey, value> and <compositeKey, value> where the compositeKey must start with 0x00. Hence, we have only documented this constraint on simpleKey (note that it is unusual for a key to start with a null char). In future (post v1), we may introduce PutCompositeKey() API so that we can explicitly impose this constraint. Other approaches are listed in FAB-2183 Change-Id: I28aee64d81e07f2a504580b3fe87a182c130d82e Signed-off-by: senthil <cendhu@gmail.com>
19d857c8