Versions in this module Expand all Collapse all v0 v0.1.0 Dec 10, 2018 Changes in this version + const BASE_APP_NAME + const ChainIDArg + const CoSiAckSyncMsg + const CoSiSyncMsg + const CoSiTimeout + const CommTypeIdentity + const CommTypeSecure + const ERR_NODE_ALREADY_RUNING + const OfficialAddress + const OrgCreate + const OrgDelete + const OrgJoin + const OrgLeave + const OrgRegister + const QueryEvents + const RPCCollectSpecialVotes + const ReceiptsPrefix + const RequestSigpart + var Apps = make(map[string]AppMaker) + var CoSiInitTag = []byte + var CoSiTag = []byte + var ErrAccountExisted = fmt.Errorf("account already existed") + var ErrAccountNotExist = fmt.Errorf("account not existed") + var ErrDataTransfer = errors.New("data transfer err") + var ErrInsufficientBalance = fmt.Errorf("balance is lower than the amount to be wired") + var ErrInvalidChainID = errors.New("no such chain id") + var ErrInvalidNonce = fmt.Errorf("invalid nonce") + var ErrMissingParams = errors.New("missing params") + var ErrOrgAlreadyIn = fmt.Errorf("already part the organization") + var ErrOrgExistsAlready = fmt.Errorf("organization already exists") + var ErrOrgFailToStop = fmt.Errorf("fail to stop organization") + var ErrOrgNotExists = fmt.Errorf("organization doesn't exist") + var ErrRevertFromBackup = errors.New("revert from backup,not find data") + var ErrUnknownTx = fmt.Errorf("please give me something that I actually know about") + var EventConfirmTag = append(EventTag, 0x05) + var EventMsgTag = append(EventTag, 0x06) + var EventNotificationTag = append(EventTag, 0x03) + var EventRequestTag = append(EventTag, 0x01) + var EventSubscribeTag = append(EventTag, 0x02) + var EventTag = []byte + var EventUnsubscribeTag = append(EventTag, 0x04) + var EventUploadCodeTag = append(EventTag, 0x07) + var OrgCancelTag = []byte + var OrgConfirmTag = []byte + var OrgTag = []byte + func AppExists(name string) (yes bool) + func BytesToInt(bs []byte) (ret int) + func CheckConfNeedInApp(appName string, conf map[string]interface{}) error + func EncodeEventData(data EventData) ([]byte, error) + func GetCoSiAddress(attr AppAttributes) string + func IntToBytes(num int) []byte + func IsCoSiInitTx(tx []byte) bool + func IsCoSiTx(tx []byte) bool + func IsEventNotificationTx(tx []byte) bool + func IsEventRequestTx(tx []byte) bool + func IsEventSubscribeTx(tx []byte) bool + func IsEventTx(tx []byte) bool + func IsEventUnsubscribeTx(tx []byte) bool + func IsEventUploadCodeTx(tx []byte) bool + func IsOrgCancelTx(tx []byte) bool + func IsOrgConfirmTx(tx []byte) bool + func IsOrgRelatedTx(tx []byte) bool + func IsOrgTx(tx []byte) bool + func NewLogger(conf *viper.Viper) (*zap.Logger, error) + func RunNode(config *viper.Viper) + func RunNodeRet(config *viper.Viper) error + type AggregateInfo struct + Commit []byte + Pubkey []byte + type AppAttributes = map[string]string + type AppMaker func(*zap.Logger, *viper.Viper, crypto.PrivKey) (Application, error) + type AppName string + type AppTool struct + func (t *AppTool) BackupLastBlock(branchName string) error + func (t *AppTool) Init(datadir string) error + func (t *AppTool) LastHeightHash() (def.INT, []byte) + func (t *AppTool) SaveNewLastBlock(fromHeight def.INT, fromAppHash []byte) error + type Application interface + GetAttributes func() AppAttributes + SetCore func(Core) + type Broadcaster interface + BroadcastTx func([]byte) error + type ChainID string + type CoSiAppBase struct + func NewCoSiAppBase(addr string) CoSiAppBase + func (app *CoSiAppBase) CheckTx(bs []byte) error + func (app *CoSiAppBase) ExecuteTx(bs []byte) error + func (app *CoSiAppBase) SetCore(core Core) + func (app *CoSiAppBase) Setup() (string, error) + type CoSiInitTx struct + ChainID string + Data []byte + Height def.INT + Receiver []byte + TxHash []byte + Type string + type CoSiModule struct + CoSigners *cosi.Cosigners + Commitments []cosi.Commitment + Conns []*p2p.SecretConnection + Nonce uint64 + Pubkeys []cosiED.PublicKey + SignatureParts []cosi.SignaturePart + func NewCoSiModule(logger *zap.Logger, privkey crypto.PrivKeyEd25519, ...) *CoSiModule + func (cm *CoSiModule) Add(n int) + func (cm *CoSiModule) Done() + func (cm *CoSiModule) FollowCoSign(leaderAddress string, data []byte) error + func (cm *CoSiModule) LeadCoSign(cosiAddr string, msg []byte) ([]byte, error) + func (cm *CoSiModule) Lock() + func (cm *CoSiModule) Read(sc *p2p.SecretConnection) ([]byte, error) + func (cm *CoSiModule) SetLeaderListener(l net.Listener) + func (cm *CoSiModule) Unlock() + func (cm *CoSiModule) Verify(sig []byte, msg []byte) bool + func (cm *CoSiModule) Wait() + func (cm *CoSiModule) Write(sc *p2p.SecretConnection, data []byte) (int, error) + type CoSiTx struct + Data []byte + Height def.INT + Leader []byte + LeaderAddr string + TxHash []byte + Type string + type CodeHash = []byte + type Core interface + BroadcastTxSuperior func([]byte) error + GetChainID func() string + GetEngine func() Engine + GetPrivateKey func() (crypto.PrivKeyEd25519, bool) + GetPublicKey func() (crypto.PubKeyEd25519, bool) + IsValidator func() bool + type CosiPacket = []byte + func CosiWrapData(data []byte) []CosiPacket + type Engine interface + BroadcastTx func([]byte) error + GetBlock func(def.INT) (*agtypes.BlockCache, *pbtypes.BlockMeta, error) + GetBlockMeta func(def.INT) (*pbtypes.BlockMeta, error) + GetValidators func() (def.INT, *agtypes.ValidatorSet) + PrivValidator func() *agtypes.PrivValidator + Query func(byte, []byte) (interface{}, error) + type EventAccount struct + ChainID string + MyPubers map[string]CodeHash + MySubers map[string]CodeHash + func NewEventAccount(es *EventState, chainID string) *EventAccount + func (ea *EventAccount) AddPublisher(pub string, hash CodeHash) + func (ea *EventAccount) AddSubscriber(sub string, hash CodeHash) + func (ea *EventAccount) Copy() *EventAccount + func (ea *EventAccount) FromBytes(bs []byte, es *EventState) error + func (ea *EventAccount) GetPublishers() map[string]CodeHash + func (ea *EventAccount) GetSubscribers() map[string]CodeHash + func (ea *EventAccount) RemovePublisher(pub string) + func (ea *EventAccount) RemoveSubscriber(sub string) + func (ea *EventAccount) ToBytes() []byte + type EventApp interface + type EventAppBase struct + func NewEventAppBase(l *zap.Logger, cosiAddr string) EventAppBase + func (app *EventAppBase) CheckTx(bs []byte) error + func (app *EventAppBase) ConfirmEvent(tx *EventNotificationTx) error + func (app *EventAppBase) ExecuteTx(bs []byte, validators *agtypes.ValidatorSet) error + func (app *EventAppBase) IncomingEvent(_ string, _ def.INT) bool + func (app *EventAppBase) PublishEvent(data []EventData, block *agtypes.BlockCache) error + func (app *EventAppBase) SetCoSiAddr(addr string) + func (app *EventAppBase) SetCore(core Core) + func (app *EventAppBase) Setup() (string, error) + func (app *EventAppBase) Start() (string, error) + func (app *EventAppBase) Stop() error + func (app *EventAppBase) SupportCoSiTx() + type EventConfirmTx struct + DataHash []byte + EventID string + Source string + Time time.Time + TxHash []byte + type EventData map[string]interface + func DecodeEventData(bs []byte) (EventData, error) + type EventMsgTx struct + DataHash []byte + EventID string + Listener string + Msg []byte + Time time.Time + type EventNotificationTx struct + DataHash []byte + Height def.INT + Listener string + RelatedTx []byte + Source string + Time time.Time + type EventRequestHandle interface + SupportCoSiTx func() + type EventRequestTx struct + Listener string + ListenerHash []byte + Source string + SourceHash []byte + Time time.Time + type EventState struct + func NewEventState(database db.DB) *EventState + func (es *EventState) Commit() ([]byte, error) + func (es *EventState) Copy() *EventState + func (es *EventState) CreateAccount(chainID string) (accnt *EventAccount, err error) + func (es *EventState) ExistAccount(chainID string) bool + func (es *EventState) GetAccount(chainID string) (accnt *EventAccount, err error) + func (es *EventState) Load(root []byte) + func (es *EventState) Lock() + func (es *EventState) ModifyAccount(a *EventAccount) + func (es *EventState) Reload(root []byte) + func (es *EventState) Unlock() + type EventSubscribeTx struct + CoSignature []byte + SignData []byte + Source string + Threshold int + Time time.Time + TxHash []byte + type EventSubscriber interface + ConfirmEvent func(tx *EventNotificationTx) error + HandleEvent func(data EventData, tx *EventNotificationTx) + IncomingEvent func(from string, height def.INT) bool + type EventUnsubscribeTx struct + Listener string + Proof []byte + Source string + Time time.Time + type EventUploadCodeTx struct + Code string + Owner string + Source string + Time time.Time + type EventWarehouse struct + func NewEventWarehouse(database db.DB) *EventWarehouse + func (ew *EventWarehouse) Batch() db.Batch + func (ew *EventWarehouse) Fetch(subID, pubID string, height def.INT) ([]byte, error) + func (ew *EventWarehouse) Flush(batch db.Batch) + func (ew *EventWarehouse) GenerateID(subID, pubID string, height def.INT) []byte + func (ew *EventWarehouse) Pop(subID, pubID string, height def.INT) ([]byte, error) + func (ew *EventWarehouse) Push(batch db.Batch, subID, pubID string, height def.INT, data []byte) + type EventWarehouseState struct + func (ews *EventWarehouseState) Append(subID, pubID string, height def.INT) []def.INT + func (ews *EventWarehouseState) Get(subID, pubID string) ([]def.INT, error) + func (ews *EventWarehouseState) Set(subID, pubID string, heights []def.INT) + func (ews *EventWarehouseState) ToBytes() ([]byte, error) + type Hashable interface + type IMetropolisApp interface + AttributeExists func(string) bool + GetAttribute func(string) (string, bool) + GetAttributes func() AppAttributes + PushAttribute func(string, string) + SetAttributes func(AppAttributes) + type IdentityAck struct + PubKey []byte + Signature []byte + Type byte + type LastBlockInfo struct + Hash []byte + Height def.INT + func NewLastBlockInfo() *LastBlockInfo + type Metropolis struct + EventCodeBase db.DB + EventState *EventState + EventStateDB db.DB + EventWarehouse *EventWarehouse + OrgApps map[ChainID]AppName + OrgState *OrgState + OrgStateDB db.DB + Orgs map[ChainID]*OrgNode + PendingEventRequestTxs map[string]*EventRequestTx + PendingOrgTxs map[string]*OrgTx + func NewMetropolis(logger *zap.Logger, conf *viper.Viper) *Metropolis + func (met *Metropolis) BroadcastTx(tx []byte) error + func (met *Metropolis) CheckTx(bs []byte) error + func (met *Metropolis) CodeExists(codehash []byte) bool + func (met *Metropolis) CompatibleWithAngine() + func (met *Metropolis) ExecuteTx(block *agtypes.BlockCache, bs []byte, txIndex int) (validtx []byte, err error) + func (met *Metropolis) GetAngineHooks() agtypes.Hooks + func (met *Metropolis) GetAttributes() map[string]string + func (met *Metropolis) GetNodePubKey() crypto.PubKey + func (met *Metropolis) GetOrg(id string) (*OrgNode, error) + func (met *Metropolis) Hash() []byte + func (met *Metropolis) Info() (resInfo agtypes.ResultInfo) + func (met *Metropolis) IsTxKnown(bs []byte) bool + func (met *Metropolis) Load(lb *LastBlockInfo) error + func (met *Metropolis) Lock() + func (met *Metropolis) OnCommit(height, round def.INT, block *agtypes.BlockCache) (interface{}, error) + func (met *Metropolis) OnExecute(height, round def.INT, block *agtypes.BlockCache) (interface{}, error) + func (met *Metropolis) PublishEvent(chainID string, block *agtypes.BlockCache, data []EventData, ...) error + func (met *Metropolis) Query(query []byte) agtypes.Result + func (met *Metropolis) RemoveOrg(id string) error + func (met *Metropolis) SetCore(c Core) + func (met *Metropolis) SetNode(n *Node) + func (met *Metropolis) SetOption() + func (met *Metropolis) SetOrg(chainID, appname string, o *OrgNode) + func (met *Metropolis) Start() error + func (met *Metropolis) Stop() + func (met *Metropolis) Unlock() + type MetropolisAppBase struct + func NewMetropolisAppBase() MetropolisAppBase + func (app *MetropolisAppBase) AttributeExists(key string) bool + func (app *MetropolisAppBase) GetAttribute(key string) (val string, exists bool) + func (app *MetropolisAppBase) GetAttributes() AppAttributes + func (app *MetropolisAppBase) PushAttribute(key, val string) + func (app *MetropolisAppBase) SetAttributes(attrs AppAttributes) + func (app *MetropolisAppBase) SetCore(c Core) + func (app *MetropolisAppBase) Start() error + func (app *MetropolisAppBase) Stop() error + type MetropolisState struct + EventStateHash []byte + OrgHeights []def.INT + OrgStateHash []byte + func (ms *MetropolisState) FromBytes(bs []byte) error + func (ms *MetropolisState) Hash() []byte + func (ms *MetropolisState) ToBytes() []byte + type Node struct + MainChainID string + MainOrg *OrgNode + func NewNode(conf *viper.Viper) *Node + func (n *Node) GetConf() *viper.Viper + func (n *Node) NodeInfo() *p2p.NodeInfo + func (n *Node) PrivValidator() *types.PrivValidator + func (n *Node) Start() error + func (n *Node) StartRPC() ([]net.Listener, error) + func (n *Node) Stop() + type OrgAccount struct + Balance int64 + ChainID string + Count int + Nodes map[string]map[string]string + Nonce uint64 + PubKey []byte + func NewOrgAccount(state *OrgState, chainID string, pubkey []byte, balance int64) *OrgAccount + func (oa *OrgAccount) AddNode(p crypto.PubKey, attr map[string]string) error + func (oa *OrgAccount) Copy() *OrgAccount + func (oa *OrgAccount) FromBytes(bytes []byte, state *OrgState) error + func (oa *OrgAccount) GetBalance() int64 + func (oa *OrgAccount) GetChainID() string + func (oa *OrgAccount) GetNodes() map[string]map[string]string + func (oa *OrgAccount) GetNonce() uint64 + func (oa *OrgAccount) GetPubkey() []byte + func (oa *OrgAccount) GetPubkeyString() string + func (oa *OrgAccount) RemoveNode(p crypto.PubKey) error + func (oa *OrgAccount) SetBalance(b int64) + func (oa *OrgAccount) SetNonce(n uint64) + func (oa *OrgAccount) ToBytes() []byte + type OrgCancelTx struct + Time time.Time + TxHash []byte + type OrgConfirmTx struct + Act byte + Attributes map[string]string + ChainID string + Time time.Time + TxHash []byte + Validators [][]byte + type OrgNode struct + Angine *angine.Angine + AngineTune *angine.Tunes + Application agtypes.Application + GenesisDoc *agtypes.GenesisDoc + Superior Superior + func NewOrgNode(logger *zap.Logger, appName string, conf *viper.Viper, metro *Metropolis) *OrgNode + func (o *OrgNode) BroadcastTxSuperior(tx []byte) error + func (o *OrgNode) CodeExists(codehash []byte) bool + func (o *OrgNode) GetAppName() string + func (o *OrgNode) GetChainID() string + func (o *OrgNode) GetEngine() Engine + func (o *OrgNode) GetPrivateKey() (r crypto.PrivKeyEd25519, b bool) + func (o *OrgNode) GetPublicKey() (r crypto.PubKeyEd25519, b bool) + func (o *OrgNode) IsRunning() bool + func (o *OrgNode) IsValidator() bool + func (o *OrgNode) PublishEvent(from string, block *agtypes.BlockCache, data []EventData, txhash []byte) error + func (o *OrgNode) Start() error + func (o *OrgNode) Stop() bool + type OrgState struct + func NewOrgState(database db.DB) *OrgState + func (os *OrgState) CanWire(fromAcc *OrgAccount, amount int64, nonce uint64, deliver bool) (bool, error) + func (os *OrgState) Commit() ([]byte, error) + func (os *OrgState) Copy() *OrgState + func (os *OrgState) CreateAccount(chainID string, balance int64) (accnt *OrgAccount, err error) + func (os *OrgState) ExistAccount(chainID string) bool + func (os *OrgState) GetAccount(chainID string) (accnt *OrgAccount, err error) + func (os *OrgState) Load(root []byte) + func (os *OrgState) Lock() + func (os *OrgState) ModifyAccount(account *OrgAccount) + func (os *OrgState) Reload(root []byte) + func (os *OrgState) RemoveAccount(chainID string) bool + func (os *OrgState) Unlock() + func (os *OrgState) Wire(from []byte, to []byte, amount int64, nonce uint64) (int64, error) + type OrgTx struct + Act byte + App string + ChainID string + Config map[string]interface{} + Genesis types.GenesisDoc + Time time.Time + type Publisher interface + CodeExists func([]byte) bool + PublishEvent func(from string, block *agtypes.BlockCache, data []EventData, txhash []byte) error + type RPCNode interface + BroadcastTx func(tx []byte) error + BroadcastTxCommit func(tx []byte) error + FlushMempool func() + GetBlacklist func() []string + GetBlock func(height def.INT) (*agtypes.BlockCache, *pbtypes.BlockMeta) + GetConsensusStateInfo func() (string, []string) + GetNumPeers func() int + GetNumUnconfirmedTxs func() int + GetOrg func(string) (*OrgNode, error) + GetP2PNetInfo func() (bool, []string, []*agtypes.Peer) + GetUnconfirmedTxs func() []agtypes.Tx + GetValidators func() (def.INT, []*agtypes.Validator) + Height func() def.INT + IsNodeValidator func(pub crypto.PubKey) bool + type Serializable interface + ToBytes func() ([]byte, error) + type Superior interface + type Unserializable interface + FromBytes func(bs []byte)