mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-05 23:13:09 +00:00
Add codex revision
This commit is contained in:
parent
23ffa5a1fb
commit
692c2805fd
@ -84,6 +84,10 @@ package main
|
||||
CODEX_CALL(codex_version(codexCtx, (CodexCallback) callback, resp));
|
||||
}
|
||||
|
||||
static void cGoCodexRevision(void* codexCtx, void* resp) {
|
||||
CODEX_CALL(codex_revision(codexCtx, (CodexCallback) callback, resp));
|
||||
}
|
||||
|
||||
static void cGoCodexStart(void* codexCtx, void* resp) {
|
||||
CODEX_CALL(codex_start(codexCtx, (CodexCallback) callback, resp));
|
||||
}
|
||||
@ -216,6 +220,19 @@ func (self *CodexNode) CodexVersion() (string, error) {
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
|
||||
func (self *CodexNode) CodexRevision() (string, error) {
|
||||
var resp = C.allocResp()
|
||||
defer C.freeResp(resp)
|
||||
C.cGoCodexRevision(self.ctx, resp)
|
||||
|
||||
if C.getRet(resp) == C.RET_OK {
|
||||
return C.GoStringN(C.getMyCharPtr(resp), C.int(C.getMyCharLen(resp))), nil
|
||||
}
|
||||
|
||||
errMsg := "error CodexStart: " + C.GoStringN(C.getMyCharPtr(resp), C.int(C.getMyCharLen(resp)))
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
|
||||
func (self *CodexNode) CodexStart() error {
|
||||
var resp = C.allocResp()
|
||||
defer C.freeResp(resp)
|
||||
@ -293,6 +310,14 @@ func main() {
|
||||
|
||||
log.Println("Codex version:", version)
|
||||
|
||||
revision, err := node.CodexRevision()
|
||||
if err != nil {
|
||||
fmt.Println("Error happened:", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("Codex revision:", revision)
|
||||
|
||||
log.Println("Starting Codex...")
|
||||
|
||||
err = node.CodexStart()
|
||||
|
||||
@ -35,6 +35,11 @@ int codex_version(
|
||||
CodexCallback callback,
|
||||
void* userData);
|
||||
|
||||
int codex_revision(
|
||||
void* ctx,
|
||||
CodexCallback callback,
|
||||
void* userData);
|
||||
|
||||
int codex_start(void* ctx,
|
||||
CodexCallback callback,
|
||||
void* userData);
|
||||
|
||||
@ -114,6 +114,20 @@ proc codex_version(
|
||||
|
||||
return RET_OK
|
||||
|
||||
proc codex_revision(
|
||||
ctx: ptr CodexContext, callback: CodexCallback, userData: pointer
|
||||
): cint {.dynlib, exportc.} =
|
||||
initializeLibrary()
|
||||
checkLibcodexParams(ctx, callback, userData)
|
||||
callback(
|
||||
RET_OK,
|
||||
cast[ptr cchar]($conf.codexRevision),
|
||||
cast[csize_t](len($conf.codexRevision)),
|
||||
userData,
|
||||
)
|
||||
|
||||
return RET_OK
|
||||
|
||||
proc codex_destroy(
|
||||
ctx: ptr CodexContext, callback: CodexCallback, userData: pointer
|
||||
): cint {.dynlib, exportc.} =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user