diff --git a/fhevm-engine/fhevm-go-coproc/fhevm/api.go b/fhevm-engine/fhevm-go-coproc/fhevm/api.go index bb88ea6f..8a66fda0 100644 --- a/fhevm-engine/fhevm-go-coproc/fhevm/api.go +++ b/fhevm-engine/fhevm-go-coproc/fhevm/api.go @@ -144,6 +144,7 @@ type ApiImpl struct { store *SqliteComputationStore address common.Address aclContractAddress common.Address + flushInterval time.Duration } type SessionImpl struct { @@ -429,10 +430,18 @@ func InitCoprocessor() (CoprocessorApi, error) { } aclContractAddress := common.HexToAddress(aclContractAddressHex) + coprocessorSyncIntervalString := os.Getenv("FHEVM_COPROCESSOR_SYNC_INTERVAL") + coprocessorSyncInterval, err := time.ParseDuration(coprocessorSyncIntervalString) + if err != nil { + return nil, fmt.Errorf("parsing FHEVM_COPROCESSOR_SYNC_INTERVAL (%s): %w", coprocessorSyncIntervalString, err) + } + fmt.Printf("Using coprocessor sync interval %s\n", coprocessorSyncInterval.String()) + apiImpl := ApiImpl{ store: ciphertextDb, address: fhevmContractAddress, aclContractAddress: aclContractAddress, + flushInterval: coprocessorSyncInterval, } // background job to submit computations to coprocessor @@ -448,7 +457,7 @@ func scheduleCoprocessorFlushes(impl *ApiImpl) { // timer to send polling for messages every 10 seconds go func() { for { - time.Sleep(time.Millisecond * 10000) + time.Sleep(impl.flushInterval) select { case impl.store.jobChannel <- true: default: