Documentation
¶
Index ¶
- Constants
- func ContextWithCoreRPCRetry(ctx context.Context, retryCount int, retryDelay time.Duration, taskName string) context.Context
- func NewCoreRPCClient(rpcHost string, rpcPort int, rpcUser string, rpcPass string) spec.Blockchain
- func NewLogger(chainEvents <-chan spec.BlockchainEvent) governor.Service
- func NewSplitter(chainEvents <-chan spec.BlockchainEvent, chanSizes []int) (governor.Service, []chan spec.BlockchainEvent)
- func NewTipChaser(coreAddrZMQ string, listener chan spec.BlockchainEvent, includeTx bool) governor.Service
- func SleepWithContext(ctx context.Context, duration time.Duration) (cancelled bool)
- type CoreRPCClient
- func (c *CoreRPCClient) EstimateFee(ctx context.Context, confirmTarget int) (feePerKB koinu.Koinu, err error)
- func (c *CoreRPCClient) GetBestBlockHash(ctx context.Context) (blockHash string, err error)
- func (c *CoreRPCClient) GetBlock(ctx context.Context, blockHash string) (block doge.Block, size int, err error)
- func (c *CoreRPCClient) GetBlockCount(ctx context.Context) (blockCount int64, err error)
- func (c *CoreRPCClient) GetBlockHash(ctx context.Context, blockHeight int64) (hash string, err error)
- func (c *CoreRPCClient) GetBlockHeader(ctx context.Context, blockHash string) (txn spec.BlockHeader, err error)
- func (c *CoreRPCClient) GetBlockchainInfo(ctx context.Context) (info spec.BlockchainInfo, err error)
- func (c *CoreRPCClient) GetMempoolEntry(ctx context.Context, txID string) (tx spec.RawMempoolTx, err error)
- func (c *CoreRPCClient) GetRawMempool(ctx context.Context) (mem spec.RawMempool, err error)
- func (c *CoreRPCClient) GetRawMempoolTxList(ctx context.Context) (txlist []string, err error)
- func (c *CoreRPCClient) GetRawTransaction(ctx context.Context, txID string) (tx doge.BlockTx, err error)
- func (c *CoreRPCClient) Request(ctx context.Context, method string, params []any, result any) (int, error)
- func (c *CoreRPCClient) SendRawTransaction(ctx context.Context, txHex string) (txid string, err error)
- func (c *CoreRPCClient) WaitForSync(ctx context.Context) bool
- type CoreRPCRetry
- type CoreRPCRetryKey
- type Logger
- type RPCError
- type Splitter
Constants ¶
const ( InvalidAddressOrKey = -5 // RPC_INVALID_ADDRESS_OR_KEY (invalid address or key) InvalidParameter = -8 // RPC_INVALID_PARAMETER (invalid, missing or duplicate parameter) VerifyError = -25 // RPC_VERIFY_ERROR (general error during transaction or block submission) VerifyRejected = -26 // RPC_VERIFY_REJECTED (transaction or block was rejected by network rules) AlreadyInUTXOSet = -27 // RPC_VERIFY_ALREADY_IN_UTXO_SET (transaction already in utxo set) InWarmup = -28 // RPC_IN_WARMUP (client still warming up) BlockNotFound = -5 // deprecated (use InvalidAddressOrKey instead) BlockHeightOutOfRange = -8 // deprecated (use InvalidParameter instead) DefaultRetryCount = 3 // make 3 attempts by default (Core returns spurious errors) DefaultRetryDelay = 200 * time.Millisecond // 200ms between retries (minimise server load) )
Core RPC error codes
const ERROR_DELAY = 1 * time.Second // for ZMQ errors.
const RETRY_DELAY = 5 * time.Second // for connect errors.
const WAIT_FOR_SYNC_RETRY_DELAY = 30 * time.Second
Variables ¶
This section is empty.
Functions ¶
func ContextWithCoreRPCRetry ¶
func ContextWithCoreRPCRetry(ctx context.Context, retryCount int, retryDelay time.Duration, taskName string) context.Context
ContextWithCoreRPCRetry returns a new context with a retry configuration. retryCount is the number of times to retry the request, default 5 attempts (0 = infinite) retryDelay is the delay between retries, default 5 seconds
func NewCoreRPCClient ¶
NewCoreRPCClient returns a Dogecoin Core Node client. Thread-safe, can be shared across Goroutines.
func NewSplitter ¶
func NewSplitter(chainEvents <-chan spec.BlockchainEvent, chanSizes []int) (governor.Service, []chan spec.BlockchainEvent)
NewSplitter creates a channel fan-out splitter. Each channel will receive a copy of the event.
All channels are treated as blocking channels, so the system will proceed at the rate of the slowest channel receiver. (DogeWalker is a non-blocking receiver, so it will not be the bottleneck.)
`chainEvents` is the channel to receive events from. `chanSizes` is the size of each channel, e.g. []int{10, 100, 1000}.
Returns the splitter service and the channels.
func NewTipChaser ¶
func NewTipChaser(coreAddrZMQ string, listener chan spec.BlockchainEvent, includeTx bool) governor.Service
* NewTipChaser listens to Core Node ZMQ interface. * * listener channel announces whenever Core finds a new Best Block Hash (Tip change) * set includeTx if you want to receive transaction events as well * set doNotBlock if you don't want to block when the listener channel is full * * `coreAddrZMQ` is the TCP address of Core ZMQ, e.g. "tcp://127.0.0.1:28332"
Types ¶
type CoreRPCClient ¶
type CoreRPCClient struct {
// contains filtered or unexported fields
}
func (*CoreRPCClient) EstimateFee ¶
func (*CoreRPCClient) GetBestBlockHash ¶
func (c *CoreRPCClient) GetBestBlockHash(ctx context.Context) (blockHash string, err error)
func (*CoreRPCClient) GetBlockCount ¶
func (c *CoreRPCClient) GetBlockCount(ctx context.Context) (blockCount int64, err error)
func (*CoreRPCClient) GetBlockHash ¶
func (*CoreRPCClient) GetBlockHeader ¶
func (c *CoreRPCClient) GetBlockHeader(ctx context.Context, blockHash string) (txn spec.BlockHeader, err error)
func (*CoreRPCClient) GetBlockchainInfo ¶
func (c *CoreRPCClient) GetBlockchainInfo(ctx context.Context) (info spec.BlockchainInfo, err error)
func (*CoreRPCClient) GetMempoolEntry ¶
func (c *CoreRPCClient) GetMempoolEntry(ctx context.Context, txID string) (tx spec.RawMempoolTx, err error)
GetMempoolEntry returns a single mempool entry (transaction) from the Core Node.
func (*CoreRPCClient) GetRawMempool ¶
func (c *CoreRPCClient) GetRawMempool(ctx context.Context) (mem spec.RawMempool, err error)
func (*CoreRPCClient) GetRawMempoolTxList ¶
func (c *CoreRPCClient) GetRawMempoolTxList(ctx context.Context) (txlist []string, err error)
func (*CoreRPCClient) GetRawTransaction ¶
func (*CoreRPCClient) SendRawTransaction ¶
func (*CoreRPCClient) WaitForSync ¶
func (c *CoreRPCClient) WaitForSync(ctx context.Context) bool
type CoreRPCRetry ¶ added in v2.0.4
type CoreRPCRetry struct {
// contains filtered or unexported fields
}
type CoreRPCRetryKey ¶ added in v2.0.4
type CoreRPCRetryKey struct{}
unique type for the context key
type Logger ¶
type Logger struct {
governor.ServiceCtx
// contains filtered or unexported fields
}