Skip to content

drewk312/go-mcminterface

 
 

Repository files navigation

mcminterface v0.1.0

Work In Progress!

This is a Golang library for interfacing with the MCM Network through the native socket/tcp protocol.
Written by NickP005

Usage

In query basics there is the main function you can test with. Compilation as usual with

go build

and then run the binary.

Or alternatively you can run the code with

go run .

There is a file, settings.json, that you can edit to change the startup settings. Below is an example of the file:

{
    "StartIPs": [
        "0.0.0.0"
    ],
    "IPs": [
        "0.0.0.0"
    ],
    "Nodes": [
        {
            "IP": "0.0.0.0",
            "LastSeen": "2024-08-05T12:54:28.9042045+02:00",
            "Ping": 792
        },
    ],
    "IPExpandDepth": 2,
    "ForceQueryStartIPs": false,
    "QuerySize": 5
}

Functions

Below there are the functions that are meant to be official: they query multiple nodes and return the most common result that is agreed by more than 50% of the nodes called.
Functions such as tag resolve haven't been implemented in query_manager.go yet, but are present in queries.go.

LoadSettings

Loads the settings from the settings.json file. For the code to properly work, ensure to call it before doing any QueryX function.

func LoadSettings() (SettingsType)

SaveSettings

Saves the settings to the settings.json file.

func SaveSettings(settings Settings)

ExpandIPs

Expands the IPs in the settings file.

func ExpandIPs() ()

BenchmarkNodes

Benchmarks all the nodes in the settings file. Useful at startup to determine the best nodes to query in later connections.

func BenchmarkNodes(n int)

n specifies how many concurrent pings to send.

QueryBalance

Queries the balance of the specified address given as hex.

func QueryBalance(wots_address string) (uint64, error) 

Notes

  • The code is still in development and is not yet ready for production use.
  • Every query asks for QuerySize nodes that are picked by PickNodes. That function picks randomly the nodes, but nodes that have lower ping time are more likely to be picked!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 100.0%