ledgerview

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OnChainStatus_UNINITIALIZED uint8 = 0
	OnChainStatus_OPERABLE      uint8 = 1
	OnChainStatus_SETTLING      uint8 = 2
	OnChainStatus_CLOSED        uint8 = 3
	OnChainStatus_MIGRATED      uint8 = 4
)

Variables

This section is empty.

Functions

func ChanStatusName

func ChanStatusName(status uint8) string

func ComputeBalance

func ComputeBalance(
	selfSimplex, peerSimplex *entity.SimplexPaymentChannel,
	onChainBalance *structs.OnChainBalance,
	myAddr, peerAddr ctype.Addr,
	nowTs uint64) *common.ChannelBalance

ComputeBalance derives free / locked channel balance. nowTs is a unix timestamp (seconds) used to evaluate the active-pending-withdraw deadline window.

func GetBalance

func GetBalance(dal *storage.DAL, cid ctype.CidType, myAddr ctype.Addr, nowTs uint64) (*common.ChannelBalance, error)

GetBalance computes the channel balance. nowTs is a unix timestamp (seconds) used to decide whether a pending withdrawal is still active per the contract's `block.timestamp`-based deadline semantics.

func GetBalanceTx

func GetBalanceTx(tx *storage.DALTx, cid ctype.CidType, myAddr ctype.Addr, nowTs uint64) (*common.ChannelBalance, error)

func GetBaseSimplex

func GetBaseSimplex(
	tx *storage.DALTx,
	cid ctype.CidType,
	selfSimplex *entity.SimplexPaymentChannel,
	baseSeq, lastAckedSeq uint64) (*entity.SimplexPaymentChannel, error)

func GetMigratedTo

func GetMigratedTo(dal *storage.DAL, cid ctype.CidType, nodeConfig common.GlobalNodeConfig) (ctype.Addr, error)

GetMigratedTo queries the ledger contract for channel migration info. When channel status is "Migrated", it would return the new ledger to which the channel migrated. When channel status is not "Migrated", it would return address 0x0. Usually call GetOnChainChannelStatus before call this

func GetOnChainChannelBalance

func GetOnChainChannelBalance(cid ctype.CidType, ledgerAddr ctype.Addr, nodeConfig common.GlobalNodeConfig) (*structs.OnChainBalance, error)

GetOnChainChannelBalance queries the ledger contract for channel balance

func GetOnChainChannelStatus

func GetOnChainChannelStatus(cid ctype.CidType, nodeConfig common.GlobalNodeConfig) (uint8, error)

func GetOnChainChannelStatusOnLedger

func GetOnChainChannelStatusOnLedger(cid ctype.CidType, nodeConfig common.GlobalNodeConfig, ledgerAddr ctype.Addr) (uint8, error)

func GetOnChainDisputeTimeout

func GetOnChainDisputeTimeout(cid ctype.CidType, nodeConfig common.GlobalNodeConfig) (uint64, error)

func GetOnChainSettleFinalizedTime

func GetOnChainSettleFinalizedTime(cid ctype.CidType, nodeConfig common.GlobalNodeConfig) (*big.Int, error)

func GetOnChainWithdrawIntent

func GetOnChainWithdrawIntent(cid ctype.CidType, nodeConfig common.GlobalNodeConfig) (
	ctype.Addr, *big.Int, uint64, ctype.CidType, error)

func SyncOnChainBalance

func SyncOnChainBalance(dal *storage.DAL, cid ctype.CidType, nodeConfig common.GlobalNodeConfig) error

SyncOnChainBalance updates local on-chain balances for the given channel

func SyncOnChainBalanceTx

func SyncOnChainBalanceTx(tx *storage.DALTx, cid ctype.CidType, nodeConfig common.GlobalNodeConfig) (*structs.OnChainBalance, error)

Types

type TxInfo

type TxInfo struct {
	From      ctype.Addr
	To        ctype.Addr
	Pending   bool
	FuncName  string
	FuncInput map[string]interface{}
}

func GetOnChainTxByHash

func GetOnChainTxByHash(txhash ctype.Hash, nodeConfig common.GlobalNodeConfig) (*TxInfo, error)

Jump to

Keyboard shortcuts

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