@@ -2,6 +2,7 @@ package main
22
33import (
44 "context"
5+ "encoding/json"
56 "fmt"
67
78 "github.com/tonkeeper/tonapi-go"
@@ -11,8 +12,13 @@ func subscribeToMempool(token string) {
1112 streamingAPI := tonapi .NewStreamingAPI (tonapi .WithStreamingToken (token ))
1213 for {
1314 err := streamingAPI .SubscribeToMempool (context .Background (),
15+ // this "accounts" parameter is optional,
16+ // if not set, you will receive all mempool events.
17+ // if defined, you will receive only mempool events that involve these accounts.
18+ []string {"-1:5555555555555555555555555555555555555555555555555555555555555555" },
1419 func (data tonapi.MempoolEventData ) {
15- fmt .Printf ("mempool event: %#v\n " , len (data .BOC ))
20+ value , _ := json .Marshal (data )
21+ fmt .Printf ("mempool event: %#v\n " , value )
1622 })
1723 if err != nil {
1824 fmt .Printf ("mempool error: %v, reconnecting...\n " , err )
@@ -23,7 +29,12 @@ func subscribeToMempool(token string) {
2329func subscribeToTransactions (token string ) {
2430 streamingAPI := tonapi .NewStreamingAPI (tonapi .WithStreamingToken (token ))
2531 for {
26- err := streamingAPI .SubscribeToTransactions (context .Background (), []string {"-1:5555555555555555555555555555555555555555555555555555555555555555" },
32+ err := streamingAPI .SubscribeToTransactions (context .Background (),
33+ []string {"-1:5555555555555555555555555555555555555555555555555555555555555555" },
34+ // this "operations" is optional,
35+ // if not set, you will receive all transactions.
36+ // if defined, you will receive only transactions with these operations.
37+ nil ,
2738 func (data tonapi.TransactionEventData ) {
2839 fmt .Printf ("New tx with hash: %v\n " , data .TxHash )
2940 })
0 commit comments