Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support WriteBatch operations #5113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/chaincode/chaincode_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ type ChaincodeSupport struct {
Runtime Runtime
TotalQueryLimit int
UserRunsCC bool
UseWriteBatch bool
MaxSizeWriteBatch uint32
}

// Launch starts executing chaincode if it is not already running. This method
Expand Down Expand Up @@ -126,6 +128,8 @@ func (cs *ChaincodeSupport) HandleChaincodeStream(stream ccintf.ChaincodeStream)
AppConfig: cs.AppConfig,
Metrics: cs.HandlerMetrics,
TotalQueryLimit: cs.TotalQueryLimit,
UseWriteBatch: cs.UseWriteBatch,
MaxSizeWriteBatch: cs.MaxSizeWriteBatch,
}

return handler.ProcessStream(stream)
Expand Down
34 changes: 22 additions & 12 deletions core/chaincode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@ import (
)

const (
defaultExecutionTimeout = 30 * time.Second
minimumStartupTimeout = 5 * time.Second
defaultExecutionTimeout = 30 * time.Second
minimumStartupTimeout = 5 * time.Second
defaultMaxSizeWriteBatch = 1000
)

type Config struct {
TotalQueryLimit int
TLSEnabled bool
Keepalive time.Duration
ExecuteTimeout time.Duration
InstallTimeout time.Duration
StartupTimeout time.Duration
LogFormat string
LogLevel string
ShimLogLevel string
SCCAllowlist map[string]bool
TotalQueryLimit int
TLSEnabled bool
Keepalive time.Duration
ExecuteTimeout time.Duration
InstallTimeout time.Duration
StartupTimeout time.Duration
LogFormat string
LogLevel string
ShimLogLevel string
SCCAllowlist map[string]bool
UseWriteBatch bool
MaxSizeWriteBatch uint32
}

func GlobalConfig() *Config {
Expand Down Expand Up @@ -71,6 +74,13 @@ func (c *Config) load() {
if viper.IsSet("ledger.state.totalQueryLimit") {
c.TotalQueryLimit = viper.GetInt("ledger.state.totalQueryLimit")
}
if viper.IsSet("chaincode.runtimeParams.useWriteBatch") {
c.UseWriteBatch = viper.GetBool("chaincode.runtimeParams.useWriteBatch")
}
c.MaxSizeWriteBatch = viper.GetUint32("chaincode.runtimeParams.maxSizeWriteBatch")
if c.MaxSizeWriteBatch <= 0 {
c.MaxSizeWriteBatch = defaultMaxSizeWriteBatch
}
}

func parseBool(s string) bool {
Expand Down
Loading