You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -54,20 +54,28 @@ class PgPeersDb(implicit ds: DataSource, lock: PgLock) extends PeersDb with Logg
54
54
statement.executeUpdate("CREATE TABLE local.relay_fees (node_id TEXT NOT NULL PRIMARY KEY, fee_base_msat BIGINT NOT NULL, fee_proportional_millionths BIGINT NOT NULL)")
55
55
}
56
56
57
+
defmigration34(statement: Statement):Unit= {
58
+
statement.executeUpdate("CREATE TABLE local.peer_storage (node_id TEXT NOT NULL PRIMARY KEY, data BYTEA NOT NULL)")
59
+
}
60
+
57
61
using(pg.createStatement()) { statement =>
58
62
getVersion(statement, DB_NAME) match {
59
63
caseNone=>
60
64
statement.executeUpdate("CREATE SCHEMA IF NOT EXISTS local")
61
-
statement.executeUpdate("CREATE TABLE local.peers (node_id TEXT NOT NULL PRIMARY KEY, data BYTEA NOT NULL)")
65
+
statement.executeUpdate("CREATE TABLE local.peers (node_id TEXT NOT NULL PRIMARY KEY, data BYTEA NOT NULL, storage BYTEA)")
62
66
statement.executeUpdate("CREATE TABLE local.relay_fees (node_id TEXT NOT NULL PRIMARY KEY, fee_base_msat BIGINT NOT NULL, fee_proportional_millionths BIGINT NOT NULL)")
63
-
caseSome(v@(1|2)) =>
67
+
statement.executeUpdate("CREATE TABLE local.peer_storage (node_id TEXT NOT NULL PRIMARY KEY, data BYTEA NOT NULL)")
68
+
caseSome(v@(1|2|3)) =>
64
69
logger.warn(s"migrating db $DB_NAME, found version=$v current=$CURRENT_VERSION")
65
70
if (v <2) {
66
71
migration12(statement)
67
72
}
68
73
if (v <3) {
69
74
migration23(statement)
70
75
}
76
+
if (v <4) {
77
+
migration34(statement)
78
+
}
71
79
caseSome(CURRENT_VERSION) => () // table is up-to-date, nothing to do
72
80
caseSome(unknownVersion) =>thrownewRuntimeException(s"Unknown version of DB $DB_NAME found, version=$unknownVersion")
73
81
}
@@ -98,6 +106,10 @@ class PgPeersDb(implicit ds: DataSource, lock: PgLock) extends PeersDb with Logg
98
106
statement.setString(1, nodeId.value.toHex)
99
107
statement.executeUpdate()
100
108
}
109
+
using(pg.prepareStatement("DELETE FROM local.peer_storage WHERE node_id = ?")) { statement =>
110
+
statement.setString(1, nodeId.value.toHex)
111
+
statement.executeUpdate()
112
+
}
101
113
}
102
114
}
103
115
@@ -155,4 +167,31 @@ class PgPeersDb(implicit ds: DataSource, lock: PgLock) extends PeersDb with Logg
goto(DISCONNECTED) using DisconnectedData(channels, None) // when we restart, we will attempt to reconnect right away, but then we'll wait
88
+
goto(DISCONNECTED) using DisconnectedData(channels, PeerStorage(nodeParams.db.peers.getStorage(remoteNodeId), written =true, TimestampMilli.min)) // when we restart, we will attempt to reconnect right away, but then we'll wait
91
89
}
92
90
93
91
when(DISCONNECTED) {
@@ -510,7 +508,19 @@ class Peer(val nodeParams: NodeParams,
510
508
stay()
511
509
512
510
caseEvent(store: PeerStorageStore, d: ConnectedData) if nodeParams.features.hasFeature(Features.ProvideStorage) && d.channels.nonEmpty =>
513
-
stay() using d.copy(peerStorage =Some(store.blob))
channels.values.toSet[ActorRef].foreach(_ !INPUT_RECONNECTED(connectionReady.peerConnection, connectionReady.localInit, connectionReady.remoteInit)) // we deduplicate with toSet because there might be two entries per channel (tmp id and final id)
0 commit comments