Skip to content

Commit

Permalink
fix(datastore): local address not properly recognized
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Oct 9, 2024
1 parent 05a848a commit b3f04fd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 8 deletions.
8 changes: 3 additions & 5 deletions datastore/core/lib/ArgonPaymentProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ export default class ArgonPaymentProcessor implements IArgonPaymentProcessor {
}

const recipient = note.noteType.recipient;
const localchainAddress = await this.localchain.address;

if (!(await this.canSign(recipient))) {
if (recipient !== localchainAddress) {
log.warn(
'This channelHold is made out to a different address than your attached localchain',
{
recipient,
channelHold: data.channelHold,
yourAddress: localchainAddress
} as any,
);
throw new Error('ChannelHold recipient not localchain address');
Expand Down Expand Up @@ -158,10 +160,6 @@ export default class ArgonPaymentProcessor implements IArgonPaymentProcessor {
return channelHold;
}

private async canSign(address: string): Promise<boolean> {
return (await this.localchain.address) === address;
}

private getDb(datastoreId: string): DatastoreChannelHoldsDb {
if (!datastoreId)
throw new Error('No datastoreId provided to get channelHold spend tracking db.');
Expand Down
6 changes: 3 additions & 3 deletions datastore/docpage/src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
</select>
</h2>
<!-- prettier-ignore -->
<Prism language="shell" v-if="exampleType === 'client'">
<Prism language="bash" v-if="exampleType === 'client'">
npm install @ulixee/client
</Prism>
<!-- prettier-ignore -->
<Prism language="shell" v-else-if="exampleType === 'stream'">
<Prism language="bash" v-else-if="exampleType === 'stream'">
npm install @ulixee/stream
</Prism>
<!-- prettier-ignore -->
<Prism language="shell" v-else-if="exampleType === 'postgres'">
<Prism language="bash" v-else-if="exampleType === 'postgres'">
npm install pg
</Prism>

Expand Down
46 changes: 46 additions & 0 deletions datastore/docs/advanced/hosted-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,56 @@

> Hosted Services centralize the storage of Datastores, Statistics and Hero Replays for a cluster of DatastoreCores.
The following is a list of the services and their descriptions. Many of these services can also be configured using the `npx @ulixee/cloud start` command.

## Setup Host

This is the address of a node in your cluster that has the services setup. This is used to configure the services for any non-leader nodes.

**Environment Variable:** `ULX_SERVICES_SETUP_HOST`

## StatsRegistry

This service centralizes the logging and tracking of statistics for Datastore Queries and individual Entities (crawlers, extractors and tables).

**Environment Variable:** `ULX_DATASTORE_STATS_HOST`

## DatastoreRegistry

This service centralizes the storage of Datastores so they can be used across a cluster of servers. A single server will serve as the cluster repository, and the other nodes will cache Datastores, but use this as the end location.

**Environment Variable:** `ULX_DATASTORE_REGISTRY_HOST`

## DatastoreLookupService

This service centralizes the lookup of Datastore Domains. There's a time and effort cost to lookup a Datastore, so this service caches the lookup results.

**Environment Variable:** `ULX_DATASTORE_LOOKUP_SERVICE_HOST`

## StorageEngine

This service centralizes the storage of Datastore's underlying SQLite databases so they can be used across a cluster of servers. A single server will serve as the cluster repository, and the other nodes will forward requests to this server.

**Environment Variable:** `ULX_STORAGE_ENGINE_HOST`

## ReplayRegistry

This service centralizes the storage of Hero Replays so they can be used across a cluster of servers. Hero Replays serve as the underlying data for cached Crawlers, so must be preserved until the cache expires.

**Environment Variable:** `ULX_REPLAY_REGISTRY_HOST`

# Hosted Services for Argon Payments

## PaymentProcessorService

This service centralizes the verification and finalizing of the Micropayment Channel payments created by datastore consumers. It's used to ensure that channelHolds are properly settled and that clients cannot double-spend across multiple nodes. This service requires a disk-local Localchain instance to claim the channelHolds.

**Environment Variable:** `ULX_PAYMENT_PROCESSOR_HOST`

If accepting payments, you must either set this or configurations for a Localchain path.

## UpstreamPaymentsService

This service is necessary if your Datastore clones another Datastore that requires payments. This payment service will be used to pay for embedded requests to upstream Datastores. A cluster can share a single payment service to reduce complexity. It can also re-use the Localchain used to accept ChannelHold Payments.

**Environment Variable:** `ULX_UPSTREAM_PAYMENTS_SERVICE_HOST`

0 comments on commit b3f04fd

Please sign in to comment.