Work In Progress!
This is a Golang library for interfacing with the MCM Network through the native socket/tcp protocol.
Written by NickP005
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
}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.
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)Saves the settings to the settings.json file.
func SaveSettings(settings Settings)Expands the IPs in the settings file.
func ExpandIPs() ()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.
Queries the balance of the specified address given as hex.
func QueryBalance(wots_address string) (uint64, error) - 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!