Skip to content

Commit 299afc4

Browse files
committed
add support GetMultipleKeys
Signed-off-by: Fedor Partanskiy <fedor.partanskiy@atme.com>
1 parent 7706b25 commit 299afc4

File tree

19 files changed

+1262
-267
lines changed

19 files changed

+1262
-267
lines changed

core/chaincode/chaincode_support.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ type ChaincodeSupport struct {
7575
UserRunsCC bool
7676
UseWriteBatch bool
7777
MaxSizeWriteBatch uint32
78+
UseGetMultipleKeys bool
79+
MaxSizeGetMultipleKeys uint32
7880
}
7981

8082
// Launch starts executing chaincode if it is not already running. This method
@@ -130,6 +132,8 @@ func (cs *ChaincodeSupport) HandleChaincodeStream(stream ccintf.ChaincodeStream)
130132
TotalQueryLimit: cs.TotalQueryLimit,
131133
UseWriteBatch: cs.UseWriteBatch,
132134
MaxSizeWriteBatch: cs.MaxSizeWriteBatch,
135+
UseGetMultipleKeys: cs.UseGetMultipleKeys,
136+
MaxSizeGetMultipleKeys: cs.MaxSizeGetMultipleKeys,
133137
}
134138

135139
return handler.ProcessStream(stream)

core/chaincode/config.go

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,27 @@ import (
1616
)
1717

1818
const (
19-
defaultExecutionTimeout = 30 * time.Second
20-
minimumStartupTimeout = 5 * time.Second
21-
defaultMaxSizeWriteBatch = 1000
19+
defaultExecutionTimeout = 30 * time.Second
20+
minimumStartupTimeout = 5 * time.Second
21+
defaultMaxSizeWriteBatch = 1000
22+
defaultMaxSizeGetMultipleKeys = 1000
2223
)
2324

2425
type Config struct {
25-
TotalQueryLimit int
26-
TLSEnabled bool
27-
Keepalive time.Duration
28-
ExecuteTimeout time.Duration
29-
InstallTimeout time.Duration
30-
StartupTimeout time.Duration
31-
LogFormat string
32-
LogLevel string
33-
ShimLogLevel string
34-
SCCAllowlist map[string]bool
35-
UseWriteBatch bool
36-
MaxSizeWriteBatch uint32
26+
TotalQueryLimit int
27+
TLSEnabled bool
28+
Keepalive time.Duration
29+
ExecuteTimeout time.Duration
30+
InstallTimeout time.Duration
31+
StartupTimeout time.Duration
32+
LogFormat string
33+
LogLevel string
34+
ShimLogLevel string
35+
SCCAllowlist map[string]bool
36+
UseWriteBatch bool
37+
MaxSizeWriteBatch uint32
38+
UseGetMultipleKeys bool
39+
MaxSizeGetMultipleKeys uint32
3740
}
3841

3942
func GlobalConfig() *Config {
@@ -77,10 +80,17 @@ func (c *Config) load() {
7780
if viper.IsSet("chaincode.additionalParams.useWriteBatch") {
7881
c.UseWriteBatch = viper.GetBool("chaincode.additionalParams.useWriteBatch")
7982
}
80-
c.MaxSizeWriteBatch = viper.GetUint32("ledger.state.maxSizeWriteBatch")
83+
c.MaxSizeWriteBatch = viper.GetUint32("chaincode.additionalParams.maxSizeWriteBatch")
8184
if c.MaxSizeWriteBatch <= 0 {
8285
c.MaxSizeWriteBatch = defaultMaxSizeWriteBatch
8386
}
87+
if viper.IsSet("chaincode.additionalParams.useGetMultipleKeys") {
88+
c.UseGetMultipleKeys = viper.GetBool("chaincode.additionalParams.useGetMultipleKeys")
89+
}
90+
c.MaxSizeGetMultipleKeys = viper.GetUint32("chaincode.additionalParams.maxSizeGetMultipleKeys")
91+
if c.MaxSizeGetMultipleKeys <= 0 {
92+
c.MaxSizeGetMultipleKeys = defaultMaxSizeGetMultipleKeys
93+
}
8494
}
8595

8696
func parseBool(s string) bool {

core/chaincode/handler.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ type Handler struct {
134134
UseWriteBatch bool
135135
// MaxSizeWriteBatch maximum batch size for the change segment
136136
MaxSizeWriteBatch uint32
137+
// UseGetMultipleKeys an indication that the peer can handle get multiple keys
138+
UseGetMultipleKeys bool
139+
// MaxSizeGetMultipleKeys maximum size of batches with get multiple keys
140+
MaxSizeGetMultipleKeys uint32
137141

138142
// stateLock is used to read and set State.
139143
stateLock sync.RWMutex
@@ -449,8 +453,10 @@ func (h *Handler) sendReady() error {
449453
chaincodeLogger.Debugf("sending READY for chaincode %s", h.chaincodeID)
450454

451455
chaincodeAdditionalParams := &pb.ChaincodeAdditionalParams{
452-
UseWriteBatch: h.UseWriteBatch,
453-
MaxSizeWriteBatch: h.MaxSizeWriteBatch,
456+
UseWriteBatch: h.UseWriteBatch,
457+
MaxSizeWriteBatch: h.MaxSizeWriteBatch,
458+
UseGetMultipleKeys: h.UseGetMultipleKeys,
459+
MaxSizeGetMultipleKeys: h.MaxSizeGetMultipleKeys,
454460
}
455461
payloadBytes, err := proto.Marshal(chaincodeAdditionalParams)
456462
if err != nil {

core/chaincode/lifecycle/mock/chaincode_stub.go

Lines changed: 170 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)