mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
Fix retry
Adding multiple contracts had broken the retry loop Signed-off-by: James Taylor <jamest@uk.ibm.com>
This commit is contained in:
parent
3667dd9322
commit
19e28d817b
2 changed files with 6 additions and 2 deletions
|
|
@ -160,6 +160,10 @@ export const startRetryLoop = (contract: Contract, redis: Redis): void => {
|
|||
pendingTransactionCount
|
||||
);
|
||||
|
||||
// TODO pick a random transaction instead to reduce chances of
|
||||
// clashing with other instances? Currently no zrandmember
|
||||
// command though...
|
||||
// https://github.com/luin/ioredis/issues/1374
|
||||
const transactionIds = await (redis as Redis).zrange(
|
||||
'index:txn:timestamp',
|
||||
-1,
|
||||
|
|
@ -309,7 +313,7 @@ const retryTransaction = async (
|
|||
await clearTransactionDetails(redis, transactionId);
|
||||
} catch (err) {
|
||||
if (isDuplicateTransaction(err)) {
|
||||
logger.debug('Transaction %s has already been committed', transactionId);
|
||||
logger.warn('Transaction %s has already been committed', transactionId);
|
||||
await clearTransactionDetails(redis, transactionId);
|
||||
} else {
|
||||
// TODO check for retry limit and update timestamp
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { createServer } from './server';
|
|||
async function main() {
|
||||
const app = await createServer();
|
||||
|
||||
const contract: Contract = app.get('contract');
|
||||
const contract: Contract = app.get('contracts').contract;
|
||||
const redis: Redis = app.get('redis');
|
||||
startRetryLoop(contract, redis);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue