Documentation ¶
Index ¶
- Constants
- func StartServer(srv *Service, grpcPort int, grpcProxyPort int)
- type Recorder
- func (recorder *Recorder) AddWitness(transfer *Transfer, witness *Witness) error
- func (recorder *Recorder) Count(opts ...TransferQueryOption) (int, error)
- func (recorder *Recorder) MarkAsFailed(id common.Hash) error
- func (recorder *Recorder) MarkAsProcessing(id common.Hash) error
- func (recorder *Recorder) MarkAsRejected(id common.Hash) error
- func (recorder *Recorder) MarkAsSettled(id common.Hash, gas uint64, ts time.Time) error
- func (recorder *Recorder) MarkAsValidated(id common.Hash, txhash common.Hash, relayer common.Address, nonce uint64, ...) error
- func (recorder *Recorder) Reset(id common.Hash) error
- func (recorder *Recorder) ResetCausedByNonce(id common.Hash) error
- func (recorder *Recorder) Start(ctx context.Context) error
- func (recorder *Recorder) Stop(ctx context.Context) error
- func (recorder *Recorder) Transfer(id common.Hash) (*Transfer, error)
- func (recorder *Recorder) Transfers(offset uint32, limit uint8, byUpdateTime bool, desc bool, ...) ([]*Transfer, error)
- func (recorder *Recorder) UpdateRecord(id common.Hash, txhash common.Hash, relayer common.Address, nonce uint64, ...) error
- func (recorder *Recorder) Witnesses(ids ...common.Hash) (map[common.Hash][]*Witness, error)
- type Service
- func (s *Service) Check(ctx context.Context, request *services.CheckRequest) (*services.CheckResponse, error)
- func (s *Service) List(ctx context.Context, request *services.ListRequest) (*services.ListResponse, error)
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context) error
- func (s *Service) Submit(ctx context.Context, w *types.Witness) (*services.WitnessSubmissionResponse, error)
- type StatusOnChainType
- type Transfer
- type TransferQueryOption
- func CashiersQueryOption(cashiers []common.Address) TransferQueryOption
- func ExcludeTokenQueryOption(token common.Address) TransferQueryOption
- func RecipientQueryOption(recipient common.Address) TransferQueryOption
- func SenderQueryOption(sender common.Address) TransferQueryOption
- func StatusQueryOption(statuses ...ValidationStatusType) TransferQueryOption
- func TokenQueryOption(token common.Address) TransferQueryOption
- type TransferValidator
- type ValidationStatusType
- type Witness
Constants ¶
const ( // WaitingForWitnesses stands for a transfer which needs more valid witnesses WaitingForWitnesses ValidationStatusType = "new" // ValidationInProcess stands for a transfer in process ValidationInProcess = "processing" // ValidationSubmitted stands for a transfer with validation submitted ValidationSubmitted = "validated" // TransferSettled stands for a transfer which has been settled TransferSettled = "settled" // ValidationFailed stands for the validation of a transfer failed ValidationFailed = "failed" // ValidationRejected stands for the validation of a transfer is rejected ValidationRejected = "rejected" )
Variables ¶
This section is empty.
Functions ¶
func StartServer ¶
Types ¶
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is a logger based on sql to record exchange events
func NewRecorder ¶
func NewRecorder( store *db.SQLStore, explorerStore *db.SQLStore, transferTableName string, witnessTableName string, explorerTableName string, ) *Recorder
NewRecorder returns a recorder for exchange
func (*Recorder) AddWitness ¶
AddWitness records a new witness
func (*Recorder) Count ¶
func (recorder *Recorder) Count(opts ...TransferQueryOption) (int, error)
Count returns the number of records of given restrictions
func (*Recorder) MarkAsFailed ¶
MarkAsFailed marks a record as failed
func (*Recorder) MarkAsProcessing ¶
MarkAsProcessing marks a record as processing
func (*Recorder) MarkAsRejected ¶
MarkAsRejected marks a record as failed
func (*Recorder) MarkAsSettled ¶
MarkAsSettled marks a record as settled
func (*Recorder) MarkAsValidated ¶
func (recorder *Recorder) MarkAsValidated(id common.Hash, txhash common.Hash, relayer common.Address, nonce uint64, gasPrice *big.Int) error
MarkAsValidated marks a transfer as validated
func (*Recorder) ResetCausedByNonce ¶
ResetCausedByNonce marks a record as new
func (*Recorder) Transfer ¶
Transfer returns the validation tx related information of a given transfer
func (*Recorder) Transfers ¶
func (recorder *Recorder) Transfers( offset uint32, limit uint8, byUpdateTime bool, desc bool, queryOpts ...TransferQueryOption, ) ([]*Transfer, error)
Transfers returns the list of records of given status
type Service ¶
type Service struct { services.UnimplementedRelayServiceServer // contains filtered or unexported fields }
Service defines the relayer service
func NewService ¶
NewService creates a new relay service
func (*Service) Check ¶
func (s *Service) Check(ctx context.Context, request *services.CheckRequest) (*services.CheckResponse, error)
Check checks the status of a transfer
func (*Service) List ¶
func (s *Service) List(ctx context.Context, request *services.ListRequest) (*services.ListResponse, error)
List lists the recent transfers
type StatusOnChainType ¶
type StatusOnChainType int
StatusOnChainType type of transfer status on chain
const ( StatusOnChainUnknown StatusOnChainType = iota StatusOnChainNotConfirmed StatusOnChainNeedSpeedUp StatusOnChainRejected StatusOnChainNonceOverwritten StatusOnChainSettled )
type Transfer ¶
type Transfer struct {
// contains filtered or unexported fields
}
Transfer defines a transfer structure
func UnmarshalTransferProto ¶
func UnmarshalTransferProto(validatorAddr common.Address, transfer *types.Transfer) (*Transfer, error)
UnmarshalTransferProto unmarshals a transfer proto
func (*Transfer) Status ¶
func (transfer *Transfer) Status() ValidationStatusType
func (*Transfer) ToTypesTransfer ¶
type TransferQueryOption ¶
type TransferQueryOption func() (string, []interface{})
func CashiersQueryOption ¶
func CashiersQueryOption(cashiers []common.Address) TransferQueryOption
func ExcludeTokenQueryOption ¶
func ExcludeTokenQueryOption(token common.Address) TransferQueryOption
func RecipientQueryOption ¶
func RecipientQueryOption(recipient common.Address) TransferQueryOption
func SenderQueryOption ¶
func SenderQueryOption(sender common.Address) TransferQueryOption
func StatusQueryOption ¶
func StatusQueryOption(statuses ...ValidationStatusType) TransferQueryOption
func TokenQueryOption ¶
func TokenQueryOption(token common.Address) TransferQueryOption
type TransferValidator ¶
type TransferValidator interface { // Size returns the number of relayers Size() int // Address returns the transfer validator contract address Address() common.Address // Check returns transfer status on chain Check(transfer *Transfer) (StatusOnChainType, error) // Submit submits validation for a transfer Submit(transfer *Transfer, witnesses []*Witness) (common.Hash, common.Address, uint64, *big.Int, error) // SpeedUp resubmits validation with higher gas price SpeedUp(transfer *Transfer, witnesses []*Witness) (common.Hash, common.Address, uint64, *big.Int, error) }
TransferValidator defines the interface of a transfer validator
func NewTransferValidatorOnEthereum ¶
func NewTransferValidatorOnEthereum( client *ethclient.Client, privateKeys []*ecdsa.PrivateKey, confirmBlockNumber uint16, defaultGasPrice *big.Int, gasPriceLimit *big.Int, gasPriceDeviation *big.Int, gasPriceGap *big.Int, validatorContractAddr common.Address, ) (TransferValidator, error)
NewTransferValidatorOnEthereum creates a new TransferValidator
func NewTransferValidatorOnIoTeX ¶
func NewTransferValidatorOnIoTeX( client iotex.AuthedClient, validatorContractAddr address.Address, ) (TransferValidator, error)
NewTransferValidatorOnIoTeX creates a new TransferValidator on IoTeX
type ValidationStatusType ¶
type ValidationStatusType string
ValidationStatusType type of transfer validation status
type Witness ¶
type Witness struct {
// contains filtered or unexported fields
}
Witness defines a witness structure
func NewWitness ¶
NewWitness creates a new witness struct