Jump to content

calculation fee and load factor from updates


jargoman

Recommended Posts

I'm changing some code to use subscribe rather than polling

public class LedgerClosed 
        {

                public int fee_base { get; set; }
                public int fee_ref { get; set; }
                public string ledger_hash { get; set; }
                public uint ledger_index { get; set; }
                public int ledger_time { get; set; }
                public int reserve_base { get; set; }
                public int reserve_inc { get; set; }
                public int txn_count { get; set; }
                public string type { get; set; }
                public string validated_ledgers { get; set; }

                public Tuple<string, UInt32?> GetFeeAndLastLedger ()
                {
                        double native_base_fee;

                        native_base_fee = fee_base; 

                        ulong transaction_fee = (ulong)((native_base_fee * 1000000) * LOADFACTOR);  <---  problem line


                        Tuple<string, UInt32?> ret = new Tuple<string, UInt32?> (transaction_fee.ToString (), ledger_index);

                        return ret;
        }

I have a feeling LOADFACTOR is not fee_ref.

Do I have to instead retrieve the load factor from the serverStatus updates?

I'm using the websocket subscribe api

oh and while I'm at it. Is subscribe Accounts[] blocked for wss://s1.ripple.com

with or without the comment Does not triggers events when tx's effect the account. Nor if transactions are signed by account

this is converted to JSON
object o = new {
                                id = identifierTag,
                                command = "subscribe",
                                accounts,
                                 //streams = new string [] { "transactions"} // somethings not working idk

                        };
 

Edited by jargoman
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

This is what I have now and I think is correct


                public static Tuple<string, UInt32> GetFeeAndLastLedger (CancellationToken token) {

                        LedgerClosed ledger = LastLedgerClosed;

                        if (ledger == null) {
                                return null;
                        }
                        

                        ServerStateEventArgs serverState = ServerStateEv;
                        if (serverState == null) {
                                return null;
                        }

                        double native_base_fee;

                        native_base_fee = serverState.base_fee;

                        ulong transaction_fee = (ulong)((native_base_fee * serverState.load_factor) / serverState.load_base);

                        Tuple<string, UInt32> ret = new Tuple<string, UInt32> (transaction_fee.ToString (), ledger.ledger_index);

                        return ret;



                }
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...