Documentation
¶
Overview ¶
Copyright 2017 - 2018 OneLedger
Basic datatypes ¶
Copyright 2017 - 2018 OneLedger ¶
Copyright 2017-2018 OneLedger ¶
Keep the state of the MerkleTrees between the different stages of consensus ¶
We need an up to date tree to check new transactions against. We then need to apply them when delivered. We also need to get to the last tree.
The difficulty comes from the underlying code not quite being thread-safe...
Copyright 2017 - 2018 OneLedger ¶
Encapsulate the coins, allow int64 for interfacing and big.Int as base type ¶
Copyright 2017-2018 OneLedger ¶
Encapsulate the underlying storage from our app. Currently using:
Tendermint's memdb (just an in-memory Merkle Tree) Tendermint's persistent kvstore (with Merkle Trees & Proofs) - Can only be opened by one process...
Index ¶
- Variables
- func Exists(name string, dir string) bool
- type Balance
- type Chain
- type ChainNode
- type ChainState
- func (state *ChainState) Commit() ([]byte, int64)
- func (state *ChainState) Dump()
- func (state *ChainState) Exists(key DatabaseKey) bool
- func (state *ChainState) Find(key DatabaseKey) *Balance
- func (state *ChainState) FindAll() map[string]*Balance
- func (state *ChainState) Set(key DatabaseKey, balance Balance)
- func (state *ChainState) Test(key DatabaseKey, balance Balance) bool
- type ChainType
- type Coin
- func (coin Coin) AsString() string
- func (coin Coin) Equals(value Coin) bool
- func (coin Coin) EqualsInt64(value int64) bool
- func (coin Coin) IsCurrency(currencies ...string) bool
- func (coin Coin) IsValid() bool
- func (coin Coin) LessThan(value int64) bool
- func (coin Coin) LessThanEqual(value int64) bool
- func (coin Coin) Minus(value Coin) Coin
- func (coin Coin) Plus(value Coin) Coin
- type Coins
- type Currency
- type DatabaseKey
- type Datastore
- func (store Datastore) Close()
- func (store Datastore) Commit()
- func (store Datastore) Dump()
- func (store Datastore) Empty()
- func (store Datastore) Exists(key DatabaseKey) bool
- func (store Datastore) List() (keys []DatabaseKey)
- func (store Datastore) Load(key DatabaseKey) (value Message)
- func (store Datastore) Store(key DatabaseKey, value Message) Message
- type DatastoreType
- type Message
Constants ¶
This section is empty.
Variables ¶
var Currencies map[string]Currency = map[string]Currency{ "OLT": Currency{"OLT", ONELEDGER, 0}, "BTC": Currency{"BTC", BITCOIN, 1}, "ETH": Currency{"ETH", ETHEREUM, 2}, }
var OLTBase *big.Float = big.NewFloat(1000000000000000000)
Functions ¶
Types ¶
type ChainState ¶
type ChainState struct {
Name string
Type DatastoreType
Delivered *iavl.VersionedTree // Build us a new set of transactions
Checked *iavl.VersionedTree // Temporary and can be Rolled Back
Committed *iavl.VersionedTree // Last Persistent Tree
// Last committed values
Version int64
Height int
Hash []byte
// contains filtered or unexported fields
}
func NewChainState ¶
func NewChainState(name string, newType DatastoreType) *ChainState
func (*ChainState) Commit ¶
func (state *ChainState) Commit() ([]byte, int64)
TODO: Not sure about this, it seems to be Cosmos-sdk's way of getting arround the immutable copy problem...
func (*ChainState) Dump ¶
func (state *ChainState) Dump()
func (*ChainState) Exists ¶
func (state *ChainState) Exists(key DatabaseKey) bool
TODO: Should be against the commit tree, not the delivered one!!!
func (*ChainState) Find ¶
func (state *ChainState) Find(key DatabaseKey) *Balance
TODO: Should be against the commit tree, not the delivered one!!!
func (*ChainState) FindAll ¶
func (state *ChainState) FindAll() map[string]*Balance
func (*ChainState) Set ¶
func (state *ChainState) Set(key DatabaseKey, balance Balance)
Do this for the Delivery side
func (*ChainState) Test ¶
func (state *ChainState) Test(key DatabaseKey, balance Balance) bool
Test this against the checked UTXO data to make sure the transaction is legit
type Coin ¶
type Coin struct {
Currency Currency `json:"currency"`
Amount *big.Int `json:"amount"` // TODO: Switch to math/big
}
Coin is the basic amount, specified in integers, at the smallest increment (i.e. a satoshi, not a bitcoin)
func (Coin) EqualsInt64 ¶
func (Coin) IsCurrency ¶
See if the coin is one of a list of currencies
func (Coin) LessThanEqual ¶
type DatabaseKey ¶
type DatabaseKey = []byte // Database key
type Datastore ¶
type Datastore struct {
Type DatastoreType
Name string
File string
// contains filtered or unexported fields
}
Wrap the underlying usage
func NewDatastore ¶
func NewDatastore(name string, newType DatastoreType) *Datastore
NewApplicationContext initializes a new application
func (Datastore) Exists ¶
func (store Datastore) Exists(key DatabaseKey) bool
func (Datastore) Load ¶
func (store Datastore) Load(key DatabaseKey) (value Message)
Load return the stored value
type DatastoreType ¶
type DatastoreType int
ENUM for datastore type
const ( MEMORY DatastoreType = iota PERSISTENT DatastoreType = iota )
Different types