func New(db *sql.DB, maxGatewayCount int) DB {
	return database{
		db:              db,
		maxGatewayCount: maxGatewayCount,
	}
}
New creates a new DB instance.
package db
import (
	"database/sql"
	"encoding/base64"
	"fmt"
	"math/big"
	"time"
	"github.com/renproject/darknode/engine"
	"github.com/renproject/darknode/tx"
	"github.com/renproject/id"
	"github.com/renproject/pack"
)
type TxStatus uint8
const (
	TxStatusNil TxStatus = iota
	TxStatusConfirming
	TxStatusConfirmed
	TxStatusSubmitted
)
type GatewayStatus uint8
const (
	GatewayStatusNil GatewayStatus = iota
	GatewayStatusEmpty
	GatewayStatusUsed
)
type Scannable interface {
	Scan(dest ...interface{}) error
}
type DB interface {
	Init() error
	InsertTx(tx tx.Tx) error
	Tx(hash id.Hash) (tx.Tx, error)
	Txs(offset, limit int, latest bool) ([]tx.Tx, error)
	TxsByTxid(id pack.Bytes) ([]tx.Tx, error)
	PendingTxs(expiry time.Duration) ([]tx.Tx, error)
	TxStatus(hash id.Hash) (TxStatus, error)
	UpdateStatus(hash id.Hash, status TxStatus) error
	Prune(expiry time.Duration) error
	InsertGateway(address string, tx tx.Tx) error
	Gateway(address string) (tx.Tx, error)
	Gateways(offset, limit int) ([]tx.Tx, error)
	GatewayCount() (int, error)
	MaxGatewayCount() int
}
type database struct {
	db              *sql.DB
	maxGatewayCount int
}