Skip to content

Commit

Permalink
Fix remaining linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Nov 13, 2020
1 parent d0735af commit 7e35430
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 80 deletions.
67 changes: 27 additions & 40 deletions asserter/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@ import (
utils "github.com/coinbase/rosetta-sdk-go/errors"
)

// Named error types for Asserter errors
var (
/////////////////////
/* ASSERTER ERRORS */
/////////////////////

// ErrAsserterNotInitialized is returned when some call in the asserter
// package requires the asserter to be initialized first.
ErrAsserterNotInitialized = errors.New("asserter not initialized")
)

//////////////////////////////////
/* ACCOUNT BALANCE QUERY ERRORS */
//////////////////////////////////

// Account Balance Errors
var (
ErrReturnedBlockHashMismatch = errors.New(
"request block hash does not match response block hash",
)
Expand All @@ -45,11 +39,10 @@ var (
ErrReturnedBlockHashMismatch,
ErrReturnedBlockIndexMismatch,
}
)

//////////////////
/* BLOCK ERRORS */
//////////////////

// Block Errors
var (
ErrAmountValueMissing = errors.New("Amount.Value is missing")
ErrAmountIsNotInt = errors.New("Amount.Value is not an integer")
ErrAmountCurrencyIsNil = errors.New("Amount.Currency is nil")
Expand Down Expand Up @@ -133,11 +126,10 @@ var (
ErrBlockHashEqualsParentBlockHash,
ErrBlockIndexPrecedesParentBlockIndex,
}
)

/////////////////
/* COIN ERRORS */
/////////////////

// Coin Errors
var (
ErrCoinIsNil = errors.New("coin cannot be nil")
ErrCoinDuplicate = errors.New("duplicate coin identifier detected")
ErrCoinIdentifierIsNil = errors.New("coin identifier cannot be nil")
Expand All @@ -153,11 +145,10 @@ var (
ErrCoinChangeIsNil,
ErrCoinActionInvalid,
}
)

/////////////////////////
/* CONSTRUCTION ERRORS */
/////////////////////////

// Construction Errors
var (
ErrConstructionPreprocessResponseIsNil = errors.New(
"ConstructionPreprocessResponse cannot be nil",
)
Expand Down Expand Up @@ -250,11 +241,10 @@ var (
ErrSignatureBytesZero,
ErrSignatureTypeNotSupported,
}
)

////////////////////
/* NETWORK ERRORS */
////////////////////

// Network Errors
var (
ErrSubNetworkIdentifierInvalid = errors.New(
"NetworkIdentifier.SubNetworkIdentifier.Network is missing",
)
Expand Down Expand Up @@ -318,11 +308,10 @@ var (
ErrBalanceExemptionNoHistoricalLookup,
ErrTimestampStartIndexInvalid,
}
)

///////////////////
/* SERVER ERRORS */
///////////////////

// Server Errors
var (
ErrNoSupportedNetworks = errors.New(
"no supported networks",
)
Expand Down Expand Up @@ -422,11 +411,10 @@ var (
ErrMaxBlockInvalid,
ErrDuplicateCurrency,
}
)

///////////////////
/* EVENTS ERRORS */
///////////////////

// Events Errors
var (
ErrMaxSequenceInvalid = errors.New("max sequence invalid")
ErrSequenceInvalid = errors.New("sequence invalid")
ErrBlockEventTypeInvalid = errors.New("block event type invalid")
Expand All @@ -438,20 +426,19 @@ var (
ErrBlockEventTypeInvalid,
ErrSequenceOutOfOrder,
}
)

///////////////////
/* SEARCH ERRORS */
///////////////////

// Search Errors
var (
ErrNextOffsetInvalid = errors.New("next offset invalid")

SearchErrs = []error{
ErrNextOffsetInvalid,
}
)

///////////////////
/* ERROR ERRORS */
///////////////////
// Error Errors
var (
ErrErrorIsNil = errors.New("Error is nil")
ErrErrorCodeIsNeg = errors.New("Error.Code is negative")
ErrErrorMessageMissing = errors.New("Error.Message is missing")
Expand Down
11 changes: 4 additions & 7 deletions parser/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ import (
utils "github.com/coinbase/rosetta-sdk-go/errors"
)

// Named error types for Parser errors
// Intent Errors
var (
///////////////////
/* INTENT ERRORS */
///////////////////
ErrExpectedOperationAccountMismatch = errors.New(
"intended account did not match observed account",
)
Expand All @@ -46,10 +43,10 @@ var (
ErrExpectedSignerUnexpectedSigner,
ErrExpectedSignerMissing,
}
)

/////////////////////////////
/* MATCH OPERATIONS ERRORS */
/////////////////////////////
// Match Operations Errors
var (
ErrAccountMatchAccountMissing = errors.New("account is missing")
ErrAccountMatchSubAccountMissing = errors.New("SubAccountIdentifier.Address is missing")
ErrAccountMatchSubAccountPopulated = errors.New("SubAccount is populated")
Expand Down
55 changes: 22 additions & 33 deletions storage/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ import (
utils "github.com/coinbase/rosetta-sdk-go/errors"
)

// Named error types for Storage errors
// Badger Storage Errors
var (
////////////////////
/* BADGER STORAGE */
////////////////////

ErrDatabaseOpenFailed = errors.New("unable to open database")
ErrCompressorLoadFailed = errors.New("unable to load compressor")
ErrDBCloseFailed = errors.New("unable to close database")
Expand Down Expand Up @@ -71,11 +67,10 @@ var (
ErrTrainZSTDFailed,
ErrWalkFilesFailed,
}
)

///////////////////////
/* BROADCAST STORAGE */
///////////////////////

// Broadcast Storage Errors
var (
ErrBroadcastTxStale = errors.New("unable to handle stale transaction")
ErrBroadcastTxConfirmed = errors.New(
"unable to handle confirmed transaction",
Expand Down Expand Up @@ -137,11 +132,10 @@ var (
ErrBroadcastCommitDeleteFailed,
ErrBroadcastPerformFailed,
}
)

//////////////////
/* COIN STORAGE */
//////////////////

// Coin Storage Errors
var (
ErrCoinQueryFailed = errors.New("unable to query for coin")
ErrCoinDecodeFailed = errors.New("unable to decode coin")
ErrCoinGetFailed = errors.New("unable to get coin")
Expand Down Expand Up @@ -187,11 +181,10 @@ var (
ErrCoinParseFailed,
ErrCoinImportFailed,
}
)

////////////////
/* COMPRESSOR */
////////////////

// Compressor Errors
var (
ErrLoadDictFailed = errors.New("unable to load dictionary")
ErrObjectEncodeFailed = errors.New("unable to encode object")
ErrRawCompressFailed = errors.New("unable to compress raw bytes")
Expand All @@ -215,11 +208,10 @@ var (
ErrReaderCloseFailed,
ErrCopyBlockFailed,
}
)

/////////////////
/* JOB STORAGE */
/////////////////

// Job Storage Errors
var (
ErrJobsGetAllFailed = errors.New("unable to get all jobs")
ErrJobIdentifierDecodeFailed = errors.New("unable to decode existing identifier")
ErrJobGetFailed = errors.New("unable to get job")
Expand Down Expand Up @@ -259,11 +251,10 @@ var (
ErrJobDoesNotExist,
ErrJobDecodeFailed,
}
)

/////////////////
/* KEY STORAGE */
/////////////////

// Key Storage Errors
var (
// ErrAddrExists is returned when key storage already
// contains an address.
ErrAddrExists = errors.New("address already exists")
Expand Down Expand Up @@ -306,11 +297,10 @@ var (
ErrAddrImportFailed,
ErrPrefundedAcctStoreFailed,
}
)

/////////////////////
/* BALANCE STORAGE */
/////////////////////

// Balance Storage Errors
var (
// ErrNegativeBalance is returned when an account
// balance goes negative as the result of an operation.
ErrNegativeBalance = errors.New("negative balance")
Expand Down Expand Up @@ -339,11 +329,10 @@ var (
ErrBlockNil,
ErrAccountMissing,
}
)

///////////////////
/* BLOCK STORAGE */
///////////////////

// Block Storage Errors
var (
// ErrHeadBlockNotFound is returned when there is no
// head block found in BlockStorage.
ErrHeadBlockNotFound = errors.New("head block not found")
Expand Down

0 comments on commit 7e35430

Please sign in to comment.