Currently, only registerFile() and viewProducers() work.
npm install
In your script file, add these lines and then you can call our methods with producer.METHOD or consumer.METHOD.
const producer = require('../Producer/producer.js').Producer;
const consumer = require('../Consumer/consumer.js').Consumer;
producer.registerFile("abc", 2, 3, 4, 5, 6);
consumer.viewProducers("abc");
Description:
Asks the market server to send all the producers currently serving the file.
Parameters:
[String] hash -> the hash of the file you want
Returns:
[false] on query error
[empty List] if no one is serving the file
[List of Users in the format ]described in the protofi otherwise
viewProducers(hash)
Description:
Tell the market that we choose this specific producer
Parameters:
[String] producerIP -> Public IP of producer
[String] consumerIP -> Public IP of consumer
[String] hash -> Hash of the file
[Number] bid -> Bid consumer agrees to pay
Returns:
[true] If producer is ready for consumer's query
[false] otherwise
selectProducer(producerIP, consumerIP, hash, bid)
Description:
Consumer downloads file, and finalizes transaction
Parameters:
[String] producerIP -> Public IP of producer
[String] hash -> Hash of the file
Returns:
[true] If consumer succesfully downloaded file
[false] otherwise
queryProducer(producerIP, hash)
Description:
Tells the market we have this file and are willing to serve it for [bid]
Parameters:
[String] hash -> the hash of the file you want to upload
[Number] uid -> peer id
[String] uname -> name of file
[Number] uip -> public IP to access producer HTTP server
[Number] uport -> port HTTP server is open on
[Number] uprice -> orcacoin producer wants in exchange
Returns:
Nothing
registerFile(hash, uid, uname, uip, uport, uprice)
Description: JS websockets were used to create a server for every newly created node. This websocket server listens for requests from the GUI and responds to its requests with the appropriate peer ID, public key, private key, or other information about the peer node.
Implementation for the websocket in the GUI project is currently stored in the DataTable.tsx Clone and replace the DataTable.tsx file in https://github.com/GreenMarioX/CSE416-OrcaNet with the DataTable.tsx in this project. webSocketService.js is an example of how to setup a server using JS websockets
Add here.