All enodes subscribe and topic same as feed

Lets see if that makes a difference
This commit is contained in:
Oskar Thoren 2019-04-10 18:01:32 +08:00
parent dbae5a0cc2
commit b7b83133dc
1 changed files with 14 additions and 9 deletions

View File

@ -415,7 +415,7 @@ func run(port int, privateKey *ecdsa.PrivateKey) {
// bob: 0x04cbd6b75038f2d1e4e8e2754ffadecaaa8d2fdbbb29311dc82a8e1880fce4576f86e3d87ab360bcdde1aaf9a01a2cf232be95684a1152a735ccb4200495e4145c // bob: 0x04cbd6b75038f2d1e4e8e2754ffadecaaa8d2fdbbb29311dc82a8e1880fce4576f86e3d87ab360bcdde1aaf9a01a2cf232be95684a1152a735ccb4200495e4145c
var topic string var topic string
err = client.Call(&topic, "pss_stringToTopic", "foo") err = client.Call(&topic, "pss_stringToTopic", "bob")
bobPubKey := "0x04cbd6b75038f2d1e4e8e2754ffadecaaa8d2fdbbb29311dc82a8e1880fce4576f86e3d87ab360bcdde1aaf9a01a2cf232be95684a1152a735ccb4200495e4145c" bobPubKey := "0x04cbd6b75038f2d1e4e8e2754ffadecaaa8d2fdbbb29311dc82a8e1880fce4576f86e3d87ab360bcdde1aaf9a01a2cf232be95684a1152a735ccb4200495e4145c"
receiver := bobPubKey receiver := bobPubKey
@ -426,14 +426,19 @@ func run(port int, privateKey *ecdsa.PrivateKey) {
err = client.Call(nil, "pss_setPeerPublicKey", bobPubKey, topic, bobBaseAddr) err = client.Call(nil, "pss_setPeerPublicKey", bobPubKey, topic, bobBaseAddr)
msgC := make(chan pss.APIMsg) msgC := make(chan pss.APIMsg)
// Only Bob gets to listen // Nope, everyone gets to listen on that topic, also maybe it should be same?
if port == 9601 { // Does it matter for feeds?
// XXX: Let'ss try
sub, err := client.Subscribe(context.Background(), "pss", msgC, "receive", topic, false, false) sub, err := client.Subscribe(context.Background(), "pss", msgC, "receive", topic, false, false)
if err != nil {
fmt.Println("Error subscribing to topic", err) // Only Bob gets to listen
} // if port == 9601 {
defer sub.Unsubscribe() // sub, err := client.Subscribe(context.Background(), "pss", msgC, "receive", topic, false, false)
} // if err != nil {
// fmt.Println("Error subscribing to topic", err)
// }
// defer sub.Unsubscribe()
// }
// XXX: Hack to make sure ready state // XXX: Hack to make sure ready state
time.Sleep(time.Second * 3) time.Sleep(time.Second * 3)
@ -466,7 +471,7 @@ func run(port int, privateKey *ecdsa.PrivateKey) {
fmt.Printf("All operations successfully completed.\n") fmt.Printf("All operations successfully completed.\n")
// Teardown // Teardown
sub.Unsubscribe()
client.Close() client.Close()
node.Stop() node.Stop()
} }