Miner S.C.

NewMinerSmartContract

Creates a new instance of the Miner Smart Contract.

goCopy codefunc NewMinerSmartContract() sci.SmartContractInterface {
	var mscCopy = &MinerSmartContract{
		SmartContract: sci.NewSC(ADDRESS),
		bcContext:     &smartcontract.BCContext{},
	}
	mscCopy.initSC()
	mscCopy.setSC(mscCopy.SmartContract, mscCopy.bcContext)
	return mscCopy
}

Execute

Executes a specified function within the Miner Smart Contract, based on the function name and input data provided.

Function Parameters:

goCopy codefunc (msc *MinerSmartContract) Execute(
	t *transaction.Transaction,
	funcName string, 
	input []byte, 
	balances cstate.StateContextI
) (string, error)

Parameters:


Global Node Management

getGlobalNode

Retrieves the global configuration node from the blockchain state.

Function Signature:

goCopy codefunc getGlobalNode(balances cstate.CommonStateContextI) (gn *GlobalNode, err error)

Parameters:

Returns:

  • *GlobalNode - Pointer to the global node configuration.

  • error - Error if retrieval fails.

InitConfig

Initializes the global configuration settings for the Miner Smart Contract.

Function Signature:

goCopy codefunc InitConfig(balances cstate.CommonStateContextI) error

Parameters:

Description: This function initializes the settings in the blockchain, validating and storing the global node configuration if it does not already exist. If a global node does not exist, a default node is created and stored.


Execution Statistics

Miner Smart Contract records performance metrics for each key function:

Last updated