Compare commits

...

4 Commits

Author SHA1 Message Date
Derrick Hammer cf201ce7f4
*Add apt packaging
ci/woodpecker/push/woodpecker Pipeline is pending Details
2022-12-07 04:36:47 -05:00
Derrick Hammer 7fabe8e61d
*use logger 2022-12-07 04:27:19 -05:00
Derrick Hammer 30f48f81ac
*Update api usage 2022-12-07 04:24:42 -05:00
Derrick Hammer bce2e9e4fc
*Need to return RPCResponse response structure 2022-08-31 00:10:47 -04:00
6 changed files with 84 additions and 16 deletions

41
.woodpecker.yml Normal file
View File

@ -0,0 +1,41 @@
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 Normal file
View File

@ -0,0 +1,23 @@
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

View File

@ -6,10 +6,11 @@
"build": "bash build.sh"
},
"devDependencies": {
"@lumeweb/relay": "https://github.com/LumeWeb/relay.git",
"@types/node": "^18.11.10",
"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"

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
systemctl restart lumeweb-relay.service

3
pkg/scripts/preremove.sh Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
systemctl restart lumeweb-relay.service

View File

@ -1,9 +1,4 @@
import type {
Plugin,
PluginAPI,
RPCResponse,
RPCRequest,
} from "@lumeweb/relay";
import type { Plugin, PluginAPI } from "@lumeweb/relay-types";
// @ts-ignore
import rand from "random-key";
// @ts-ignore
@ -11,9 +6,11 @@ import SPVNode from "hsd/lib/node/spvnode.js";
// @ts-ignore
import { NodeClient } from "hs-client";
async function boot(config: any) {
async function boot(api: PluginAPI) {
let hsdServer: SPVNode;
const { config } = api;
let clientArgs = {
network: "main",
host: "127.0.0.1",
@ -38,20 +35,20 @@ async function boot(config: any) {
});
hsdServer.on("abort", async (err: any) => {
const timeout = setTimeout(() => {
console.error("Shutdown is taking a long time. Exiting.");
api.logger.error("Shutdown is taking a long time. Exiting.");
process.exit(3);
}, 5000);
timeout.unref();
try {
console.error("Shutting down...");
api.logger.error("Shutting down...");
await hsdServer.close();
clearTimeout(timeout);
console.error((err as Error).stack);
api.logger.error((err as Error).stack);
process.exit(2);
} catch (e: any) {
console.error(
api.logger.error(
`Error occurred during shutdown: ${(e as Error).message}`
);
process.exit(3);
@ -66,7 +63,7 @@ async function boot(config: any) {
hsdServer.startSync();
} catch (e: any) {
console.error((e as Error).stack);
api.logger.error((e as Error).stack);
}
})();
} else {
@ -84,14 +81,14 @@ async function boot(config: any) {
const plugin: Plugin = {
name: "handshake",
async plugin(api: PluginAPI): Promise<void> {
const client = await boot(api.config);
const client = await boot(api);
api.registerMethod("getnameresource", {
cacheable: true,
async handler(request: RPCRequest): Promise<RPCResponse> {
async handler(name: string): Promise<any> {
let resp;
try {
resp = await client.execute("getnameresource", request.data);
resp = await client.execute("getnameresource", name);
} catch (e: any) {
e = e as Error;
const eType = e.type.toLowerCase();