-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish config / analytics opt out support
- Loading branch information
1 parent
61d3841
commit 0dc6b28
Showing
10 changed files
with
251 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM rust:slim-buster | ||
|
||
RUN rustup toolchain install nightly && rustup default nightly && rustup component add rustfmt | ||
RUN apt-get update && apt-get install -y git pkg-config libudev-dev make libclang-dev clang | ||
ENV SOLANA_VERSION v1.8.14 | ||
RUN git clone -b $SOLANA_VERSION --depth 1 https://github.com/solana-labs/solana | ||
WORKDIR solana | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=/solana/target/release/build \ | ||
--mount=type=cache,target=/solana/target/release/deps \ | ||
--mount=type=cache,target=/solana/target/release/incremental \ | ||
cargo build --release | ||
|
||
FROM debian:bullseye-slim | ||
|
||
RUN apt-get update && apt-get install -y bzip2 | ||
VOLUME ["/var/lib/solana-ledger"] | ||
COPY --from=0 /solana/target/release/* /usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM solanalabs/solana:v1.9.2 | ||
|
||
RUN apt-get update && apt-get install -y curl build-essential | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
ENV PATH $PATH:/root/.cargo/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
CREATE TABLE config ( | ||
id INTEGER PRIMARY KEY, | ||
key TEXT NOT NULL, | ||
val TEXT NOT NULL, | ||
val TEXT NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
import { WBConfigRequest, WBConfigResponse } from 'types/types'; | ||
import { | ||
ConfigAction, | ||
ConfigMap, | ||
WBConfigRequest, | ||
WBConfigResponse, | ||
} from '../types/types'; | ||
import { db } from './db'; | ||
|
||
async function wbConfig(msg: WBConfigRequest): Promise<WBConfigResponse> { | ||
const { action, key } = msg; | ||
if (action === 'set') { | ||
if (action === ConfigAction.Set) { | ||
const { val } = msg; | ||
db.run('UPDATE config SET val = ? WHERE name = ?', val, key); | ||
return { val }; | ||
const existingRow = await db.get('SELECT * FROM config WHERE key = ?', key); | ||
if (existingRow) { | ||
await db.run('UPDATE config SET val = ? WHERE key = ?', val, key); | ||
} else { | ||
await db.run('INSERT INTO config (key, val) VALUES (?, ?)', key, val); | ||
} | ||
} | ||
const val = await db.get('SELECT val FROM config WHERE name = ?', key); | ||
return { val }; | ||
const cfgVals = await db.all('SELECT * FROM config'); | ||
const values: ConfigMap = {}; | ||
if (cfgVals) { | ||
cfgVals.forEach((setting: any) => { | ||
values[setting.key] = setting.val; | ||
}); | ||
} | ||
return { values }; | ||
} | ||
|
||
export default wbConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.