Documentation ¶
Index ¶
- Variables
- type Config
- type ConfirmationInfo
- type Database
- func (d *Database) Close() error
- func (d *Database) CompletedTeleports() ([]Teleport, error)
- func (d *Database) ConfirmedDeposits(blockNumber, confirmations uint64) ([]Deposit, error)
- func (d *Database) DeletePendingTx(startID, endID uint64) error
- func (d *Database) LastProcessedBlock() (*uint64, error)
- func (d *Database) LatestDisbursementID() (*uint64, error)
- func (d *Database) ListPendingTxs() ([]PendingTx, error)
- func (d *Database) LoadTeleportByDepositHash(txHash common.Hash) (*Teleport, error)
- func (d *Database) LoadTeleportsByAddress(addr common.Address) ([]Teleport, error)
- func (d *Database) Migrate() error
- func (d *Database) UpsertDeposits(deposits []Deposit, lastProcessedBlock uint64) error
- func (d *Database) UpsertDisbursement(id uint64, txnHash common.Hash, blockNumber uint64, blockTimestamp time.Time, ...) error
- func (d *Database) UpsertPendingTx(pendingTx PendingTx) error
- type Deposit
- type Disbursement
- type PendingTx
- type Scanner
- type Teleport
Constants ¶
This section is empty.
Variables ¶
var ( // ErrZeroTimestamp signals that the caller attempted to insert deposits // with a timestamp of zero. ErrZeroTimestamp = errors.New("timestamp is zero") // ErrUnknownDeposit signals that the target deposit could not be found. ErrUnknownDeposit = errors.New("unknown deposit") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Host is the database hostname. Host string Port uint16 // User is the database user to log in as. User string // Password is the user's password to authenticate. Password string // DBName is the name of the database to connect to. DBName string // EnableSSL enables SLL on the connection if set to true. EnableSSL bool }
Config houses the data required to connect to a Postgres backend.
type ConfirmationInfo ¶
ConfirmationInfo holds metadata about a tx on either the L1 or L2 chain.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database provides a Go API for accessing Teleportr read/write operations.
func Open ¶
Open creates a new database connection to the configured Postgres backend and applies any migrations.
func (*Database) CompletedTeleports ¶
CompletedTeleports returns the set of all deposits that have also been disbursed.
func (*Database) ConfirmedDeposits ¶
ConfirmedDeposits returns the set of all deposits that have sufficient confirmation, but do not have a recorded disbursement.
func (*Database) DeletePendingTx ¶
DeletePendingTx removes any pending txs with matching start and end ids. This allows the caller to remove any logically-conflicting pending txs from the database after successfully processing the outcomes.
func (*Database) LastProcessedBlock ¶
func (*Database) LatestDisbursementID ¶
LatestDisbursementID returns the latest deposit id known to the database that has a recorded disbursement.
func (*Database) ListPendingTxs ¶
ListPendingTxs returns all pending txs stored in the database.
func (*Database) LoadTeleportByDepositHash ¶
func (*Database) LoadTeleportsByAddress ¶
func (*Database) UpsertDeposits ¶
UpsertDeposits inserts a list of deposits into the database, or updats an existing deposit in place if the same ID is found.
func (*Database) UpsertDisbursement ¶
func (d *Database) UpsertDisbursement( id uint64, txnHash common.Hash, blockNumber uint64, blockTimestamp time.Time, success bool, ) error
UpsertDisbursement inserts a disbursement, or updates an existing record in-place if the ID already exists.
func (*Database) UpsertPendingTx ¶
UpsertPendingTx inserts a disbursement, or updates the entry if the TxHash already exists.
type Deposit ¶
Deposit represents an event emitted from the TeleportrDeposit contract on L1, along with additional info about the tx that generated the event.
type Disbursement ¶
type Disbursement struct { Success bool ConfirmationInfo }
type PendingTx ¶
type PendingTx struct { // Txhash is the tx hash of the disbursement tx. TxHash common.Hash // StartID is the deposit id of the first disbursement, inclusive. StartID uint64 // EndID is the deposit id fo the last disbursement, exclusive. EndID uint64 }
PendingTx encapsulates the metadata stored about published disbursement txs.
type Teleport ¶
type Teleport struct { Deposit Disbursement *Disbursement }
Teleport represents the combination of an L1 deposit and its disbursement on L2. Disburment will be nil if the L2 disbursement has not occurred.