You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
638 B

  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "time"
  6. "github.com/ethereum/go-ethereum/log"
  7. swarm "github.com/vocdoni/go-dvote/net/swarm"
  8. )
  9. func main() {
  10. sn := new(swarm.SwarmNet)
  11. err := sn.Init()
  12. if err != nil {
  13. fmt.Printf("%v\n", err)
  14. return
  15. }
  16. key := os.Args[1]
  17. topic := "vocdoni_test"
  18. sn.PssSub("asym", key, topic, "")
  19. go func() {
  20. for {
  21. msg := <-sn.PssTopics[topic].Delivery
  22. fmt.Printf("Pss received: %s\n", msg)
  23. }
  24. }()
  25. hostname, _ := os.Hostname()
  26. for {
  27. err := sn.PssPub("asym", key, topic, fmt.Sprintf("Hello world from %s", hostname), "")
  28. log.Info("pss sent", "err", err)
  29. time.Sleep(10 * time.Second)
  30. }
  31. }