Skip to content

Commit

Permalink
change naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindavee committed Jan 10, 2025
1 parent f68fbff commit 7f36372
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 34 deletions.
4 changes: 2 additions & 2 deletions packages/data-access/src/combined-data-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export abstract class CombinedDataAccess implements DataAccessTypes.IDataAccess
await this.reader.close();
}

isPersisting(): boolean {
return !(this.writer instanceof NoPersistDataWrite);
skipPersistence(): boolean {
return this.writer instanceof NoPersistDataWrite;
}

async getTransactionsByChannelId(
Expand Down
6 changes: 3 additions & 3 deletions packages/request-client.js/src/api/request-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class RequestNetwork {

const transactionData = requestLogicCreateResult.meta?.transactionManagerMeta.transactionData;
const requestId = requestLogicCreateResult.result.requestId;
const isSkippingPersistence = !this.dataAccess.isPersisting();
const isSkippingPersistence = this.dataAccess.skipPersistence();
// create the request object
const request = new Request(requestId, this.requestLogic, this.currencyManager, {
contentDataExtension: this.contentData,
Expand Down Expand Up @@ -157,7 +157,7 @@ export default class RequestNetwork {
throw new Error('Cannot persist request without inMemoryInfo.');
}

if (!this.dataAccess.isPersisting()) {
if (this.dataAccess.skipPersistence()) {
throw new Error(
'Cannot persist request when skipPersistence is enabled. To persist the request, create a new instance of RequestNetwork without skipPersistence being set to true.',
);
Expand Down Expand Up @@ -197,7 +197,7 @@ export default class RequestNetwork {

const transactionData = requestLogicCreateResult.meta?.transactionManagerMeta.transactionData;
const requestId = requestLogicCreateResult.result.requestId;
const isSkippingPersistence = !this.dataAccess.isPersisting();
const isSkippingPersistence = this.dataAccess.skipPersistence();

// create the request object
const request = new Request(requestId, this.requestLogic, this.currencyManager, {
Expand Down
13 changes: 6 additions & 7 deletions packages/request-client.js/src/http-data-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@ export default class HttpDataAccess extends CombinedDataAccess {
{
httpConfig,
nodeConnectionConfig,
persist,
skipPersistence,
}: {
httpConfig?: Partial<ClientTypes.IHttpDataAccessConfig>;
nodeConnectionConfig?: Partial<NodeConnectionConfig>;
persist?: boolean;
skipPersistence?: boolean;
} = {
httpConfig: {},
nodeConnectionConfig: {},
persist: true,
skipPersistence: true,
},
) {
const dataAccessConfig = new HttpDataAccessConfig({ httpConfig, nodeConnectionConfig });
const transaction = new HttpTransaction(dataAccessConfig);
const reader = new HttpDataRead(dataAccessConfig);
const writer =
persist === false
? new NoPersistDataWrite()
: new HttpDataWrite(dataAccessConfig, transaction);
const writer = skipPersistence
? new NoPersistDataWrite()
: new HttpDataWrite(dataAccessConfig, transaction);

super(reader, writer);

Expand Down
2 changes: 1 addition & 1 deletion packages/request-client.js/src/http-request-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class HttpRequestNetwork extends RequestNetwork {
) {
const dataAccess: DataAccessTypes.IDataAccess = useMockStorage
? new MockDataAccess(new MockStorage())
: new HttpDataAccess({ httpConfig, nodeConnectionConfig, persist: !skipPersistence });
: new HttpDataAccess({ httpConfig, nodeConnectionConfig, skipPersistence });

if (!currencyManager) {
currencyManager = CurrencyManager.getDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const mockDataAccess: DataAccessTypes.IDataAccess = {
close: jest.fn(),
persistTransaction: jest.fn(),
getChannelsByMultipleTopics: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

describe('api/request-network', () => {
Expand Down
38 changes: 19 additions & 19 deletions packages/transaction-manager/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('index', () => {
);
return fakeMetaDataAccessPersistReturn;
}),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};
});

Expand Down Expand Up @@ -228,7 +228,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn().mockReturnValue(fakeMetaDataAccessPersistReturn),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -275,7 +275,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn().mockReturnValue(fakeMetaDataAccessPersistReturn),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -318,7 +318,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn().mockReturnValue(fakeMetaDataAccessPersistReturn),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -395,7 +395,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(fakeDataAccess);
Expand Down Expand Up @@ -446,7 +446,7 @@ describe('index', () => {
.mockReturnValue(fakeMetaDataAccessGetReturnFirstHashWrong),
initialize: jest.fn(),
close: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
persistTransaction: jest.fn(),
};

Expand Down Expand Up @@ -506,7 +506,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -564,7 +564,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(fakeDataAccess);
Expand Down Expand Up @@ -638,7 +638,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -726,7 +726,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -803,7 +803,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -882,7 +882,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -960,7 +960,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -1109,7 +1109,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -1184,7 +1184,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down Expand Up @@ -1253,7 +1253,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(fakeDataAccess);
Expand Down Expand Up @@ -1333,7 +1333,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(fakeDataAccess);
Expand Down Expand Up @@ -1403,7 +1403,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(fakeDataAccess);
Expand Down Expand Up @@ -1483,7 +1483,7 @@ describe('index', () => {
initialize: jest.fn(),
close: jest.fn(),
persistTransaction: jest.fn(),
isPersisting: jest.fn().mockReturnValue(true),
skipPersistence: jest.fn().mockReturnValue(true),
};

const transactionManager = new TransactionManager(
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/data-access-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface IDataWrite {
}

export interface IDataAccess extends IDataRead, IDataWrite {
isPersisting(): boolean;
skipPersistence(): boolean;
_getStatus?(): Promise<IDataAccessStatus>;
getLitCapacityDelegationAuthSig?: (delegateeAddress: string) => Promise<AuthSig>;
}
Expand Down

0 comments on commit 7f36372

Please sign in to comment.