-
Notifications
You must be signed in to change notification settings - Fork 13
/
txprocessor.go
52 lines (42 loc) · 2.05 KB
/
txprocessor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package relay
import (
"context"
ctypes "github.com/cometbft/cometbft/rpc/core/types"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
)
// Transaction represents single searched tx with height
type Transaction struct {
Tx *neutrontypes.TxValue `json:"tx"`
Height uint64 `json:"height"`
}
// TXQuerier fetches transactions from a remote chain with specified txFilter
type TXQuerier interface {
// SearchTransactions searches for transactions from remote chain.
// the returned transactions channel can be closed due to one of the following cases:
// a) All transactions from an RPC call preprocessed successfully
// b) error encountered during the SearchTransactions method (the error will be written into the returned errs channel)
// After a txs channel is closed, it's necessary to check the errs channel for a possible errors in a SearchTransactions goroutine
SearchTransactions(ctx context.Context, query string) (<-chan Transaction, <-chan error)
}
// ChainClient is a minimal interface for tendermint client
type ChainClient interface {
BlockResults(ctx context.Context, height *int64) (*ctypes.ResultBlockResults, error)
TxSearch(ctx context.Context, query string, prove bool, page, perPage *int, orderBy string) (*ctypes.ResultTxSearch, error)
}
// TXProcessor precesses transactions from a remote chain and sends them to the neutron
type TXProcessor interface {
ProcessAndSubmit(ctx context.Context, queryID uint64, tx Transaction, submittedTxsTasksQueue chan PendingSubmittedTxInfo) error
}
// NewErrSubmitTxProofCritical creates a new ErrSubmitTxProofCritical.
func NewErrSubmitTxProofCritical(details error) ErrSubmitTxProofCritical {
return ErrSubmitTxProofCritical{details: details}
}
// ErrSubmitTxProofCritical is an error type that represents errors critical for the Relayer.
type ErrSubmitTxProofCritical struct {
// details is the inner error.
details error
}
// Error implements the error interface.
func (e ErrSubmitTxProofCritical) Error() string {
return "failed to submit tx proof: " + e.details.Error()
}