Skip to content

Commit

Permalink
chore: variable renames
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Sep 20, 2024
1 parent 42bc301 commit 589741a
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cloud/main/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ ULX_ENABLE_GLOBAL_CONFIG=true
ARGON_LOCALCHAIN_PATH=
# Default Argon mainchain host TODO: fill in once mainchain is up#
ARGON_MAINCHAIN_URL=
# A vote output address for the localchain (activates vote creation)
ARGON_VOTES_ADDRESS=
# An address that will be where any rewards are sent for closed blocks (activates block voting)
ARGON_BLOCK_REWARDS_ADDRESS=
# The preferred notary to use
ARGON_NOTARY_ID=1
# Prompt for an interactive password on the cli
Expand Down
2 changes: 1 addition & 1 deletion datastore/broker/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getLocalchainConfig(): ILocalchainConfig | undefined {

return <ILocalchainConfig>{
localchainPath: env.ARGON_LOCALCHAIN_PATH,
argonMainchainUrl: env.ARGON_MAINCHAIN_URL,
mainchainUrl: env.ARGON_MAINCHAIN_URL,
notaryId: parseEnvInt(env.NOTARY_ID),
keystorePassword: {
interactiveCli: parseEnvBool(env.ARGON_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI),
Expand Down
4 changes: 2 additions & 2 deletions datastore/core/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ ULX_ENABLE_GLOBAL_CONFIG=true
ARGON_LOCALCHAIN_PATH=
# Default Argon mainchain host TODO: fill in once mainchain is up#
ARGON_MAINCHAIN_URL=
# A vote output address for the localchain (activates vote creation)
ARGON_VOTES_ADDRESS=
# An address that will be where any rewards are sent for closed blocks (activates block voting)
ARGON_BLOCK_REWARDS_ADDRESS=
# The preferred notary to use
ARGON_NOTARY_ID=1
# Prompt for an interactive password on the cli
Expand Down
4 changes: 2 additions & 2 deletions datastore/core/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function getLocalchainConfig(): ILocalchainConfig | undefined {

return <ILocalchainConfig>{
localchainPath: env.ARGON_LOCALCHAIN_PATH,
argonMainchainUrl: env.ARGON_MAINCHAIN_URL,
votesAddress: parseAddress(env.ARGON_VOTES_ADDRESS, 'Votes Address'),
mainchainUrl: env.ARGON_MAINCHAIN_URL,
blockRewardsAddress: parseAddress(env.ARGON_BLOCK_REWARDS_ADDRESS, 'Block Rewards Address'),
notaryId: parseEnvInt(env.NOTARY_ID),
keystorePassword: {
interactiveCli: parseEnvBool(env.ARGON_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI),
Expand Down
2 changes: 1 addition & 1 deletion datastore/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export default class DatastoreCore extends TypedEventEmitter<{
this.upstreamDatastorePaymentService = new EmbeddedPaymentService();
if (!this.datastoreHostLookup) {
const argonMainchainUrl =
this.options.localchainConfig?.argonMainchainUrl ?? Env.localchainConfig?.argonMainchainUrl;
this.options.localchainConfig?.mainchainUrl ?? Env.localchainConfig?.mainchainUrl;
const mainchainClient = argonMainchainUrl
? await MainchainClient.connect(argonMainchainUrl, 10e3)
: null;
Expand Down
14 changes: 13 additions & 1 deletion datastore/docs/links.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
- title: Overview
items:
- Introduction
- Configuration
- Concepts
- Configuration
- Deployment
- Relationship with Argon

- title: Basics
items:
Expand All @@ -17,16 +18,27 @@
- Input
- Output

- title: Guides
items:
- Create a Localchain
- Register a Data Domain
- Setup Datastore Payments
- Close Argon Blocks

- title: Advanced
items:
- Extractor Schemas
- Schema
- Payments
- Databrokers
- Credits
- Plugins
- Hosted Services
- Storage Engines
- Hero Plugin
- Puppeteer Plugin


- title: Help
items:
- Prerequisites
Expand Down
7 changes: 7 additions & 0 deletions datastore/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import PassthroughExtractor from './lib/PassthroughExtractor';
import PassthroughTable from './lib/PassthroughTable';
import Extractor from './lib/Extractor';
import Crawler from './lib/Crawler';
import DefaultPaymentService from './payments/DefaultPaymentService';
import LocalchainWithSync from './payments/LocalchainWithSync';
import { IEscrowAllocationStrategy, IEscrowSource } from './payments/ArgonReserver';

export * as Schema from '@ulixee/schema';

Expand All @@ -26,8 +29,12 @@ export {
Extractor,
Crawler,
ConnectionToDatastoreCore,
LocalchainWithSync,
PassthroughExtractor,
DefaultPaymentService,
PassthroughTable,
IEscrowAllocationStrategy,
IEscrowSource,
IExtractorComponents,
IExtractorRunOptions,
IExtractorSchema,
Expand Down
6 changes: 3 additions & 3 deletions datastore/main/interfaces/ILocalchainConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { KeystorePasswordOption } from '@argonprotocol/localchain';
import { IEscrowAllocationStrategy } from '../payments/ArgonReserver';

export default interface ILocalchainConfig {
argonMainchainUrl?: string;
mainchainUrl?: string;
notaryId?: number;
localchainPath?: string;
/**
* Strategy to use to create escrows. Defaults to a 100 query multiplier
*/
escrowAllocationStrategy?: IEscrowAllocationStrategy;
/**
* Must be set to enable vote creation
* Must be set to enable block vote creation. This is the address where block rewards will be sent.
*/
votesAddress?: string;
blockRewardsAddress?: string;
/**
* A password, if applicable, to the localchain
*/
Expand Down
10 changes: 6 additions & 4 deletions datastore/main/payments/BrokerEscrowSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export default class BrokerEscrowSource implements IEscrowSource {

private readonly connectionToCore: ConnectionToCore<IDatabrokerApis, {}>;
private keyring = new Keyring({ type: 'sr25519', ss58Format: ADDRESS_PREFIX });
private loadPromise: Promise<void>;
private readonly loadPromise: Promise<void | Error>;

constructor(
public host: string,
public readonly authentication: Identity,
) {
this.connectionToCore = new ConnectionToCore(new HttpTransportToCore(this.host));
this.loadPromise = this.load().catch(() => null);
this.loadPromise = this.load().catch(err => err);
}

public async close(): Promise<void> {
Expand All @@ -42,7 +42,8 @@ export default class BrokerEscrowSource implements IEscrowSource {
}

public async getBalance(): Promise<bigint> {
await this.loadPromise;
const error = await this.loadPromise;
if (error) throw error;
const { balance } = await this.connectionToCore.sendRequest({
command: 'Databroker.getBalance',
args: [{ identity: this.authentication.bech32 }],
Expand All @@ -54,7 +55,8 @@ export default class BrokerEscrowSource implements IEscrowSource {
paymentInfo: IPaymentServiceApiTypes['PaymentService.reserve']['args'],
milligons: bigint,
): Promise<IEscrowDetails> {
await this.loadPromise;
const error = await this.loadPromise;
if (error) throw error;
const nonce = nanoid(10);
const signatureMessage = BrokerEscrowSource.createSignatureMessage(
paymentInfo.domain,
Expand Down
10 changes: 5 additions & 5 deletions datastore/main/payments/LocalchainWithSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ export default class LocalchainWithSync extends TypedEventEmitter<{ sync: Balanc
}

public async load(): Promise<void> {
const { argonMainchainUrl, localchainPath } = this.localchainConfig;
const { mainchainUrl, localchainPath } = this.localchainConfig;

let defaultPath = localchainPath ?? Localchain.getDefaultPath();
if (!defaultPath.endsWith('.db')) {
defaultPath = Path.join(defaultPath, 'primary.db');
}

log.info(`Loading ${argonMainchainUrl ? 'online' : 'offline'} localchain`, {
log.info(`Loading ${mainchainUrl ? 'online' : 'offline'} localchain`, {
localchainPath: defaultPath,
} as any);
const keystorePassword = this.getPassword();

if (argonMainchainUrl) {
if (mainchainUrl) {
this.#localchain = await Localchain.load({
path: localchainPath,
mainchainUrl: argonMainchainUrl,
mainchainUrl,
keystorePassword,
});
this.datastoreLookup = new DatastoreLookup(await this.#localchain.mainchainClient);
Expand Down Expand Up @@ -156,7 +156,7 @@ export default class LocalchainWithSync extends TypedEventEmitter<{ sync: Balanc
this.nextTick = setTimeout(async () => {
try {
const result = await this.#localchain.balanceSync.sync({
votesAddress: this.localchainConfig.votesAddress,
votesAddress: this.localchainConfig.blockRewardsAddress,
});
this.emit('sync', result);
if (this.enableLogging) {
Expand Down
2 changes: 1 addition & 1 deletion end-to-end/test/payments-broker.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async function setupDatastore(
ULX_IDENTITY_PATH: identityPath,
ARGON_MAINCHAIN_URL: argonMainchainUrl,
ARGON_LOCALCHAIN_PATH: localchain.path,
ARGON_VOTES_ADDRESS: votesAddress,
ARGON_BLOCK_REWARDS_ADDRESS: votesAddress,
ARGON_NOTARY_ID: '1',
});
expect(cloudAddress).toBeTruthy();
Expand Down
6 changes: 3 additions & 3 deletions end-to-end/test/payments.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describeIntegration('Payments E2E', () => {

const bobchain = await LocalchainWithSync.load({
localchainPath: Path.join(storageDir, 'bobchain.db'),
argonMainchainUrl,
mainchainUrl: argonMainchainUrl,
automaticallyRunSync: false,
escrowAllocationStrategy: {
type: 'multiplier',
Expand Down Expand Up @@ -120,7 +120,7 @@ describeIntegration('Payments E2E', () => {
ULX_IDENTITY_PATH: identityPath,
ARGON_MAINCHAIN_URL: argonMainchainUrl,
ARGON_LOCALCHAIN_PATH: ferdiechain.path,
ARGON_VOTES_ADDRESS: ferdieVotesAddress,
ARGON_BLOCK_REWARDS_ADDRESS: ferdieVotesAddress,
ARGON_NOTARY_ID: '1',
});
expect(cloudAddress).toBeTruthy();
Expand Down Expand Up @@ -239,7 +239,7 @@ describeIntegration('Payments E2E', () => {

const bobchain = await LocalchainWithSync.load({
localchainPath: Path.join(storageDir, 'bobchain.db'),
argonMainchainUrl,
mainchainUrl: argonMainchainUrl,
escrowAllocationStrategy: {
type: 'multiplier',
queries: 2,
Expand Down

0 comments on commit 589741a

Please sign in to comment.