Skip to content
Merged
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
6 changes: 3 additions & 3 deletions pc/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void product::update( T *res )
return;
}
pc_prod_t *prod;
size_t plen = std::max( sizeof(pc_price_t), (size_t)PC_PROD_ACC_SIZE );
size_t plen = std::max( PRICE_ACCOUNT_SIZE, (size_t)PC_PROD_ACC_SIZE );
if ( sizeof( pc_prod_t ) > res->get_data_ref( prod, plen ) ||
prod->magic_ != PC_MAGIC ||
!init_from_account( prod ) ) {
Expand Down Expand Up @@ -464,7 +464,7 @@ price::price( const pub_key& acc, product *prod )
preq_->set_account( &apub_ );
areq_->set_sub( this );
preq_->set_sub( this );
size_t tlen = ZSTD_compressBound( sizeof(pc_price_t) );
size_t tlen = ZSTD_compressBound( PRICE_ACCOUNT_SIZE );
pptr_ = (pc_price_t*)new char[tlen];
__builtin_memset( pptr_, 0, tlen );
}
Expand Down Expand Up @@ -952,7 +952,7 @@ void price::update( T *res )
}

// get account data
size_t tlen = ZSTD_compressBound( sizeof(pc_price_t) );
size_t tlen = ZSTD_compressBound( PRICE_ACCOUNT_SIZE );
res->get_data_val( pptr_, tlen );
if ( PC_UNLIKELY( pptr_->magic_ != PC_MAGIC ) ) {
on_error_sub( "bad price account header", this );
Expand Down
3 changes: 3 additions & 0 deletions program/c/src/oracle/oracle.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "oracle.h"
#include "upd_aggregate.h"


// Returns the minimum number of lamports required to make an account
// with dlen bytes of data rent exempt. These values were calculated
// using the getMinimumBalanceForRentExemption RPC call, and are
Expand All @@ -19,6 +20,8 @@ static uint64_t rent_exempt_amount( uint64_t dlen )
return 4454400;
case sizeof( pc_price_t ):
return 23942400;
case PRICE_ACCOUNT_SIZE:
return 36915840;
default:
return UINT64_MAX;
}
Expand Down
5 changes: 5 additions & 0 deletions program/c/src/oracle/oracle.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const uint64_t SUCCESSFULLY_UPDATED_AGGREGATE = 1000ULL;
// Rust portion of the codebase.
const uint64_t TIME_MACHINE_STRUCT_SIZE = 1864ULL;

const uint64_t EXTRA_PUBLISHER_SPACE = 1000ULL;


// magic number at head of account
#define PC_MAGIC 0xa1b2c3d4

Expand Down Expand Up @@ -190,6 +193,8 @@ typedef struct pc_price

static_assert( sizeof( pc_price_t ) == 3312, "" );

const uint64_t PRICE_ACCOUNT_SIZE = TIME_MACHINE_STRUCT_SIZE + EXTRA_PUBLISHER_SPACE + sizeof( pc_price_t );

// command enumeration
typedef enum {

Expand Down