@@ -24,6 +24,42 @@ func sendCommand(command string, payload []byte) {
2424 }
2525}
2626
27+ func networkRegistration () {
28+ network1 := chainbridge.Network {
29+ Identifier : "0x000" ,
30+ Parameters : []byte ("pA: 1\n pB: 2\n pC: 3\n " ),
31+ }
32+ log .Printf ("Network in: %+v" , network1 )
33+
34+ // register the network
35+ command := fmt .Sprintf (
36+ chainbridge .Cmd_networks_register ,
37+ network1 .Identifier ,
38+ )
39+ response , err := chBridge .Command (command , network1 .Parameters )
40+ log .Printf ("Response (%s): %+v\n " , command , response )
41+ if err != nil {
42+ log .Printf ("ChainBridge command error: %v" , err )
43+ }
44+ if response .Error != "" {
45+ log .Printf ("ChainBridge response error: %v" , response .Error )
46+ }
47+
48+ // retrieve the network
49+ command = fmt .Sprintf (chainbridge .Cmd_networks_getNetwork , network1 .Identifier )
50+ response , err = chBridge .Command (command , nil )
51+ if err != nil {
52+ log .Printf ("ChainBridge command error: %v" , err )
53+ } else {
54+ log .Printf ("Response (%s): %+v\n " , command , response )
55+ }
56+ var network2 chainbridge.Network
57+ if err := chBridge .DataUnmarshal (response , & network2 ); err != nil {
58+ log .Printf ("ChainBridge data error: %v" , err )
59+ }
60+ log .Printf ("Network out: %+v" , network2 )
61+ }
62+
2763func nodeRegistration () {
2864 node1 := chainbridge.Node {
2965 Identifier : "node-5000" ,
@@ -186,6 +222,7 @@ func main() {
186222 }
187223 wg .Wait ()
188224
225+ networkRegistration ()
189226 nodeRegistration ()
190227
191228 log .Printf ("genesisEpoch: %d" , getGenesisEpoch ())
0 commit comments