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
- type Adapter
- func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)
- func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
- func (a *Adapter) GetTransfersByChain(ctx context.Context, store storage.Store, chainID string, direction string, ...) ([]Transfer, error)
- func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)
- func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error
- func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)
- func (a *Adapter) StoreProof(ctx context.Context, store storage.Store, p *Proof) error
- func (a *Adapter) StoreTransfer(ctx context.Context, store storage.Store, vertexID string, t *Transfer) error
- func (a *Adapter) UpdateBridgeStats(ctx context.Context, store storage.Store) error
- type BridgeStatus
- type LockedAsset
- type Proof
- type Transfer
Constants ¶
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 (*Adapter) GetRecentVertices ¶
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 ¶
GetVertexByID fetches a specific vertex by ID
func (*Adapter) InitSchema ¶
InitSchema creates B-Chain specific database tables
func (*Adapter) ParseVertex ¶
ParseVertex parses B-Chain vertex data from RPC response
func (*Adapter) StoreProof ¶
StoreProof stores a bridge proof
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