Documentation ¶
Overview ¶
Package simsol stands for 'simulation solution' and it contains structs and functions to work with files created by running simulation tasks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateFolder ¶
func CreateFolder(folderPath string)
CreateFolder takes a path to a folder and creates that folder if it does not exist already.
func DeleteFolder ¶
func DeleteFolder(folderPath string)
DeleteFolder takes a path to a folder and deletes it (and all files it contains) if it does exist.
func WriteSimsolbytesToFilesystem ¶
WriteSimsolbytesToFilesystem takes a serialized BlockProblemSolution and the blockID that the solution will be included as winner solution in, then deserializes the solution and then writes the sim files to disk.
Types ¶
type BlockProblemSolution ¶
type BlockProblemSolution struct { Subsolutions []SimulationSolution ProblemHash hash.Hash // unique block problem hash that represents the problem that was solved with this solution SolutionHash hash.Hash // hash of this solution is determined by combining and hashing the fields Subsolutions and ProblemHash. }
BlockProblemSolution contains all subproblem solution, the problem ID and the solution hash. This is what nodes serializes and broadcast to RA after they have finished all simulations.
func NewBlockProblemSolution ¶
func NewBlockProblemSolution(subSolSlice []SimulationSolution, problemHash hash.Hash) BlockProblemSolution
NewBlockProblemSolution is the constructor of lockProblemSolution. It automatically determines the solution hash which is stored in the field SolutionHash.
type MinerCommitment ¶
type MinerCommitment struct { OriginalSenderNodeID string // NodeID who this commitment is originally from. This is required because pubsub.Message.ReceivedFrom is the address of whoever forwarded the message to you, but this does not have to be the original sender! HashCommit hash.Hash // Hash of hash (prove you know the hash without revealing it) SigCommit []byte // Sig of hash (so that miners can not just re-broadcast the Hash-of-hashes of other miners' solutions) }
MinerCommitment is a struct used after a miner solved the block problem to store original sender ID, Hash(Hash(solutiondata)) and Sig(solutionHash)
type SimulationPath ¶
SimulationPath holds filepaths to the data that was created by running a simulation. Each subproblem solution has its own SimulationPath instance.
func NewSimulationPath ¶
func NewSimulationPath(geoFilePath string, mcFilePath string) SimulationPath
NewSimulationPath is the constructor function of SimulationPath.
func (SimulationPath) SimsolReadBytes ¶
func (simPath SimulationPath) SimsolReadBytes() ([]byte, []byte, error)
SimsolReadBytes takes a SimulationPath and then reads the bytes of both files from the filesystem and returns them along with an error.
type SimulationSolution ¶
SimulationSolution holds a subproblem solution. It stores the different files that are created during simulation as bytes.
func NewSimulationSolution ¶
func NewSimulationSolution(simPath SimulationPath) (SimulationSolution, error)
NewSimulationSolution is the constructor function of SimulationSolution. It reads simulation-related files from the file system, stores them in a SimulationSolution instance and returns all of this data along with an error.