diff --git a/.github/libsqlite3-arm64.so b/.github/libsqlite3-arm64.so new file mode 100644 index 0000000..0836eb1 Binary files /dev/null and b/.github/libsqlite3-arm64.so differ diff --git a/.github/libsqlite3.so b/.github/libsqlite3.so new file mode 100644 index 0000000..df28d78 Binary files /dev/null and b/.github/libsqlite3.so differ diff --git a/.github/package.yaml b/.github/package.yaml index 5fbb774..2fa6f2d 100644 --- a/.github/package.yaml +++ b/.github/package.yaml @@ -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" diff --git a/.github/sqlite3.dll b/.github/sqlite3.dll new file mode 100644 index 0000000..70a8f7f Binary files /dev/null and b/.github/sqlite3.dll differ diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 71f8cf4..bc274cf 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -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 @@ -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 @@ -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' diff --git a/.gitmodules:Zone.Identifier b/.gitmodules:Zone.Identifier new file mode 100644 index 0000000..d0a3c62 --- /dev/null +++ b/.gitmodules:Zone.Identifier @@ -0,0 +1,3 @@ +[ZoneTransfer] +ZoneId=3 +ReferrerUrl=C:\Users\giln\Downloads\farmr-29034b7b6cc51cb41ce3b43efefa279cda2baf2b.zip diff --git a/lib/utils/sqlite.dart b/lib/utils/sqlite.dart index 3218e45..7edc010 100644 --- a/lib/utils/sqlite.dart +++ b/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) { diff --git a/pubspec.yaml b/pubspec.yaml index 4ea53a6..4290152 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: farmr_client -version: 1.8.1 +version: 1.7.6 publish_to: none description: environment: @@ -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 diff --git a/server/farmr_server.dart b/server/farmr_server.dart index 3d5853f..f59d0df 100644 --- a/server/farmr_server.dart +++ b/server/farmr_server.dart @@ -113,18 +113,14 @@ Future main(List 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."); }