Merge pull request #6 from logos-storage/chore/update-to-0.3.1

chore: update project to 0.3.2
This commit is contained in:
Arnaud 2026-03-18 12:22:32 +04:00 committed by GitHub
commit 828667de07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 55 deletions

View File

@ -19,7 +19,7 @@ jobs:
name: linux name: linux
- os: macos-latest - os: macos-latest
name: macos name: darwin
cpu: arm64 cpu: arm64
- os: windows-latest - os: windows-latest

View File

@ -4,7 +4,7 @@ LIBS_DIR := $(abspath ./libs)
# Flags for CGO to find the headers and the shared library # Flags for CGO to find the headers and the shared library
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
CGO_CFLAGS := -I$(LIBS_DIR) CGO_CFLAGS := -I$(LIBS_DIR)
CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) CGO_LDFLAGS := -L$(LIBS_DIR) -lstorage -Wl,-rpath,$(LIBS_DIR)
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
BIN_NAME := example.exe BIN_NAME := example.exe
@ -15,15 +15,15 @@ endif
# Configuration for fetching the right binary # Configuration for fetching the right binary
OS ?= "linux" OS ?= "linux"
ARCH ?= "amd64" ARCH ?= "amd64"
VERSION ?= "v0.0.21" VERSION ?= "v0.3.2"
DOWNLOAD_URL := "https://github.com/codex-storage/codex-go-bindings/releases/download/$(VERSION)/codex-${OS}-${ARCH}.zip" DOWNLOAD_URL := "https://github.com/logos-storage/logos-storage-nim/releases/download/$(VERSION)/libstorage-${OS}-${ARCH}-$(VERSION).zip"
all: run all: run
fetch: fetch:
@echo "Fetching libcodex from GitHub Actions from: ${DOWNLOAD_URL}" @echo "Fetching libstorage from GitHub Actions from: ${DOWNLOAD_URL}"
curl -fSL --create-dirs -o $(LIBS_DIR)/codex-${OS}-${ARCH}.zip ${DOWNLOAD_URL} curl -fSL --create-dirs -o $(LIBS_DIR)/libstorage-${OS}-${ARCH}-$(VERSION).zip ${DOWNLOAD_URL}
unzip -o -qq $(LIBS_DIR)/codex-${OS}-${ARCH}.zip -d $(LIBS_DIR) unzip -o -qq $(LIBS_DIR)/libstorage-${OS}-${ARCH}-$(VERSION).zip -d $(LIBS_DIR)
rm -f $(LIBS_DIR)/*.zip rm -f $(LIBS_DIR)/*.zip
build: build:
@ -38,4 +38,4 @@ endif
clean: clean:
rm -f $(BIN_NAME) rm -f $(BIN_NAME)
rm -Rf $(LIBS_DIR)/* rm -Rf $(LIBS_DIR)/*

View File

@ -1,8 +1,8 @@
# Example Codex Go Bindings # Example Logos Storage Go Bindings
This repository demonstrates how to integrate the [Codex Go bindings](https://github.com/codex-storage/codex-go-bindings) into a Go project. This repository demonstrates how to integrate the [Logos Storage Go bindings](https://github.com/logos-storage/logos-storage-go-bindings/) into a Go project.
The project starts a Codex node, uploads and downloads some data and then stops the node. The project starts a Logos Storage node, uploads and downloads some data and then stops the node.
## Usage ## Usage
@ -22,13 +22,13 @@ The default `OS` is `linux` and the default `ARCH` is `amd64`.
You can provide them as environment variables: You can provide them as environment variables:
```sh ```sh
OS="macos" ARCH="arm64" make fetch OS="darwin" ARCH="arm64" make fetch
``` ```
You can change the version by providing it as environment variables: You can change the version by providing it as environment variables:
```sh ```sh
VERSION="v0.0.21" make fetch VERSION="v0.3.2" make fetch
``` ```
The default folder is `libs`, you can change it by editing the `Makefile`. The default folder is `libs`, you can change it by editing the `Makefile`.

2
go.mod
View File

@ -2,4 +2,4 @@ module example
go 1.25.1 go 1.25.1
require github.com/codex-storage/codex-go-bindings v0.0.21 require github.com/logos-storage/logos-storage-go-bindings v0.3.2

26
go.sum
View File

@ -1,24 +1,2 @@
github.com/codex-storage/codex-go-bindings v0.0.1 h1:u6Z/Y01Wpxckrg4ATsO/xD/9XVRa6PdHy2AVHYjx9iU= github.com/logos-storage/logos-storage-go-bindings v0.3.2 h1:pG2j+sPyhb4u04qK12F1Rpo02HxKy22ENIGvXzbgMMM=
github.com/codex-storage/codex-go-bindings v0.0.1/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg= github.com/logos-storage/logos-storage-go-bindings v0.3.2/go.mod h1:5NzkHakOYX0iwgJk9X6NKN3AoDIvr8JTwpnl5SWdPVg=
github.com/codex-storage/codex-go-bindings v0.0.10 h1:szqFD1CWb5ELY+pnlj87PM+nUIiZwjnFYLzTgbiGsDQ=
github.com/codex-storage/codex-go-bindings v0.0.10/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.11 h1:mGzkebWuCwtfNinyplNBZ+QFlvlu0Wkg+wQ3fNegCJc=
github.com/codex-storage/codex-go-bindings v0.0.11/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.13 h1:svQT3hzH+J5ys5cPqNUXxrPYi57bfoNrzywFZiJZJDE=
github.com/codex-storage/codex-go-bindings v0.0.13/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.14 h1:Pk/DDEGW3OGTefEyoBHvw2RUgpAzG6TBtoMmtH1HXI4=
github.com/codex-storage/codex-go-bindings v0.0.14/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.15 h1:7usvjbqm5BjRICk7uLu1C+fU69cSLvefcH7rdCy9MTg=
github.com/codex-storage/codex-go-bindings v0.0.15/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.16 h1:rDjkcR9NdN6JKVAdnX7RSGkkc5l3/din4QMDRAUJZ7w=
github.com/codex-storage/codex-go-bindings v0.0.16/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.17 h1:lKtYBqUIDsZdgEe1f4DGfv/K+ANx9b7VUtfIu8YOT6A=
github.com/codex-storage/codex-go-bindings v0.0.17/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.18 h1:0l9XEoH9O5Akg7KCJreZq5jQxdky8Y79T/2TopHdBIY=
github.com/codex-storage/codex-go-bindings v0.0.18/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.19 h1:zhEhwzcavvYdfkHpB5BH+PaqYvQ4VonIKhebS1vbKh0=
github.com/codex-storage/codex-go-bindings v0.0.19/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.20 h1:vK9jU8vafSJkMpOEHdPiQ9S8owSGUaPGVUxb7hKaIck=
github.com/codex-storage/codex-go-bindings v0.0.20/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=
github.com/codex-storage/codex-go-bindings v0.0.21 h1:DAwXw2Xq7wyKyI5j3Jk8ZYBruFP9dOpqEeVMOyEsJxA=
github.com/codex-storage/codex-go-bindings v0.0.21/go.mod h1:8yC11Vr1Mu5sqZyQ33GaSCr0uUIbQnGkm0aWqZj62Kg=

31
main.go
View File

@ -2,34 +2,33 @@ package main
import ( import (
"bytes" "bytes"
"context"
"log" "log"
"os" "os"
"github.com/codex-storage/codex-go-bindings/codex" "github.com/logos-storage/logos-storage-go-bindings/storage"
) )
func main() { func main() {
node, err := codex.New(codex.Config{ node, err := storage.New(storage.Config{
BlockRetries: 5, BlockRetries: 5,
}) })
if err != nil { if err != nil {
log.Fatalf("Failed to create Codex node: %v", err) log.Fatalf("Failed to create Logos Storage node: %v", err)
} }
version, err := node.Version() version := node.Version()
if err != nil {
log.Fatalf("Failed to get Codex version: %v", err) log.Printf("Logos Storage version: %s", version)
}
log.Printf("Codex version: %s", version)
if err := node.Start(); err != nil { if err := node.Start(); err != nil {
log.Fatalf("Failed to start Codex node: %v", err) log.Fatalf("Failed to start Logos Storage node: %v", err)
} }
log.Println("Codex node started") log.Println("Logos Storage node started")
buf := bytes.NewBuffer([]byte("Hello World!")) buf := bytes.NewBuffer([]byte("Hello World!"))
len := buf.Len() len := buf.Len()
cid, err := node.UploadReader(codex.UploadOptions{Filepath: "hello.txt"}, buf) cid, err := node.UploadReader(context.Background(), storage.UploadOptions{Filepath: "hello.txt"}, buf)
if err != nil { if err != nil {
log.Fatalf("Failed to upload data: %v", err) log.Fatalf("Failed to upload data: %v", err)
} }
@ -41,11 +40,11 @@ func main() {
} }
defer f.Close() defer f.Close()
opt := codex.DownloadStreamOptions{ opt := storage.DownloadStreamOptions{
Writer: f, Writer: f,
} }
if err := node.DownloadStream(cid, opt); err != nil { if err := node.DownloadStream(context.Background(), cid, opt); err != nil {
log.Fatalf("Failed to download data: %v", err) log.Fatalf("Failed to download data: %v", err)
} }
@ -57,11 +56,11 @@ func main() {
// <-ch // <-ch
if err := node.Stop(); err != nil { if err := node.Stop(); err != nil {
log.Fatalf("Failed to stop Codex node: %v", err) log.Fatalf("Failed to stop Logos Storage node: %v", err)
} }
log.Println("Codex node stopped") log.Println("Logos Storage node stopped")
if err := node.Destroy(); err != nil { if err := node.Destroy(); err != nil {
log.Fatalf("Failed to destroy Codex node: %v", err) log.Fatalf("Failed to destroy Logos Storage node: %v", err)
} }
} }