core

package
v2.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
const ERROR_DELAY = 1 * time.Second // for ZMQ errors.
View Source
const RETRY_DELAY = 5 * time.Second // for connect errors.
View Source
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

func NewCoreRPCClient(rpcHost string, rpcPort int, rpcUser string, rpcPass string) spec.Blockchain

NewCoreRPCClient returns a Dogecoin Core Node client. Thread-safe, can be shared across Goroutines.

func NewLogger

func NewLogger(chainEvents <-chan spec.BlockchainEvent) governor.Service

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"

func SleepWithContext

func SleepWithContext(ctx context.Context, duration time.Duration) (cancelled bool)

Types

type CoreRPCClient

type CoreRPCClient struct {
	// contains filtered or unexported fields
}

func (*CoreRPCClient) EstimateFee

func (c *CoreRPCClient) EstimateFee(ctx context.Context, confirmTarget int) (feePerKB koinu.Koinu, err error)

func (*CoreRPCClient) GetBestBlockHash

func (c *CoreRPCClient) GetBestBlockHash(ctx context.Context) (blockHash string, err error)

func (*CoreRPCClient) GetBlock

func (c *CoreRPCClient) GetBlock(ctx context.Context, blockHash string) (block doge.Block, size int, err error)

func (*CoreRPCClient) GetBlockCount

func (c *CoreRPCClient) GetBlockCount(ctx context.Context) (blockCount int64, err error)

func (*CoreRPCClient) GetBlockHash

func (c *CoreRPCClient) GetBlockHash(ctx context.Context, blockHeight int64) (hash string, err error)

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 (c *CoreRPCClient) GetRawTransaction(ctx context.Context, txID string) (tx doge.BlockTx, err error)

func (*CoreRPCClient) Request

func (c *CoreRPCClient) Request(ctx context.Context, method string, params []any, result any) (int, error)

func (*CoreRPCClient) SendRawTransaction

func (c *CoreRPCClient) SendRawTransaction(ctx context.Context, txHex string) (txid string, err error)

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
}

func (*Logger) Run

func (l *Logger) Run()

type RPCError added in v2.0.6

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (RPCError) Error added in v2.0.6

func (e RPCError) Error() string

func (RPCError) Is added in v2.0.7

func (e RPCError) Is(target error) bool

type Splitter

type Splitter struct {
	governor.ServiceCtx
	// contains filtered or unexported fields
}

func (*Splitter) Run

func (s *Splitter) Run()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL