Skip to content

Commit 7980b4a

Browse files
committed
Merge branch 'v5.0.15' of github.com:ergoplatform/ergo into v5.0.15
2 parents 9ab35f6 + edd390a commit 7980b4a

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/main/resources/api/openapi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2704,7 +2704,7 @@ paths:
27042704
$ref: '#/components/schemas/ApiError'
27052705

27062706
/blocks/headerIds:
2707-
get:
2707+
post:
27082708
summary: Get the list of full block info by given header ids
27092709
operationId: getFullBlockByIds
27102710
tags:

src/main/scala/scorex/core/network/ConnectedPeer.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import scorex.core.network.peer.PeerInfo
1010
*
1111
* @param connectionId - connection address
1212
* @param handlerRef - reference to PeerConnectionHandler that is responsible for communication with this peer
13-
* @param lastMessage - timestamp of last received message
1413
* @param peerInfo - information about this peer. May be None if peer is connected, but is not handshaked yet
1514
*/
1615
case class ConnectedPeer(connectionId: ConnectionId,

src/main/scala/scorex/core/network/NetworkController.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,10 @@ class NetworkController(ergoSettings: ErgoSettings,
425425
peerManagerRef ! RemovePeer(peerAddress)
426426
connections -= connectedPeer.connectionId.remoteAddress
427427
} else {
428-
peerManagerRef ! AddOrUpdatePeer(peerInfo)
428+
val newPeerInfo = peerInfo.copy(lastStoredActivityTime = time())
429+
peerManagerRef ! AddOrUpdatePeer(newPeerInfo)
429430

430-
val updatedConnectedPeer = connectedPeer.copy(peerInfo = Some(peerInfo))
431+
val updatedConnectedPeer = connectedPeer.copy(peerInfo = Some(newPeerInfo))
431432
connections += remoteAddress -> updatedConnectedPeer
432433
context.system.eventStream.publish(HandshakedPeer(updatedConnectedPeer))
433434
}

src/main/scala/scorex/core/network/peer/PeerInfo.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ object PeerInfo {
3737
*/
3838
def fromAddress(address: InetSocketAddress): PeerInfo = {
3939
val peerSpec = PeerSpec("unknown", Version.initial, s"unknown-$address", Some(address), Seq())
40-
PeerInfo(peerSpec, 0L, None)
40+
PeerInfo(peerSpec, 0L, None, 0L)
4141
}
4242

4343
}
@@ -51,12 +51,14 @@ object PeerInfoSerializer extends ErgoSerializer[PeerInfo] {
5151
w.putLong(obj.lastHandshake)
5252
w.putOption(obj.connectionType)((w,d) => w.putBoolean(d.isIncoming))
5353
PeerSpecSerializer.serialize(obj.peerSpec, w)
54+
w.putLong(obj.lastStoredActivityTime)
5455
}
5556

5657
override def parse(r: Reader): PeerInfo = {
5758
val lastHandshake = r.getLong()
5859
val connectionType = r.getOption(if (r.getUByte() != 0) Incoming else Outgoing)
5960
val peerSpec = PeerSpecSerializer.parse(r)
60-
PeerInfo(peerSpec, lastHandshake, connectionType)
61+
val lastStoredTime = r.getLong()
62+
PeerInfo(peerSpec, lastHandshake, connectionType, lastStoredTime)
6163
}
6264
}

src/test/scala/org/ergoplatform/http/routes/BlocksApiRouteSpec.scala

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import akka.http.scaladsl.model.{ContentTypes, HttpEntity, StatusCodes, Universa
44
import akka.http.scaladsl.server.Route
55
import akka.http.scaladsl.testkit.ScalatestRouteTest
66
import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport
7+
import io.circe.Json
78
import io.circe.syntax._
89
import org.ergoplatform.http.api.BlocksApiRoute
910
import org.ergoplatform.modifiers.ErgoFullBlock
@@ -34,8 +35,7 @@ class BlocksApiRouteSpec
3435
history
3536
.headerIdsAt(0, 50)
3637
.map(Algos.encode)
37-
.asJson
38-
.toString() shouldEqual responseAs[String]
38+
.asJson shouldEqual responseAs[Json]
3939
}
4040
}
4141

@@ -56,8 +56,7 @@ class BlocksApiRouteSpec
5656
.lastHeaders(1)
5757
.headers
5858
.map(_.asJson)
59-
.asJson
60-
.toString() shouldEqual responseAs[String]
59+
.asJson shouldEqual responseAs[Json]
6160
}
6261
}
6362

@@ -67,19 +66,18 @@ class BlocksApiRouteSpec
6766
history
6867
.headerIdsAtHeight(0)
6968
.map(Algos.encode)
70-
.asJson
71-
.toString() shouldEqual responseAs[String]
69+
.asJson shouldEqual responseAs[Json]
7270
}
7371
}
7472

7573
it should "get chain slice" in {
7674
Get(prefix + "/chainSlice?fromHeight=0") ~> route ~> check {
7775
status shouldBe StatusCodes.OK
78-
chain.map(_.header).asJson.toString() shouldEqual responseAs[String]
76+
chain.map(_.header).asJson shouldEqual responseAs[Json]
7977
}
8078
Get(prefix + "/chainSlice?fromHeight=2&toHeight=4") ~> route ~> check {
8179
status shouldBe StatusCodes.OK
82-
chain.slice(2, 4).map(_.header).asJson.toString() shouldEqual responseAs[String]
80+
chain.slice(2, 4).map(_.header).asJson shouldEqual responseAs[Json]
8381
}
8482
}
8583

@@ -91,8 +89,8 @@ class BlocksApiRouteSpec
9189
.flatMap(history.getFullBlock)
9290
.map(_.asJson)
9391
.get
94-
.toString
95-
responseAs[String] shouldEqual expected
92+
93+
responseAs[Json] shouldEqual expected
9694
}
9795
}
9896

@@ -121,8 +119,8 @@ class BlocksApiRouteSpec
121119
.flatMap(history.getFullBlock)
122120
.map(_.header.asJson)
123121
.get
124-
.toString
125-
responseAs[String] shouldEqual expected
122+
123+
responseAs[Json] shouldEqual expected
126124
}
127125
}
128126

@@ -131,8 +129,8 @@ class BlocksApiRouteSpec
131129
status shouldBe StatusCodes.OK
132130
val header = history.typedModifierById[Header](headerIdBytes).value
133131
val fullBlock = history.getFullBlock(header).value
134-
val expected = fullBlock.blockTransactions.asJson.toString
135-
responseAs[String] shouldEqual expected
132+
val expected = fullBlock.blockTransactions.asJson
133+
responseAs[Json] shouldEqual expected
136134
}
137135
}
138136

0 commit comments

Comments
 (0)