Skip to content

Commit

Permalink
fabric batch operations
Browse files Browse the repository at this point in the history
Signed-off-by: Fedor Partanskiy <[email protected]>
  • Loading branch information
pfi79 committed Jan 25, 2025
1 parent c3e868c commit 4790b27
Show file tree
Hide file tree
Showing 21 changed files with 2,274 additions and 79 deletions.
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

0 comments on commit 4790b27

Please sign in to comment.