From 21b0f45997d247479e466738dc3aa1bad38e1c35 Mon Sep 17 00:00:00 2001 From: lovedret Date: Wed, 22 May 2024 23:07:56 +0800 Subject: [PATCH] Fix bug --- internal/postrs/proof.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/postrs/proof.go b/internal/postrs/proof.go index d23d577f1..3788fde1c 100644 --- a/internal/postrs/proof.go +++ b/internal/postrs/proof.go @@ -87,13 +87,15 @@ func GeneratePow(dataDir string, postServer string, priority uint, challenge []b config.pow_difficulty[i] = C.uchar(b) } - cPow := C.generate_pow(dataDirPtr, challengePtr, config, C.size_t(nonces), powFlags, postServerPtr, C.size_t(priority)) + cPow := C.generate_pow(dataDirPtr, (*C.uchar)(challengePtr), config, C.size_t(nonces), powFlags, postServerPtr, C.size_t(priority)) - if cPow == nil { + goStr := C.GoString(cPow) + C.free(unsafe.Pointer(cPow)) + if &goStr == nil { return nil, fmt.Errorf("got nil") } - return &cPow, nil + return &goStr, nil } func GenerateProof(dataDir string, postServer string, powResponse string, challenge []byte, logger *zap.Logger, nonces, threads uint, K1, K2 uint32, powDifficulty [32]byte, powFlags PowFlags, options ...PostOptionFunc) (*shared.Proof, error) {