func (db *Database) RecordInfo(
	name string,
	block uint64,
	balances, denormWeights, tokenTotalSupplies map[string]interface{},
) error {
	name = strings.ToLower(name)
	db.namedLock.Lock(name)
	defer db.namedLock.Unlock(name)
	return db.db.Transaction(func(tx *gorm.DB) error {
		var pool Pool
		if err := tx.Model(&Pool{}).Where(
			"name = ?", name,
		).First(&pool).Error; err != nil {
			return err
		}
		if pool.LastUpdateAt == block {
			// no need to update
			return nil
		}
		pool.LastUpdateAt = block
		pool.Infos[strconv.FormatUint(block, 10)] = PoolInfo{
			Balances:            balances,
			DenormalizedWeights: denormWeights,
			TokenTotalSupplies:  tokenTotalSupplies,
		}
		return tx.Save(&pool).Error
	})
}
// RecordInfo is used to record updates infos for the given block
RecordInfo is used to record updates infos for the given block
// RecordInfo is used to record updates infos for the given block
func (db *Database) RecordInfo(
	name string,
	block uint64,
	balances, denormWeights, tokenTotalSupplies map[string]interface{},
) error {
	name = strings.ToLower(name)
	db.namedLock.Lock(name)
	defer db.namedLock.Unlock(name)
	return db.db.Transaction(func(tx *gorm.DB) error {
		var pool Pool
		if err := tx.Model(&Pool{}).Where(
			"name = ?", name,
		).First(&pool).Error; err != nil {
			return err
		}
		if pool.LastUpdateAt == block {
			return nil
		}
		pool.LastUpdateAt = block
		pool.Infos[strconv.FormatUint(block, 10)] = PoolInfo{
			Balances:            balances,
			DenormalizedWeights: denormWeights,
			TokenTotalSupplies:  tokenTotalSupplies,
		}
		return tx.Save(&pool).Error
	})
}
func ( db * Database ) RecordInfo ( name string , block uint64 , balances , denormWeights , tokenTotalSupplies map [ string ] interface { } , ) error { name = strings . ToLower ( name ) db . namedLock . Lock ( name ) defer db . namedLock . Unlock ( name ) return db . db . Transaction ( func ( tx * gorm . DB ) error { var pool Pool if err := tx . Model ( & Pool { } ) . Where ( " " , name , ) . First ( & pool ) . Error ; err != nil { return err } if pool . LastUpdateAt == block { return nil } pool . LastUpdateAt = block pool . Infos [ strconv . FormatUint ( block , 10 ) ] = PoolInfo { Balances : balances , DenormalizedWeights : denormWeights , TokenTotalSupplies : tokenTotalSupplies , } return tx . Save ( & pool ) . Error } ) }
RecordInfo is used to record updates infos for the given block
RecordInfo is used to record updates infos for the given block
// no need to update