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 Oct 7, 2024
1 parent 6cc9ed0 commit 20f5957
Show file tree
Hide file tree
Showing 69 changed files with 3,003 additions and 341 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
UsePutStateBatch bool
MaxSizePutStateBatch 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,
UsePutStateBatch: cs.UsePutStateBatch,
MaxSizePutStateBatch: cs.MaxSizePutStateBatch,
}

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
defaultMaxSizePutStateBatch = 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
UsePutStateBatch bool
MaxSizePutStateBatch 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.additionalParams.usePutStateBatch") {
c.UsePutStateBatch = viper.GetBool("chaincode.additionalParams.usePutStateBatch")
}
c.MaxSizePutStateBatch = viper.GetUint32("ledger.state.maxSizePutStateBatch")
if c.MaxSizePutStateBatch <= 0 {
c.MaxSizePutStateBatch = defaultMaxSizePutStateBatch
}
}

func parseBool(s string) bool {
Expand Down
Loading

0 comments on commit 20f5957

Please sign in to comment.