in src/stm.ts [477:495]
private transactInner<T>(retries: number, fn: (tx: this) => T | PromiseLike<T>): Promise<T> {
this.tx =
this.options.isolation === Isolation.Serializable ||
this.options.isolation === Isolation.SerializableSnapshot
? new SerializableTransaction(this.options, this.rawKV)
: new BasicTransaction(this.options);
return Promise.resolve(fn(this)).then(value => {
return this.commit()
.then(() => value)
.catch(err => {
if (retries === 0 || !(err instanceof STMConflictError)) {
throw err;
}
return this.transactInner(retries - 1, fn);
});
});
}