storage

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoTxID = uint32(0) // reserved for non-transactional operations
)

Variables

View Source
var (
	ErrNoRows     = errors.New("No rows matched in the database")
	ErrTxConflict = errors.New("Transaction conflict")
	ErrTxInvalid  = errors.New("Invalid transaction")
)
View Source
var (
	ErrNilValue          = errors.New("Value cannot be nil")
	ErrSQLiteRequiresCgo = errors.New("sqlite3 requires cgo; rebuild with CGO_ENABLED=1 or use -storesql")
)

Functions

func IsDbError

func IsDbError(err error) bool

Return true if the error database error is not a business logic response (e.g. no rows found).

Types

type DAL

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

func NewDAL

func NewDAL(store KVStore) *DAL

func (*DAL) CountCidsByTokenAndState

func (d *DAL) CountCidsByTokenAndState(token *entity.TokenInfo, state int) (int, error)

func (*DAL) CountInactiveCidsByTokenAndState

func (d *DAL) CountInactiveCidsByTokenAndState(token *entity.TokenInfo, state int, stateTs time.Time) (int, error)

func (*DAL) CountPayments

func (d *DAL) CountPayments() (int, error)

func (*DAL) DeleteBridgeRouting

func (d *DAL) DeleteBridgeRouting(destNetId uint64) error

func (*DAL) DeleteChan

func (d *DAL) DeleteChan(cid ctype.CidType) error

func (*DAL) DeleteChanMessage

func (d *DAL) DeleteChanMessage(cid ctype.CidType, seqnum uint64) error

func (*DAL) DeleteChanMigration

func (d *DAL) DeleteChanMigration(cid ctype.CidType) error

func (*DAL) DeleteCooperativeWithdrawJob

func (d *DAL) DeleteCooperativeWithdrawJob(withdrawHash string) error

func (*DAL) DeleteCrossNetPay

func (d *DAL) DeleteCrossNetPay(payID ctype.PayIDType) error

func (*DAL) DeleteDelegatedPay

func (d *DAL) DeleteDelegatedPay(payID ctype.PayIDType) error

func (*DAL) DeleteDeposit

func (d *DAL) DeleteDeposit(uuid string) error

func (*DAL) DeleteDestToken

func (d *DAL) DeleteDestToken(dest ctype.Addr, token *entity.TokenInfo) error

func (*DAL) DeleteEdge

func (d *DAL) DeleteEdge(cid ctype.CidType) error

func (*DAL) DeleteLeaseOwner

func (d *DAL) DeleteLeaseOwner(id, owner string) error

func (*DAL) DeleteNetBridge

func (d *DAL) DeleteNetBridge(bridgeAddr ctype.Addr) error

func (*DAL) DeleteNetToken

func (d *DAL) DeleteNetToken(netId uint64, netToken *entity.TokenInfo) error

func (*DAL) DeletePayPath

func (d *DAL) DeletePayPath(payID ctype.PayIDType) error

func (*DAL) DeletePayment

func (d *DAL) DeletePayment(payID ctype.PayIDType) error

func (*DAL) DeleteQueryTime

func (d *DAL) DeleteQueryTime(query string) error

func (*DAL) DeleteRouting

func (d *DAL) DeleteRouting(dest ctype.Addr, token *entity.TokenInfo) error

func (*DAL) DeleteSecret

func (d *DAL) DeleteSecret(hash string) error

func (*DAL) DeleteSecretByPayID

func (d *DAL) DeleteSecretByPayID(payID ctype.PayIDType) error

func (*DAL) GetAllBridgeRouting

func (d *DAL) GetAllBridgeRouting() (map[uint64]ctype.Addr, error)

func (*DAL) GetAllChanLedgers

func (d *DAL) GetAllChanLedgers() ([]ctype.Addr, error)

func (*DAL) GetAllChanMessages

func (d *DAL) GetAllChanMessages(cid ctype.CidType) ([]*rpc.CelerMsg, error)

func (*DAL) GetAllCooperativeWithdrawJobKeys

func (d *DAL) GetAllCooperativeWithdrawJobKeys() ([]string, error)

func (*DAL) GetAllDepositJobsByCid

func (d *DAL) GetAllDepositJobsByCid(cid ctype.CidType) ([]*structs.DepositJob, error)

func (*DAL) GetAllDepositJobsByState

func (d *DAL) GetAllDepositJobsByState(state int) ([]*structs.DepositJob, error)

func (*DAL) GetAllDestTokenOsps

func (d *DAL) GetAllDestTokenOsps() (map[ctype.Addr]map[ctype.Addr]map[ctype.Addr]bool, error)

func (*DAL) GetAllEdges

func (d *DAL) GetAllEdges() ([]*structs.Edge, error)

func (*DAL) GetAllNetBridges

func (d *DAL) GetAllNetBridges() (map[ctype.Addr]uint64, error)

func (*DAL) GetAllNetTokents

func (d *DAL) GetAllNetTokents() (map[ctype.Addr]map[uint64]ctype.Addr, error)

func (*DAL) GetAllPayIDs

func (d *DAL) GetAllPayIDs() ([]ctype.PayIDType, error)

func (*DAL) GetAllPaymentInfoByCid

func (d *DAL) GetAllPaymentInfoByCid(cid ctype.CidType) ([]ctype.PayIDType, []*entity.ConditionalPay, []*anypb.Any, []ctype.CidType, []int, []ctype.CidType, []int, []*time.Time, error)

func (*DAL) GetAllPeerServers

func (d *DAL) GetAllPeerServers() ([]string, error)

func (*DAL) GetAllRoutingCids

func (d *DAL) GetAllRoutingCids() (map[ctype.Addr]map[ctype.Addr]ctype.CidType, error)

func (*DAL) GetAllRunningDepositJobs

func (d *DAL) GetAllRunningDepositJobs() ([]*structs.DepositJob, error)

func (*DAL) GetAllSubmittedDepositTxHashes

func (d *DAL) GetAllSubmittedDepositTxHashes() ([]string, error)

func (*DAL) GetBridgeRouting

func (d *DAL) GetBridgeRouting(destNetId uint64) (ctype.Addr, uint64, bool, error)

func (*DAL) GetChanForDeposit

func (d *DAL) GetChanForDeposit(cid ctype.CidType) (int, *entity.TokenInfo, ctype.Addr, ctype.Addr, bool, error)

func (*DAL) GetChanForMigration

func (d *DAL) GetChanForMigration(cid ctype.CidType) (int, ctype.Addr, bool, error)

func (*DAL) GetChanLedger

func (d *DAL) GetChanLedger(cid ctype.CidType) (ctype.Addr, bool, error)

func (*DAL) GetChanMessage

func (d *DAL) GetChanMessage(cid ctype.CidType, seqnum uint64) (*rpc.CelerMsg, bool, error)

func (*DAL) GetChanMigration

func (d *DAL) GetChanMigration(cid ctype.CidType, toLedger ctype.Addr) (uint64, int, []byte, bool, error)

func (*DAL) GetChanMigrationReqByLedgerAndStateWithLimit

func (d *DAL) GetChanMigrationReqByLedgerAndStateWithLimit(toLedger ctype.Addr, state, limit int) (map[ctype.CidType][]byte, map[ctype.CidType]uint64, error)

func (*DAL) GetChanOpenResp

func (d *DAL) GetChanOpenResp(cid ctype.CidType) (*rpc.OpenChannelResponse, bool, error)

func (*DAL) GetChanPeer

func (d *DAL) GetChanPeer(cid ctype.CidType) (ctype.Addr, bool, error)

func (*DAL) GetChanSeqNums

func (d *DAL) GetChanSeqNums(cid ctype.CidType) (uint64, uint64, uint64, uint64, bool, error)

func (*DAL) GetChanState

func (d *DAL) GetChanState(cid ctype.CidType) (int, bool, error)

func (*DAL) GetChanStateToken

func (d *DAL) GetChanStateToken(cid ctype.CidType) (int, *entity.TokenInfo, bool, error)

func (*DAL) GetChannelsForAuthAck

func (d *DAL) GetChannelsForAuthAck(peerAddr ctype.Addr) ([]*chanForAuthAck, error)

func (*DAL) GetChannelsForAuthReq

func (d *DAL) GetChannelsForAuthReq(peerAddr ctype.Addr) ([]*rpc.ChannelSummary, error)

func (*DAL) GetCidByPeerToken

func (d *DAL) GetCidByPeerToken(peer ctype.Addr, token *entity.TokenInfo) (ctype.CidType, bool, error)

func (*DAL) GetCidStateByPeerToken

func (d *DAL) GetCidStateByPeerToken(peer ctype.Addr, token *entity.TokenInfo) (ctype.CidType, int, bool, error)

func (*DAL) GetCidTokensByPeer

func (d *DAL) GetCidTokensByPeer(peerAddr ctype.Addr) ([]ctype.CidType, []ctype.Addr, error)

func (*DAL) GetCidsByTokenAndState

func (d *DAL) GetCidsByTokenAndState(token *entity.TokenInfo, state int) ([]ctype.CidType, error)

func (*DAL) GetClosedChan

func (d *DAL) GetClosedChan(cid ctype.CidType) (ctype.Addr, *entity.TokenInfo, *time.Time, *time.Time, bool, error)

func (*DAL) GetCooperativeWithdrawJob

func (d *DAL) GetCooperativeWithdrawJob(withdrawHash string) (*structs.CooperativeWithdrawJob, error)

func (*DAL) GetCrossNetInfoByOrignalPayID

func (d *DAL) GetCrossNetInfoByOrignalPayID(originalPayID ctype.PayIDType) (ctype.PayIDType, int, ctype.Addr, bool, error)

func (*DAL) GetCrossNetInfoByPayID

func (d *DAL) GetCrossNetInfoByPayID(payID ctype.PayIDType) (ctype.PayIDType, int, ctype.Addr, bool, error)

func (*DAL) GetDelegatedPayStatus

func (d *DAL) GetDelegatedPayStatus(payID ctype.PayIDType) (int, bool, error)

func (*DAL) GetDelegatedPaysOnStatus

func (d *DAL) GetDelegatedPaysOnStatus(dest ctype.Addr, status int) (map[ctype.PayIDType]*entity.ConditionalPay, error)

func (*DAL) GetDeposit

func (d *DAL) GetDeposit(uuid string) (ctype.CidType, bool, *big.Int, bool, time.Time, int, string, string, bool, error)

func (*DAL) GetDepositByTxHash

func (d *DAL) GetDepositByTxHash(txhash string) (string, ctype.CidType, bool, *big.Int, bool, time.Time, int, string, bool, error)

func (*DAL) GetDepositJob

func (d *DAL) GetDepositJob(uuid string) (*structs.DepositJob, bool, error)

func (*DAL) GetDepositJobByTxHash

func (d *DAL) GetDepositJobByTxHash(txhash string) (*structs.DepositJob, bool, error)

func (*DAL) GetDepositState

func (d *DAL) GetDepositState(uuid string) (int, string, bool, error)

func (*DAL) GetDestTokenOpenChanBlkNum

func (d *DAL) GetDestTokenOpenChanBlkNum(dest ctype.Addr, token *entity.TokenInfo) (uint64, bool, error)

func (*DAL) GetDestTokenOsps

func (d *DAL) GetDestTokenOsps(dest ctype.Addr, token *entity.TokenInfo) ([]ctype.Addr, error)

func (*DAL) GetInactiveChansByTokenAndState

func (d *DAL) GetInactiveChansByTokenAndState(token *entity.TokenInfo, state int, stateTs time.Time) ([]ctype.CidType, []ctype.Addr, []*entity.TokenInfo, []*time.Time, []*time.Time, []*structs.OnChainBalance, []*entity.SimplexPaymentChannel, []*entity.SimplexPaymentChannel, error)

func (*DAL) GetInactiveCidsByTokenAndState

func (d *DAL) GetInactiveCidsByTokenAndState(token *entity.TokenInfo, state int, stateTs time.Time) ([]ctype.CidType, error)

func (*DAL) GetLeaseOwner

func (d *DAL) GetLeaseOwner(id string) (string, bool, error)

func (*DAL) GetLocalToken

func (d *DAL) GetLocalToken(netId uint64, netToken *entity.TokenInfo) (*entity.TokenInfo, bool, error)

func (*DAL) GetMonitorAddrsByEventAndRestart

func (d *DAL) GetMonitorAddrsByEventAndRestart(eventName string, restart bool) ([]ctype.Addr, error)

func (*DAL) GetMonitorBlock

func (d *DAL) GetMonitorBlock(event string) (uint64, int64, bool, error)

func (*DAL) GetMonitorRestart

func (d *DAL) GetMonitorRestart(event string) (bool, bool, error)

func (*DAL) GetNetBridge

func (d *DAL) GetNetBridge(bridgeAddr ctype.Addr) (uint64, bool, error)

func (*DAL) GetNetId

func (d *DAL) GetNetId() (uint64, error)

func (*DAL) GetOnChainBalance

func (d *DAL) GetOnChainBalance(cid ctype.CidType) (*structs.OnChainBalance, bool, error)

func (*DAL) GetPayAndEgressState

func (d *DAL) GetPayAndEgressState(payID ctype.PayIDType) (*entity.ConditionalPay, []byte, int, bool, error)

GetPayAndEgressState returns (pay, pay_bytes, egress_state, found, error)

func (*DAL) GetPayDelegator

func (d *DAL) GetPayDelegator(payID ctype.PayIDType) (ctype.Addr, bool, error)

func (*DAL) GetPayEgress

func (d *DAL) GetPayEgress(payID ctype.PayIDType) (ctype.CidType, int, bool, error)

func (*DAL) GetPayEgressChannel

func (d *DAL) GetPayEgressChannel(payID ctype.PayIDType) (ctype.CidType, bool, error)

func (*DAL) GetPayForRecvSettleProof

func (d *DAL) GetPayForRecvSettleProof(payID ctype.PayIDType) (*entity.ConditionalPay, ctype.Addr, bool, error)

func (*DAL) GetPayHistory

func (d *DAL) GetPayHistory(
	peer ctype.Addr, beforeTs time.Time, smallestPayID ctype.PayIDType, maxResultSize int32) ([]ctype.PayIDType, []*entity.ConditionalPay, []int64, []int64, error)

GetPayHistory returns payIDs, pay entities, pay in_states and creation time where peer is either src or dest of the pay. Pays are sorted in reverse-chronological order. smallestPayID: if query result contains multiple entries with creation timestamp equals to beforeTs, the pays returned from this func will only include ones that has higher payID than smallestPayID. Same dimensions of the four guaranteed.

func (*DAL) GetPayIngress

func (d *DAL) GetPayIngress(payID ctype.PayIDType) (ctype.CidType, int, bool, error)

func (*DAL) GetPayIngressChannel

func (d *DAL) GetPayIngressChannel(payID ctype.PayIDType) (ctype.CidType, bool, error)

func (*DAL) GetPayIngressPeer

func (d *DAL) GetPayIngressPeer(payID ctype.PayIDType) (ctype.Addr, bool, error)

func (*DAL) GetPayNote

func (d *DAL) GetPayNote(payID ctype.PayIDType) (*anypb.Any, bool, error)

func (*DAL) GetPayPath

func (d *DAL) GetPayPath(payID ctype.PayIDType) (*rpc.PayPath, error)

func (*DAL) GetPayStates

func (d *DAL) GetPayStates(payID ctype.PayIDType) (int, int, bool, error)

func (*DAL) GetPayment

func (d *DAL) GetPayment(payID ctype.PayIDType) (*entity.ConditionalPay, []byte, bool, error)

func (*DAL) GetPaymentInfo

func (d *DAL) GetPaymentInfo(payID ctype.PayIDType) (*entity.ConditionalPay, *anypb.Any, ctype.CidType, int, ctype.CidType, int, *time.Time, bool, error)

func (*DAL) GetPaysForAuthAck

func (d *DAL) GetPaysForAuthAck(payIDs []ctype.PayIDType, isOut bool) ([]*rpc.PayInAuthAck, error)

func (*DAL) GetPeerCids

func (d *DAL) GetPeerCids(peer ctype.Addr) ([]ctype.CidType, bool, error)

func (*DAL) GetPeerDelegateProof

func (d *DAL) GetPeerDelegateProof(peer ctype.Addr) (*rpc.DelegationProof, bool, error)

func (*DAL) GetPeerServer

func (d *DAL) GetPeerServer(peer ctype.Addr) (string, bool, error)

func (*DAL) GetPeerSimplex

func (*DAL) GetQueryTime

func (d *DAL) GetQueryTime(query string) (uint64, error)

func (*DAL) GetRoutingCid

func (d *DAL) GetRoutingCid(dest ctype.Addr, token *entity.TokenInfo) (ctype.CidType, bool, error)

func (*DAL) GetSecret

func (d *DAL) GetSecret(hash string) (string, bool, error)

func (*DAL) GetSelfSimplex

func (*DAL) GetTcbDeposit

func (d *DAL) GetTcbDeposit(addr ctype.Addr, token *entity.TokenInfo) (*big.Int, bool, error)

func (*DAL) HasCooperativeWithdrawJob

func (d *DAL) HasCooperativeWithdrawJob(withdrawHash string) (bool, error)

func (*DAL) HasDepositTxHash

func (d *DAL) HasDepositTxHash(txhash string) (bool, error)

func (*DAL) HasNetId

func (d *DAL) HasNetId() (bool, error)

func (*DAL) InsertChan

func (d *DAL) InsertChan(cid ctype.CidType, peer ctype.Addr, token *entity.TokenInfo, ledger ctype.Addr, state int, openResp *rpc.OpenChannelResponse, onchainBalance *structs.OnChainBalance, baseSeqNum uint64, lastUsedSeqNum uint64, lastAckedSeqNum uint64, lastNackedSeqNum uint64, selfSimplex *rpc.SignedSimplexState, peerSimplex *rpc.SignedSimplexState) error

func (*DAL) InsertChanMessage

func (d *DAL) InsertChanMessage(cid ctype.CidType, seqnum uint64, msg *rpc.CelerMsg) error

The "messages" table.

func (*DAL) InsertChanWithTs

func (d *DAL) InsertChanWithTs(cid ctype.CidType, peer ctype.Addr, token *entity.TokenInfo, ledger ctype.Addr, state int, stateTs, openTs time.Time, openResp *rpc.OpenChannelResponse, onchainBalance *structs.OnChainBalance, baseSeqNum uint64, lastUsedSeqNum uint64, lastAckedSeqNum uint64, lastNackedSeqNum uint64, selfSimplex *rpc.SignedSimplexState, peerSimplex *rpc.SignedSimplexState) error

The "channels" table.

func (*DAL) InsertClosedChan

func (d *DAL) InsertClosedChan(cid ctype.CidType, peer ctype.Addr, token *entity.TokenInfo, openTs time.Time, closeTs time.Time) error

The "closedchannels" table.

func (*DAL) InsertCrossNetPay

func (d *DAL) InsertCrossNetPay(payID, originalPayID ctype.PayIDType, originalPay []byte, state int, srcNetId, DstNetId uint64, bridgeAddr ctype.Addr, bridgeNetId uint64) error

The "crossnetpays" table.

func (*DAL) InsertDelegatedPay

func (d *DAL) InsertDelegatedPay(payID ctype.PayIDType, dest ctype.Addr, status int) error

The "paydelegation" table.

func (*DAL) InsertDeposit

func (d *DAL) InsertDeposit(uuid string, cid ctype.CidType, topeer bool, amount *big.Int, refill bool, deadline time.Time, state int, txhash string, errmsg string) error

The "deposit" table

func (*DAL) InsertDestToken

func (d *DAL) InsertDestToken(dest ctype.Addr, token *entity.TokenInfo, osps []ctype.Addr, chanBlockNum uint64) error

The "desttokens" table.

func (*DAL) InsertEdge

func (d *DAL) InsertEdge(token *entity.TokenInfo, cid ctype.CidType, addr1, addr2 ctype.Addr) error

The "edges" table.

func (*DAL) InsertMonitor

func (d *DAL) InsertMonitor(event string, blockNum uint64, blockIdx int64, restart bool) error

The "monitor" table.

func (*DAL) InsertPayDelegator

func (d *DAL) InsertPayDelegator(payID ctype.PayIDType, dest, delegator ctype.Addr) error

func (*DAL) InsertPayment

func (d *DAL) InsertPayment(payID ctype.PayIDType, payBytes []byte, pay *entity.ConditionalPay, note *anypb.Any, inCid ctype.CidType, inState int, outCid ctype.CidType, outState int) error

func (*DAL) InsertPaymentWithTs

func (d *DAL) InsertPaymentWithTs(payID ctype.PayIDType, payBytes []byte, pay *entity.ConditionalPay, note *anypb.Any, inCid ctype.CidType, inState int, outCid ctype.CidType, outState int, createTs time.Time) error

The "payments" table.

func (*DAL) InsertPeer

func (d *DAL) InsertPeer(peer ctype.Addr, server string, cids []ctype.CidType) error

The "peers" table.

func (*DAL) InsertSecret

func (d *DAL) InsertSecret(hash, preImage string, payID ctype.PayIDType) error

The "secrets" table.

func (*DAL) InsertTcb

func (d *DAL) InsertTcb(addr ctype.Addr, token *entity.TokenInfo, deposit *big.Int) error

The "tcb" table.

func (*DAL) OpenTransaction

func (d *DAL) OpenTransaction() (*DALTx, error)

func (*DAL) PutCooperativeWithdrawJob

func (d *DAL) PutCooperativeWithdrawJob(
	withdrawHash string, job *structs.CooperativeWithdrawJob) error

func (*DAL) PutNetId

func (d *DAL) PutNetId(id uint64) error

func (*DAL) PutPayPath

func (d *DAL) PutPayPath(payID ctype.PayIDType, path *rpc.PayPath) error

func (*DAL) PutQueryTime

func (d *DAL) PutQueryTime(query string, ts uint64) error

func (*DAL) Transactional

func (d *DAL) Transactional(callback TxFunc, args ...interface{}) error

func (*DAL) UpdateChanLedger

func (d *DAL) UpdateChanLedger(cid ctype.CidType, ledger ctype.Addr) error

func (*DAL) UpdateChanMigrationState

func (d *DAL) UpdateChanMigrationState(cid ctype.CidType, toLedger ctype.Addr, state int) error

func (*DAL) UpdateChanOpenResp

func (d *DAL) UpdateChanOpenResp(cid ctype.CidType, openResp *rpc.OpenChannelResponse) error

func (*DAL) UpdateChanSeqNums

func (d *DAL) UpdateChanSeqNums(cid ctype.CidType, baseSeqNum uint64, lastUsedSeqNum uint64, lastAckedSeqNum uint64, lastNackedSeqNum uint64) error

func (*DAL) UpdateChanState

func (d *DAL) UpdateChanState(cid ctype.CidType, state int) error

func (*DAL) UpdateDelegatedPayStatus

func (d *DAL) UpdateDelegatedPayStatus(payID ctype.PayIDType, status int) error

func (*DAL) UpdateDepositErrMsg

func (d *DAL) UpdateDepositErrMsg(uuid, errmsg string) error

func (*DAL) UpdateDepositErrMsgByTxHash

func (d *DAL) UpdateDepositErrMsgByTxHash(txhash, errmsg string) error

func (*DAL) UpdateDepositStateAndTxHash

func (d *DAL) UpdateDepositStateAndTxHash(uuid string, state int, txhash string) error

func (*DAL) UpdateDepositStatesByTxHashAndCid

func (d *DAL) UpdateDepositStatesByTxHashAndCid(txhash string, cid ctype.CidType, state int) error

func (*DAL) UpdateDepositsErrMsg

func (d *DAL) UpdateDepositsErrMsg(uuids []string, errmsg string) error

func (*DAL) UpdateDepositsStateAndTxHash

func (d *DAL) UpdateDepositsStateAndTxHash(uuids []string, state int, txhash string) error

func (*DAL) UpdateDestTokenOsps

func (d *DAL) UpdateDestTokenOsps(dest ctype.Addr, token *entity.TokenInfo, osps []ctype.Addr) error

func (*DAL) UpdateLeaseTimestamp

func (d *DAL) UpdateLeaseTimestamp(id, owner string) error

func (*DAL) UpdateMonitorBlock

func (d *DAL) UpdateMonitorBlock(event string, blockNum uint64, blockIdx int64) error

func (*DAL) UpdateOnChainBalance

func (d *DAL) UpdateOnChainBalance(cid ctype.CidType, balance *structs.OnChainBalance) error

func (*DAL) UpdatePeerCid

func (d *DAL) UpdatePeerCid(peer ctype.Addr, cid ctype.CidType, add bool) error

func (*DAL) UpdatePeerCids

func (d *DAL) UpdatePeerCids(peer ctype.Addr, cids []ctype.CidType) error

func (*DAL) UpdatePeerDelegateProof

func (d *DAL) UpdatePeerDelegateProof(peer ctype.Addr, proof *rpc.DelegationProof) error

func (*DAL) UpdateTcbDeposit

func (d *DAL) UpdateTcbDeposit(addr ctype.Addr, token *entity.TokenInfo, deposit *big.Int) error

func (*DAL) UpsertBridgeRouting

func (d *DAL) UpsertBridgeRouting(destNetId uint64, bridgeAddr ctype.Addr) error

The "bridgerouting" table

func (*DAL) UpsertChanMigration

func (d *DAL) UpsertChanMigration(cid ctype.CidType, toLedger ctype.Addr, deadline uint64, state int, onchainReq *chain.ChannelMigrationRequest) error

The "migration" table

func (*DAL) UpsertDestTokenOpenChanBlkNum

func (d *DAL) UpsertDestTokenOpenChanBlkNum(dest ctype.Addr, token *entity.TokenInfo, chanBlockNum uint64) error

func (*DAL) UpsertMonitorBlock

func (d *DAL) UpsertMonitorBlock(event string, blockNum uint64, blockIdx int64, restart bool) error

func (*DAL) UpsertMonitorRestart

func (d *DAL) UpsertMonitorRestart(event string, restart bool) error

func (*DAL) UpsertNetBridge

func (d *DAL) UpsertNetBridge(bridgeAddr ctype.Addr, bridgeNetId uint64) error

The "netbridge" table

func (*DAL) UpsertNetToken

func (d *DAL) UpsertNetToken(netId uint64, netToken *entity.TokenInfo, localToken *entity.TokenInfo) error

The "nettokens" table

func (*DAL) UpsertPeerServer

func (d *DAL) UpsertPeerServer(peer ctype.Addr, server string) error

func (*DAL) UpsertRouting

func (d *DAL) UpsertRouting(dest ctype.Addr, token *entity.TokenInfo, cid ctype.CidType) error

The "routing" table.

type DALTx

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

func (*DALTx) Commit

func (tx *DALTx) Commit() error

func (*DALTx) ConvertError

func (tx *DALTx) ConvertError(err error) error

func (*DALTx) DeleteChan

func (dtx *DALTx) DeleteChan(cid ctype.CidType) error

func (*DALTx) DeleteChanMessage

func (dtx *DALTx) DeleteChanMessage(cid ctype.CidType, seqnum uint64) error

func (*DALTx) DeleteChanMigration

func (dtx *DALTx) DeleteChanMigration(cid ctype.CidType) error

func (*DALTx) DeleteCooperativeWithdrawJob

func (dtx *DALTx) DeleteCooperativeWithdrawJob(withdrawHash string) error

func (*DALTx) DeleteDelegatedPay

func (dtx *DALTx) DeleteDelegatedPay(payID ctype.PayIDType) error

func (*DALTx) DeleteLease

func (dtx *DALTx) DeleteLease(id string) error

func (*DALTx) DeleteOpenChannelTs

func (dtx *DALTx) DeleteOpenChannelTs(peerAddr, tokenAddr ctype.Addr) error

func (*DALTx) DeletePayment

func (dtx *DALTx) DeletePayment(payID ctype.PayIDType) error

func (*DALTx) DeleteQueryTime

func (dtx *DALTx) DeleteQueryTime(query string) error

func (*DALTx) DeleteRouting

func (dtx *DALTx) DeleteRouting(dest ctype.Addr, token *entity.TokenInfo) error

func (*DALTx) DeleteSecretByPayID

func (dtx *DALTx) DeleteSecretByPayID(payID ctype.PayIDType) error

func (*DALTx) Discard

func (tx *DALTx) Discard()

func (*DALTx) GetAllCooperativeWithdrawJobKeys

func (dtx *DALTx) GetAllCooperativeWithdrawJobKeys() ([]string, error)

func (*DALTx) GetChanForClose

func (dtx *DALTx) GetChanForClose(cid ctype.CidType) (ctype.Addr, *entity.TokenInfo, time.Time, bool, error)

func (*DALTx) GetChanForIntendSettle

func (dtx *DALTx) GetChanForIntendSettle(cid ctype.CidType) (ctype.Addr, int, *entity.SimplexPaymentChannel, *entity.SimplexPaymentChannel, bool, error)

func (*DALTx) GetChanForMigration

func (dtx *DALTx) GetChanForMigration(cid ctype.CidType) (int, ctype.Addr, bool, error)

func (*DALTx) GetChanForRecvResponse

func (dtx *DALTx) GetChanForRecvResponse(cid ctype.CidType) (ctype.Addr, int, uint64, uint64, uint64, uint64, bool, error)

func (*DALTx) GetChanForSendPaySettleRequest

func (dtx *DALTx) GetChanForSendPaySettleRequest(cid ctype.CidType) (ctype.Addr, int, uint64, uint64, uint64, *entity.SimplexPaymentChannel, bool, error)

func (*DALTx) GetChanLedger

func (dtx *DALTx) GetChanLedger(cid ctype.CidType) (ctype.Addr, bool, error)

func (*DALTx) GetChanMessage

func (dtx *DALTx) GetChanMessage(cid ctype.CidType, seqnum uint64) (*rpc.CelerMsg, bool, error)

func (*DALTx) GetChanMigration

func (dtx *DALTx) GetChanMigration(cid ctype.CidType, toLedger ctype.Addr) (uint64, int, []byte, bool, error)

func (*DALTx) GetChanPeer

func (dtx *DALTx) GetChanPeer(cid ctype.CidType) (ctype.Addr, bool, error)

func (*DALTx) GetChanPeerState

func (dtx *DALTx) GetChanPeerState(cid ctype.CidType) (ctype.Addr, int, bool, error)

func (*DALTx) GetChanSeqNums

func (dtx *DALTx) GetChanSeqNums(cid ctype.CidType) (uint64, uint64, uint64, uint64, bool, error)

func (*DALTx) GetChanState

func (dtx *DALTx) GetChanState(cid ctype.CidType) (int, bool, error)

func (*DALTx) GetChanStateAndPeerSimplex

func (dtx *DALTx) GetChanStateAndPeerSimplex(cid ctype.CidType) (int, *entity.SimplexPaymentChannel, bool, error)

func (*DALTx) GetCooperativeWithdrawJob

func (dtx *DALTx) GetCooperativeWithdrawJob(
	withdrawHash string) (*structs.CooperativeWithdrawJob, error)

func (*DALTx) GetDelegatedPayStatus

func (dtx *DALTx) GetDelegatedPayStatus(payID ctype.PayIDType) (int, bool, error)

func (*DALTx) GetLease

func (dtx *DALTx) GetLease(id string) (string, time.Time, bool, error)

func (*DALTx) GetMonitorBlock

func (dtx *DALTx) GetMonitorBlock(event string) (uint64, int64, bool, error)

func (*DALTx) GetMonitorRestart

func (dtx *DALTx) GetMonitorRestart(event string) (bool, bool, error)

func (*DALTx) GetOnChainBalance

func (dtx *DALTx) GetOnChainBalance(cid ctype.CidType) (*structs.OnChainBalance, bool, error)

func (*DALTx) GetOpenChannelTs

func (dtx *DALTx) GetOpenChannelTs(peerAddr, tokenAddr ctype.Addr) (*openchannelts.OpenChannelTs, error)

func (*DALTx) GetPayAndEgressState

func (dtx *DALTx) GetPayAndEgressState(payID ctype.PayIDType) (*entity.ConditionalPay, []byte, int, bool, error)

func (*DALTx) GetPayDelegator

func (dtx *DALTx) GetPayDelegator(payID ctype.PayIDType) (ctype.Addr, bool, error)

func (*DALTx) GetPayEgress

func (dtx *DALTx) GetPayEgress(payID ctype.PayIDType) (ctype.CidType, int, bool, error)

func (*DALTx) GetPayForRecvSecret

func (dtx *DALTx) GetPayForRecvSecret(payID ctype.PayIDType) (*entity.ConditionalPay, *anypb.Any, int, bool, error)

func (*DALTx) GetPayForRecvSettleReq

func (dtx *DALTx) GetPayForRecvSettleReq(payID ctype.PayIDType) (*entity.ConditionalPay, *anypb.Any, ctype.CidType, int, int, bool, error)

func (*DALTx) GetPayIngress

func (dtx *DALTx) GetPayIngress(payID ctype.PayIDType) (ctype.CidType, int, bool, error)

func (*DALTx) GetPayIngressChannel

func (dtx *DALTx) GetPayIngressChannel(payID ctype.PayIDType) (ctype.CidType, bool, error)

func (*DALTx) GetPayNote

func (dtx *DALTx) GetPayNote(payID ctype.PayIDType) (*anypb.Any, bool, error)

func (*DALTx) GetPayment

func (dtx *DALTx) GetPayment(payID ctype.PayIDType) (*entity.ConditionalPay, []byte, bool, error)

func (*DALTx) GetPeerCids

func (dtx *DALTx) GetPeerCids(peer ctype.Addr) ([]ctype.CidType, bool, error)

func (*DALTx) GetPeerServer

func (dtx *DALTx) GetPeerServer(peer ctype.Addr) (string, bool, error)

func (*DALTx) GetPeerSimplex

func (*DALTx) GetQueryTime

func (dtx *DALTx) GetQueryTime(query string) (uint64, error)

func (*DALTx) GetSecret

func (dtx *DALTx) GetSecret(hash string) (string, bool, error)

func (*DALTx) GetTcbDeposit

func (dtx *DALTx) GetTcbDeposit(addr ctype.Addr, token *entity.TokenInfo) (*big.Int, bool, error)

func (*DALTx) HasCooperativeWithdrawJob

func (dtx *DALTx) HasCooperativeWithdrawJob(withdrawHash string) (bool, error)

func (*DALTx) HasDepositRefillPending

func (dtx *DALTx) HasDepositRefillPending(cid ctype.CidType) (bool, error)

func (*DALTx) HasOpenChannelTs

func (dtx *DALTx) HasOpenChannelTs(peerAddr, tokenAddr ctype.Addr) (bool, error)

func (*DALTx) InsertChan

func (dtx *DALTx) InsertChan(cid ctype.CidType, peer ctype.Addr, token *entity.TokenInfo, ledger ctype.Addr, state int, openResp *rpc.OpenChannelResponse, onchainBalance *structs.OnChainBalance, baseSeqNum uint64, lastUsedSeqNum uint64, lastAckedSeqNum uint64, lastNackedSeqNum uint64, selfSimplex *rpc.SignedSimplexState, peerSimplex *rpc.SignedSimplexState) error

func (*DALTx) InsertChanMessage

func (dtx *DALTx) InsertChanMessage(cid ctype.CidType, seqnum uint64, msg *rpc.CelerMsg) error

func (*DALTx) InsertClosedChan

func (dtx *DALTx) InsertClosedChan(cid ctype.CidType, peer ctype.Addr, token *entity.TokenInfo, openTs time.Time, closeTs time.Time) error

func (*DALTx) InsertDelegatedPay

func (dtx *DALTx) InsertDelegatedPay(payID ctype.PayIDType, dest ctype.Addr, status int) error

func (*DALTx) InsertDeposit

func (dtx *DALTx) InsertDeposit(uuid string, cid ctype.CidType, topeer bool, amount *big.Int, refill bool, deadline time.Time, state int, txhash string, errmsg string) error

func (*DALTx) InsertLease

func (dtx *DALTx) InsertLease(id, owner string) error

func (*DALTx) InsertMonitor

func (dtx *DALTx) InsertMonitor(event string, blockNum uint64, blockIdx int64, restart bool) error

func (*DALTx) InsertPayment

func (dtx *DALTx) InsertPayment(payID ctype.PayIDType, payBytes []byte, pay *entity.ConditionalPay, note *anypb.Any, inCid ctype.CidType, inState int, outCid ctype.CidType, outState int) error

func (*DALTx) InsertPeer

func (dtx *DALTx) InsertPeer(peer ctype.Addr, server string, cids []ctype.CidType) error

func (*DALTx) InsertSecret

func (dtx *DALTx) InsertSecret(hash, preImage string, payID ctype.PayIDType) error

func (*DALTx) InsertTcb

func (dtx *DALTx) InsertTcb(addr ctype.Addr, token *entity.TokenInfo, deposit *big.Int) error

func (*DALTx) PutCooperativeWithdrawJob

func (dtx *DALTx) PutCooperativeWithdrawJob(
	withdrawHash string, job *structs.CooperativeWithdrawJob) error

func (*DALTx) PutOpenChannelTs

func (dtx *DALTx) PutOpenChannelTs(peerAddr, tokenAddr ctype.Addr, openChannelTs *openchannelts.OpenChannelTs) error

func (*DALTx) PutQueryTime

func (dtx *DALTx) PutQueryTime(query string, ts uint64) error

func (*DALTx) UpdateChanForRecvRequest

func (dtx *DALTx) UpdateChanForRecvRequest(cid ctype.CidType, peerSimplex *rpc.SignedSimplexState) error

func (*DALTx) UpdateChanForRecvResponse

func (dtx *DALTx) UpdateChanForRecvResponse(cid ctype.CidType, baseSeqNum uint64, lastUsedSeqNum uint64, lastAckedSeqNum uint64, lastNackedSeqNum uint64, selfSimplex *rpc.SignedSimplexState) error

func (*DALTx) UpdateChanForSendRequest

func (dtx *DALTx) UpdateChanForSendRequest(cid ctype.CidType, baseSeqNum uint64, lastUsedSeqNum uint64) error

func (*DALTx) UpdateChanLedger

func (dtx *DALTx) UpdateChanLedger(cid ctype.CidType, ledger ctype.Addr) error

func (*DALTx) UpdateChanMigrationState

func (dtx *DALTx) UpdateChanMigrationState(cid ctype.CidType, toLedger ctype.Addr, state int) error

func (*DALTx) UpdateChanSeqNums

func (dtx *DALTx) UpdateChanSeqNums(cid ctype.CidType, baseSeqNum uint64, lastUsedSeqNum uint64, lastAckedSeqNum uint64, lastNackedSeqNum uint64) error

func (*DALTx) UpdateChanState

func (dtx *DALTx) UpdateChanState(cid ctype.CidType, state int) error

func (*DALTx) UpdateDelegatedPayStatus

func (dtx *DALTx) UpdateDelegatedPayStatus(payID ctype.PayIDType, status int) error

func (*DALTx) UpdateDepositStatesByTxHashAndCid

func (dtx *DALTx) UpdateDepositStatesByTxHashAndCid(txhash string, cid ctype.CidType, state int) error

func (*DALTx) UpdateLeaseOwner

func (dtx *DALTx) UpdateLeaseOwner(id, owner string) error

func (*DALTx) UpdateLeaseTimestamp

func (dtx *DALTx) UpdateLeaseTimestamp(id, owner string) error

func (*DALTx) UpdateMonitorBlock

func (dtx *DALTx) UpdateMonitorBlock(event string, blockNum uint64, blockIdx int64) error

func (*DALTx) UpdateOnChainBalance

func (dtx *DALTx) UpdateOnChainBalance(cid ctype.CidType, balance *structs.OnChainBalance) error

func (*DALTx) UpdatePayEgress

func (dtx *DALTx) UpdatePayEgress(payID ctype.PayIDType, cid ctype.CidType, state int) error

func (*DALTx) UpdatePayEgressState

func (dtx *DALTx) UpdatePayEgressState(payID ctype.PayIDType, state int) error

func (*DALTx) UpdatePayIngressState

func (dtx *DALTx) UpdatePayIngressState(payID ctype.PayIDType, state int) error

func (*DALTx) UpdatePeerCid

func (dtx *DALTx) UpdatePeerCid(peer ctype.Addr, cid ctype.CidType, add bool) error

func (*DALTx) UpdatePeerCids

func (dtx *DALTx) UpdatePeerCids(peer ctype.Addr, cids []ctype.CidType) error

func (*DALTx) UpdateSendingDelegatedPay

func (dtx *DALTx) UpdateSendingDelegatedPay(payID, payIDout ctype.PayIDType) error

func (*DALTx) UpdateTcbDeposit

func (dtx *DALTx) UpdateTcbDeposit(addr ctype.Addr, token *entity.TokenInfo, deposit *big.Int) error

func (*DALTx) UpsertChanMigration

func (dtx *DALTx) UpsertChanMigration(cid ctype.CidType, toLedger ctype.Addr, deadline uint64, state int, onchainReq *chain.ChannelMigrationRequest) error

func (*DALTx) UpsertMonitorBlock

func (dtx *DALTx) UpsertMonitorBlock(event string, blockNum uint64, blockIdx int64, restart bool) error

func (*DALTx) UpsertMonitorRestart

func (dtx *DALTx) UpsertMonitorRestart(event string, restart bool) error

type KVStore

type KVStore interface {
	Close()
	OpenTransaction() (Transaction, error)
	Put(table, key string, value interface{}) error
	Get(table, key string, value interface{}) error
	Delete(table, key string) error
	Has(table, key string) (bool, error)
	GetKeysByPrefix(table, prefix string) ([]string, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

KVStore is the interface implemented by the local store (LevelDB wrapper) and by the remote store (gRPC calls to a store server).

type KVStoreSQL

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

func NewKVStoreSQL

func NewKVStoreSQL(driver, info string) (*KVStoreSQL, error)

Create a new remote K/V store.

func (*KVStoreSQL) Close

func (s *KVStoreSQL) Close()

Close the remote K/V store.

func (*KVStoreSQL) Delete

func (s *KVStoreSQL) Delete(table, key string) error

func (*KVStoreSQL) Exec

func (s *KVStoreSQL) Exec(query string, args ...interface{}) (sql.Result, error)

func (*KVStoreSQL) Get

func (s *KVStoreSQL) Get(table, key string, value interface{}) error

func (*KVStoreSQL) GetKeysByPrefix

func (s *KVStoreSQL) GetKeysByPrefix(table, prefix string) ([]string, error)

func (*KVStoreSQL) Has

func (s *KVStoreSQL) Has(table, key string) (bool, error)

func (*KVStoreSQL) OpenTransaction

func (s *KVStoreSQL) OpenTransaction() (Transaction, error)

func (*KVStoreSQL) Put

func (s *KVStoreSQL) Put(table, key string, value interface{}) error

func (*KVStoreSQL) Query

func (s *KVStoreSQL) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*KVStoreSQL) QueryRow

func (s *KVStoreSQL) QueryRow(query string, args ...interface{}) *sql.Row

type OnChainBalance

type OnChainBalance struct {
	MyDeposit         []byte
	MyWithdrawal      []byte
	PeerDeposit       []byte
	PeerWithdrawal    []byte
	PendingWithdrawal *PendingWithdrawal
}

DAL for on chain balances

type PendingWithdrawal

type PendingWithdrawal struct {
	Amount   []byte
	Receiver ctype.Addr
	Deadline uint64
}

type SqlStorage

type SqlStorage interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

type Storage

type Storage interface {
	Put(table, key string, value interface{}) error
	Get(table, key string, value interface{}) error
	Delete(table, key string) error
	Has(table, key string) (bool, error)
	GetKeysByPrefix(table, prefix string) ([]string, error)
}

type Transaction

type Transaction interface {
	Commit() error
	Discard()
	ConvertError(err error) error
	Put(table, key string, value interface{}) error
	Get(table, key string, value interface{}) error
	Delete(table, key string) error
	Has(table, key string) (bool, error)
	GetKeysByPrefix(table, prefix string) ([]string, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

Transaction is the interface implemented by the local and remote stores.

type TransactionSQL

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

func (*TransactionSQL) Commit

func (tx *TransactionSQL) Commit() error

func (*TransactionSQL) ConvertError

func (tx *TransactionSQL) ConvertError(err error) error

func (*TransactionSQL) Delete

func (tx *TransactionSQL) Delete(table, key string) error

func (*TransactionSQL) Discard

func (tx *TransactionSQL) Discard()

func (*TransactionSQL) Exec

func (tx *TransactionSQL) Exec(query string, args ...interface{}) (sql.Result, error)

func (*TransactionSQL) Get

func (tx *TransactionSQL) Get(table, key string, value interface{}) error

func (*TransactionSQL) GetKeysByPrefix

func (tx *TransactionSQL) GetKeysByPrefix(table, prefix string) ([]string, error)

func (*TransactionSQL) Has

func (tx *TransactionSQL) Has(table, key string) (bool, error)

func (*TransactionSQL) Put

func (tx *TransactionSQL) Put(table, key string, value interface{}) error

func (*TransactionSQL) Query

func (tx *TransactionSQL) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*TransactionSQL) QueryRow

func (tx *TransactionSQL) QueryRow(query string, args ...interface{}) *sql.Row

type TxFunc

type TxFunc func(tx *DALTx, args ...interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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