Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update websocket jsonrpc subscribe request parsing and response building #20

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions pc/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ void user::parse_sub_price( uint32_t tok, uint32_t itok )
do {
// unpack and verify parameters
uint32_t ntok,ptok = jp_.find_val( tok, "params" );
if ( ptok == 0 || jp_.get_type(ptok) != jtree::e_obj ) break;
if ( 0 == (ntok = jp_.find_val( ptok, "account" ) ) ) break;
if ( ptok == 0 || jp_.get_type(ptok) != jtree::e_arr ) break;
if ( 0 == (ntok = jp_.get_first( ptok ))) break;
if ( 0 == (ntok = jp_.find_val( ntok , "account" ) ) ) break;
pub_key pkey;
pkey.init_from_text( jp_.get_str( ntok ) );
price *sptr = sptr_->get_price( pkey );
Expand All @@ -222,9 +223,7 @@ void user::parse_sub_price( uint32_t tok, uint32_t itok )

// create result
add_header();
jw_.add_key( "result", json_wtr::e_obj );
jw_.add_key( "subscription", sub_id );
jw_.pop();
jw_.add_key( "result", sub_id );
add_tail( itok );

// add subscription
Expand All @@ -240,8 +239,9 @@ void user::parse_sub_price_sched( uint32_t tok, uint32_t itok )
do {
// unpack and verify parameters
uint32_t ntok,ptok = jp_.find_val( tok, "params" );
if ( ptok == 0 || jp_.get_type(ptok) != jtree::e_obj ) break;
if ( 0 == (ntok = jp_.find_val( ptok, "account" ) ) ) break;
if ( ptok == 0 || jp_.get_type(ptok) != jtree::e_arr ) break;
if ( 0 == (ntok = jp_.get_first( ptok ))) break;
if ( 0 == (ntok = jp_.find_val( ntok , "account" ) ) ) break;
pub_key pkey;
pkey.init_from_text( jp_.get_str( ntok ) );
price *sptr = sptr_->get_price( pkey );
Expand All @@ -252,9 +252,7 @@ void user::parse_sub_price_sched( uint32_t tok, uint32_t itok )

// create result
add_header();
jw_.add_key( "result", json_wtr::e_obj );
jw_.add_key( "subscription", sub_id );
jw_.pop();
jw_.add_key( "result", sub_id );
add_tail( itok );
return;
} while( 0 );
Expand Down
2 changes: 1 addition & 1 deletion pctest/init_key_store.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

check()
{
Expand Down