From a3ae663392909e169bc0669daed8093747969b33 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen <ben@erisindustries.com> Date: Sat, 21 May 2016 12:21:07 +0200 Subject: [PATCH] Start Application interface from TMSP provided template; this is a starting point; where E-DB can restructure this interface for a more capable pipe, while maintaining compativility with Tendermint-TMSP --- manager/types/application.go | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 manager/types/application.go diff --git a/manager/types/application.go b/manager/types/application.go new file mode 100644 index 00000000..3abdc4e0 --- /dev/null +++ b/manager/types/application.go @@ -0,0 +1,77 @@ +// Copyright 2015, 2016 Eris Industries (UK) Ltd. +// This file is part of Eris-RT + +// Eris-RT is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Eris-RT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Eris-RT. If not, see <http://www.gnu.org/licenses/>. + +package types + +// TODO: Result is not yet defined (originally defined as tmsp protobuf type) + +// NOTE: [ben] this interface is likely to be changed. Currently it is taken +// from the tendermint socket protocol application interface; +// but for the needs of eris-rt and generalisation improvements will be made. + +// Application interface applies transactions to the state. +// +type Application interface { + + // Info returns application information as a string + // NOTE: [ben] likely to move + Info() (info string) + + // Set application option (e.g. mode=mempool, mode=consensus) + // NOTE: [ben] taken from tendermint, but it is unclear what the use is, + // specifically, when will tendermint call this over tmsp ? + SetOption(key string, value string) (log string) + + // Append transaction applies a transaction to the state regardless of + // whether the transaction is valid or not. + // Currently AppendTx is taken from tmsp, and returns a result. + // This will be altered, as AppendTransaction needs to more strongly reflect + // the theoretical logic: + // Append(StateN, Transaction) = StateN+1 + // here invalid transactions are allowed, but should act as the identity on + // the state: + // Append(StateN, InvalidTransaction) = StateN + // TODO: implementation notes: + // 1. at this point the transaction should already be strongly typed + // 2. + AppendTx(tx []byte) Result + + // Check Transaction validates a transaction before being allowed into the + // consensus' engine memory pool. This is the original defintion and + // intention as taken from tmsp, but should be remapped to the more + // general concept of basic, cheap verification; + // Check Transaction does not alter the state, but does require an immutable + // copy of the state. In particular there is no consensus on ordering yet. + // TODO: implementation notes: + // 1. at this point the transaction should already be strongly typed + // 2. + CheckTx(tx []byte) Result + + // Commit returns the root hash of the current application state + // NOTE: [ben] Because the concept of the block has been erased here + // the commit root hash is a fully implict stateful function; + // the opposit the principle of explicit stateless functions. + // This will be amended when we introduce the concept of (streaming) + // blocks in the pipe. + Commit() Result + + // Query for state. This query request is not passed over the p2p network + // and is called from Tendermint rpc directly up to the application. + // NOTE: [ben] Eris-DB will give preference to queries from the local client + // directly over the Eris-DB rpc. + // We will support this for Tendermint compatibility. + Query(query []byte) Result +} -- GitLab