The scope of the acquisition "ByRange" is different from the FabricNodeSDK.
oOhoraOo opened this issue · 1 comments
oOhoraOo commented
The scope of the data to be acquired in getStateByRange is different from the FabricNodeSDK.
FabricNodeSDK
getStateByRange(startKey, endKey)
Parameters:
Name Type Description
startKey string State variable key as the start of the key range (inclusive)
endKey string State variable key as the end of the key range (exclusive)
howabout, fabric-mock-stub is ,,
startKey → inclusive
endKey → inclusive
getStateByRange(startKey: string, endKey: string): Promise<Iterators.StateQueryIterator> {
const items: Iterators.KV[] = Object.keys(this.state)
.filter((k: string) => {
const comp1 = Helpers.strcmp(k, startKey);
const comp2 = Helpers.strcmp(k, endKey);
return (comp1 >= 0 && comp2 <= 0) || (startKey == '' && endKey == ''); // " comp2 <= 0 " should be "comp2 < 0"
})
.map((k: string) => new MockKeyValue(k, this.state[k]));
return Promise.resolve(new MockStateQueryIterator(items, this.txID));
}
Furthermore, getPrivateDataByRange contains the same bug.
oOhoraOo commented
This is my first pull request. I'm very glad you accepted my request.