github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/token/memory_cache.go (about)

     1  package token
     2  
     3  const (
     4  	// InitFeeDetailsCap default fee detail list cap
     5  	InitFeeDetailsCap = 2000
     6  )
     7  
     8  // Cache for detail
     9  type Cache struct {
    10  	FeeDetails []*FeeDetail
    11  }
    12  
    13  // NewCache news cache for detail
    14  func NewCache() *Cache {
    15  	return &Cache{
    16  		FeeDetails: []*FeeDetail{},
    17  	}
    18  }
    19  
    20  func (c *Cache) reset() {
    21  	feeDetails := make([]*FeeDetail, 0, InitFeeDetailsCap)
    22  	c.FeeDetails = feeDetails
    23  }
    24  
    25  func (c *Cache) addFeeDetail(feeDetail *FeeDetail) {
    26  	c.FeeDetails = append(c.FeeDetails, feeDetail)
    27  }
    28  
    29  func (c *Cache) getFeeDetailList() []*FeeDetail {
    30  	return c.FeeDetails
    31  }