You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because of their concurrent non blocking success criteria, the choosen solution pretends to orquest # concurrent writes over the same file implementing a concurrent queue model.
Even though it´s possible to resolve the issue using lock techniques, this perspective lacks in # unnecesary time for each concurrent request waiting to release the resource and then, get the last # inserted line, calculate prev_hash, generate nonce, write new line.
In an hypotetical context in which a huge amount of client´s make requests (for write line service, in # the same file, and simultaneously) the waiting time will be enormus.
The choosen solution has two stages:
-----------------------------------
First stage:
NodeJS service for Inserting into MongoDB colleciton, just the Message with a TimeStamp and # CryptoRandomKey signature. This "ensure" ordered unique message identification. # CryptoRandomKey increases the difficulty over more than one request with the same TimeStamp (exceptional # cases).
Second stage:
Separated NodeJS service for process syncronization of DB and phisical file.
Client Interaction:
Within a GUI, clients can view the file content. The can write a message and added to the shared file.
If the file has been edited by other client after the file has shown to the GUI, it will be informed via # status notifications prior to dispatch the current action. So it doesn´t stop the write operation but # let the client to be informed that his message will have a prev_hash asociated to an unknown line until # the moment.
If not, the action will be triggered immediately without previous notification.
Aditional the GUI has other actions. The actions are Checkintegrity, Recalculate Nonces, Edit and Delete.
Check Integrity, tests all the file in order to check hash/prev_hash correlation and correct format.
Edit, allows to make modificatioins to a message in order to break nonce integrity.
Delete, allows to delete entry in order to break prev_hash/hash integrity.
Recalculate Nonces, could be used after Check Integrity Failure to regerenate a new valid message chain.
Open browser in http://localhost:3456 and you will see at the bottom of the page a data grid showing # prev_hash/hash/nonce, message and actions (delete,edit) by entry.
Use Case 'Add Message':
Open browser in http://localhost:3456 and you will see at the top of the page a text area for input a # new message. There are 3 possible scenarios:
1. Add button pressed with no message. Fires error message 'Empty Message. Insert Message to add # new line'. Stops the action.
2. Add button pressed within the message, anyone else add new line first. Send Request. Add entry. # Reload the page without showing message.
3. Add button pressed with message, but other request add entry first. Fires a Warning message. # Send Request. Add entry. Reload the page without showing message.
Use Case 'Edit Message':
Open browser in http://localhost:3456 and you will see a data grid showing prev_hash/hash/nonce, # message and actions (delete,edit) by entry. This action only can be requested if exists at least one # entry in the grid. With entries in the grid, choose one line and click Edit. A modal window will apear. # After that you will see inside the modal a text area with the current message. There are 3 possible # scenarios:
1. Edit to an empty message and save. Closes modal. Fires error message 'Empty Message. Insert Message # to to apply changes'. Stops the action.
2. Edit button pressed within the message, Send Request. Edit entry. Reload the page without # showing message but showing the entry with the new message. At this point the chain integrity was # broken due to nonce / message concistency.
3. Close button or X button, Closes modal. No changes are commited.
Use Case 'Delete Message':
Open browser in http://localhost:3456 and you will see a data grid showing prev_hash/hash/nonce, # message and actions (delete,edit) by entry. This action only can be requested if exists at least one # entry in the grid. With entries in the grid, choose one line and click Delete. Reload the page without # showing message and without showing the deleted entry. At this point the chain integrity was broken due # to prev_hash / hash concistency.
Use Case 'Check Integrity':
Open browser in http://localhost:3456 and you will see a data grid showing prev_hash/hash/nonce, # message and actions (delete,edit) by entry. Click Check Integrity Button.
With no entries in the grid, you will see the error message 'No Entries to evaluate.'.
With entries in the grid there are two possible scenarios, with error and with success.
1.Error message, possible messages are:
'Integrity check: Failure. prev_hash not sha256'
'Integrity check: Failure. hash not sha256'
'Integrity check: Failure. nonce not numeric'
'Integrity check: Failure. Message doesn´t correspond to Nonce. Message was changed without # 'Recalculate Nonces' or Nonce was editted'
'Integrity check: Failure. prev_hash differs from expected prev_hash.'
2.Success message, 'Integrity check: Success.'
Use Case 'Recalculate Nonces':
Open browser in http://localhost:3456 and you will see a data grid showing prev_hash/hash/nonce, # message and actions (delete,edit) by entry. Click Recalculate Nonces Button.
With no entries in the grid, you will see the error message 'No Entries to evaluate.'.
With entries in the grid there are two possible scenarios, both with success.
1.Success message, possible messages are:
'Regenerate Nonces: Success.'
'Check Integrity: Successful. No need to Regenerate Nonces.'
How efficient could Node.js be, in order to manage multiple updates over the same file and (if necessary), spread # those changes over the network?
Since the server is listening for incoming TCP connections (open a http connection means open a connection on its # underlying transport layer, therefore TCP) on a single socket in a single process, there cannot be two incoming # # connections at exactly the same time. One will be processed by the underlying operating system slightly before the # other one. Think of it this way. An incoming connection is a set of packets over a network connection. One of the # incoming connections will have its packets before the other one.
This is valid even if you had multiple network cards and multiple network links so two incoming connections could # literally arrive at the server at the exact same moment. Because node.js JS execution is single threaded, the code # processing that request will run its synchronous code to completion. The one that is processed by the OS first # will be put into the node.js event queue before the other one. When node.js is available to process the next item # in the event queue, then whichever incoming request was first in the event queue will start processing first.
So, to reach the challenge goal I would prefer C++ language in order to manage multithread requests.