BitShares Forum

Main => Technical Support => Topic started by: alt on November 02, 2015, 06:11:19 am

Title: how to use websocket subscribe?
Post by: alt on November 02, 2015, 06:11:19 am
I try to subscribe a useraccount's transaction, but when I run set_subscribe_callback,
I receive too many data every 3 seconds, these data is not I want to receive.  how can I avoid these?

Code: [Select]
$ wscat -c ws://127.0.0.1:8090                                                                   
connected (press CTRL+C to quit)
> {"id":1,"method":"call","params":[1,"login",["",""]]}
< {"id":1,"result":true}
> {"id":2,"method":"call","params":[1,"database",[]]}
< {"id":2,"result":2}
> {"id":3,"method":"call","params":[2,"set_subscribe_callback",[200,true]]}
< {"id":3,"result":null}
< {"method":"notice","params":[200,[[{"id":"2.12.0","current_shuffled_witnesses":["1.6.24","1.6.32","1.6.20","1.6.16","1.6.29","1.6.49","1.6.37","1.6.14","1.6.45","1.6.23
","1.6.13","1.6.28","1.6.26","1.6.12","1.6.15","1.6.22","1.6.21","1.6.18","1.6.34","1.6.35","1.6.25","1.6.42","1.6.40","1.6.43","1.6.17","1.6.19","1.6.46","1.6.44","1.6.30","1.6.38","1.6.27"]},{"id":"2.4.32","feeds":[["1.2.277",["2015-10-14T21:36:18",{"settlement_price":{"base":{"amount":3065,"asset_id":"1.3.524"},"quote":{"amount":"1
0000000000","asset_id":"1.3.0"}},"maintenance_collateral_ratio":1750,"maximum_short_squeeze_ratio":1500,"core_exchange_rate":{"base":{"amount":3065,"asset_id":"1.3.524"
},"quote":{"amount":"10500000000","asset_id":"1.3.0"}}}]]],"current_feed":{"settlement_price":{"base":{"amount":0,"asset_id":"1.3.0"},"quote":{"amount":0,"asset_id":"1.
3.0"}},"maintenance_collateral_ratio":1750,"maximum_short_squeeze_ratio":1500,"core_exchange_rate":{"base":{"amount":0,"asset_id":"1.3.0"},"quote":{"amount":0,"asset_id
":"1.3.0"}}},"current_feed_publication_time":"2015-11-02T06:04:54","options":{"feed_lifetime_sec":86400,"minimum_feeds":7,"force_settlement_delay_sec":86400,"force_sett
lem ..............
..................
Title: Re: how to use websocket subscribe?
Post by: svk on November 02, 2015, 06:33:08 am
You can't I think, you get notified of everything. You can simply ignore any object that isn't the account you want though.
Title: Re: how to use websocket subscribe?
Post by: alt on November 02, 2015, 06:41:01 am
You can't I think, you get notified of everything. You can simply ignore any object that isn't the account you want though.
OK. But I still can't understand why so many notify  every 3 sec. for example, object 2.4.32 update every 3 secs,but only 'current_feed_publication_time' change to the current timestamp.
maybe these notify is not necessary?
Code: [Select]
.....
               'current_feed_publication_time': '2015-11-02T05:26:09',
               'feeds': [['1.2.277',
                          ['2015-10-14T21:36:18',
                           {'core_exchange_rate': {'base': {'amount': 3065,
                                                            'asset_id': '1.3.524'},
                                                   'quote': {'amount': '10500000000',
                                                             'asset_id': '1.3.0'}},
                            'maintenance_collateral_ratio': 1750,
                            'maximum_short_squeeze_ratio': 1500,
                            'settlement_price': {'base': {'amount': 3065,
                                                          'asset_id': '1.3.524'},
                                                 'quote': {'amount': '10000000000',
                                                           'asset_id': '1.3.0'}}}]]],
               'force_settled_volume': 0,
               'id': '2.4.32',
               'is_prediction_market': False,

....
               'current_feed_publication_time': '2015-11-02T05:26:12',
               'feeds': [['1.2.277',
                          ['2015-10-14T21:36:18',
                           {'core_exchange_rate': {'base': {'amount': 3065,
                                                            'asset_id': '1.3.524'},
                                                   'quote': {'amount': '10500000000',
                                                             'asset_id': '1.3.0'}},
                            'maintenance_collateral_ratio': 1750,
                            'maximum_short_squeeze_ratio': 1500,
                            'settlement_price': {'base': {'amount': 3065,
                                                          'asset_id': '1.3.524'},
                                                 'quote': {'amount': '10000000000',
                                                           'asset_id': '1.3.0'}}}]]],
               'force_settled_volume': 0,
               'id': '2.4.32',
               'is_prediction_market': False,
Title: Re: how to use websocket subscribe?
Post by: svk on November 02, 2015, 06:43:18 am
The dynamic global object 2.1.0 updates every time a block is produced so that's every 3 secs, not sure what 2.4.32 is though
Title: Re: how to use websocket subscribe?
Post by: alt on November 02, 2015, 07:06:45 am
this is the notify list for every block:
Code: [Select]
1.13.24
1.6.15
2.1.0
2.4.12
2.4.13
2.4.14
2.4.15
2.4.16
2.4.17
2.4.18
2.4.19
2.4.2
2.4.20
2.4.21
2.4.28
2.4.29
2.4.3
2.4.30
2.4.31
2.4.32
2.4.5
2.4.6
2.4.7
2.4.8
2.4.9
2.8.36790
Title: Re: how to use websocket subscribe?
Post by: theoretical on November 02, 2015, 11:26:32 pm

Those 2.4.x should not be on there every block.  Bug report filed.

Originally we intended you to manually subscribe to every object you wanted to track, but that made it difficult to write a GUI which could function without a bunch of network round trips making it slow and clunky.

Now you just get everything.  But the old calls are still there.  Really our subscription model is a mess and it needs cleaned up.  Which is going to be part of The Massive Plugin Architecture Fix that I'm going to do when I finally have some time that's not earmarked for Important Production Stuff like today's release.
Title: Re: how to use websocket subscribe?
Post by: svk on November 26, 2015, 09:45:27 am

Those 2.4.x should not be on there every block.  Bug report filed.

Originally we intended you to manually subscribe to every object you wanted to track, but that made it difficult to write a GUI which could function without a bunch of network round trips making it slow and clunky.

Now you just get everything.  But the old calls are still there.  Really our subscription model is a mess and it needs cleaned up.  Which is going to be part of The Massive Plugin Architecture Fix that I'm going to do when I finally have some time that's not earmarked for Important Production Stuff like today's release.

We're still getting spammed with 2.4.x objects every block, any update on this?