# Miner S.C.

### Miner-related Functions

**`NewMinerSmartContract`**

Creates a new instance of the Miner Smart Contract.

```go
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:**

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

**Parameters:**

| Field      | Description                                               |
| ---------- | --------------------------------------------------------- |
| `t`        | Transaction to be executed.                               |
| `funcName` | The function name to execute within the smart contract.   |
| `input`    | Byte array of input data for the function.                |
| `balances` | State context interface for maintaining blockchain state. |

***

### Global Node Management

**`getGlobalNode`**

Retrieves the global configuration node from the blockchain state.

**Function Signature:**

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

**Parameters:**

| Field      | Description                         |
| ---------- | ----------------------------------- |
| `balances` | Blockchain state context interface. |

**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:**

```go
goCopy codefunc InitConfig(balances cstate.CommonStateContextI) error
```

**Parameters:**

| Field      | Description                         |
| ---------- | ----------------------------------- |
| `balances` | Blockchain state context interface. |

**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:

| Function Name             | Description                                              |
| ------------------------- | -------------------------------------------------------- |
| `add_miner`               | Tracks time taken to add a new miner.                    |
| `add_sharder`             | Tracks time taken to add a new sharder.                  |
| `collect_reward`          | Measures the time required for reward collection.        |
| `miner_health_check`      | Monitors time taken to conduct miner health checks.      |
| `sharder_health_check`    | Tracks time taken for sharder health checks.             |
| `update_globals`          | Counts the number of global configuration updates.       |
| `update_miner_settings`   | Tracks the time taken to update miner settings.          |
| `update_sharder_settings` | Tracks time taken to update sharder settings.            |
| `payFees`                 | Monitors the time taken for processing fee payments.     |
| `feesPaid`                | Keeps a count of total fees paid by miners and sharders. |
| `mintedTokens`            | Counts the total tokens minted in the smart contract.    |
