diff --git a/erisdb/pipe/transactor.go b/erisdb/pipe/transactor.go index 81d536f6c93926fdbb6829483e52fd725806adec..afcb69674b8c145b3ea35cfe69fc0f60871ef52b 100644 --- a/erisdb/pipe/transactor.go +++ b/erisdb/pipe/transactor.go @@ -10,7 +10,6 @@ import ( "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" - "sync" ) const ( @@ -22,8 +21,6 @@ const ( type transactor struct { consensusState *cs.ConsensusState mempoolReactor *mempl.MempoolReactor - pending []TxFuture - pendingLock *sync.Mutex eventEmitter EventEmitter } @@ -31,18 +28,8 @@ func newTransactor(consensusState *cs.ConsensusState, mempoolReactor *mempl.Memp txs := &transactor{ consensusState, mempoolReactor, - []TxFuture{}, - &sync.Mutex{}, eventEmitter, } - /* - eventEmitter.Subscribe(SUB_ID, EVENT_ID, func(v interface{}) { - block := v.(*types.Block) - for _, fut := range txs.pending { - fut.NewBlock(block) - } - }) - */ return txs } @@ -235,85 +222,3 @@ func toVMAccount(acc *account.Account) *vm.Account { Other: acc.PubKey, } } - -// This is the different status codes for transactions. -// 0 - the tx tracker object is being set up. -// 1 - the tx has been created and passed into the tx pool. -// 2 - the tx was succesfully committed into a block. -// Errors -// -1 - the tx failed. -const ( - TX_NEW_CODE int8 = 0 - TX_POOLED_CODE int8 = 1 - TX_COMITTED_CODE int8 = 2 - TX_FAILED_CODE int8 = -1 -) - -// Number of bytes in a transaction hash -const TX_HASH_BYTES = 32 - -// Length of the tx hash hex-string (prepended by 0x) -const TX_HASH_LENGTH = 2 * TX_HASH_BYTES - -type TxFuture interface { - // Tx Hash - Hash() string - // Target account. - Target() string - // Get the Receipt for this transaction. - Results() *TransactionResult - // This will block and wait for the tx to be done. - Get() *TransactionResult - // This will block for 'timeout' miliseconds and wait for - // the tx to be done. 0 means no timeout, and is equivalent - // to calling 'Get()'. - GetWithTimeout(timeout uint64) *TransactionResult - // Checks the status. The status codes can be find near the - // top of this file. - StatusCode() int8 - // This is true when the transaction is done (whether it was successful or not). - Done() bool -} - -// Implements the 'TxFuture' interface. -type TxFutureImpl struct { - receipt *Receipt - result *TransactionResult - target string - status int8 - transactor Transactor - errStr string - getLock *sync.Mutex -} - -func (this *TxFutureImpl) Results() *TransactionResult { - return this.result -} - -func (this *TxFutureImpl) StatusCode() int8 { - return this.status -} - -func (this *TxFutureImpl) Done() bool { - return this.status == TX_COMITTED_CODE || this.status == TX_FAILED_CODE -} - -func (this *TxFutureImpl) Wait() *TransactionResult { - return this.WaitWithTimeout(0) -} - -// We wait for blocks, and when a block arrives we check if tx is committed. -// This will return after it has been confirmed that tx was committed, or if -// it failed, and for a maximum of 'blocks' blocks. If 'blocks' is set to 0, -// it will be set to DEFAULT_BLOCKS_WAIT. -// This is a temporary solution until we have solidity events. -func (this *TxFutureImpl) WaitWithTimeout(blocks int) *TransactionResult { - return nil -} - -func (this *TxFutureImpl) setStatus(status int8, errorStr string) { - this.status = status - if status == TX_FAILED_CODE { - this.errStr = errorStr - } -} diff --git a/files/files.go b/files/files.go index eaa2b3bab1d3f40af149d60e6182ed140739af65..aa9e59c83a11c980383e50198125fde577dd59cf 100644 --- a/files/files.go +++ b/files/files.go @@ -71,7 +71,12 @@ func IsRegular(fileName string) bool { func WriteAndBackup(fileName string, data []byte) error { fs, err := os.Stat(fileName) + fmt.Println("Write and backup") if err != nil { + if os.IsNotExist(err) { + WriteFileRW(fileName, data) + return nil + } return err } if !fs.Mode().IsRegular() { diff --git a/server/config.go b/server/config.go index a3e012a906eafb9209b76cb700da8b614db875a4..ae5f2f5c64c8312a390cf247c27924356f296239 100644 --- a/server/config.go +++ b/server/config.go @@ -99,11 +99,10 @@ func ReadServerConfig(filePath string) (*ServerConfig, error) { } // Write a server configuration file. -// TODO use the backup file write. func WriteServerConfig(filePath string, cfg *ServerConfig) error { bts, err := toml.Marshal(*cfg) if err != nil { return err } - return files.WriteFileRW(filePath, bts) + return files.WriteAndBackup(filePath, bts) } diff --git a/server/server.go b/server/server.go index 2d90023fb6d60732a23cfcf706a316bd8fe72fff..950a5b17ff012f18319c54ff508f415bfe923bc7 100644 --- a/server/server.go +++ b/server/server.go @@ -15,7 +15,6 @@ var ( killTime = 100 * time.Millisecond ) -// TODO should this be here. type HttpService interface { Process(*http.Request, http.ResponseWriter) } @@ -205,7 +204,6 @@ func NewServeProcess(config *ServerConfig, servers ...Server) *ServeProcess { // Used to enable log15 logging instead of the default Gin logging. // This is done mainly because we at Eris uses log15 in other components. -// TODO make this optional perhaps. func logHandler(c *gin.Context) { path := c.Request.URL.Path diff --git a/server/server_test.go b/server/server_test.go index a857e6af249d14d3954ac42e80c98ee7a8b18ae1..55bfb66676a76ad2c610f67874cbb62b0196efcf 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -7,7 +7,7 @@ import ( ) // Unit tests for server components goes here. Full-on client-server tests -// can be found in the test folder. TODO change that? +// can be found in the test folder. func TestIdGet(t *testing.T) { idPool := NewIdPool(100) diff --git a/server/websocket.go b/server/websocket.go index 08ac2ddf23d2a7609340d6c33a5437fecadb97f1..e83729d81254c6a99211385f7c4ffeb4db70089e 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -60,7 +60,6 @@ func NewWebSocketServer(maxSessions uint, service WebSocketService) *WebSocketSe } // Start the server. Adds the handler to the router and sets everything up. -// TODO fix CORS. func (this *WebSocketServer) Start(config *ServerConfig, router *gin.Engine) { this.config = config @@ -81,9 +80,6 @@ func (this *WebSocketServer) Running() bool { } // Shut the server down. -// TODO This should only ensure that all read/write procceses and -// timers has been terminated. Closing the sockets should be done -// by the http.Server func (this *WebSocketServer) ShutDown() { this.sessionManager.Shutdown() this.running = false @@ -113,7 +109,6 @@ func (this *WebSocketServer) handleFunc(c *gin.Context) { if cErr != nil { cErrStr := "Failed to establish websocket connection: " + cErr.Error() http.Error(w, cErrStr, 503) - // TODO Look into what these logging params all mean.. log.Info(cErrStr) return } @@ -329,7 +324,7 @@ func NewSessionManager(maxSessions uint, wss WebSocketService) *SessionManager { } } -// TODO should ensure all session objects are released. +// TODO func (this *SessionManager) Shutdown() { this.activeSessions = nil } @@ -407,7 +402,6 @@ func (this *SessionManager) createSession(wsConn *websocket.Conn) (*WSSession, e sessionManager: this, id: newId, wsConn: wsConn, - // TODO Tracking removed as of now. writeChan: make(chan []byte, writeChanBufferSize), writeCloseChan: make(chan struct{}), service: this.service, diff --git a/test/server/ws_burst_test.go b/test/server/ws_burst_test.go index a5104c3be2de64e924b9de2bee66f45203c749d3..b894aeea9c5f2e07a721ac551a2b898e5e51bc2a 100644 --- a/test/server/ws_burst_test.go +++ b/test/server/ws_burst_test.go @@ -36,9 +36,8 @@ func (this *SessionCounter) Report() (int, int, int) { return this.opened, this.closed, this.opened - this.closed } -// Coarse flood testing just to ensure that websocket server -// does not crash, and that it cleans up after itself. -// TODO clean this up. +// Testing to ensure that websocket server does not crash, and that it +// cleans up after itself. func TestWsFlooding(t *testing.T) { // New websocket server. diff --git a/test/testdata/filters/testdata_filters.go b/test/testdata/filters/testdata_filters.go index 51bd863397734d106f8c5484096c27329c5a136b..2c0aac8205267b5643fe7c99a07c83ad784546ae 100644 --- a/test/testdata/filters/testdata_filters.go +++ b/test/testdata/filters/testdata_filters.go @@ -229,7 +229,6 @@ func LoadTestData() *TestData { codec := edb.NewTCodec() testData := &TestData{} err := codec.DecodeBytes(testData, []byte(testDataJson)) - // TODO for now. if err != nil { panic(err) } diff --git a/test/testdata/testdata/testdata.go b/test/testdata/testdata/testdata.go index 1ba598b4611e9e4cd4e840bf7bcd4fc32ae79033..943c2b1fe7a65df8c651bd8ca754463d43df9697 100644 --- a/test/testdata/testdata/testdata.go +++ b/test/testdata/testdata/testdata.go @@ -336,7 +336,6 @@ func LoadTestData() *TestData { codec := edb.NewTCodec() testData := &TestData{} err := codec.DecodeBytes(testData, []byte(testDataJson)) - // TODO for now. if err != nil { panic(err) } diff --git a/test/web_api/query_test.go b/test/web_api/query_test.go index acfa17eebe72e5a45b3259cabee27afab4454bce..5368b5246eb7f664e6904004a868c20cf920d2c1 100644 --- a/test/web_api/query_test.go +++ b/test/web_api/query_test.go @@ -71,7 +71,7 @@ func (this *QuerySuite) TearDownSuite() { // ********************************************* Tests ********************************************* -// TODO make these functions into one. +// TODO less duplication. func (this *QuerySuite) Test_Accounts0() { fd := this.testData.Input.Filters0 resp := this.get("/accounts?" + generateQuery(fd))