Compare commits
2 Commits
4264ca099e
...
1b876bb78f
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | 1b876bb78f | |
Derrick Hammer | c7d963c9b1 |
23
src/index.ts
23
src/index.ts
|
@ -91,10 +91,7 @@ const plugin: Plugin = {
|
|||
api = _api;
|
||||
setup();
|
||||
|
||||
if (
|
||||
api.pluginConfig.bool("storememory") &&
|
||||
!api.pluginConfig.bool("store")
|
||||
) {
|
||||
if (api.pluginConfig.bool("store.memory")) {
|
||||
memStore = new NodeCache();
|
||||
}
|
||||
|
||||
|
@ -111,15 +108,15 @@ const plugin: Plugin = {
|
|||
}
|
||||
let entry = (await getEntry(newEntry.pk)) as SignedRegistryEntry;
|
||||
|
||||
async function setAndRespond() {
|
||||
async function setAndRespond(entry: SignedRegistryEntry) {
|
||||
await setEntry(newEntry);
|
||||
sendDirectOrBroadcast(
|
||||
Message.create({
|
||||
type: MessageType.CREATED,
|
||||
pubkey: newEntry.pk,
|
||||
revision: newEntry.revision,
|
||||
signature: newEntry.signature,
|
||||
data: newEntry.data,
|
||||
pubkey: entry.pk,
|
||||
revision: entry.revision,
|
||||
signature: entry.signature,
|
||||
data: entry.data,
|
||||
}),
|
||||
origin
|
||||
);
|
||||
|
@ -127,11 +124,13 @@ const plugin: Plugin = {
|
|||
|
||||
if (entry) {
|
||||
if (newEntry.revision <= entry.revision) {
|
||||
setAndRespond();
|
||||
setAndRespond(newEntry);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
setAndRespond();
|
||||
setAndRespond(entry);
|
||||
return;
|
||||
}
|
||||
setAndRespond(newEntry);
|
||||
});
|
||||
|
||||
events.on("query", async (query: Query, origin: Buffer) => {
|
||||
|
|
Reference in New Issue