Documentation
¶
Index ¶
- type NonParticipantChannel
- type PubRewardDB
- func (pdb *PubRewardDB) InsertHistoryReward(clientid, ethaddr string, nowsum int) (lastid int64, err error)
- func (pdb *PubRewardDB) SelectHistoryReward(clientid, ethaddr string) (ri *RewardInfo, err error)
- func (pdb *PubRewardDB) UpdateHistoryReward(clientid, ethaddr string, nowsum int) (affectid int64, err error)
- type RewardInfo
- type StormDB
- func (model *StormDB) AddToken(token common.Address, tokenNetworkAddress common.Address) error
- func (model *StormDB) CheckChainEventDelivered(id models.ChainEventID) (blockNumber uint64, delivered bool)
- func (model *StormDB) ClearOldChainEventRecord(blockNumber uint64)
- func (model *StormDB) CloseDB()
- func (model *StormDB) DeleteEnvelopMessager(echohash common.Hash)
- func (model *StormDB) GetAck(echoHash common.Hash) []byte
- func (model *StormDB) GetAllFeeChargeRecord(tokenAddress common.Address, fromTime, toTime int64) (records []*models.FeeChargeRecord, err error)
- func (model *StormDB) GetAllNonParticipantChannelByToken(token common.Address) (edges []common.Address, err error)
- func (model *StormDB) GetAllOrderedSentEnvelopMessager() []*models.SentEnvelopMessager
- func (model *StormDB) GetAllSettledChannel() (chs []*channeltype.Serialization, err error)
- func (model *StormDB) GetAllTokens() (tokens models.AddressMap, err error)
- func (model *StormDB) GetChainID() int64
- func (model *StormDB) GetChannel(token, partner common.Address) (c *channeltype.Serialization, err error)
- func (model *StormDB) GetChannelAnnounceDisposed(channelIdentifier common.Hash) []*models.ReceivedAnnounceDisposed
- func (model *StormDB) GetChannelByAddress(ChannelIdentifier common.Hash) (c *channeltype.Serialization, err error)
- func (model *StormDB) GetChannelList(token, partner common.Address) (cs []*channeltype.Serialization, err error)
- func (model *StormDB) GetContractStatus() models.ContractStatus
- func (model *StormDB) GetFeeChargeRecordByLockSecretHash(lockSecretHash common.Hash) (records []*models.FeeChargeRecord, err error)
- func (model *StormDB) GetFeePolicy() (fp *models.FeePolicy)
- func (model *StormDB) GetLastBlockNumberTime() time.Time
- func (model *StormDB) GetLatestBlockNumber() int64
- func (model *StormDB) GetNonParticipantChannelByID(channelIdentifierForQuery common.Hash) (tokenAddress common.Address, participant1, participant2 common.Address, ...)
- func (model *StormDB) GetReceivedAnnounceDisposed(lockHash, channelIdentifier common.Hash) *models.ReceivedAnnounceDisposed
- func (model *StormDB) GetReceivedTransfer(key string) (*models.ReceivedTransfer, error)
- func (model *StormDB) GetReceivedTransferList(tokenAddress common.Address, fromBlock, toBlock, fromTime, toTime int64) (transfers []*models.ReceivedTransfer, err error)
- func (model *StormDB) GetSentTransferDetail(tokenAddress common.Address, lockSecretHash common.Hash) (*models.SentTransferDetail, error)
- func (model *StormDB) GetSentTransferDetailList(tokenAddress common.Address, fromTime, toTime int64, fromBlock, toBlock int64) (transfers []*models.SentTransferDetail, err error)
- func (model *StormDB) GetSettledChannel(channelIdentifier common.Hash, openBlockNumber int64) (c *channeltype.Serialization, err error)
- func (model *StormDB) GetTXInfoList(channelIdentifier common.Hash, openBlockNumber int64, ...) (list []*models.TXInfo, err error)
- func (model *StormDB) GetTokenNodes(token common.Address) (nodes []common.Address)
- func (model *StormDB) IsDbCrashedLastTime() bool
- func (model *StormDB) IsLockHashCanPunish(lockHash, channelIdentifier common.Hash) bool
- func (model *StormDB) IsLockSecretHashChannelIdentifierDisposed(lockSecretHash common.Hash, ChannelIdentifier common.Hash) bool
- func (model *StormDB) IsLockSecretHashDisposed(lockSecretHash common.Hash) bool
- func (model *StormDB) IsThisLockHasUnlocked(channel common.Hash, lockHash common.Hash) bool
- func (model *StormDB) IsThisLockRemoved(channel common.Hash, sender common.Address, lockHash common.Hash) bool
- func (model *StormDB) MakeChainEventID(l *types.Log) models.ChainEventID
- func (model *StormDB) MarkDbOpenedStatus()
- func (model *StormDB) MarkLockHashCanPunish(r *models.ReceivedAnnounceDisposed) error
- func (model *StormDB) MarkLockSecretHashDisposed(lockSecretHash common.Hash, ChannelIdentifier common.Hash) error
- func (model *StormDB) NewChannel(c *channeltype.Serialization) error
- func (model *StormDB) NewDeliveredChainEvent(id models.ChainEventID, blockNumber uint64)
- func (model *StormDB) NewNonParticipantChannel(token common.Address, channel common.Hash, ...) error
- func (model *StormDB) NewPendingTXInfo(tx *types.Transaction, txType models.TXInfoType, channelIdentifier common.Hash, ...) (txInfo *models.TXInfo, err error)
- func (model *StormDB) NewReceivedTransfer(blockNumber int64, channelIdentifier common.Hash, openBlockNumber int64, ...) *models.ReceivedTransfer
- func (model *StormDB) NewSentEnvelopMessager(msg encoding.EnvelopMessager, receiver common.Address)
- func (model *StormDB) NewSentTransferDetail(tokenAddress, target common.Address, amount *big.Int, data string, ...)
- func (model *StormDB) NewSettledChannel(c *channeltype.Serialization) error
- func (model *StormDB) RegisterChannelDepositCallback(f cb.ChannelCb)
- func (model *StormDB) RegisterChannelSettleCallback(f cb.ChannelCb)
- func (model *StormDB) RegisterChannelStateCallback(f cb.ChannelCb)
- func (model *StormDB) RegisterNewChannelCallback(f cb.ChannelCb)
- func (model *StormDB) RegisterNewTokenCallback(f cb.NewTokenCb)
- func (model *StormDB) RemoveChannel(c *channeltype.Serialization) error
- func (model *StormDB) RemoveLock(channel common.Hash, sender common.Address, lockHash common.Hash)
- func (model *StormDB) RemoveNonParticipantChannel(channel common.Hash) error
- func (model *StormDB) SaveAck(echoHash common.Hash, ack []byte, tx models.TX)
- func (model *StormDB) SaveAckNoTx(echoHash common.Hash, ack []byte)
- func (model *StormDB) SaveChainID(chainID int64)
- func (model *StormDB) SaveContractStatus(contractStatus models.ContractStatus)
- func (model *StormDB) SaveEventToTXInfo(event interface{}) (txInfo *models.TXInfo, err error)
- func (model *StormDB) SaveFeeChargeRecord(r *models.FeeChargeRecord) (err error)
- func (model *StormDB) SaveFeePolicy(fp *models.FeePolicy) (err error)
- func (model *StormDB) SaveLatestBlockNumber(blockNumber int64)
- func (model *StormDB) StartTx() (tx models.TX)
- func (model *StormDB) UnlockThisLock(channel common.Hash, lockHash common.Hash)
- func (model *StormDB) UpdateChannel(c *channeltype.Serialization, tx models.TX) error
- func (model *StormDB) UpdateChannelAndSaveAck(c *channeltype.Serialization, echohash common.Hash, ack []byte) (err error)
- func (model *StormDB) UpdateChannelContractBalance(c *channeltype.Serialization) error
- func (model *StormDB) UpdateChannelNoTx(c *channeltype.Serialization) error
- func (model *StormDB) UpdateChannelState(c *channeltype.Serialization) error
- func (model *StormDB) UpdateSentTransferDetailStatus(tokenAddress common.Address, lockSecretHash common.Hash, ...) (transfer *models.SentTransferDetail)
- func (model *StormDB) UpdateSentTransferDetailStatusMessage(tokenAddress common.Address, lockSecretHash common.Hash, statusMessage string) (transfer *models.SentTransferDetail)
- func (model *StormDB) UpdateTXInfoStatus(txHash common.Hash, status models.TXInfoStatus, packBlockNumber int64, ...) (txInfo *models.TXInfo, err error)
- func (model *StormDB) UpdateTokenNodes(token common.Address, nodes []common.Address) error
- func (model *StormDB) XMPPIsAddrSubed(addr common.Address) bool
- func (model *StormDB) XMPPMarkAddrSubed(addr common.Address)
- func (model *StormDB) XMPPUnMarkAddr(addr common.Address)
- type StormTx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NonParticipantChannel ¶
type NonParticipantChannel struct { ChannelIdentifierBytes []byte `storm:"id"` TokenAddressBytes []byte `storm:"index"` Participant1Bytes []byte Participant2Bytes []byte }
NonParticipantChannel 所有的通道信息在本地的存储 因为合约不提供直接查询通道信息,只能通过事件获取,所以需要在本地保存一份,以便查询
- NonParticipantChannel : structure for back up of channel information at local storage.
- Because contract does not provide direct check for channel information, so we need to backup at local storage.
type PubRewardDB ¶
type PubRewardDB struct {
// contains filtered or unexported fields
}
PubDB init
func OpenPubDB ¶
func OpenPubDB(pubDataSource string) (DB *PubRewardDB, err error)
func (*PubRewardDB) InsertHistoryReward ¶
func (pdb *PubRewardDB) InsertHistoryReward(clientid, ethaddr string, nowsum int) (lastid int64, err error)
InsertHistoryReward
func (*PubRewardDB) SelectHistoryReward ¶
func (pdb *PubRewardDB) SelectHistoryReward(clientid, ethaddr string) (ri *RewardInfo, err error)
SelectHistoryReward
func (*PubRewardDB) UpdateHistoryReward ¶
func (pdb *PubRewardDB) UpdateHistoryReward(clientid, ethaddr string, nowsum int) (affectid int64, err error)
UpdateHistoryReward
type RewardInfo ¶
RewardInfo
type StormDB ¶
type StormDB struct { Name string // contains filtered or unexported fields }
StormDB is thread safe
func (*StormDB) CheckChainEventDelivered ¶
func (model *StormDB) CheckChainEventDelivered(id models.ChainEventID) (blockNumber uint64, delivered bool)
CheckChainEventDelivered check one ChainEvent is delivered or not
func (*StormDB) ClearOldChainEventRecord ¶
ClearOldChainEventRecord delete records which blockNumber <= blockNumber in param
func (*StormDB) DeleteEnvelopMessager ¶
DeleteEnvelopMessager delete a sending message from db
func (*StormDB) GetAllFeeChargeRecord ¶
func (model *StormDB) GetAllFeeChargeRecord(tokenAddress common.Address, fromTime, toTime int64) (records []*models.FeeChargeRecord, err error)
GetAllFeeChargeRecord :
func (*StormDB) GetAllNonParticipantChannelByToken ¶
func (model *StormDB) GetAllNonParticipantChannelByToken(token common.Address) (edges []common.Address, err error)
GetAllNonParticipantChannelByToken returna all channel on this `token`
func (*StormDB) GetAllOrderedSentEnvelopMessager ¶
func (model *StormDB) GetAllOrderedSentEnvelopMessager() []*models.SentEnvelopMessager
GetAllOrderedSentEnvelopMessager returns all EnvelopMessager message that have not receive ack and order them by nonce
func (*StormDB) GetAllSettledChannel ¶
func (model *StormDB) GetAllSettledChannel() (chs []*channeltype.Serialization, err error)
GetAllSettledChannel returns all settled channel
func (*StormDB) GetAllTokens ¶
func (model *StormDB) GetAllTokens() (tokens models.AddressMap, err error)
GetAllTokens returna all tokens on this registry contract
func (*StormDB) GetChannel ¶
func (model *StormDB) GetChannel(token, partner common.Address) (c *channeltype.Serialization, err error)
GetChannel return a channel queried by (token,partner),this channel must not settled
func (*StormDB) GetChannelAnnounceDisposed ¶
func (model *StormDB) GetChannelAnnounceDisposed(channelIdentifier common.Hash) []*models.ReceivedAnnounceDisposed
GetChannelAnnounceDisposed 获取指定 channel中对方声明放弃的锁,
- GetChannelAnnounceDisposed : function to receive disposed locks claimed by channel partner in specific channel
func (*StormDB) GetChannelByAddress ¶
func (model *StormDB) GetChannelByAddress(ChannelIdentifier common.Hash) (c *channeltype.Serialization, err error)
GetChannelByAddress return a channel queried by channel address
func (*StormDB) GetChannelList ¶
func (model *StormDB) GetChannelList(token, partner common.Address) (cs []*channeltype.Serialization, err error)
GetChannelList returns all related channels one of token and partner must be empty
func (*StormDB) GetContractStatus ¶
func (model *StormDB) GetContractStatus() models.ContractStatus
GetContractStatus returns registry address in db
func (*StormDB) GetFeeChargeRecordByLockSecretHash ¶
func (model *StormDB) GetFeeChargeRecordByLockSecretHash(lockSecretHash common.Hash) (records []*models.FeeChargeRecord, err error)
GetFeeChargeRecordByLockSecretHash :
func (*StormDB) GetFeePolicy ¶
GetFeePolicy :
func (*StormDB) GetLastBlockNumberTime ¶
GetLastBlockNumberTime return when last block received
func (*StormDB) GetLatestBlockNumber ¶
GetLatestBlockNumber lastest block number
func (*StormDB) GetNonParticipantChannelByID ¶
func (model *StormDB) GetNonParticipantChannelByID(channelIdentifierForQuery common.Hash) ( tokenAddress common.Address, participant1, participant2 common.Address, err error)
GetNonParticipantChannelByID return one channel's information
func (*StormDB) GetReceivedAnnounceDisposed ¶
func (model *StormDB) GetReceivedAnnounceDisposed(lockHash, channelIdentifier common.Hash) *models.ReceivedAnnounceDisposed
GetReceivedAnnounceDisposed return a ReceivedAnnounceDisposed ,if not exist,return nil
func (*StormDB) GetReceivedTransfer ¶
func (model *StormDB) GetReceivedTransfer(key string) (*models.ReceivedTransfer, error)
GetReceivedTransfer return the received transfer by key
func (*StormDB) GetReceivedTransferList ¶
func (model *StormDB) GetReceivedTransferList(tokenAddress common.Address, fromBlock, toBlock, fromTime, toTime int64) (transfers []*models.ReceivedTransfer, err error)
GetReceivedTransferList returns the received transfer between from and to blocks
func (*StormDB) GetSentTransferDetail ¶
func (model *StormDB) GetSentTransferDetail(tokenAddress common.Address, lockSecretHash common.Hash) (*models.SentTransferDetail, error)
GetSentTransferDetail :
func (*StormDB) GetSentTransferDetailList ¶
func (model *StormDB) GetSentTransferDetailList(tokenAddress common.Address, fromTime, toTime int64, fromBlock, toBlock int64) (transfers []*models.SentTransferDetail, err error)
GetSentTransferDetailList : 参数均为查询条件,传空值或负值代表不限制
func (*StormDB) GetSettledChannel ¶
func (model *StormDB) GetSettledChannel(channelIdentifier common.Hash, openBlockNumber int64) (c *channeltype.Serialization, err error)
GetSettledChannel 返回某个指定的已经 settle 的 channel GetSettledChannel : function to return a specific settled channel.
func (*StormDB) GetTXInfoList ¶
func (model *StormDB) GetTXInfoList(channelIdentifier common.Hash, openBlockNumber int64, tokenAddress common.Address, txType models.TXInfoType, status models.TXInfoStatus) (list []*models.TXInfo, err error)
GetTXInfoList : 如果参数不为空,则根据参数查询
func (*StormDB) GetTokenNodes ¶
GetTokenNodes return all nodes has channel with me
func (*StormDB) IsDbCrashedLastTime ¶
IsDbCrashedLastTime return true when quit but db not closed
func (*StormDB) IsLockHashCanPunish ¶
IsLockHashCanPunish can punish this unlock?
func (*StormDB) IsLockSecretHashChannelIdentifierDisposed ¶
func (model *StormDB) IsLockSecretHashChannelIdentifierDisposed(lockSecretHash common.Hash, ChannelIdentifier common.Hash) bool
IsLockSecretHashChannelIdentifierDisposed `lockSecretHash` and `ChannelIdentifier` is the id of AnnounceDisposed
func (*StormDB) IsLockSecretHashDisposed ¶
IsLockSecretHashDisposed this lockSecretHash has Announced Disposed
func (*StormDB) IsThisLockHasUnlocked ¶
IsThisLockHasUnlocked return ture when lockhash has unlocked on channel?
func (*StormDB) IsThisLockRemoved ¶
func (model *StormDB) IsThisLockRemoved(channel common.Hash, sender common.Address, lockHash common.Hash) bool
IsThisLockRemoved return true when a expired hashlock has been removed from channel status.
func (*StormDB) MakeChainEventID ¶
func (model *StormDB) MakeChainEventID(l *types.Log) models.ChainEventID
MakeChainEventID :
func (*StormDB) MarkDbOpenedStatus ¶
func (model *StormDB) MarkDbOpenedStatus()
MarkDbOpenedStatus First step open the database Second step detection for normal closure IsDbCrashedLastTime Third step recovers the data according to the second step Fourth step mark the database for processing the data normally. MarkDbOpenedStatus
func (*StormDB) MarkLockHashCanPunish ¶
func (model *StormDB) MarkLockHashCanPunish(r *models.ReceivedAnnounceDisposed) error
MarkLockHashCanPunish 收到了一个放弃声明,需要保存,在收到 unlock 事件的时候进行 punish
- MarkLockHashCanPunish : Once receiving an AnnounceDisposed message, we need to store it
- and submit it to enforce punishment procedure while receiving unlock.
func (*StormDB) MarkLockSecretHashDisposed ¶
func (model *StormDB) MarkLockSecretHashDisposed(lockSecretHash common.Hash, ChannelIdentifier common.Hash) error
MarkLockSecretHashDisposed mark `locksecrethash` disposed on channel `ChannelIdentifier`
func (*StormDB) NewChannel ¶
func (model *StormDB) NewChannel(c *channeltype.Serialization) error
NewChannel save a just created channel to db
func (*StormDB) NewDeliveredChainEvent ¶
func (model *StormDB) NewDeliveredChainEvent(id models.ChainEventID, blockNumber uint64)
NewDeliveredChainEvent save one
func (*StormDB) NewNonParticipantChannel ¶
func (model *StormDB) NewNonParticipantChannel(token common.Address, channel common.Hash, participant1, participant2 common.Address) error
NewNonParticipantChannel 需要保存 channel identifier, 通道的事件都是与此有关系的
func (*StormDB) NewPendingTXInfo ¶
func (model *StormDB) NewPendingTXInfo(tx *types.Transaction, txType models.TXInfoType, channelIdentifier common.Hash, openBlockNumber int64, txParams models.TXParams) (txInfo *models.TXInfo, err error)
NewPendingTXInfo 创建pending状态的TXInfo,即自己发起的tx
func (*StormDB) NewReceivedTransfer ¶
func (model *StormDB) NewReceivedTransfer(blockNumber int64, channelIdentifier common.Hash, openBlockNumber int64, tokenAddr, fromAddr common.Address, nonce uint64, amount *big.Int, lockSecretHash common.Hash, data string) *models.ReceivedTransfer
NewReceivedTransfer save a new received transfer to db
func (*StormDB) NewSentEnvelopMessager ¶
func (model *StormDB) NewSentEnvelopMessager(msg encoding.EnvelopMessager, receiver common.Address)
NewSentEnvelopMessager create a sending EnvelopMessager in db
func (*StormDB) NewSentTransferDetail ¶
func (model *StormDB) NewSentTransferDetail(tokenAddress, target common.Address, amount *big.Int, data string, isDirect bool, lockSecretHash common.Hash)
NewSentTransferDetail :
func (*StormDB) NewSettledChannel ¶
func (model *StormDB) NewSettledChannel(c *channeltype.Serialization) error
NewSettledChannel save a settled channel to db
func (*StormDB) RegisterChannelDepositCallback ¶
RegisterChannelDepositCallback register channel deposit callback
func (*StormDB) RegisterChannelSettleCallback ¶
RegisterChannelSettleCallback notify when channel settled
func (*StormDB) RegisterChannelStateCallback ¶
RegisterChannelStateCallback notify when channel closed
func (*StormDB) RegisterNewChannelCallback ¶
RegisterNewChannelCallback register a new channel callback
func (*StormDB) RegisterNewTokenCallback ¶
func (model *StormDB) RegisterNewTokenCallback(f cb.NewTokenCb)
RegisterNewTokenCallback register a new token callback
func (*StormDB) RemoveChannel ¶
func (model *StormDB) RemoveChannel(c *channeltype.Serialization) error
RemoveChannel a settled channel from db
func (*StormDB) RemoveLock ¶
RemoveLock remember this lock has been removed from channel status.
func (*StormDB) RemoveNonParticipantChannel ¶
RemoveNonParticipantChannel a channel is settled
func (*StormDB) SaveAckNoTx ¶
SaveAckNoTx save a ack to db
func (*StormDB) SaveContractStatus ¶
func (model *StormDB) SaveContractStatus(contractStatus models.ContractStatus)
SaveContractStatus save registry address to db
func (*StormDB) SaveEventToTXInfo ¶
SaveEventToTXInfo 保存事件到TXInfo里面,当收到链上事件的时候调用 如果tx存在,保存事件到tx的事件列表里面 如果tx不存在,说明该tx非自己发起,直接创建success状态的tx并保存 TODO
func (*StormDB) SaveFeeChargeRecord ¶
func (model *StormDB) SaveFeeChargeRecord(r *models.FeeChargeRecord) (err error)
SaveFeeChargeRecord :
func (*StormDB) SaveFeePolicy ¶
SaveFeePolicy :
func (*StormDB) SaveLatestBlockNumber ¶
SaveLatestBlockNumber block numer has been processed
func (*StormDB) UnlockThisLock ¶
UnlockThisLock marks that I have withdrawed this secret on channel.
func (*StormDB) UpdateChannel ¶
func (model *StormDB) UpdateChannel(c *channeltype.Serialization, tx models.TX) error
UpdateChannel update channel status in a Tx
func (*StormDB) UpdateChannelAndSaveAck ¶
func (model *StormDB) UpdateChannelAndSaveAck(c *channeltype.Serialization, echohash common.Hash, ack []byte) (err error)
UpdateChannelAndSaveAck update channel and save ack, must atomic
func (*StormDB) UpdateChannelContractBalance ¶
func (model *StormDB) UpdateChannelContractBalance(c *channeltype.Serialization) error
UpdateChannelContractBalance update channel balance
func (*StormDB) UpdateChannelNoTx ¶
func (model *StormDB) UpdateChannelNoTx(c *channeltype.Serialization) error
UpdateChannelNoTx update channel status without a Tx
func (*StormDB) UpdateChannelState ¶
func (model *StormDB) UpdateChannelState(c *channeltype.Serialization) error
UpdateChannelState update channel state ,close settle
func (*StormDB) UpdateSentTransferDetailStatus ¶
func (model *StormDB) UpdateSentTransferDetailStatus(tokenAddress common.Address, lockSecretHash common.Hash, status models.TransferStatusCode, statusMessage string, otherParams interface{}) (transfer *models.SentTransferDetail)
UpdateSentTransferDetailStatus :
func (*StormDB) UpdateSentTransferDetailStatusMessage ¶
func (model *StormDB) UpdateSentTransferDetailStatusMessage(tokenAddress common.Address, lockSecretHash common.Hash, statusMessage string) (transfer *models.SentTransferDetail)
UpdateSentTransferDetailStatusMessage :
func (*StormDB) UpdateTXInfoStatus ¶
func (model *StormDB) UpdateTXInfoStatus(txHash common.Hash, status models.TXInfoStatus, packBlockNumber int64, gasUsed uint64) (txInfo *models.TXInfo, err error)
UpdateTXInfoStatus :
func (*StormDB) UpdateTokenNodes ¶
UpdateTokenNodes update all nodes that open channel
func (*StormDB) XMPPIsAddrSubed ¶
XMPPIsAddrSubed return true when `addr` already subscirbed
func (*StormDB) XMPPMarkAddrSubed ¶
XMPPMarkAddrSubed mark `addr` subscribed
func (*StormDB) XMPPUnMarkAddr ¶
XMPPUnMarkAddr mark `addr` has been unsubscribed