mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 15:02:32 +00:00

* [NOD-350] Implement testnet faucet * [NOD-350] Add JSON annotations to api server response types * [NOD-350] Fix IP check query, update IP usage with upsert, and make IP a primary key * [NOD-377] Remove redundant float conversion * [NOD-377] Change not current database error message * [NOD-377] change API route from /money_request to /request_money * [NOD-377] Add a constant for 24 hours * [NOD-377] Remove redundant call for getWalletUTXOSet() * [NOD-377] Condition refactoring * [NOD-377] Fix POST request to API server content type * [NOD-350] Rename day -> timeBetweenRequests * [NOD-377] Rename timeBetweenRequests -> minRequestInterval, timeBefore24Hours -> minRequestInterval * [NOD-350] Rename file responsetypes -> response_types * [NOD-350] Rename convertTxModelToTxResponse -> convertTxDBModelToTxResponse * [NOD-350] Explicitly select blue_score in fetchSelectedTipBlueScore * [NOD-350] Refactor and add comments * [NOD-350] Make calcFee use MassPerTxByte * [NOD-350] Convert IP column to varchar(39) to allow ipv6 addresses * [NOD-350] Add comments to isFundedAndIsChangeOutputRequired * [NOD-350] Remove approximateConfirmationsForCoinbaseMaturity * [NOD-350] Fix comments
30 lines
698 B
Go
30 lines
698 B
Go
package panics
|
|
|
|
import (
|
|
"github.com/daglabs/btcd/logs"
|
|
"os"
|
|
"runtime/debug"
|
|
)
|
|
|
|
// HandlePanic recovers panics, log them, and then exits the process.
|
|
func HandlePanic(log logs.Logger, backendLog *logs.Backend) {
|
|
if err := recover(); err != nil {
|
|
log.Criticalf("Fatal error: %+v", err)
|
|
log.Criticalf("Stack trace: %s", debug.Stack())
|
|
if backendLog != nil {
|
|
backendLog.Close()
|
|
}
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// GoroutineWrapperFunc returns a goroutine wrapper function that handles panics and write them to the log.
|
|
func GoroutineWrapperFunc(log logs.Logger, backendLog *logs.Backend) func(func()) {
|
|
return func(f func()) {
|
|
go func() {
|
|
defer HandlePanic(log, backendLog)
|
|
f()
|
|
}()
|
|
}
|
|
}
|