Skip to content

Informer API

Junha Yang(양준하) edited this page Jul 20, 2020 · 1 revision

Overview

What is the Informer API

Informer is the name for the event sourcing API. The events will contain information to help to manage a Foundry program.

How to use the Informer API

Informer API is supposed to propagate information related to events in foundry. Clients can make a websocket connection with foundry and temporarily register itself to its desired event or events using JSON-RPC notifications. As long as the connection is alive, foundry keeps informing the client about the specific event or events in case the event happens.

Example:

>> {"id": 1, "method": "register", "params": ["peerConnection", {}]}

<< {"jsonrpc":"2.0","id":1,"result":"0xcd0c3e8af590364c09d0fa6a1210faf5"}

// incoming notifications

<< {"jsonrpc":"2.0","method":"register","params":{"registration":"0xcd0c3e8af590364c09d0fa6a1210faf5","result":{"difficulty":"0xd9263f42a87",<...>, "uncles":[]}}}

<< {"jsonrpc":"2.0","method":"register","params":{"subscription":"0xcd0c3e8af590364c09d0fa6a1210faf5","result":{"difficulty":"0xd90b1a7ad02", <...>, "uncles":["0x80aacd1ea4c9da32efd8c2cc9ab38f8f70578fcd46a1a4ed73f82f3e0957f936"]}}}

//deregister

>> {"id": 1, "method": "deregister", "params": ["0xcd0c3e8af590364c09d0fa6a1210faf5"]}

<< {"jsonrpc":"2.0","id":1,"result":true}

Registration:

A client can register itself to a particular event or set of events by sending a regular RPC request. The RPC call contains register as the "method" object in the RPC Request, the desired event as "params" . Afterward, the client is registered to that particular event and will be informed as soon as the event happens.

Parameters:

1- event name

Example:

>> {"method": "register", "params": ["peerAdded"]}
<< {"jsonrpc":"2.0","result": 7984544580733757718 ,"id":1}

Deregistration:

A client can deregister its previous registrations to a particular event or set of events by sending a regular RPC request. The RPC call contains deregister as the "method" object in the RPC Request, the desire event as "params" .

Parameters:

1- subscribtion id

Example:

>> {"method": "deregister", "params": ["7984544580733757718"]}
<< {"jsonrpc":"2.0","id":1,"result":true}

Supported events:

peerConnection:

This a sample event for the first draft. A notification will be triggered as soon as a peer connects to the network. A user can choose whether he is interested in extra information or not like the peer’s ip address.

Notes:

Soon to be completed.