Documentation ¶
Overview ¶
Copyright (c) 2023, redgla authors <dbadoy4874@gmail.com> All rights reserved.
Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Copyright (c) 2023, redgla authors <dbadoy4874@gmail.com> All rights reserved.
Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Copyright (c) 2023, redgla authors <dbadoy4874@gmail.com> All rights reserved.
Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Copyright (c) 2023, redgla authors <dbadoy4874@gmail.com> All rights reserved.
Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- Variables
- func DefaultHeartbeatFn(ctx context.Context, endpoint string) error
- type Config
- type HeartbeatFn
- type Redgla
- func (r *Redgla) AddNode(endpoint string) error
- func (r *Redgla) Benchmark(height uint64, cnt int) (map[string]time.Duration, error)
- func (r *Redgla) BlockByRange(start uint64, end uint64) (map[uint64]*types.Block, error)
- func (r *Redgla) BlockByRangeWithBatch(start uint64, end uint64) (map[uint64]*types.Block, error)
- func (r *Redgla) DelNode(endpoint string) error
- func (r *Redgla) ReceiptByTxs(txs []*types.Transaction) (map[common.Hash]*types.Receipt, error)
- func (r *Redgla) ReceiptByTxsWithBatch(txs []*types.Transaction) (map[common.Hash]*types.Receipt, error)
- func (r *Redgla) Run()
- func (r *Redgla) Stop()
- func (r *Redgla) TransactionByHashes(hashes []common.Hash) (map[common.Hash]*types.Transaction, error)
- func (r *Redgla) TransactionByHashesWithBatch(hashes []common.Hash) (map[common.Hash]*types.Transaction, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoAliveNode = errors.New("there is no alive node") ErrBatchFailure = errors.New("batch request failure") )
Functions ¶
Types ¶
type Config ¶
type Config struct { // A list of endpoints to send batch requests to. Endpoints []string // Threshold to send a batch request. If the number of requests is // greater than the value, they are converted to batch requests. Threshold int // This is the timeout of the request to the Ethereum node. It also // seems okay to give a very large value and rely on the Ethereum // node's request timeout. RequestTimeout time.Duration // Ping interval for checks alive endpoints. HeartbeatInterval time.Duration // Timeout for requests to determine 'alive'. HeartbeatTimeout time.Duration }
func DefaultConfig ¶
func DefaultConfig() *Config
There is no default value for Endpoints. Set the Endpoints on the created default Config.
type HeartbeatFn ¶
HeartbeatFn is a method that can check whether the endpoint is working or not. Since it is not possible to specify which service endpoint it is, it is appropriately injected from the outside according to the usage.
type Redgla ¶
type Redgla struct {
// contains filtered or unexported fields
}
func (*Redgla) AddNode ¶
AddNode adds the target endpoint to the list of batch processing nodes. The endpoint entered will take effect starting from the next HeartbeatInterval.
func (*Redgla) Benchmark ¶
Benchmark measures and returns the response time of each node.
Batch request performance is matched to the speed of the slowest node. Removing nodes that are too slow to respond from the list can help improve performance. This method performs a benchmark for requests to fetch 'cnt' times a random number of block numbers less than 'height'.
func (*Redgla) BlockByRange ¶
BlockByRange requests blocks from a range to a node.
func (*Redgla) BlockByRangeWithBatch ¶
BlockByRangeWithBatch transmits and receives batch requests to healthy nodes among the list of registered nodes.
func (*Redgla) DelNode ¶
DelNode removes the target endpoint from the list of batch processing nodes. Removed endpoints take effect from the next HeartbeatInterval.
func (*Redgla) ReceiptByTxs ¶
ReceiptByTxs requests receipts from given transactions to a node.
func (*Redgla) ReceiptByTxsWithBatch ¶
func (r *Redgla) ReceiptByTxsWithBatch(txs []*types.Transaction) (map[common.Hash]*types.Receipt, error)
ReceiptByTxsWithBatch transmits and receives batch requests to healthy nodes among the list of registered nodes.
func (*Redgla) TransactionByHashes ¶
func (r *Redgla) TransactionByHashes(hashes []common.Hash) (map[common.Hash]*types.Transaction, error)
TransactionByHashes requests transactions from given hashes to a node.
func (*Redgla) TransactionByHashesWithBatch ¶
func (r *Redgla) TransactionByHashesWithBatch(hashes []common.Hash) (map[common.Hash]*types.Transaction, error)
TransactionByHashesWithBatch transmits and receives batch requests to healthy nodes among the list of registered nodes.