Skip to content

Commit

Permalink
Merge pull request #34 from bnogalm/fee-stats-response
Browse files Browse the repository at this point in the history
Horizon v0.24.0 added a `fee_charged` and `max_fee` object with infor…
  • Loading branch information
bnogalm authored Feb 2, 2020
2 parents b985e49 + dd8ed2c commit cc7188d
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 87 deletions.
116 changes: 88 additions & 28 deletions src/responses/feestatsresponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,44 @@

FeeStatsResponse::FeeStatsResponse(QNetworkReply* reply)
:Response(reply)
,m_min(0)
,m_ledgerCapacityUsage(0)
,m_lastLedgerBaseFee(0)
,m_lastLedger(0)
{

}


FeeStatsResponse::~FeeStatsResponse(){}



float FeeStatsResponse::getLedgerCapacityUsage() const {
return m_ledgerCapacityUsage;
}

qint64 FeeStatsResponse::getLastLedgerBaseFee() const
{
return m_lastLedgerBaseFee;
}

qint64 FeeStatsResponse::getLastLedger() const
{
return m_lastLedger;
}

FeeDistribution FeeStatsResponse::getFeeCharged() const
{
return m_feeCharged;
}

FeeDistribution FeeStatsResponse::getMaxFee() const{
return m_maxFee;
}

FeeDistribution::FeeDistribution()
:m_min(0)
,m_max(0)
,m_mode(0)
,m_p10(0)
,m_p20(0)
Expand All @@ -15,79 +52,102 @@ FeeStatsResponse::FeeStatsResponse(QNetworkReply* reply)
,m_p90(0)
,m_p95(0)
,m_p99(0)
,m_ledgerCapacityUsage(0)
,m_lastLedgerBaseFee(0)
,m_lastLedger(0)
{

}

FeeStatsResponse::~FeeStatsResponse(){}

qint64 FeeStatsResponse::getMin() const
qint64 FeeDistribution::getMin() const
{
return m_min;
}

qint64 FeeStatsResponse::getMode() const
qint64 FeeDistribution::getMax() const
{
return m_max;
}

qint64 FeeDistribution::getMode() const
{
return m_mode;
}

qint64 FeeStatsResponse::getP10() const{
qint64 FeeDistribution::getP10() const{
return m_p10;
}

qint64 FeeStatsResponse::getP20() const{
qint64 FeeDistribution::getP20() const{
return m_p20;
}

qint64 FeeStatsResponse::getP30() const{
qint64 FeeDistribution::getP30() const{
return m_p30;
}

qint64 FeeStatsResponse::getP40() const{
qint64 FeeDistribution::getP40() const{
return m_p40;
}

qint64 FeeStatsResponse::getP50() const{
qint64 FeeDistribution::getP50() const{
return m_p50;
}

qint64 FeeStatsResponse::getP60() const{
qint64 FeeDistribution::getP60() const{
return m_p60;
}

qint64 FeeStatsResponse::getP70() const{
qint64 FeeDistribution::getP70() const{
return m_p70;
}

qint64 FeeStatsResponse::getP80() const{
qint64 FeeDistribution::getP80() const{
return m_p80;
}

qint64 FeeStatsResponse::getP90() const{
qint64 FeeDistribution::getP90() const{
return m_p90;
}

qint64 FeeStatsResponse::getP95() const{
qint64 FeeDistribution::getP95() const{
return m_p95;
}

qint64 FeeStatsResponse::getP99() const{
qint64 FeeDistribution::getP99() const{
return m_p99;
}

float FeeStatsResponse::getLedgerCapacityUsage() const {
return m_ledgerCapacityUsage;
}

qint64 FeeStatsResponse::getLastLedgerBaseFee() const
bool FeeDistribution::operator !=(FeeDistribution &feeDistribution)
{
return m_lastLedgerBaseFee;
}

qint64 FeeStatsResponse::getLastLedger() const
return (m_min != feeDistribution.m_min) ||
(m_max != feeDistribution.m_max) ||
(m_mode != feeDistribution.m_mode) ||
(m_p10 != feeDistribution.m_p10) ||
(m_p20 != feeDistribution.m_p20) ||
(m_p30 != feeDistribution.m_p30) ||
(m_p40 != feeDistribution.m_p40) ||
(m_p50 != feeDistribution.m_p50) ||
(m_p60 != feeDistribution.m_p60) ||
(m_p70 != feeDistribution.m_p70) ||
(m_p80 != feeDistribution.m_p80) ||
(m_p90 != feeDistribution.m_p90) ||
(m_p95 != feeDistribution.m_p95) ||
(m_p99 != feeDistribution.m_p99);
}

bool FeeDistribution::operator ==(FeeDistribution &feeDistribution)
{
return m_lastLedger;
return (m_min == feeDistribution.m_min) &&
(m_max == feeDistribution.m_max) &&
(m_mode == feeDistribution.m_mode) &&
(m_p10 == feeDistribution.m_p10) &&
(m_p20 == feeDistribution.m_p20) &&
(m_p30 == feeDistribution.m_p30) &&
(m_p40 == feeDistribution.m_p40) &&
(m_p50 == feeDistribution.m_p50) &&
(m_p60 == feeDistribution.m_p60) &&
(m_p70 == feeDistribution.m_p70) &&
(m_p80 == feeDistribution.m_p80) &&
(m_p90 == feeDistribution.m_p90) &&
(m_p95 == feeDistribution.m_p95) &&
(m_p99 == feeDistribution.m_p99);
}
81 changes: 53 additions & 28 deletions src/responses/feestatsresponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@

#include "response.h"

class FeeStatsResponse : public Response
class FeeDistribution
{
Q_OBJECT
Q_PROPERTY(qint64 min_accepted_fee MEMBER m_min)
Q_PROPERTY(qint64 mode_accepted_fee MEMBER m_mode)

Q_PROPERTY(qint64 p10_accepted_fee MEMBER m_p10)
Q_PROPERTY(qint64 p20_accepted_fee MEMBER m_p20)
Q_PROPERTY(qint64 p30_accepted_fee MEMBER m_p30)
Q_PROPERTY(qint64 p40_accepted_fee MEMBER m_p40)
Q_PROPERTY(qint64 p50_accepted_fee MEMBER m_p50)
Q_PROPERTY(qint64 p60_accepted_fee MEMBER m_p60)
Q_PROPERTY(qint64 p70_accepted_fee MEMBER m_p70)
Q_PROPERTY(qint64 p80_accepted_fee MEMBER m_p80)
Q_PROPERTY(qint64 p90_accepted_fee MEMBER m_p90)
Q_PROPERTY(qint64 p95_accepted_fee MEMBER m_p95)
Q_PROPERTY(qint64 p99_accepted_fee MEMBER m_p99)
Q_PROPERTY(float ledger_capacity_usage MEMBER m_ledgerCapacityUsage)
Q_PROPERTY(qint64 last_ledger_base_fee MEMBER m_lastLedgerBaseFee)
Q_PROPERTY(qint64 last_ledger MEMBER m_lastLedger)
Q_GADGET
Q_PROPERTY(qint64 min MEMBER m_min)
Q_PROPERTY(qint64 max MEMBER m_max)
Q_PROPERTY(qint64 mode MEMBER m_mode)

Q_PROPERTY(qint64 p10 MEMBER m_p10)
Q_PROPERTY(qint64 p20 MEMBER m_p20)
Q_PROPERTY(qint64 p30 MEMBER m_p30)
Q_PROPERTY(qint64 p40 MEMBER m_p40)
Q_PROPERTY(qint64 p50 MEMBER m_p50)
Q_PROPERTY(qint64 p60 MEMBER m_p60)
Q_PROPERTY(qint64 p70 MEMBER m_p70)
Q_PROPERTY(qint64 p80 MEMBER m_p80)
Q_PROPERTY(qint64 p90 MEMBER m_p90)
Q_PROPERTY(qint64 p95 MEMBER m_p95)
Q_PROPERTY(qint64 p99 MEMBER m_p99)
qint64 m_min;
qint64 m_max;
qint64 m_mode;

qint64 m_p10;
Expand All @@ -37,18 +36,12 @@ class FeeStatsResponse : public Response
qint64 m_p90;
qint64 m_p95;
qint64 m_p99;
float m_ledgerCapacityUsage;


qint64 m_lastLedgerBaseFee;
qint64 m_lastLedger;

public:
Q_INVOKABLE explicit FeeStatsResponse(QNetworkReply* reply=nullptr);
virtual ~FeeStatsResponse();

FeeDistribution();
qint64 getMin() const;

qint64 getMax() const;

qint64 getMode() const;

qint64 getP10() const;
Expand All @@ -73,14 +66,46 @@ class FeeStatsResponse : public Response

qint64 getP99() const;

bool operator !=(FeeDistribution& feeDistribution);
bool operator ==(FeeDistribution& feeDistribution);
};

class FeeStatsResponse : public Response
{
Q_OBJECT
Q_PROPERTY(float ledger_capacity_usage MEMBER m_ledgerCapacityUsage)
Q_PROPERTY(qint64 last_ledger_base_fee MEMBER m_lastLedgerBaseFee)
Q_PROPERTY(qint64 last_ledger MEMBER m_lastLedger)
Q_PROPERTY(FeeDistribution fee_charged MEMBER m_feeCharged)
Q_PROPERTY(FeeDistribution max_fee MEMBER m_maxFee)

float m_ledgerCapacityUsage;


qint64 m_lastLedgerBaseFee;
qint64 m_lastLedger;
FeeDistribution m_feeCharged;
FeeDistribution m_maxFee;

public:
Q_INVOKABLE explicit FeeStatsResponse(QNetworkReply* reply=nullptr);
virtual ~FeeStatsResponse();


float getLedgerCapacityUsage() const;

qint64 getLastLedgerBaseFee() const;

qint64 getLastLedger() const;

FeeDistribution getFeeCharged() const;

FeeDistribution getMaxFee() const;

};

Q_DECLARE_METATYPE(FeeDistribution)

#endif // FEESTATSRESPONSE_H


Expand Down
Loading

0 comments on commit cc7188d

Please sign in to comment.