Compare commits
No commits in common. "cf201ce7f476d1729639fa29b181a531bd2b562b" and "8379fb73a4b116c5bcc1fe02dade3fc2e55e352d" have entirely different histories.
cf201ce7f4
...
8379fb73a4
|
@ -1,41 +0,0 @@
|
|||
pipeline:
|
||||
build:
|
||||
image: git.lumeweb.com/lumeweb/ci-node
|
||||
commands:
|
||||
- yarn
|
||||
- yarn build
|
||||
package:
|
||||
image: ghcr.io/goreleaser/nfpm
|
||||
commands:
|
||||
- nfpm pkg --packager deb
|
||||
publish_focal:
|
||||
image: git.lumeweb.com/lumeweb/aptly-publisher
|
||||
settings:
|
||||
apt_username:
|
||||
from_secret: apt_username
|
||||
apt_password:
|
||||
from_secret: apt_password
|
||||
repo: apt.web3relay.io
|
||||
folder: ubuntu
|
||||
distro: focal
|
||||
gpg_password:
|
||||
from_secret: gpg_password
|
||||
publish_jammy:
|
||||
image: git.lumeweb.com/lumeweb/aptly-publisher
|
||||
settings:
|
||||
apt_username:
|
||||
from_secret: apt_username
|
||||
apt_password:
|
||||
from_secret: apt_password
|
||||
repo: apt.web3relay.io
|
||||
folder: ubuntu
|
||||
distro: jammy
|
||||
gpg_password:
|
||||
from_secret: gpg_password
|
||||
purge_cdn:
|
||||
image: git.lumeweb.com/lumeweb/do-cdn-purge
|
||||
settings:
|
||||
DIGITALOCEAN_ACCESS_TOKEN:
|
||||
from_secret: DIGITALOCEAN_ACCESS_TOKEN
|
||||
DIGITALOCEAN_CDN_ID:
|
||||
from_secret: DIGITALOCEAN_CDN_ID
|
23
nfpm.yaml
23
nfpm.yaml
|
@ -1,23 +0,0 @@
|
|||
name: "lumeweb-relay-plugin-handshake"
|
||||
arch: "amd64"
|
||||
platform: "linux"
|
||||
version: "v0.1.0"
|
||||
section: "default"
|
||||
priority: "extra"
|
||||
maintainer: "Derrick Hammer contact@lumeweb.com"
|
||||
description: Handshake plugin for lumeweb-relay
|
||||
vendor: "Hammer Technologies LLC"
|
||||
homepage: "https://lumeweb.com"
|
||||
license: "MIT"
|
||||
contents:
|
||||
- src: ./build/Release/bcryto.node
|
||||
dst: /etc/lumeweb/relay/plugins/build/Release/bcryto.node
|
||||
- src: ./build/Release/goosig.node
|
||||
dst: /etc/lumeweb/relay/plugins/build/Release/goosig.node
|
||||
- src: ./build/Release/leveldown.node
|
||||
dst: /etc/lumeweb/relay/plugins/build/Release/leveldown.node
|
||||
- src: ./build/Release/mrmr.node
|
||||
dst: /etc/lumeweb/relay/plugins/build/Release/mrmr.node
|
||||
scripts:
|
||||
postinstall: ./pkg/scripts/postinstall.sh
|
||||
preremove: ./pkg/scripts/preremove.sh
|
|
@ -6,11 +6,10 @@
|
|||
"build": "bash build.sh"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.11.10",
|
||||
"@lumeweb/relay": "https://github.com/LumeWeb/relay.git",
|
||||
"esbuild": "^0.15.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lumeweb/relay-types": "https://git.lumeweb.com/LumeWeb/relay-types.git",
|
||||
"hs-client": "^0.0.11",
|
||||
"hsd": "https://github.com/LumeWeb/hsd.git#spv-namestate",
|
||||
"random-key": "^0.3.2"
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
systemctl restart lumeweb-relay.service
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
systemctl restart lumeweb-relay.service
|
27
src/index.ts
27
src/index.ts
|
@ -1,4 +1,9 @@
|
|||
import type { Plugin, PluginAPI } from "@lumeweb/relay-types";
|
||||
import type {
|
||||
Plugin,
|
||||
PluginAPI,
|
||||
RPCResponse,
|
||||
RPCRequest,
|
||||
} from "@lumeweb/relay";
|
||||
// @ts-ignore
|
||||
import rand from "random-key";
|
||||
// @ts-ignore
|
||||
|
@ -6,11 +11,9 @@ import SPVNode from "hsd/lib/node/spvnode.js";
|
|||
// @ts-ignore
|
||||
import { NodeClient } from "hs-client";
|
||||
|
||||
async function boot(api: PluginAPI) {
|
||||
async function boot(config: any) {
|
||||
let hsdServer: SPVNode;
|
||||
|
||||
const { config } = api;
|
||||
|
||||
let clientArgs = {
|
||||
network: "main",
|
||||
host: "127.0.0.1",
|
||||
|
@ -35,20 +38,20 @@ async function boot(api: PluginAPI) {
|
|||
});
|
||||
hsdServer.on("abort", async (err: any) => {
|
||||
const timeout = setTimeout(() => {
|
||||
api.logger.error("Shutdown is taking a long time. Exiting.");
|
||||
console.error("Shutdown is taking a long time. Exiting.");
|
||||
process.exit(3);
|
||||
}, 5000);
|
||||
|
||||
timeout.unref();
|
||||
|
||||
try {
|
||||
api.logger.error("Shutting down...");
|
||||
console.error("Shutting down...");
|
||||
await hsdServer.close();
|
||||
clearTimeout(timeout);
|
||||
api.logger.error((err as Error).stack);
|
||||
console.error((err as Error).stack);
|
||||
process.exit(2);
|
||||
} catch (e: any) {
|
||||
api.logger.error(
|
||||
console.error(
|
||||
`Error occurred during shutdown: ${(e as Error).message}`
|
||||
);
|
||||
process.exit(3);
|
||||
|
@ -63,7 +66,7 @@ async function boot(api: PluginAPI) {
|
|||
|
||||
hsdServer.startSync();
|
||||
} catch (e: any) {
|
||||
api.logger.error((e as Error).stack);
|
||||
console.error((e as Error).stack);
|
||||
}
|
||||
})();
|
||||
} else {
|
||||
|
@ -81,14 +84,14 @@ async function boot(api: PluginAPI) {
|
|||
const plugin: Plugin = {
|
||||
name: "handshake",
|
||||
async plugin(api: PluginAPI): Promise<void> {
|
||||
const client = await boot(api);
|
||||
const client = await boot(api.config);
|
||||
|
||||
api.registerMethod("getnameresource", {
|
||||
cacheable: true,
|
||||
async handler(name: string): Promise<any> {
|
||||
async handler(request: RPCRequest): Promise<RPCResponse> {
|
||||
let resp;
|
||||
try {
|
||||
resp = await client.execute("getnameresource", name);
|
||||
resp = await client.execute("getnameresource", request.data);
|
||||
} catch (e: any) {
|
||||
e = e as Error;
|
||||
const eType = e.type.toLowerCase();
|
||||
|
|
Loading…
Reference in New Issue