hyperledger / hyperledger/fabric-chaincode-java

Read/write batching

Open
#378 3 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Java
Stars
323
Forks
210
Avg merge
8h 1m
Merged PRs (30d)
8

Description

Fabric [v3.1.0](https://github.com/hyperledger/fabric/releases/tag/v3.1.0) introduced a new performance optimization that allows ledger reads and writes to be performed in batches. This feature is described in the [Peer to Chaincode Communication Optimization RFC](https://github.com/hyperledger/fabric-rfcs/blob/main/text/0011-peer-chaincode-optimization.md).

[fabric-chaincode-go](https://github.com/hyperledger/fabric-chaincode-go) provides a reference implementation of this functionality, which should be replicated by the Java chaincode libraries.

Implementation is composed of these component parts:

- [Configuration of batching based on peer capabilities when a connection is established](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/handler.go#L807-L819)
- Modifications to [PutState](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/stub.go#L203-L221) (and [PutPrivateData](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/stub.go#L288-L295)) API functions
- An accompanying [WriteBatch](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/batch.go) implementation to collect batched writes.
- Modification of [handleInit](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/handler.go#L200-L202) and [handleTransaction](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/handler.go#L230-L232) to ensure that batched writes are sent at the end of a client invocation
- New Stub API functions:
- [StartWriteBatch](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/stub.go#L652-L657)
- [FinishWriteBatch](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/stub.go#L659-L664)
- [GetMultipleStates](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/stub.go#L169-L174)
- [GetMultiplePrivateData](https://github.com/hyperledger/fabric-chaincode-go/blob/9e139c0c2edd362fbfe24261de66fff60eccc6d0/shim/stub.go#L272-L278)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.