Skip to content

Commit

Permalink
Merge pull request #2170 from ergoplatform/v5.0.22
Browse files Browse the repository at this point in the history
Candidate for 5.0.22 release
  • Loading branch information
kushti authored Jul 26, 2024
2 parents 1a417f4 + 0821f4b commit b0fc5ab
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 87 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ By default, the node processes all blocks from the genesis block. However, there
ergo {
...
node.utxoBootstrap = true
node.utxo.utxoBootstrap = true
...
}
```
Expand Down
11 changes: 9 additions & 2 deletions src/main/resources/api/openapi-ai.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: "3.0.2"

info:
version: "5.0.21"
version: "5.0.22"
title: Ergo Node API
description: Specification of Ergo Node API for ChatGPT plugin.
The following endpoints supported
Expand Down Expand Up @@ -1390,6 +1390,13 @@ paths:
schema:
type: string
default: desc
- in: query
name: excludeMempoolSpent
required: false
description: if true exclude spent inputs from mempool
schema:
type: boolean
default: false
responses:
'200':
description: unspent boxes associated with wanted address
Expand Down Expand Up @@ -1479,4 +1486,4 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
$ref: '#/components/schemas/ApiError'
9 changes: 8 additions & 1 deletion src/main/resources/api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: "3.0.2"

info:
version: "5.0.21"
version: "5.0.22"
title: Ergo Node API
description: API docs for Ergo Node. Models are shared between all Ergo products
contact:
Expand Down Expand Up @@ -6413,6 +6413,13 @@ paths:
schema:
type: boolean
default: false
- in: query
name: excludeMempoolSpent
required: false
description: if true exclude spent inputs from mempool
schema:
type: boolean
default: false
responses:
'200':
description: unspent boxes associated with wanted address
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ scorex {
nodeName = "ergo-node"

# Network protocol version to be sent in handshakes
appVersion = 5.0.21
appVersion = 5.0.22

# Network agent name. May contain information about client code
# stack, starting from core code-base up to the end graphical interface.
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/mainnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ ergo {
#
# To validate all the scripts for all the blocks, set checkpoint = null.
checkpoint = {
height = 1020454
blockId = "7829c6513c5b319b86e87253ed29d51fed61597c65e32f5197434461ccc4c905"
height = 1231454
blockId = "ca5aa96a2d560f49cd5652eae4b9e16bbf410ee32365313dc16544ee5fda1e6d"
}

# List with hex-encoded identifiers of transactions banned from getting into memory pool
Expand Down
39 changes: 27 additions & 12 deletions src/main/scala/org/ergoplatform/http/api/BlockchainApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,39 +242,54 @@ case class BlockchainApiRoute(readersHolder: ActorRef, ergoSettings: ErgoSetting
validateAndGetBoxesByAddress(address, offset, limit)
}

private def getBoxesByAddressUnspent(addr: ErgoAddress, offset: Int, limit: Int, sortDir: Direction, unconfirmed: Boolean): Future[Seq[IndexedErgoBox]] =
private def getBoxesByAddressUnspent(
addr: ErgoAddress,
offset: Int,
limit: Int,
sortDir: Direction,
unconfirmed: Boolean,
excludeMempoolSpent: Boolean
): Future[Seq[IndexedErgoBox]] = {

getHistoryWithMempool.map { case (history, mempool) =>
val spentBoxesIdsInMempool = if (excludeMempoolSpent) mempool.spentInputs.map(bytesToId).toSet else Set.empty[ModifierId]

getAddress(addr)(history)
.getOrElse(IndexedErgoAddress(hashErgoTree(addr.script)))
.retrieveUtxos(history, mempool, offset, limit, sortDir, unconfirmed)
.retrieveUtxos(history, mempool, offset, limit, sortDir, unconfirmed, spentBoxesIdsInMempool)
}
}

private def validateAndGetBoxesByAddressUnspent(address: ErgoAddress,
offset: Int,
limit: Int,
dir: Direction,
unconfirmed: Boolean): Route = {
unconfirmed: Boolean,
excludeMempoolSpent: Boolean): Route = {
if (limit > MaxItems) {
BadRequest(s"No more than $MaxItems boxes can be requested")
} else if (dir == SortDirection.INVALID) {
BadRequest("Invalid parameter for sort direction, valid values are \"ASC\" and \"DESC\"")
} else {
ApiResponse(getBoxesByAddressUnspent(address, offset, limit, dir, unconfirmed))
ApiResponse(getBoxesByAddressUnspent(address, offset, limit, dir, unconfirmed, excludeMempoolSpent))
}
}

private def getBoxesByAddressUnspentR: Route =
(post & pathPrefix("box" / "unspent" / "byAddress") & ergoAddress & paging & sortDir & unconfirmed) {
(address, offset, limit, dir, unconfirmed) =>
validateAndGetBoxesByAddressUnspent(address, offset, limit, dir, unconfirmed)
(post & pathPrefix("box" / "unspent" / "byAddress") & ergoAddress & paging & sortDir & unconfirmed & parameter('excludeMempoolSpent.as[Boolean].?)) {
(address, offset, limit, dir, unconfirmed, excludeMempoolSpentOption) =>
val excludeMempoolSpent = excludeMempoolSpentOption.getOrElse(false)
validateAndGetBoxesByAddressUnspent(address, offset, limit, dir, unconfirmed, excludeMempoolSpent)
}

private def getBoxesByAddressUnspentGetRoute: Route =
(pathPrefix("box" / "unspent" / "byAddress") & get & addressPass & paging & sortDir & unconfirmed) {
(address, offset, limit, dir, unconfirmed) =>
validateAndGetBoxesByAddressUnspent(address, offset, limit, dir, unconfirmed)
(pathPrefix("box" / "unspent" / "byAddress") & get & addressPass & paging & sortDir & unconfirmed & parameter('excludeMempoolSpent.as[Boolean].?)) {
(address, offset, limit, dir, unconfirmed, excludeMempoolSpentOption) =>
val excludeMempoolSpent = excludeMempoolSpentOption.getOrElse(false)
validateAndGetBoxesByAddressUnspent(address, offset, limit, dir, unconfirmed, excludeMempoolSpent)
}


private def getBoxRange(offset: Int, limit: Int): Future[Seq[ModifierId]] =
getHistory.map { history =>
val base: Long = getIndex(GlobalBoxIndexKey, history).getLong - offset
Expand Down Expand Up @@ -313,7 +328,7 @@ case class BlockchainApiRoute(readersHolder: ActorRef, ergoSettings: ErgoSetting
getHistoryWithMempool.map { case (history, mempool) =>
getAddress(tree)(history)
.getOrElse(IndexedErgoAddress(hashErgoTree(tree)))
.retrieveUtxos(history, mempool, offset, limit, sortDir, unconfirmed)
.retrieveUtxos(history, mempool, offset, limit, sortDir, unconfirmed, Set.empty)
}

private def getBoxesByErgoTreeUnspentR: Route = (post & pathPrefix("box" / "unspent" / "byErgoTree") & ergoTree & paging & sortDir & unconfirmed) { (tree, offset, limit, dir, unconfirmed) =>
Expand Down Expand Up @@ -352,7 +367,7 @@ case class BlockchainApiRoute(readersHolder: ActorRef, ergoSettings: ErgoSetting
getHistoryWithMempool.map { case (history, mempool) =>
history.typedExtraIndexById[IndexedToken](uniqueId(id))
.getOrElse(IndexedToken(id))
.retrieveUtxos(history, mempool, offset, limit, sortDir, unconfirmed)
.retrieveUtxos(history, mempool, offset, limit, sortDir, unconfirmed, Set.empty)
}

private def getBoxesByTokenIdUnspentR: Route = (get & pathPrefix("box" / "unspent" / "byTokenId") & modifierId & paging & sortDir & unconfirmed) { (id, offset, limit, dir, unconfirmed) =>
Expand Down
Loading

0 comments on commit b0fc5ab

Please sign in to comment.