bfgd

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotificationBtcBlocks             database.NotificationName = "btc_blocks"
	NotificationAccessPublicKeyDelete database.NotificationName = "access_public_keys"
	NotificationL2Keystones           database.NotificationName = "l2_keystones"
)

NotificationName identifies a database notification type.

View Source
const (
	IdentifierBTCNewBlock = "btc-new-block"
	IdentifierBTCFinality = "btc-finality"
)

Variables

View Source
var BTCFinalityNotification = Notification{
	ID: IdentifierBTCFinality,
}
View Source
var BTCNewBlockNotification = Notification{
	ID: IdentifierBTCNewBlock,
}

Functions

func NotificationPayload

func NotificationPayload(ntfn database.NotificationName) (any, bool)

NotificationPayload returns the data structure corresponding to the given notification type.

Types

type AccessPublicKey

type AccessPublicKey struct {
	PublicKey []byte
	CreatedAt database.Timestamp `deep:"-"`

	// this is a hack to pull the public key from db notifications,
	// since it comes back as an encoded string
	PublicKeyEncoded string `json:"public_key" deep:"-"`
}

type BtcBlock

type BtcBlock struct {
	Hash      database.ByteArray `json:"hash"`
	Header    database.ByteArray `json:"header"`
	Height    uint64             `json:"height"`
	CreatedAt database.Timestamp `deep:"-"`
	UpdatedAt database.Timestamp `deep:"-"`
}

type Database

type Database interface {
	database.Database

	// Version table
	Version(ctx context.Context) (int, error)

	// L2 keystone table
	L2KeystonesInsert(ctx context.Context, l2ks []L2Keystone) error
	L2KeystonesCount(ctx context.Context) (int, error)
	L2KeystoneByAbrevHash(ctx context.Context, aHash [32]byte) (*L2Keystone, error)
	L2KeystonesMostRecentN(ctx context.Context, n uint32) ([]L2Keystone, error)

	// Btc block table
	BtcBlockInsert(ctx context.Context, bb *BtcBlock) error
	BtcBlockByHash(ctx context.Context, hash [32]byte) (*BtcBlock, error)
	BtcBlockHeightByHash(ctx context.Context, hash [32]byte) (uint64, error)

	// Pop data
	PopBasisByL2KeystoneAbrevHash(ctx context.Context, aHash [32]byte, excludeUnconfirmed bool) ([]PopBasis, error)
	PopBasisInsertFull(ctx context.Context, pb *PopBasis) error
	PopBasisInsertPopMFields(ctx context.Context, pb *PopBasis) error
	PopBasisUpdateBTCFields(ctx context.Context, pb *PopBasis) (int64, error)

	L2BTCFinalityMostRecent(ctx context.Context, limit uint32) ([]L2BTCFinality, error)
	L2BTCFinalityByL2KeystoneAbrevHash(ctx context.Context, l2KeystoneAbrevHashes []database.ByteArray) ([]L2BTCFinality, error)

	BtcBlockCanonicalHeight(ctx context.Context) (uint64, error)

	AccessPublicKeyInsert(ctx context.Context, publicKey *AccessPublicKey) error
	AccessPublicKeyExists(ctx context.Context, publicKey *AccessPublicKey) (bool, error)
	AccessPublicKeyDelete(ctx context.Context, publicKey *AccessPublicKey) error
}

type L2BTCFinality

type L2BTCFinality struct {
	L2Keystone       L2Keystone
	BTCPubHeight     int64
	BTCPubHeaderHash database.ByteArray
	EffectiveHeight  uint32
	BTCTipHeight     uint32
}

type L2Keystone

type L2Keystone struct {
	Hash               database.ByteArray // lookup key
	Version            uint32
	L1BlockNumber      uint32
	L2BlockNumber      uint32
	ParentEPHash       database.ByteArray
	PrevKeystoneEPHash database.ByteArray
	StateRoot          database.ByteArray
	EPHash             database.ByteArray
	CreatedAt          database.Timestamp `deep:"-"`
	UpdatedAt          database.Timestamp `deep:"-"`
}

type Notification

type Notification struct {
	ID string
}

XXX this needs to be generic

type PopBasis

type PopBasis struct {
	ID                  uint64 `deep:"-"`
	BtcTxId             database.ByteArray
	BtcRawTx            database.ByteArray
	BtcHeaderHash       database.ByteArray
	BtcTxIndex          *uint64
	BtcMerklePath       []string
	PopTxId             database.ByteArray
	PopMinerPublicKey   database.ByteArray
	L2KeystoneAbrevHash database.ByteArray
	CreatedAt           database.Timestamp `deep:"-"`
	UpdatedAt           database.Timestamp `deep:"-"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL