github.com/condensat/bank-core@v0.1.0/database/model/batch.go (about)

     1  // Copyright 2020 Condensat Tech. All rights reserved.
     2  // Use of this source code is governed by a MIT
     3  // license that can be found in the LICENSE file.
     4  
     5  package model
     6  
     7  import (
     8  	"time"
     9  )
    10  
    11  type BatchID ID
    12  type BatchData String
    13  type BatchNetwork String
    14  
    15  const (
    16  	BatchNetworkSepa  BatchNetwork = "sepa"
    17  	BatchNetworkSwift BatchNetwork = "swift"
    18  	BatchNetworkCard  BatchNetwork = "card"
    19  
    20  	BatchNetworkBitcoin          BatchNetwork = "bitcoin"
    21  	BatchNetworkBitcoinTestnet   BatchNetwork = "bitcoin-testnet"
    22  	BatchNetworkBitcoinLiquid    BatchNetwork = "liquid"
    23  	BatchNetworkBitcoinLightning BatchNetwork = "lightning"
    24  )
    25  
    26  type Batch struct {
    27  	ID           BatchID      `gorm:"primary_key"`
    28  	Timestamp    time.Time    `gorm:"index;not null;type:timestamp"`   // Creation timestamp
    29  	ExecuteAfter time.Time    `gorm:"index;not null;type:timestamp"`   // Execute after timestamp
    30  	Capacity     Int          `gorm:"index;not null"`                  // Batch capacity
    31  	Network      BatchNetwork `gorm:"index;not null;size:24"`          // Network [sepa, swift, card, bitcoin, bitcoin-testnet, liquid, lightning]
    32  	Data         BatchData    `gorm:"type:blob;not null;default:'{}'"` // Batch data
    33  }
    34  
    35  func (p *Batch) IsComplete() bool {
    36  	return !time.Now().UTC().Before(p.ExecuteAfter)
    37  }