Files
core/Blockchain.go
Kleissner 446c62bcd9 Explicitly define locations for important files and folders in the config file.
This removes the hardcoded paths for the blockchain and warehouse.
2021-11-17 17:37:04 +01:00

29 lines
768 B
Go

/*
File Name: Blockchain.go
Copyright: 2021 Peernet s.r.o.
Author: Peter Kleissner
*/
package core
import (
"os"
"github.com/PeernetOfficial/core/blockchain"
)
// UserBlockchain is the user's blockchain and exports functions to directly read and write it
var UserBlockchain *blockchain.Blockchain
// initUserBlockchain initializes the users blockchain. It creates the blockchain file if it does not exist already.
// If it is corrupted, it will log the error and exit the process.
func initUserBlockchain() {
var err error
UserBlockchain, err = blockchain.Init(peerPrivateKey, config.BlockchainMain)
if err != nil {
Filters.LogError("initUserBlockchain", "error: %s\n", err.Error())
os.Exit(ExitBlockchainCorrupt)
}
}