rpc error code constants

This commit is contained in:
Matt Johnstone 2024-10-14 11:01:24 +02:00
parent 4f2c927054
commit bc96a3ee11
No known key found for this signature in database
GPG Key ID: BE985FBB9BE7D3BB
2 changed files with 24 additions and 1 deletions

View File

@ -337,7 +337,7 @@ func (c *SlotWatcher) fetchAndEmitSingleFeeReward(
var rpcError *rpc.RPCError
if errors.As(err, &rpcError) {
// this is the error code for slot was skipped:
if rpcError.Code == -32007 && strings.Contains(rpcError.Message, "skipped") {
if rpcError.Code == rpc.SlotSkippedCode && strings.Contains(rpcError.Message, "skipped") {
klog.Infof("slot %v was skipped, no fee rewards.", slot)
return nil
}

23
pkg/rpc/errors.go Normal file
View File

@ -0,0 +1,23 @@
package rpc
// error codes: https://github.com/anza-xyz/agave/blob/489f483e1d7b30ef114e0123994818b2accfa389/rpc-client-api/src/custom_error.rs#L17
const (
BlockCleanedUpCode = -32001
SendTransactionPreflightFailureCode = -32002
TransactionSignatureVerificationFailureCode = -32003
BlockNotAvailableCode = -32004
NodeUnhealthyCode = -32005
TransactionPrecompileVerificationFailureCode = -32006
SlotSkippedCode = -32007
NoSnapshotCode = -32008
LongTermStorageSlotSkippedCode = -32009
KeyExcludedFromSecondaryIndexCode = -32010
TransactionHistoryNotAvailableCode = -32011
ScanErrorCode = -32012
TransactionSignatureLengthMismatchCode = -32013
BlockStatusNotYetAvailableCode = -32014
UnsupportedTransactionVersionCode = -32015
MinContextSlotNotReachedCode = -32016
EpochRewardsPeriodActiveCode = -32017
SlotNotEpochBoundaryCode = -32018
)