-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
486 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/command/flagset" | ||
"github.com/ethereum/go-ethereum/command/server/proto" | ||
) | ||
|
||
// ChainWatchCommand is the command to group the peers commands | ||
type ChainWatchCommand struct { | ||
*Meta2 | ||
} | ||
|
||
// Help implements the cli.Command interface | ||
func (c *ChainWatchCommand) Help() string { | ||
return `` | ||
} | ||
|
||
func (c *ChainWatchCommand) Flags() *flagset.Flagset { | ||
flags := c.NewFlagSet("chain watch") | ||
|
||
return flags | ||
} | ||
|
||
// Synopsis implements the cli.Command interface | ||
func (c *ChainWatchCommand) Synopsis() string { | ||
return "" | ||
} | ||
|
||
// Run implements the cli.Command interface | ||
func (c *ChainWatchCommand) Run(args []string) int { | ||
flags := c.Flags() | ||
if err := flags.Parse(args); err != nil { | ||
c.UI.Error(err.Error()) | ||
return 1 | ||
} | ||
|
||
borClt, err := c.BorConn() | ||
if err != nil { | ||
c.UI.Error(err.Error()) | ||
return 1 | ||
} | ||
|
||
sub, err := borClt.ChainWatch(context.Background(), &proto.ChainWatchRequest{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for { | ||
msg, err := sub.Recv() | ||
if err != nil { | ||
// if err == EOF if finished on the other side | ||
panic(err) | ||
} | ||
fmt.Println("message received") | ||
fmt.Println(msg) | ||
} | ||
|
||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.