Node control

Now that we have obtained the knowledge on how to initialize our main IOTA repository object, we can explore what are we able to do with the node that we are connected to.

The first thing we can do is to fetch node info by calling the method GetNodeInfo as follows:

var repository = IotaRepositoryFactory.Create("https://altnodes.devnet.iota.org");
var info = repository.GetNodeInfo();

As we can see, the method returns quite a lot of information about the node that we are currently connected to. One of the things to pay attention to here is the LatestMilestoneIndex and the LatestSolidSubtangleMilestoneIndex numbers. If both numbers are equal, it means that the node is currently in sync with the network.

WARNING: The next set of methods are by default blocked by the nodes. The only way to access them is from localhost.

Another method we can call is GetNeighbors which will return the list of IRI neighbors:

var repository = IotaRepositoryFactory.Create("https://altnodes.devnet.iota.org");
var neighbors = repository.GetNeighbors();

We can also add neighbors to the node by calling AddNeighbors method:

var repository = IotaRepositoryFactory.Create("https://altnodes.devnet.iota.org");
var response = repository.AddNeighbors(new List<string>() {
    "https://to.add.neighbor.URL"
});

We're also able to remove them by calling RemoveNeighbors method:

var repository = IotaRepositoryFactory.Create("https://altnodes.devnet.iota.org");
var response = repository.RemoveNeighbors(new List<string>() {
    "https://to.remove.neighbor.URL"
});

Last updated