package
0.9.32
Repository: https://github.com/felix314159/gophy.git
Documentation: pkg.go.dev

# Functions

AddPendingSimpar is used after the RA used to locally hosted website to broadcast a new simulation task to add the input values as SimulationParameters object to the slice PendingSimpars.
AddPendingTransaction adds a transaction received via the transaction topic handler to the slice PendingTransactions in a concurrency-safe way.
AmIInterestedInThisDirectChatData checks whether a node in a given sync mode is interested of received data of a given type.
BlockchainVerifyValidity goes through every block in the local blockchain and ensures that the chaindb data is valid.
BlockGetBytesFromDb takes a db key, checks whether this value is "latest" or a valid key in the local database and if so, returns the value of this key-value pair as bytes.
BlockVerifyValidity takes a bool (iAmFullNode), and two blocks (might just be header if you are light node) in serialized form (prev and new) and another bool (newBlockIsFull is used so that light nodes can receive new full blocks broadcast by the RA and extract their header) and then checks whether the latter block or header can be a continuation of the former without affecting the state.
BlockWriteToDb writes only to the chaindb bucket.
BoltBucketExists checks whether a given bucket name exists in the db or not.
BoltGetChainDBKeys returns a []string which contains all keys of chaindb bucket.
BoltGetDbKeys takes the name of a db bucket and returns a sorted []string which contains all keys of that bucket.
BytesToChainDBRequest unmarshals a serialized ChainDBRequest if possible.
BytesToSimsolBlockProblemSolution takes bytes and deserializes them into simsol.BlockProblemSolution.
BytesToStringSlice unmarshals []byte to []string.
ChainDbGetGenesisHash retrieves the hash of the genesis block and returns it as string.
ChainDBRequestToBytes casts an instance of ChainDBRequest to bytes by serializing it.
CreatePseudoBlockchainFull is a helper testing function which creates a few example block.Block and adds them to pouw_blockchain.db.
CreatePseudoBlockchainLight is a helper testing function which creates a few example block.Header and adds them to pouw_blockchain.db.
CreateRandomTransaction is used to generate a (pseudo-)random, valid transaction.
DetermineLocallyMissingBlockHashes takes a slice of received blockHashes and then compares them with locally available blocks to determine which blocks are missing.
DiscoverPeers uses Kademlia DHT bootstrap nodes and the Rendezvous protocol.
EncryptKeyAndWriteToFile takes a private ed25519 key, a password and a filepath string and writes the encrypted key in OpenSSH format to that location.
FullBlockBytesToBlock takes a serialized byte slice that represents a full block and returns a block.Block object.
FullBlockBytesToBlockLight takes a serialized byte slice that represents a block.Block and returns a block.Header (which basically is a light block) and its hash.
FullBlockToFullBlockBytes takes a block instance and serializes it and returns these serialized block bytes.
GenerateRandomIntBetween takes min and max and returns an int in [min,max].
GenerateRandomStringOfLength generates random bytes, encodes them to base58 (like libp2p peerIDs) and return the first stringlen characters of that string (stringlen is the int input parameter of the function).
GetAllBlockHashesAscending goes through every block of the local database and returns their hashes in ascending order (ascending by block ID, not by hash).
GetAllBlockHashesAscendingSerialized uses GetAllBlockHashesAscending() to get a string slice of all block hashes and then return them as serialized msgpack object.
GetPendingTransactionSlice returns slice of currently pending transactions.
HandleIncomingChatMessage is used to handle directly incoming data.
HeaderBytesToBlockLight takes a serialized byte slice that represents a block.Header and returns a block.Header.
HeaderToBytes takes a block.Header and returns it as msgpacked []byte.
HeaderToHash takes a block.Header and returns its hash.Hash.
HexStringToNumber takes the output string of a hash function and returns a uint64 number that is derived from this value.
InitDHT connects to a few known default bootstrap nodes (they enable distributed node discovery and are the only centralized necessity in kademlia DHT).
IsPendingSimparAvailable checks whether PendingSimpars is empty or not.
NewActiveMiner is the constructor for ActiveMiner.
NewChainDBRequest is the constructor of ChainDBRequest.
NewLiveData is the constructor for LiveData.
NewTransportStruct is the constructor for TransportStruct.
NodeIDStringToPubKey uses btcsuite's base58 decode to convert NodeID to the Ed25519 public key of that node.
PendingTransactionsRemoveThese takes a list of transactions that were included in a block and removes them from pending transactions if possible Note: AFAIK there should be no need to panic if a transaction that is not in pending was included in a block.
PerformStateDbTransaction takes transaction related info (state of involved wallets after tx was processed) as input and performs the transaction to affect the state.
PrintBlock prints the entire block content.
PrintBlockHeader prints the provided block.Header.
PrintSerializedStringSliceBlockHashes takes a serialized slice of strings, and prints its content after deserialization.
PrintStateDB gets all keys from the statedb, retrieves the corresponding values (wallets) and prints their info.
PrintStateDbWallet takes a StateValueStruct and prints it.
PubKeyToNodeID takes a PubKey and returns the human-readable node ID (12D3Koo...).
RACreateNewBlock is used by RA to create new chaindb block after block problem has been solved and winner has been chosen.
RAGetPendingTransactions is used by RA to get up to <TransactionsPerBlockCap> many transactions from the PendingTransactions slice.
RaGetProblemDefMessage is used to generate a new valid simtask.
RALoop is the loop that the RA is in.
RandomShortSleep is used to sleep for a short amount (between 5 and 15 milliseconds).
RAReceivedSimSol is used by the RA to determine the validity of a received simulation solution and to store it if it is valid.
ReadFromBucket takes a key as string and returns its corresponding value as []byte.
ReadKeyFromFileAndDecrypt takes the password that the key was encrypted with and the location of the key and returns the decrypted ed25519.PrivateKey).
RemoveDuplicateStrings removes duplicate strings from []string and return the cleansed slice that does not contain any duplicates.
ResetAndInitializeGenesis deletes the local database, creates a new database with chaindb and statedb buckets and then initializes the genesis block.
ResetBucket deletes and re-creates the given bucket.
SendViaChat is used to send a message directly to a peer (no topic involved).
SimparToSimtask takes a simpar slice that was retrieved from the queue 'PendingSimpars', sets the correct value for each 'Seed' field, then determines further values needed to construct SimulationTask and then returns 3 values: It returns: 1.
SimSolToBytes takes a simsol.SimulationSolution, serializes it and returns that data and an error.
SimtaskBytesToSimTask takes serialized SimulationTask as bytes and returns it as simpar.SimulationTask object.
SimtaskToBytes takes a SimulationTask and returns the msgpacked bytes.
SimtaskValidityCheck takes a simulationTask (problem def) and the latest block header, and then determines whether this simTask is valid or not and returns err (only nil return means valid).
SortStringSliceAscending takes a string slice and sorts it (original is modified) ascending, case-insensitive.
StateDbAwardWinner is used when a block that has been signed by the RA is received to award the block's winner address.
StateDbBytesToStruct takes bytes that were retrieved from the statedb and returns the corresponding StateValueStruct instance and an error.
StateDbGetMerkleProof takes a nodeID and a stateMerkleTree and returns the merkle proof for that leaf.
StateDbGetMerkleTree uses bbolt to get all keys of statedb in ascending order, then gets their values and hashes them, then these hashes are used ascending as leafs of the merkle tree.
StateDbNodeIDToMerkleHash takes a nodeID as string and returns its corresponding hash in the state merkle tree.
StateDbProcessAndUpdateBlock takes a block and performs its transactions in the statedb (statedb is affected) while also awarding the winner of this block.
StateDbStructToBytes takes a StateValueStruct and msgpack serializes it.
StateDbTransactionIsAllowed takes a transaction and checks whether it is valid or not.
StringToMode takes a string that represents a Mode and returns the Mode and error.
SubproblemIsValid takes the string values of the fields of the submit-simtask form and aims to ensure that each field is valid (e.g.
SyncNode starts an automatic sync between nodes.
TopicChaindbReceiveEvent is a topic-specific function that is triggered when a node receives a message for topic "pouw_chaindb".
TopicNewBlockReceiveEvent is a topic-specific function that is triggered when a node receives a message in topic "pouw_newBlock".
TopicNewCommitmentReceiveEvent is a topic-specific function that is triggered when a node receives a message for topic "pouw_minerCommitments".
TopicNewProblemReceiveEvent is a topic-specific function that is triggered when a node receives a message in topic "pouw_newProblem".
TopicNewRASecretRevealEvent is a topic-specific function that is triggered when a node receives a message in topic "pouw_raSecretReveal".
TopicNewTransactionReceiveEvent is a topic-specific function that is triggered when a node receives a message for topic "pouw_transactions".
TopicReceiveMessage is responsible for calling a suitable topic handler function whenever a message is received on any subscribed topic.
TopicSendMessage is used to automatically (as in no user input from console required) send messages to a pubsub topic.
TransactionIsValid takes the string values of the fields of the submit-transaction form and aims to ensure that each field is valid.
TransactionListFilterOutInvalid takes a transaction list and filter out transactions that can not be performed.
TransactionSliceToBytes serializes []transaction.Transaction and returns []byte and error.
TransactionToBytes serializes a transaction and returns []byte and error.
TransportStructExtraction takes the expected DataID (the data type you requested) and a serialized TransportStruct (contains data you received, includes metadata) and a bool (which when true says only accept the data if it was originally sent by the RA) and then determines five things.
TransportStructGetDataID takes a serialized TransportStruct, deserializes it and returns the enum value of DataID.
UnpackSerializedStringSliceBlockHashes takes msgpack serialized slice of strings, then unpacks and returns it.
WinnerSelection takes a slice of elgible miners and the RAcommitSecret and then performs the winner selection after the block problem has expired and RA has published its secretCommitBytes.
WriteToBucket is the equivalent of BlockWriteToDb but instead of writing to the chaindb bucket it writes to the statedb or simdb bucket.

# Constants

BlockTime is the interval at which RA broadcasts new problems and ideally creates new blocks.
DebugLogging affects how much data is being logged, setting it to true results in a huge log file because all state and state merkle related info is logged.
MaxReferenceLength defines an upper cap for how many chars are allowed to be put in the transaction 'Reference' field.
1 GB.
RANodeID holds the known nodeID of root authority (before production use, if you want to change RA private key ensure that this address is correctly derived from your new RA public key).
RendezvousString is the rendezvous string for initial node discovery.
No description provided by the author
No description provided by the author
No description provided by the author
ensure to NOT start at 0 because that is the nil value of int which could lead to confusing problems.
No description provided by the author
No description provided by the author
Miners should be in Continuous_Mine, that's why there is no Passive_Mine.
No description provided by the author
rough estimate rationale can be found in transaction.go.
TransactionsPerNodePerBlockCap is an upper cap to the amount of tx each sender is allowed to have included in a singe block (avoids high fee tx spam of a rich malicious node to prevent tx of other nodes).
iota ensures auto-increment for each element.
you want to request chaindb data from any node.
.
Struct that holds BlockProblemHelper and slice of pending transactions.
defined in simsol.MinerCommitment.
string that is revealed as soon as block problem expires.
this means you are sending/receiving a simsol.BlockProblemSolution.
SimulationTask is defined in simpar.SimulationTask.
.
transaction.Transaction.

# Variables

BlockProblemHelper is used to keep track of other miner's commitments for the current block problem.
HttpapiSimparMutex is a mutex used to allow concurrency-safe access to pending simtasks (use this for writing).
HttpapiSimparRMutex is a mutex used to allow concurrency-safe access to pending simtasks (use this for read-only).
HttpapiTransactionMutex is a mutex used to allow concurrency-safe access to pending transactions (use this for writing).
HttpapiTransactionRMutex is a mutex used to allow concurrency-safe access to pending transactions (use this for read-only).
HttpPort defines on which port the local websites for sending transactions and simtasks are run on.
IAmFullNode describes whether a node is a full node or not.
IAmRA describes whether a node is the RA or not.
MyDockerAlias specifies the name of the docker instance that runs this node.
MyNodeIDString holds your own nodeID as 12D3Koo..
OriginalMode stores the initial mode a node was in at startup.
each SimTask can consist of many simpar.
keep track of pending transactions and simpars.
PrivateKey holds your own private key.
PubsubTopicSlice holds all *pubsub.Topic.
RAnonce is a global nonce for testing/simulation purposes.
RApub is the known public key of the RA (will be dynamically set by converting RANodeID constant to PubKey).
SyncHelper is used to coordinate the current sync.
TopicSlice holds topics (as strings) that user wants to subscribe to.

# Structs

ActiveMiner is used to aggregate information about an active miner that has broadcast commitments before problem expiry.
BlockProblemHelperStruct is used to keep track of the current block problem and miner commitments.
ChainDBRequest is the struct used to request specific chaindb data from other nodes via the topic 'pouw_chaindb'.
LiveData is a struct used to transmit current live data state to nodes that just completed their initial sync.
StateValueStruct is a custom struct for the statedb.
SyncHelperStruct is a custom struct that a node uses to keep track of its syncmode, which data it has received and from whom and how often etc.
TransportStruct is a struct that contains serialized data and an enum element (TSData) that tells the receiver which kind of data it contains.

# Type aliases

Mode is an int alias used to implement what would be called an enum in other languages (which Go does not have yet as of writing).
TSData is an alias for int which describes which kind of data was put in a TransportStruct.