From 51ad071446858a8c79cd45b93f5f63fa73f8d068 Mon Sep 17 00:00:00 2001
From: Andreas Brekken
Date: Sat, 1 Mar 2014 19:04:43 +0100
Subject: [PATCH 1/2] Remove txdb. close #39
---
src/txdb.js | 64 -----------------------------------------------------
1 file changed, 64 deletions(-)
delete mode 100644 src/txdb.js
diff --git a/src/txdb.js b/src/txdb.js
deleted file mode 100644
index 5baff7c9d..000000000
--- a/src/txdb.js
+++ /dev/null
@@ -1,64 +0,0 @@
-var Transaction = require('./transaction');
-
-var TransactionDatabase = function () {
- this.txs = [];
- this.txIndex = {};
-};
-
-EventEmitter.augment(TransactionDatabase.prototype);
-
-TransactionDatabase.prototype.addTransaction = function (tx) {
- this.addTransactionNoUpdate(tx);
- $(this).trigger('update');
-};
-
-TransactionDatabase.prototype.addTransactionNoUpdate = function (tx) {
- // Return if transaction is already known
- if (this.txIndex[tx.hash]) {
- return;
- }
-
- this.txs.push(new Transaction(tx));
- this.txIndex[tx.hash] = tx;
-};
-
-TransactionDatabase.prototype.removeTransaction = function (hash) {
- this.removeTransactionNoUpdate(hash);
- $(this).trigger('update');
-};
-
-TransactionDatabase.prototype.removeTransactionNoUpdate = function (hash) {
- var tx = this.txIndex[hash];
-
- if (!tx) {
- // If the tx is not in the index, we don't actually waste our
- // time looping through the array.
- return;
- }
-
- for (var i = 0, l = this.txs.length; i < l; i++) {
- if (this.txs[i].hash == hash) {
- this.txs.splice(i, 1);
- break;
- }
- }
-
- delete this.txIndex[hash];
-};
-
-TransactionDatabase.prototype.loadTransactions = function (txs) {
- for (var i = 0; i < txs.length; i++) {
- this.addTransactionNoUpdate(txs[i]);
- }
- $(this).trigger('update');
-};
-
-TransactionDatabase.prototype.getTransactions = function () {
- return this.txs;
-};
-
-TransactionDatabase.prototype.clear = function () {
- this.txs = [];
- this.txIndex = {};
- $(this).trigger('update');
-};
From 23ccb974392e68a2c21243a70b0f4fdbaa25ae01 Mon Sep 17 00:00:00 2001
From: Andreas Brekken
Date: Sat, 1 Mar 2014 19:06:30 +0100
Subject: [PATCH 2/2] Remove EventEmitter.js. close #37
---
src/events/eventemitter.js | 98 --------------------------------------
1 file changed, 98 deletions(-)
delete mode 100644 src/events/eventemitter.js
diff --git a/src/events/eventemitter.js b/src/events/eventemitter.js
deleted file mode 100644
index 85d9dce36..000000000
--- a/src/events/eventemitter.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * EventEmitter Mixin
- *
- * Designed to be used in conjunction with a mixin "augment" function,
- * such as http://chamnapchhorn.blogspot.com/2009/05/javascript-mixins.html
- *
- * @usage augment(MyClass, EventEmitter);
- * my_inst = new MyClass();
- * my_inst.on('someEvent', function(e){ console.dir(e); });
- * my_inst.trigger('someEvent', {eventProp:'value'});
- *
- * @example
- * // create a 'class'
- * MyClass = function() {}
- * // augment it with EventEmitter
- * EventEmitter.augment(MyClass.prototype);
- * // create a method, which triggers an event
- * MyClass.prototype.scrollComplete = function() {
- * this.trigger('scrolled', {baz:'eck'});
- * };
- *
- * // this callback is pulled out into a named function so that we can unbind it
- * var callback = function(e) {
- * console.log('the scrolled event was fired! this.foo='+this.foo+', e.baz='+e.baz);
- * };
- * // create an instance of th class
- * var myinstance = new MyClass();
- * // set a property on the instance
- * myinstance.foo = 'bar';
- * // bind to the scrollComplete event
- * myinstance.on('scrolled', callback, myinstance);
- * // fire the method, which should trigger the event and therefore our callback
- * myinstance.scrollComplete();
- * // unbind the event, so that our callback should not get called
- * myinstance.removeListener('scrolled', callback);
- * // this should now not fire the callback
- * myinstance.scrollComplete();
- */
-var EventEmitter = function() {};
-/**
- * Bind a callback to an event, with an option scope context
- *
- * @param {string} name the name of the event
- * @param {function} callback the callback function to fire when the event is triggered
- * @param {object} context the scope to use for the callback (which will become 'this' inside the callback)
- */
-EventEmitter.prototype.on = function(name, callback, context) {
- if (!context) context = this;
- if (!this._listeners) this._listeners = {};
- if (!this._listeners[name]) this._listeners[name] = [];
- if (!this._unbinders) this._unbinders = {};
- if (!this._unbinders[name]) this._unbinders[name] = [];
- var f = function(e) {
- callback.apply(context, [e]);
- };
- this._unbinders[name].push(callback);
- this._listeners[name].push(f);
-};
-/**
- * Trigger an event, firing all bound callbacks
- *
- * @param {string} name the name of the event
- * @param {object} event the event object to be passed through to the callback
- */
-EventEmitter.prototype.trigger = function(name, event) {
- if (event === undefined) event = {}
- if (!this._listeners) this._listeners = {};
- if (!this._listeners[name]) return;
- var i = this._listeners[name].length;
- while (i--) this._listeners[name][i](event);
-};
-/**
- * Remove a bound listener
- *
- * @param {string} name the name of the event
- * @param {object} event the event object to be passed through to the callback
- */
-EventEmitter.prototype.removeListener = function(name, callback) {
- if (!this._unbinders) this._unbinders = {};
- if (!this._unbinders[name]) return;
- var i = this._unbinders[name].length;
- while (i--) {
- if (this._unbinders[name][i] === callback) {
- this._unbinders[name].splice(i, 1);
- this._listeners[name].splice(i, 1);
- }
- }
-};
-/**
- * Augment an object with the EventEmitter mixin
- *
- * @param {object} obj The object to be augmented (often an object's protoype)
- */
-EventEmitter.augment = function(obj) {
- for (var method in EventEmitter.prototype) {
- if (!obj[method]) obj[method] = EventEmitter.prototype[method];
- }
-};