All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.proximax.sdk.FeeCalculationStrategy Maven / Gradle / Ivy

Go to download

The ProximaX Sirius Chain Java SDK is a Java library for interacting with the Sirius Blockchain.

The newest version!
/*
 * Copyright 2019 ProximaX Limited. All rights reserved.
 * Use of this source code is governed by the Apache 2.0
 * license that can be found in the LICENSE file.
 */
package io.proximax.sdk;

import java.math.BigInteger;

/**
 * Fee calculation strategies for transactions
 */
public enum FeeCalculationStrategy {
   ZERO(0),
   LOW(25),
   MEDIUM(250),
   HIGH(2500);
   
   private static final int MAX_FEE = 5_000_000;
   
   private final int coefficient;

   /**
    * @param coefficient
    */
   private FeeCalculationStrategy(int coefficient) {
      this.coefficient = coefficient;
   }

   /**
    * @return the coefficient
    */
   public int getCoefficient() {
      return coefficient;
   }
   
   /**
    * calculate fee based on the transaction size
    * 
    * @param transactionSize size of transaction when serialized
    * @return the default maxFee
    */
   public BigInteger calculateFee(int transactionSize) {
      return BigInteger.valueOf(Math.min(MAX_FEE, transactionSize * getCoefficient()));
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy