ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.75k stars 20.22k forks source link

improve context management, error handling, and replace var with let/const #30758

Closed mrnazu closed 2 weeks ago

mrnazu commented 2 weeks ago

This pull request contains two key updates:

  1. secp256k1 JNI integration:

    • i added context destruction function named secp256k1_destroy_context to free resources after use, preventing memory leaks, which i thought it will be good contribution :)
    • implemented error handling: throws a RuntimeException in Java if context creation fails.
    • i also increased portability by using intptr_t for pointer casting to ensure compatibility across different architectures.
  2. Refactoring makeTest:

    • i replaced all instances of var with const and let to align the code with modern JavaScript standards for improved scope safety and readability. No functional changes were made.

Changes:

Tags:

Checklist:

mrnazu commented 2 weeks ago

@s1na , could you please review this PR and let me know if everything looks good? Thank you!

fjl commented 2 weeks ago

We do not use the Java binding of libsecp256k1, so this change is not useful to us.