double-check that blocks have been written

even if 'write' calls back with no error
also update the changelog
pull/1/head
ansuz 4 years ago
parent 29d2fb38ef
commit 09cbeefd99

@ -35,6 +35,9 @@
* guard against domExceptions
* catch errors thrown by the diff applier
* don't bother returning the hash of a pin list to the client, since they don't use it
* accounts
* trim leading and trailing whitespace from usernames when registering
* double-check that login blocks can be loaded after they have been written without error
# 4.7.0

@ -153,7 +153,7 @@ define([
register: isRegister,
};
var RT, blockKeys, blockHash, Pinpad, rpc, userHash;
var RT, blockKeys, blockHash, blockUrl, Pinpad, rpc, userHash;
nThen(function (waitFor) {
// derive a predefined number of bytes from the user's inputs,
@ -171,7 +171,7 @@ define([
// the rest of their data
// determine where a block for your set of keys would be stored
var blockUrl = Block.getBlockUrl(res.opt.blockKeys);
blockUrl = Block.getBlockUrl(res.opt.blockKeys);
// Check whether there is a block at that location
Util.fetch(blockUrl, waitFor(function (err, block) {
@ -412,12 +412,21 @@ define([
toPublish.edPublic = RT.proxy.edPublic;
var blockRequest = Block.serialize(JSON.stringify(toPublish), res.opt.blockKeys);
rpc.writeLoginBlock(blockRequest, waitFor(function (e) {
if (e) {
console.error(e);
waitFor.abort();
return void cb(e);
}
}));
}).nThen(function (waitFor) {
// confirm that the block was actually written before considering registration successful
Util.fetch(blockUrl, waitFor(function (err /*, block */) {
if (err) {
console.error(err);
waitFor.abort();
return void cb(err);
}
console.log("blockInfo available at:", blockHash);
LocalStore.setBlockHash(blockHash);

@ -1937,6 +1937,17 @@ define([
waitFor.abort();
return void cb(obj);
}
}));
}).nThen(function (waitFor) {
var blockUrl = Block.getBlockUrl(blockKeys);
Util.fetch(blockUrl, waitFor(function (err /* block */) {
if (err) {
console.error(err);
waitFor.abort();
return cb({
error: err,
});
}
console.log("new login block written");
var newBlockHash = Block.getBlockHash(blockKeys);
LocalStore.setBlockHash(newBlockHash);

Loading…
Cancel
Save