bridge

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package bchain provides the B-Chain (Bridge) adapter for cross-chain bridge operations. B-Chain uses DAG consensus for fast finality of bridge transfers.

Index

Constants

View Source
const (
	DefaultPort     = 4600
	DefaultDatabase = "explorer_bchain"
	RPCMethod       = "bvm"
)

Default configuration

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter implements dag.Adapter for B-Chain bridge operations

func New

func New(rpcEndpoint string) *Adapter

New creates a new B-Chain adapter

func (*Adapter) GetRecentVertices

func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)

GetRecentVertices fetches recent vertices from the B-Chain RPC

func (*Adapter) GetStats

func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)

GetStats returns B-Chain specific statistics

func (*Adapter) GetTransfersByChain

func (a *Adapter) GetTransfersByChain(ctx context.Context, store storage.Store, chainID string, direction string, limit int) ([]Transfer, error)

GetTransfersByChain retrieves transfers for a specific chain

func (*Adapter) GetVertexByID

func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)

GetVertexByID fetches a specific vertex by ID

func (*Adapter) InitSchema

func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error

InitSchema creates B-Chain specific database tables

func (*Adapter) ParseVertex

func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)

ParseVertex parses B-Chain vertex data from RPC response

func (*Adapter) StoreProof

func (a *Adapter) StoreProof(ctx context.Context, store storage.Store, p *Proof) error

StoreProof stores a bridge proof

func (*Adapter) StoreTransfer

func (a *Adapter) StoreTransfer(ctx context.Context, store storage.Store, vertexID string, t *Transfer) error

StoreTransfer stores a bridge transfer

func (*Adapter) UpdateBridgeStats

func (a *Adapter) UpdateBridgeStats(ctx context.Context, store storage.Store) error

UpdateBridgeStats updates aggregate bridge statistics

type BridgeStatus

type BridgeStatus string

BridgeStatus indicates the state of a cross-chain transfer

const (
	BridgeStatusPending   BridgeStatus = "pending"
	BridgeStatusLocked    BridgeStatus = "locked"
	BridgeStatusConfirmed BridgeStatus = "confirmed"
	BridgeStatusReleased  BridgeStatus = "released"
	BridgeStatusFailed    BridgeStatus = "failed"
)

type LockedAsset

type LockedAsset struct {
	AssetID     string    `json:"assetId"`
	SourceChain string    `json:"sourceChain"`
	Amount      string    `json:"amount"`
	LockTxID    string    `json:"lockTxId"`
	LockedAt    time.Time `json:"lockedAt"`
	UnlockedAt  time.Time `json:"unlockedAt,omitempty"`
}

LockedAsset represents an asset locked in the bridge

type Proof

type Proof struct {
	ID         string    `json:"id"`
	TransferID string    `json:"transferId"`
	ProofType  string    `json:"proofType"` // merkle, signature, zk
	ProofData  string    `json:"proofData"`
	Validators []string  `json:"validators,omitempty"`
	Signatures []string  `json:"signatures,omitempty"`
	Verified   bool      `json:"verified"`
	VerifiedAt time.Time `json:"verifiedAt,omitempty"`
	CreatedAt  time.Time `json:"createdAt"`
}

Proof represents a bridge proof for cross-chain validation

type Transfer

type Transfer struct {
	ID            string       `json:"id"`
	SourceChain   string       `json:"sourceChain"`
	DestChain     string       `json:"destChain"`
	SourceTxID    string       `json:"sourceTxId"`
	DestTxID      string       `json:"destTxId,omitempty"`
	Sender        string       `json:"sender"`
	Recipient     string       `json:"recipient"`
	AssetID       string       `json:"assetId"`
	Amount        string       `json:"amount"`
	Fee           string       `json:"fee,omitempty"`
	Status        BridgeStatus `json:"status"`
	LockHeight    uint64       `json:"lockHeight,omitempty"`
	ReleaseHeight uint64       `json:"releaseHeight,omitempty"`
	ProofHash     string       `json:"proofHash,omitempty"`
	Timestamp     time.Time    `json:"timestamp"`
}

Transfer represents a cross-chain bridge transfer

Jump to

Keyboard shortcuts

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