Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Reverts sqlite3 changes
Browse files Browse the repository at this point in the history
Updates sqlite3 native libraries to 3.38.5
Updates sqlite3 dart library to 1.7.2
  • Loading branch information
gilnobrega committed Jun 24, 2022
1 parent 294a421 commit 4b70adc
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 8 deletions.
Binary file added .github/libsqlite3-arm64.so
Binary file not shown.
Binary file added .github/libsqlite3.so
Binary file not shown.
5 changes: 5 additions & 0 deletions .github/package.yaml
Expand Up @@ -15,6 +15,11 @@ files:
file: .github/workflows/farmr-hpool.service
mode: "0644"
user: "root"
"/etc/farmr/libsqlite3.so":
file: libsqlite3.so
mode: "0644"
user: "root"
keep: true
"/etc/farmr/config/config-xch.json":
file: config/config-xch.json
mode: "0644"
Expand Down
Binary file added .github/sqlite3.dll
Binary file not shown.
14 changes: 13 additions & 1 deletion .github/workflows/dart.yml
Expand Up @@ -59,6 +59,14 @@ jobs:
chmod +x ./farmr.sh
chmod +x ./hpool.sh
- name: Moves SQLite3 library (x86_64)
if: matrix.architecture == 'x86_64'
run: mv .github/libsqlite3.so ./libsqlite3.so

- name: Moves SQLite3 library (aarch64)
if: matrix.architecture == 'aarch64'
run: mv .github/libsqlite3-arm64.so ./libsqlite3.so

- uses: uraimo/run-on-arch-action@v2.1.0
name: Compile aarch64
id: runcmd
Expand Down Expand Up @@ -94,7 +102,7 @@ jobs:
uses: xom9ikk/dotenv@v1.0.2

- name: Compressing ${{ matrix.architecture }} .tar.gz
run: tar -czvf ./farmr-linux-${{ matrix.architecture }}.tar.gz farmr blockchain farmr.sh hpool.sh
run: tar -czvf ./farmr-linux-${{ matrix.architecture }}.tar.gz farmr blockchain farmr.sh hpool.sh libsqlite3.so

- name: Build .deb file for ${{ matrix.architecture }}
uses: kentik/pkg@v1.0.0-rc7
Expand Down Expand Up @@ -201,6 +209,10 @@ jobs:
move ./farmr.exe ./farmr.exe
move ./farmr_hpool.exe ./hpool.exe
- name: Moves SQLite3 library
if: matrix.os == 'windows-latest'
run: move ./.github/sqlite3.dll ./sqlite3.dll

- name: Created windows zip file
shell: bash
if: matrix.os == 'windows-latest'
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules:Zone.Identifier
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\giln\Downloads\farmr-29034b7b6cc51cb41ce3b43efefa279cda2baf2b.zip
38 changes: 37 additions & 1 deletion lib/utils/sqlite.dart
@@ -1,7 +1,43 @@
import 'package:sqlite3/open.dart';
import 'package:sqlite3/sqlite3.dart';
import 'dart:ffi';
import 'dart:io' as io;

Database openSQLiteDB(String dbPath, OpenMode mode) {
return sqlite3.open(dbPath, mode: mode);
late final Database db;

try {
db = sqlite3.open(dbPath, mode: mode);
} catch (error) {
open.overrideFor(
OperatingSystem.linux, _openOnLinux); //provides .so file to linux
open.overrideFor(OperatingSystem.windows,
_openOnWindows); // provides .dll file to windows
db = sqlite3.open(dbPath, mode: mode);
}

return db;
}

DynamicLibrary _openOnLinux() {
final String scriptDir =
io.File(io.Platform.script.toFilePath()).parent.path + "/";

var libraryNextToScript;

if (io.File("/etc/farmr/libsqlite3.so").existsSync())
libraryNextToScript = io.File("/etc/farmr/libsqlite3.so");
else
libraryNextToScript = io.File(scriptDir + 'libsqlite3.so');

return DynamicLibrary.open(libraryNextToScript.path);
}

DynamicLibrary _openOnWindows() {
final scriptDir = io.File(io.Platform.script.toFilePath()).parent;

final libraryNextToScript = io.File(scriptDir.path + '/sqlite3.dll');
return DynamicLibrary.open(libraryNextToScript.path);
}

int? coinbaseParentHeight(String input) {
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
@@ -1,5 +1,5 @@
name: farmr_client
version: 1.8.1
version: 1.7.6
publish_to: none
description:
environment:
Expand Down Expand Up @@ -28,5 +28,4 @@ dependencies:
tcp_scanner: 2.0.5
bech32m: 0.2.2
sqlite3: 1.7.2
sqlite3_flutter_libs: 0.5.7
hex: 0.2.0
4 changes: 0 additions & 4 deletions server/farmr_server.dart
Expand Up @@ -113,18 +113,14 @@ Future<void> main(List<String> args) async {
int farmersCount = 0;
int harvestersCount = 0;

NetSpace netspace = NetSpace();

try {
//Gets user data and Price in parallel, since both are parsed from web
final async1 = _getUserData(userID, blockchain);

final async2 = _getPrice();
final async3 = netspace.init();

harvesters = await async1;
price = await async2;
await async3;
} catch (e) {
print("Failed to connect to server.");
}
Expand Down

0 comments on commit 4b70adc

Please sign in to comment.