Added receiverID field
This commit is contained in:
parent
4b15ca2673
commit
f2da7f0a35
46
index.html
46
index.html
@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
//Required for Supernode operations
|
//Required for Supernode operations
|
||||||
supernodes: {}, //each supnernode must be stored as floID : {uri:<uri>,pubKey:<publicKey>}
|
supernodes: {}, //each supnernode must be stored as floID : {uri:<uri>,pubKey:<publicKey>}
|
||||||
storageList = ["General","RIBC"],
|
storageList : ["General"],
|
||||||
defaultStorage = "General"
|
defaultStorage : "General"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -5381,13 +5381,13 @@
|
|||||||
reactor.addEventListener('supernode_processRequest', function (request) {
|
reactor.addEventListener('supernode_processRequest', function (request) {
|
||||||
console.log('Request :', request);
|
console.log('Request :', request);
|
||||||
try {
|
try {
|
||||||
request = request.split(/ (.+)/);
|
request = request.split(" ");
|
||||||
if (floGlobals.storageList.include(request[1]))
|
if (floGlobals.storageList.include(request[1]))
|
||||||
compactIDB.readAllData(request[1])
|
compactIDB.searchData(request[1], (k, v) => { return (v.receiverID == request[2]) })
|
||||||
.then(result => floSupernode.supernodeClientWS.send(request[0] + JSON.stringify(result)))
|
.then(result => floSupernode.supernodeClientWS.send(request[0] + JSON.stringify(result)))
|
||||||
.catch(error => console.log(error))
|
.catch(error => console.log(error))
|
||||||
else
|
else
|
||||||
compactIDB.searchData(floGlobals.defaultStorage, (k, v) => { return v.application == request[1] })
|
compactIDB.searchData(floGlobals.defaultStorage, (k, v) => { return (v.application == request[1] && v.receiverID == request[2]) })
|
||||||
.then(result => floSupernode.supernodeClientWS.send(request[0] + JSON.stringify(result)))
|
.then(result => floSupernode.supernodeClientWS.send(request[0] + JSON.stringify(result)))
|
||||||
.catch(error => console.log(error))
|
.catch(error => console.log(error))
|
||||||
|
|
||||||
@ -5403,29 +5403,25 @@
|
|||||||
console.log('Data :', data);
|
console.log('Data :', data);
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(data)
|
data = JSON.parse(data)
|
||||||
floSupernode.kBucket.determineClosestSupernode(data.floID).then(result => {
|
floSupernode.kBucket.determineClosestSupernode(data.receiverID).then(result => {
|
||||||
if (result[0].floID != myFloID)
|
if (result[0].floID != myFloID)
|
||||||
return;
|
return;
|
||||||
if (data.floID == floCrypto.getFloIDfromPubkeyHex(data.pubKey) && floCrypto.verifySign(
|
if (data.senderID == floCrypto.getFloIDfromPubkeyHex(data.pubKey) && floCrypto.verifySign(
|
||||||
JSON.stringify(data.data), data.sign, data.pubKey)) {
|
JSON.stringify(data.data), data.sign, data.pubKey)) {
|
||||||
if (floGlobals.storageList.include(data.application))
|
if (floGlobals.storageList.include(data.application))
|
||||||
compactIDB.addData(data.application, {
|
let table = data.application;
|
||||||
floID: data.floID,
|
|
||||||
message: data.message,
|
|
||||||
sign: data.sign,
|
|
||||||
application: data.application,
|
|
||||||
type: data.type,
|
|
||||||
comment: data.comment
|
|
||||||
})
|
|
||||||
else
|
else
|
||||||
compactIDB.addData(floGlobals.defaultStorage, {
|
let table = floGlobals.defaultStorage;
|
||||||
floID: data.floID,
|
|
||||||
message: data.message,
|
compactIDB.addData(table, {
|
||||||
sign: data.sign,
|
senderID: data.senderID,
|
||||||
application: data.application,
|
receiverID: data.receiverID,
|
||||||
type: data.type,
|
message: data.message,
|
||||||
comment: data.comment
|
sign: data.sign,
|
||||||
})
|
application: data.application,
|
||||||
|
type: data.type,
|
||||||
|
comment: data.comment
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -5983,7 +5979,7 @@
|
|||||||
|
|
||||||
<script id="SuperNodeStorageScript">
|
<script id="SuperNodeStorageScript">
|
||||||
function onLoadStartUp() {
|
function onLoadStartUp() {
|
||||||
myPrivKey = prompt("Enter Private Key : ");
|
myPrivKey = prompt("Enter Private Key : ")
|
||||||
myPubKey = floCrypto.getPubKeyHex(myPrivKey)
|
myPubKey = floCrypto.getPubKeyHex(myPrivKey)
|
||||||
myFloID = floCrypto.getFloIDfromPubkeyHex(myPubKey)
|
myFloID = floCrypto.getFloIDfromPubkeyHex(myPubKey)
|
||||||
|
|
||||||
@ -6006,7 +6002,7 @@
|
|||||||
|
|
||||||
function initIndexedDBforSupernode(){
|
function initIndexedDBforSupernode(){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var IndexesList = ["floID","data","sign","application","type","additionData"];
|
var IndexesList = ["senderID","receiverID","message","sign","application","type","comment"];
|
||||||
var primaryKey = "vectorClock";
|
var primaryKey = "vectorClock";
|
||||||
var obj = {
|
var obj = {
|
||||||
lastTx:{},
|
lastTx:{},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user