forked from cory/tildefriends
Add replication to what -t bench measures. Add a bool to control printing RPC messages. Respond to ebt.replicate with messages that weren't requested.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4095 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
23
core/ssb.js
23
core/ssb.js
@ -284,12 +284,16 @@ function formatMessage(row) {
|
||||
|
||||
function ebtReplicateRegisterMessageCallback(request) {
|
||||
ssb.addEventListener('message', function(message_id) {
|
||||
ssb.sqlStream(
|
||||
'SELECT previous, author, id, sequence, timestamp, hash, content, signature FROM messages WHERE id = ?1',
|
||||
[message_id],
|
||||
function (row) {
|
||||
request.send_json(formatMessage(row));
|
||||
});
|
||||
if (request.connection.send_clock) {
|
||||
ssb.sqlStream(
|
||||
'SELECT previous, author, id, sequence, timestamp, hash, content, signature FROM messages WHERE id = ?1',
|
||||
[message_id],
|
||||
function (row) {
|
||||
if (request.connection.send_clock[row.author] < row.sequence) {
|
||||
request.send_json(formatMessage(row));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -299,14 +303,21 @@ function ebtReplicateCommon(request) {
|
||||
} else {
|
||||
ebtReplicateSendClock(request, request.message);
|
||||
|
||||
if (!request.connection.send_clock) {
|
||||
request.connection.send_clock = {};
|
||||
}
|
||||
for (let id of Object.keys(request.message)) {
|
||||
if (request.message[id] >= 0 && (request.message[id] & 1) == 0) {
|
||||
request.connection.send_clock[id] = request.message[id] >> 1;
|
||||
ssb.sqlStream(
|
||||
'SELECT previous, author, id, sequence, timestamp, hash, content, signature FROM messages WHERE author = ?1 AND sequence >= ?2 ORDER BY sequence',
|
||||
[id, request.message[id] >> 1],
|
||||
function (row) {
|
||||
request.send_json(formatMessage(row));
|
||||
request.connection.send_clock[id] = row.sequence;
|
||||
});
|
||||
} else {
|
||||
delete request.connection.send_clock[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user