Skip to content

Commit

Permalink
chore: removed console.logs
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Sep 20, 2018
1 parent 1338dc1 commit eb766cd
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions src/modules/transaction/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,21 @@ function* handleFetchTransactionRequest(action: FetchTransactionRequestAction) {
const nonceInState = txInState == null ? null : txInState.nonce
const nonceInNetwork = isUnknown ? null : (tx as TransactionStatus).nonce

console.log(
`[${hash}] Nonce in state: ${nonceInState} - Nonce in network: ${nonceInNetwork}`
)

if (nonceInNetwork != null && nonceInState == null) {
console.log(`[${hash}] Update nonce {${nonceInNetwork}}`)
yield put(updateTransactionNonce(hash, nonceInNetwork))
}

// update status
const statusInState = txInState == null ? null : txInState.status
const statusInNetwork = isUnknown ? null : tx.type
console.log(
`[${hash}] Status in state: ${statusInState} - Status in network: ${statusInNetwork}`
)

if (statusInState !== statusInNetwork) {
// check if dropped
if (statusInState != null && statusInNetwork == null) {
console.log(`[${hash}] Detected dropped tx`)
const nonce = nonceInState || nonceInNetwork
if (nonce) {
console.log(`[${hash}] The tx nonce is ${nonce}`)
yield put(replaceTransactionRequest(hash, nonce))
}
console.log(`[${hash}] About to throw`)
throw new FailedTransactionError(
hash,
txUtils.TRANSACTION_TYPES.dropped
Expand All @@ -124,11 +114,6 @@ function* handleFetchTransactionRequest(action: FetchTransactionRequestAction) {
isUnknown = tx == null
}

console.log(
`[${hash}] Done with status ${tx.type}`,
JSON.parse(JSON.stringify(tx))
)

delete watchPendingIndex[hash]

if (tx.type === 'confirmed') {
Expand Down Expand Up @@ -157,8 +142,6 @@ function* handleReplaceTransactionRequest(

watchDroppedIndex[hash] = true

console.log(`[${hash}] watching dropped transaction`)

let checkpoint = null

while (true) {
Expand All @@ -170,9 +153,7 @@ function* handleReplaceTransactionRequest(
}

// get latest block
console.log(`Fetching latest block...`)
const blockNumber = yield call(() => eth.getBlockNumber())
console.log(`Starting from block ${blockNumber}`)

let highestNonce = 0
let replacedBy = null
Expand All @@ -181,9 +162,6 @@ function* handleReplaceTransactionRequest(
const startBlock = blockNumber
const endBlock = checkpoint || blockNumber - 100
for (let i = startBlock; i > endBlock; i--) {
console.log(
`Checking block ${i} - ${startBlock - i + 1}/${startBlock - endBlock}`
)
let block = yield call(() => eth.getBlock(i, true))
const transactions: TransactionStatus[] =
block != null && block.transactions != null ? block.transactions : []
Expand All @@ -201,18 +179,15 @@ function* handleReplaceTransactionRequest(
}

checkpoint = blockNumber
console.log(`Checkpoint at block ${blockNumber}`)

// if a replacement tx was found, replace it
if (replacedBy) {
console.log(`[${hash}] found replacement tranasction ${replacedBy.hash}`)
yield put(replaceTransactionSuccess(hash, replacedBy.hash))
break
}

// if there was nonce higher to than the one in the tx, we can mark it as replaced (altough we don't know which tx replaced it)
if (highestNonce >= nonce) {
console.log(`[${hash}] found transactions with higher nonce`)
yield put(
updateTransactionStatus(
action.payload.hash,
Expand All @@ -226,7 +201,6 @@ function* handleReplaceTransactionRequest(
yield call(delay, txUtils.TRANSACTION_FETCH_DELAY)
}

console.log(`[${hash}] stop watching dropped transaction`)
delete watchDroppedIndex[action.payload.hash]
}

Expand All @@ -240,11 +214,6 @@ function* handleWatchPendingTransactions() {

const allTransactions = transactionRequests.concat(pendingTransactions)

console.log(
`Watching ${allTransactions.length} pending transactions`,
allTransactions
)

for (const tx of allTransactions) {
if (!watchPendingIndex[tx.hash]) {
// don't watch transactions that are older than 72 hs
Expand All @@ -265,11 +234,6 @@ function* handleWatchDroppedTransactions() {
transaction.nonce != null
)

console.log(
`Watching ${droppedTransactions.length} dropped transactions`,
droppedTransactions
)

for (const tx of droppedTransactions) {
if (!watchDroppedIndex[tx.hash]) {
yield fork(
Expand Down

0 comments on commit eb766cd

Please sign in to comment.