Documentation ¶
Overview ¶
Package simpar stands for 'simulation parameters'. In this package it is defined what a block problem is, how it is constructed and how to interface with the HEP environment. Defining problems is the responsibility of the Root Authority and there both is a way to manually enter a problem via locally hosted website or it will automatically generate a problem so that transaction throughput does not suffer if no manually defined problems are queued. RA only: In order to manually define a new simulation task navigate your browser to localhost:8087/send-simtask after you have found at least one peer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RunSimMutex sync.Mutex
RunSimMutex is a mutex used to prevent a miner from working on old and new block problem at the same time (e.g. while working on old problem a new one is received and this function triggered again)
Functions ¶
Types ¶
type SimulationHeader ¶
type SimulationHeader struct { // metadata CreationTime uint64 // when was this first broadcast ExpirationTime uint64 // until when does problem solution have to be uploaded BlockID uint32 // current blockID + 1 (human-readable value so that it's clear on which blocks this problem builds) AmountSubProblems uint32 // amount of sub problems that need to be solved by the miners (length of SimulationParameters slice) RAcommit hash.Hash // Keccak256(PrevBlockHash + secretBytes), which later is used in winner selection algorithm SubProblemHashes []hash.Hash // hash of [ serialized(SimulationParameters) + serialized(SimulationHeader) ] }
SimulationHeader holds the metadata of a problem definition. It has values such as CreationTime, ExpirationTime, BlockID, AmountSubProblems and SubProblemHashes.
func NewSimulationHeader ¶
func NewSimulationHeader(creationTime uint64, expirationTime uint64, blockID uint32, amountSubProblems uint32, raCommit hash.Hash, simParSlice []SimulationParameters) SimulationHeader
NewSimulationHeader is the constructor function for SimulationHeader. In addition to header related values it also requires the full slice of problem definitions.
type SimulationParameters ¶
type SimulationParameters struct { Seed uint32 // Pythia max seed: 900000000 (negative would be default seed, so only positive here) AmountEvents uint32 RunID uint64 Particles uint32 // 0=pions, 1=eplus, 2=proton Momentum float64 Theta float64 }
SimulationParameters holds the parameters that define the simulation.
func NewSimulationParameters ¶
func NewSimulationParameters(seed uint32, amountEvents uint32, runID uint64, particles uint32, momentum float64, theta float64) SimulationParameters
NewSimulationParameters is the constructor function for SimulationParameters.
type SimulationTask ¶
type SimulationTask struct { // problem definitions (contains all subproblems) SimPar []SimulationParameters // metadata of this block problem SimHeader SimulationHeader ProblemHash hash.Hash // hash of serialized SimHeader (this is the unique ProblemID) }
SimulationTask is equal to a full problem definition. It contains all required information (SimulationParameters and SimulationHeader).
func NewSimulationTask ¶
func NewSimulationTask(simPar []SimulationParameters, simHeader SimulationHeader) SimulationTask
NewSimulationTask is the constructor function for SimulationTask. It takes a slice of problem definitions and a header and returns the hash of the block problem along with the problem itself.
func (SimulationTask) GetHash ¶
func (s SimulationTask) GetHash() hash.Hash
GetHash is a helper method of SimulationTask that returns the unique problem hash by serializing and hashing the block problem header.
func (SimulationTask) PrintSimTask ¶
func (s SimulationTask) PrintSimTask()
PrintSimTask is a method of SimulationTask that visually prints relevant info of the entire block problem.
func (SimulationTask) RunSimulation ¶
func (s SimulationTask) RunSimulation() ([]byte, hash.Hash, error)
RunSimulation takes a SimulationParameters object, runs the simulation and returns the serialized block problem solution (which contains all subproblem solutions) and an error. Note: The simulation can only be run if the code is run in the CBM environment. In order to be able to use root in cbm env ensure you have followed the cbmroot tutorial in this repo.