Documentation
¶
Index ¶
- Variables
- type APISignRequestFetcher
- type Block
- type Blockchain
- type Indexer
- func (i *Indexer) Close(ctx context.Context) error
- func (i *Indexer) HandleBlock(ctx context.Context, b Block) error
- func (i *Indexer) HandleNewBlock(ctx context.Context, b Block) error
- func (i *Indexer) HandleTx(ctx context.Context, blockHeight, blockTimeUnix int, tx Tx) error
- func (i *Indexer) IndexBlocksFromTo(ctx context.Context, from, to int)
- func (i *Indexer) IndexOldBlocks(ctx context.Context)
- func (i *Indexer) Start(ctx context.Context) error
- type SignReq
- type SignReqFetcher
- type SignReqs
- type Tx
Constants ¶
This section is empty.
Variables ¶
var ErrNoFetcher = errors.New("sign requests fetcher cannot be nil")
ErrNoFetcher is returned when the fetcher is nil.
Functions ¶
This section is empty.
Types ¶
type APISignRequestFetcher ¶
type APISignRequestFetcher struct {
APIURL string
}
APISignRequestFetcher SignRequestFetcher implementation: fetches sign requests from an API.
func NewMockAPISignRequestFetcher ¶
func NewMockAPISignRequestFetcher() (*APISignRequestFetcher, error)
NewMockAPISignRequestFetcher creates a new APISignRequestFetcher with a mock API URL.
func (*APISignRequestFetcher) GetBtcSignRequests ¶
func (f *APISignRequestFetcher) GetBtcSignRequests(from, limit int) ([]SignReq, error)
GetBtcSignRequests retrieves sign requests from the API.
type Block ¶
type Block interface {
Transactions() []Tx
}
Block is a universal blockchain block type
type Blockchain ¶
type Blockchain interface {
Close(ctx context.Context) error
ChainID() string
ChainHeader() (chainID string, latestBlock uint64, err error)
SubscribeNewBlock(ctx context.Context) (<-chan Block, error)
Block(ctx context.Context, height int64) (blk Block, err error)
}
Blockchain is the expected blockchain interface the indexer needs to store data in the database.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer struct responsible for calling blockchain rpc/websocket for data and storing that into the database.
func NewIndexer ¶
func NewIndexer(ctx context.Context, b Blockchain, logger zerolog.Logger, startBlockHeight int, ika remote2ika.Client) (*Indexer, error)
NewIndexer returns a new indexer struct with open connections.
func (*Indexer) HandleBlock ¶
HandleBlock handles the receive of a block from the chain.
func (*Indexer) HandleNewBlock ¶
HandleNewBlock handles the receive of new block from the chain.
func (*Indexer) IndexBlocksFromTo ¶
IndexBlocksFromTo index blocks from specific heights.
func (*Indexer) IndexOldBlocks ¶
IndexOldBlocks checks if it is needed to index old blocks and index them as needed.
type SignReq ¶
type SignReq struct {
ID uint64 // Unique sequence number for the sign request
Payload []byte // Bytes to be signed
DWalletID string // ID of the dwallet
UserSig string // Partial signature created with the user's share of the private key
FinalSig []byte // Full signature generated by the IKA network
Timestamp int64 // Timestamp of the sign request (in Unix time)
}
SignReq represents a signature request.
func (*SignReq) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type SignReqFetcher ¶
SignReqFetcher is an interface for getting sign requests from the Native network.
type SignReqs ¶
type SignReqs []SignReq
SignReqs is a slice of SignReq
func (SignReqs) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler