Skip to content

Commit b505d92

Browse files
committed
remove get_block utility command
1 parent 9aab30f commit b505d92

File tree

5 files changed

+0
-358
lines changed

5 files changed

+0
-358
lines changed

pc/request.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -258,47 +258,6 @@ void get_mapping::update( T *res )
258258
cptr->write( (pc_pub_key_t*)mkey_.data(), (pc_acc_t*)tab );
259259
}
260260

261-
///////////////////////////////////////////////////////////////////////////
262-
// get_block
263-
264-
get_block::get_block()
265-
: st_( e_sent )
266-
{
267-
}
268-
269-
void get_block::set_slot( uint64_t slot )
270-
{
271-
req_->set_slot( slot );
272-
}
273-
274-
void get_block::set_commitment( commitment cmt )
275-
{
276-
req_->set_commitment( cmt );
277-
}
278-
279-
void get_block::on_response( rpc::get_block *res )
280-
{
281-
if ( res->get_is_err() ) {
282-
on_error_sub( res->get_err_msg(), this );
283-
st_ = e_error;
284-
} else if ( st_ == e_sent && res->get_is_end() ) {
285-
st_ = e_done;
286-
}
287-
}
288-
289-
bool get_block::get_is_done() const
290-
{
291-
return st_ == e_done;
292-
}
293-
294-
void get_block::submit()
295-
{
296-
st_ = e_sent;
297-
req_->set_sub( this );
298-
req_->set_program( get_manager()->get_program_pub_key() );
299-
get_rpc_client()->send( req_ );
300-
}
301-
302261
///////////////////////////////////////////////////////////////////////////
303262
// product
304263

pc/request.hpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,6 @@ namespace pc
146146
rpc::get_account_info areq_[1];
147147
};
148148

149-
// get transactions in single block
150-
class get_block : public request,
151-
public rpc_sub_i<rpc::get_block>
152-
{
153-
public:
154-
get_block();
155-
void set_slot( uint64_t slot );
156-
void set_commitment( commitment cmt );
157-
public:
158-
void submit() override;
159-
void on_response( rpc::get_block * ) override;
160-
bool get_is_done() const override;
161-
protected:
162-
typedef enum { e_sent, e_done, e_error } state_t;
163-
state_t st_;
164-
rpc::get_block req_[1];
165-
};
166-
167149
// product symbol and other reference-data attributes
168150
class product : public request,
169151
public attr_dict,

pc/rpc_client.cpp

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -753,118 +753,6 @@ bool rpc::get_program_accounts::get_is_http() const
753753
return true;
754754
}
755755

756-
///////////////////////////////////////////////////////////////////////////
757-
// get_block
758-
759-
void rpc::get_block::set_slot( uint64_t slot )
760-
{
761-
bslot_ = slot;
762-
}
763-
764-
void rpc::get_block::set_commitment( commitment cmt )
765-
{
766-
cmt_ = cmt;
767-
}
768-
769-
void rpc::get_block::set_program( pub_key *gkey )
770-
{
771-
gkey_ = gkey;
772-
}
773-
774-
void rpc::get_block::request( json_wtr& msg )
775-
{
776-
msg.add_key( "method", "getConfirmedBlock" );
777-
msg.add_key( "params", json_wtr::e_arr );
778-
msg.add_val( bslot_ );
779-
msg.add_val( json_wtr::e_obj );
780-
msg.add_key( "encoding", "json" );
781-
msg.add_key( "rewards", json_wtr::jfalse() );
782-
msg.add_key( "commitment", commitment_to_str( cmt_ ) );
783-
msg.pop();
784-
msg.pop();
785-
}
786-
787-
unsigned rpc::get_block::get_num_key() const
788-
{
789-
return kvec_.size();
790-
}
791-
792-
pub_key *rpc::get_block::get_key( unsigned i )
793-
{
794-
return &kvec_[i];
795-
}
796-
797-
char *rpc::get_block::get_cmd()
798-
{
799-
return &ibuf_[0];
800-
}
801-
802-
bool rpc::get_block::get_is_tx_err() const
803-
{
804-
return is_tx_err_;
805-
}
806-
807-
uint64_t rpc::get_block::get_tx_fee() const
808-
{
809-
return fee_;
810-
}
811-
812-
str rpc::get_block::get_tx_err() const
813-
{
814-
return tx_err_;
815-
}
816-
817-
bool rpc::get_block::get_is_end() const
818-
{
819-
return is_end_;
820-
}
821-
822-
void rpc::get_block::response( const jtree& jt )
823-
{
824-
if ( on_error( jt, this ) ) return;
825-
is_end_ = false;
826-
uint32_t rtok = jt.find_val( 1, "result" );
827-
uint32_t ttok = jt.find_val( rtok, "transactions" );
828-
for( uint32_t it = jt.get_first( ttok ); it; it = jt.get_next( it ) ) {
829-
uint32_t tx = jt.find_val( it, "transaction" );
830-
uint32_t ms = jt.find_val( tx, "message" );
831-
// determine if this is a pyth transaction
832-
uint32_t ak = jt.find_val( ms, "accountKeys" );
833-
bool found = false;
834-
pub_key ikey;
835-
kvec_.clear();
836-
for( uint32_t at = jt.get_first( ak ); at; at = jt.get_next( at ) ) {
837-
ikey.init_from_text( jt.get_str( at ) );
838-
kvec_.push_back( ikey );
839-
if ( ikey == *gkey_ ) {
840-
found = true;
841-
}
842-
}
843-
if ( !found ) continue;
844-
// get meta-data
845-
is_tx_err_ = false;
846-
fee_ = 0UL;
847-
uint32_t mx = jt.find_val( it, "meta" );
848-
if ( mx && jt.get_type( mx ) == jtree::e_obj ) {
849-
fee_ = jt.get_uint( jt.find_val( mx, "fee" ) );
850-
uint32_t ex = jt.find_val( mx, "err" );
851-
if ( ex && jt.get_type( ex ) == jtree::e_obj ) {
852-
is_tx_err_ = true;
853-
tx_err_ = jt.get_str( jt.get_key( jt.get_first( ex ) ) );
854-
}
855-
}
856-
// get transaction details
857-
uint32_t ix = jt.find_val( ms, "instructions" );
858-
str idata = jt.get_str( jt.find_val( jt.get_first( ix ), "data" ) );
859-
ibuf_.resize( idata.len_ );
860-
dec_base58( (const uint8_t*)idata.str_, idata.len_,
861-
(uint8_t*)&ibuf_[0] );
862-
on_response( this );
863-
}
864-
is_end_ = true;
865-
on_response( this );
866-
}
867-
868756
///////////////////////////////////////////////////////////////////////////
869757
// upd_price
870758

pc/rpc_client.hpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -391,38 +391,6 @@ namespace pc
391391
uint32_t acct_type_;
392392
};
393393

394-
// get all (pyth) transactions in a slot
395-
class get_block : public rpc_request
396-
{
397-
public:
398-
void set_slot( uint64_t slot );
399-
void set_commitment( commitment );
400-
void set_program( pub_key * );
401-
void request( json_wtr& ) override;
402-
void response( const jtree& ) override;
403-
uint64_t get_fee() const;
404-
bool get_is_tx_err() const;
405-
str get_tx_err() const;
406-
uint64_t get_tx_fee() const;
407-
unsigned get_num_key() const;
408-
pub_key *get_key( unsigned i );
409-
char *get_cmd();
410-
bool get_is_end() const;
411-
412-
private:
413-
typedef std::vector<pub_key> key_vec_t;
414-
typedef std::vector<char> ins_vec_t;
415-
uint64_t bslot_;
416-
commitment cmt_;
417-
pub_key *gkey_;
418-
key_vec_t kvec_;
419-
ins_vec_t ibuf_;
420-
uint64_t fee_;
421-
str tx_err_;
422-
bool is_end_;
423-
bool is_tx_err_;
424-
};
425-
426394
// set new component price
427395
class upd_price : public tx_request, public rpc_request
428396
{

0 commit comments

Comments
 (0)