Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

demo — копия.html
demo — копия — копия.html
node_modules
3 changes: 2 additions & 1 deletion candy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const MessageType = {
MY_PEERS: 3,
BROADCAST: 4,
META: 5,
SW_BROADCAST: 6
SW_BROADCAST: 6,
TRANS_COLL:7,
};

const BlockchainRequestors = {
Expand Down
53 changes: 53 additions & 0 deletions transactionCollector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
Module which made transactions collections
*/

'use strict';
//unify browser and node
if (typeof _this ==='undefined') {
var _this = this;
}
if (_this.window === undefined){

}

class TransactionCollector {

constructor (candy) {
this.candy = candy;
this.lastAddedTransaction = {};
}


/**
* create alert about new transaction
* @param data
* @param index
* @returns {{type: number, data: *, index: string}}
*/
createMessage(data, index = ''){
let JSONdata = JSON.stringify(data);
return {
type: this.candy.MessageType.TRANS_COLL,
data: JSONdata,
index:index
}
}

/**
* broadcasting message to all peers about new element of collection, excluding excludeSocket
* @param data
* @param broadcastFunction
* @param excludeSocket
*/
sendTransactionToAllPeers(data, broadcastFunction, excludeSocket){
let message = this.createMessage(data);
broadcastFunction (message, excludeSocket);
return message;
}
}

//unify browser and node
if (this.window === undefined){
module.exports = TransactionCollector;
}