-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from wavesplatform/node-93-rebroadcast-tx
NODE-93: do not rebroadcast existing tx
- Loading branch information
Showing
8 changed files
with
51 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
package scorex | ||
|
||
import com.wavesplatform.UtxPool | ||
import com.wavesplatform.network.{RawBytes, TransactionMessageSpec} | ||
import com.wavesplatform.network._ | ||
import io.netty.channel.group.ChannelGroup | ||
import scorex.api.http.ApiError | ||
import scorex.transaction.{Transaction, ValidationError} | ||
import com.wavesplatform.network._ | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.Future | ||
|
||
trait BroadcastRoute { | ||
def utx: UtxPool | ||
|
||
def allChannels: ChannelGroup | ||
|
||
protected def doBroadcast(v: Either[ValidationError, Transaction]): Future[Either[ApiError, Transaction]] = | ||
Future(v.flatMap(t => utx.putIfNew(t) | ||
.map(t => { | ||
allChannels.broadcast(RawBytes(TransactionMessageSpec.messageCode, t.bytes)) | ||
t | ||
})).left.map(ApiError.fromValidationError)) | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
protected def doBroadcast(v: Either[ValidationError, Transaction]): Future[Either[ApiError, Transaction]] = Future { | ||
(for { | ||
tx <- v | ||
utxResult <- utx.putIfNew(tx) | ||
} yield { | ||
if (utxResult) { | ||
allChannels.broadcastTx(tx, None) | ||
} | ||
tx | ||
}).left.map(ApiError.fromValidationError) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters