chore: add debug logs
This commit is contained in:
parent
b8811d730a
commit
7b64bc523a
@ -341,6 +341,12 @@ export const createWrap = (unsignedEvent: UnsignedEvent, receiver: string) => {
|
|||||||
// Check if the leading zero bits meet the required difficulty
|
// Check if the leading zero bits meet the required difficulty
|
||||||
if (leadingZeroes >= difficulty) {
|
if (leadingZeroes >= difficulty) {
|
||||||
// Finalize the event (sign it) and return the result
|
// Finalize the event (sign it) and return the result
|
||||||
|
console.log(
|
||||||
|
'event OUT: ',
|
||||||
|
unsignedEvent,
|
||||||
|
' for this user ',
|
||||||
|
hexToNpub(receiver)
|
||||||
|
)
|
||||||
return finalizeEvent(event, randomKey)
|
return finalizeEvent(event, randomKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,13 +532,18 @@ export const updateUsersAppData = async (meta: Meta) => {
|
|||||||
if (existingMeta.modifiedAt < meta.modifiedAt) {
|
if (existingMeta.modifiedAt < meta.modifiedAt) {
|
||||||
sigits[id] = meta
|
sigits[id] = meta
|
||||||
isUpdated = true
|
isUpdated = true
|
||||||
|
} else {
|
||||||
|
console.log('event NEWER EXISTS', existingMeta, meta)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sigits[id] = meta
|
sigits[id] = meta
|
||||||
isUpdated = true
|
isUpdated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUpdated) return null
|
if (!isUpdated) {
|
||||||
|
console.log('event NOT UPDATED', sigits[id], meta)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
const blossomUrls = [...appData.blossomUrls]
|
const blossomUrls = [...appData.blossomUrls]
|
||||||
|
|
||||||
@ -869,12 +880,13 @@ const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
|||||||
.processedGiftWraps
|
.processedGiftWraps
|
||||||
if (processedEvents.includes(event.id)) return
|
if (processedEvents.includes(event.id)) return
|
||||||
|
|
||||||
store.dispatch(updateProcessedGiftWraps([...processedEvents, event.id]))
|
|
||||||
|
|
||||||
// validate PoW
|
// validate PoW
|
||||||
// Count the number of leading zero bits in the hash
|
// Count the number of leading zero bits in the hash
|
||||||
const leadingZeroes = countLeadingZeroes(event.id)
|
const leadingZeroes = countLeadingZeroes(event.id)
|
||||||
if (leadingZeroes < difficulty) return
|
if (leadingZeroes < difficulty) {
|
||||||
|
console.log('processReceivedEvent leading zeroes error')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// decrypt the content of gift wrap event
|
// decrypt the content of gift wrap event
|
||||||
const nostrController = NostrController.getInstance()
|
const nostrController = NostrController.getInstance()
|
||||||
@ -882,7 +894,6 @@ const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
|||||||
event.pubkey,
|
event.pubkey,
|
||||||
event.content
|
event.content
|
||||||
)
|
)
|
||||||
|
|
||||||
const internalUnsignedEvent = await parseJson<UnsignedEvent>(decrypted).catch(
|
const internalUnsignedEvent = await parseJson<UnsignedEvent>(decrypted).catch(
|
||||||
(err) => {
|
(err) => {
|
||||||
console.log(
|
console.log(
|
||||||
@ -893,8 +904,21 @@ const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!internalUnsignedEvent || internalUnsignedEvent.kind !== 938) return
|
if (!internalUnsignedEvent || internalUnsignedEvent.kind !== 938) {
|
||||||
|
console.log(
|
||||||
|
'processReceivedEvent missing internal unsigned event, or internal event not sigit kind'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
'event IN: ',
|
||||||
|
new Date(internalUnsignedEvent.created_at * 1000),
|
||||||
|
internalUnsignedEvent.kind,
|
||||||
|
internalUnsignedEvent.pubkey,
|
||||||
|
hexToNpub(internalUnsignedEvent.pubkey),
|
||||||
|
internalUnsignedEvent.content
|
||||||
|
)
|
||||||
const meta = await parseJson<Meta>(internalUnsignedEvent.content).catch(
|
const meta = await parseJson<Meta>(internalUnsignedEvent.content).catch(
|
||||||
(err) => {
|
(err) => {
|
||||||
console.log(
|
console.log(
|
||||||
@ -907,7 +931,8 @@ const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
|||||||
|
|
||||||
if (!meta) return
|
if (!meta) return
|
||||||
|
|
||||||
updateUsersAppData(meta)
|
await updateUsersAppData(meta)
|
||||||
|
store.dispatch(updateProcessedGiftWraps([...processedEvents, event.id]))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user