{"modulePath":"github.com/dcnt-developer/dcnt","version":"v0.0.0-20190910072103-303b43720a74","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package engine\n\nInterface that allows dcnt to offload the dbstate fetching to this plugin. If offloaded, dcnt will need to drain the buffer by launching a drain go routine\n\n## Variables\n\n```go\nvar (\n\t// Messages\n\tRepeatMsgs = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"dcnt_state_msg_replay_toss_total\",\n\t\tHelp: \"Number of repeated msgs.\",\n\t})\n\n\tBroadInCastQueue = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tName: \"dcnt_state_broadcast_in_current\",\n\t\tHelp: \"Number of msgs in broadcastin queue.\",\n\t})\n\n\tBroadCastInQueueDrop = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"dcnt_state_broadcast_in_drop_total\",\n\t\tHelp: \"How many messages are dropped due to full queues\",\n\t})\n\n\t// NetworkReplayFilter\n\tTotalNetworkReplayFilter = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"dcnt_state_network_replay_filter_total\",\n\t\tHelp: \"Tally of total messages gone into NetworkReplayFilter\",\n\t})\n\tTotalNetworkAckReplayFilter = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"dcnt_state_network_ack_replay_filter_total\",\n\t\tHelp: \"Tally of total messages gone into NetworkAckReplayFilter\",\n\t})\n\n\t// Network Out Queue\n\tNetworkOutTotalDequeue = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"dcnt_state_queue_netoutmsg_total_general\",\n\t\tHelp: \"Count of all messages being dequeued\",\n\t})\n\n\t// Send/Receive Times\n\tTotalSendTime = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tName: \"dcnt_state_total_send_time\",\n\t\tHelp: \"Time spent sending (nanoseconds)\",\n\t})\n\tTotalReceiveTime = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tName: \"dcnt_state_total_receive_time\",\n\t\tHelp: \"Time spent receiving (nanoseconds)\",\n\t})\n)\n```\n\n```go\nvar Build string\n```\nBuild sets the dcnt build id using git's SHA Version sets the semantic version number of the build $ go install -ldflags \"-X github.com/DCNT-developer/dcnt/engine.Build=\\`git rev-parse HEAD\\` -X github.com/DCNT-developer/dcnt/engine.=\\`cat VERSION\\`\" It also seems to need to have the previous binary deleted if recompiling to have this message show up if no code has changed. Since we are tracking code changes, then there is no need to delete the binary to use the latest message\n\n```go\nvar CHECK_BUFFER time.Duration = 2 * time.Second\n```\nHow often to check the plugin if it has messages ready\n\n```go\nvar LOCAL_NET_PRIV_KEY string = \"4c38c72fc5cdad68f13b74674d3ffb1f3d63a112710868c9b08946553448d26d\"\n```\nUsed for signing messages\n\n```go\nvar ListenTo int\n```\n\n```go\nvar (\n\tSTACK_HEIGHT = 100\n)\n```\n\n```go\nvar SortByID bool\n```\n\n```go\nvar VerboseAuthorityDeltas = false\n```\n\n```go\nvar VerboseAuthoritySet = false\n```\n\n```go\nvar VerboseFaultOutput = false\n```\n\n## Functions\n\n```go\nfunc AddInterruptHandler(handler func())\n```\nAddInterruptHandler adds a handler to call when a SIGINT (Ctrl+C) is received.\n\n```go\nfunc AddNode()\n```\n\n```go\nfunc AddSimPeer(fnodes []*FactomNode, i1 int, i2 int)\n```\n\n```go\nfunc ComposeEcTransaction(inSec interfaces.IHash, outEC interfaces.IHash, timeInMilliseconds *primitives.Timestamp, amt uint64, ecPrice uint64) (*factoid.Transaction, error)\n```\ncreate a transaction to buy Entry Credits this adds the EC fee on top of the input amount\n\n```go\nfunc ComposeFctTransaction(amt uint64, inSec interfaces.IHash, outPub interfaces.IHash, ecPrice uint64) (*factoid.Transaction, error)\n```\ncreate a transaction to transfer FCT between addresses adds EC fee on top of input amount\n\n```go\nfunc FaultSummary() string\n```\n\n```go\nfunc FundECWallet(st *state.State, inSec interfaces.IHash, outEC interfaces.IHash, amt uint64) (error, string)\n```\nFundECWallet get the current time in ms, add to it the offset provided (usually zero, except for tests)\n\n```go\nfunc FundWallet(st *state.State, amt uint64) (error, string)\n```\nFundWallet() Entry Point for no time offset on the transaction.\n\n```go\nfunc FundWalletTOFF(st *state.State, timeOffsetInMilliseconds int64, amt uint64) (error, string)\n```\nFundWalletTOFF() Entry Point where test code allows the transaction to have a time offset from the current time.\n\n```go\nfunc GetBalance(s *state.State, userStr string) int64\n```\n\n```go\nfunc GetBalanceEC(s *state.State, userStr string) int64\n```\n\n```go\nfunc GetLine(listenToStdin bool) string\n```\nvar InputChan = make(chan string)\n\n```go\nfunc GetSystemStatus(listenTo int, wsapiNode int) string\n```\n\n```go\nfunc HandleLogfiles(stdoutlog string, stderrlog string)\n```\n\n```go\nfunc InvalidOutputs(fnode *FactomNode)\n```\nJust throw away the trash\n\n```go\nfunc LaunchDBStateManagePlugin(path string, inQueue interfaces.IQueue, s *state.State, sigKey *primitives.PrivateKey, memProfileRate int) (interfaces.IManagerController, error)\n```\nLaunchDBStateManagePlugin launches the plugin and returns an interface that can be interacted with like a usual interface. The client returned must be killed before we exit\n\n```go\nfunc LaunchDebugServer(service string)\n```\n\n```go\nfunc LoadJournal(s interfaces.IState, journal string)\n```\n\n```go\nfunc LoadJournalFromReader(s interfaces.IState, r *bufio.Reader)\n```\n\n```go\nfunc LoadJournalFromString(s interfaces.IState, journalStr string)\n```\n\n```go\nfunc NetStart(s *state.State, p *FactomParams, listenToStdin bool)\n```\n\n```go\nfunc NetworkOutputs(fnode *FactomNode)\n```\n\n```go\nfunc NetworkProcessorNet(fnode *FactomNode)\n```\n\n```go\nfunc NewTransaction(amt uint64, userSecretIn string, userPublicOut string, ecPrice uint64) (*factoid.Transaction, error)\n```\nconstruct a new factoid transaction\n\n```go\nfunc ParseCmdLine(args []string) *FactomParams\n```\n\n```go\nfunc Peers(fnode *FactomNode)\n```\n\n```go\nfunc PostTransaction(st *state.State, trans *factoid.Transaction) (error, string)\n```\ncreate wsapi Post and invoke v2Request handler\n\n```go\nfunc PrintBusy(state interfaces.IState, i int)\n```\n\n```go\nfunc PrintOneStatus(listenTo int, wsapiNode int)\n```\n\n```go\nfunc RandomEntry() *entryBlock.Entry\n```\n\n```go\nfunc RandomFctAddressPair() (string, string)\n```\ngenerate a pair of user-strings Fs.., FA..\n\n```go\nfunc RegisterPrometheus()\n```\nRegisterPrometheus registers the variables to be exposed. This can only be run once, hence the boolean flag to prevent panics if launched more than once. This is called in NetStart\n\n```go\nfunc SendTxn(s *state.State, amt uint64, userSecretIn string, userPubOut string, ecPrice uint64) (*factoid.Transaction, error)\n```\nSendTxn() adds transaction to APIQueue bypassing the wsapi / json encoding\n\n```go\nfunc SimControl(listenTo int, listenStdin bool)\n```\n\n```go\nfunc StartProfiler(mpr int, expose bool)\n```\nStartProfiler runs the go pprof tool \\`go tool pprof [http://localhost:6060/debug/pprof/profile](http://localhost:6060/debug/pprof/profile)\\` [https://golang.org/pkg/net/http/pprof/](https://golang.org/pkg/net/http/pprof/)\n\n```go\nfunc SystemFaults(f *FactomNode) string\n```\n\n```go\nfunc Timer(state interfaces.IState)\n```\n\n## Types\n\n```go\ntype CompletedHeightsManager struct {\n\tCompleted []int64\n\tBase      int\n}\n```\nCompletedHeightsManager ensures the same height is not processed many times\n\n```go\nfunc NewCompletedHeightManager() *CompletedHeightsManager\n```\n\n```go\nfunc (c *CompletedHeightsManager) ClearTo(height int)\n```\nClearTo will indicate anything below this height is no longer needed\n\n```go\nfunc (c *CompletedHeightsManager) CompleteHeight(height int) bool\n```\nCompleteHeight will signal a height has been completed. It will return a boolean value to indicate whether or not to allow this height to be added to the inmsg queue\n\n```go\ntype FactomMessage struct {\n\tMessage  []byte\n\tPeerHash string\n\tAppHash  string\n\tAppType  string\n}\n```\n\n```go\nfunc (e *FactomMessage) JSONByte() ([]byte, error)\n```\n\n```go\nfunc (e *FactomMessage) JSONString() (string, error)\n```\n\n```go\nfunc (e *FactomMessage) String() string\n```\n\n```go\ntype FactomNode struct {\n\tIndex    int\n\tState    *state.State\n\tPeers    []interfaces.IPeer\n\tMLog     *MsgLog\n\tP2PIndex int\n}\n```\n\n```go\nfunc GetFnodes() []*FactomNode\n```\n\n```go\nfunc GetFocus() *FactomNode\n```\n\n```go\ntype IManagerPlugin struct {\n\t// Impl Injection\n\tImpl interfaces.IManagerController\n}\n```\nThis is the implementation of plugin.Plugin so we can serve/consume this\n\nThis has two methods: Server must return an RPC server for this plugin type. We construct a IManagerPluginRPCServer for this.\n\nClient must return an implementation of our interface that communicates over an RPC client. We return IManagerPluginRPC for this.\n\nIgnore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.\n\n```go\nfunc (IManagerPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)\n```\n\n```go\nfunc (p *IManagerPlugin) Server(*plugin.MuxBroker) (interface{}, error)\n```\n\n```go\ntype IManagerPluginRPC struct {\n\t// contains filtered or unexported fields\n}\n```\nHere is an implementation that talks over RPC\n\n```go\nfunc (g *IManagerPluginRPC) Alive() error\n```\n\n```go\nfunc (g *IManagerPluginRPC) CompletedHeightTo(height uint32) error\n```\n\n```go\nfunc (g *IManagerPluginRPC) FetchFromBuffer() []byte\n```\n\n```go\nfunc (g *IManagerPluginRPC) IsBufferEmpty() bool\n```\n\n```go\nfunc (g *IManagerPluginRPC) RetrieveDBStateByHeight(height uint32) error\n```\n\n```go\nfunc (g *IManagerPluginRPC) SetSigningKey(sec []byte) error\n```\n\n```go\nfunc (g *IManagerPluginRPC) UploadDBStateBytes(data []byte, sign bool) error\n```\n\n```go\nfunc (g *IManagerPluginRPC) UploadIfOnDisk(height uint32) bool\n```\n\n```go\ntype IManagerPluginRPCServer struct {\n\t// This is the real implementation\n\tImpl interfaces.IManagerController\n}\n```\nHere is the RPC server that IManagerPluginRPC talks to, conforming to the requirements of net/rpc\n\n```go\nfunc (s *IManagerPluginRPCServer) Alive(args interface{}, resp *error) error\n```\n\n```go\nfunc (s *IManagerPluginRPCServer) CompletedHeightTo(height uint32, resp *error) error\n```\n\n```go\nfunc (s *IManagerPluginRPCServer) FetchFromBuffer(args interface{}, resp *[]byte) error\n```\n\n```go\nfunc (s *IManagerPluginRPCServer) IsBufferEmpty(args interface{}, resp *bool) error\n```\n\n```go\nfunc (s *IManagerPluginRPCServer) RetrieveDBStateByHeight(height uint32, resp *error) error\n```\n\n```go\nfunc (s *IManagerPluginRPCServer) SetSigningKey(key []byte, resp *error) error\n```\n\n```go\nfunc (s *IManagerPluginRPCServer) UploadDBStateBytes(args *UploadDBStateArgs, resp *error) error\n```\n\n```go\nfunc (s *IManagerPluginRPCServer) UploadIfOnDisk(height uint32, resp *bool) error\n```\n\n```go\ntype LoadGenerator struct {\n\tECKey     *primitives.PrivateKey // Entry Credit private key\n\tToSend    int                    // How much to send\n\tPerSecond atomic.AtomicInt       // How much per second\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewLoadGenerator(s *state.State) *LoadGenerator\n```\nNewLoadGenerator makes a new load generator. The state is used for funding the transaction\n\n```go\nfunc (lg *LoadGenerator) KeepUsFunded()\n```\n\n```go\nfunc (lg *LoadGenerator) NewCommitChain(entry *entryBlock.Entry) *messages.CommitChainMsg\n```\n\n```go\nfunc (lg *LoadGenerator) NewCommitEntry(entry *entryBlock.Entry) *messages.CommitEntryMsg\n```\n\n```go\nfunc (lg *LoadGenerator) NewRevealEntry(entry *entryBlock.Entry) *messages.RevealEntryMsg\n```\n\n```go\nfunc (lg *LoadGenerator) Run()\n```\n\n```go\nfunc (lg *LoadGenerator) Stop()\n```\n\n```go\ntype MsgLog struct {\n\tEnable bool\n\n\tMsgList []*msglist\n\tLast    interfaces.Timestamp\n\n\t// The last period (msg rate over the last period, so msg changes can be seen)\n\tPeriod     int64\n\tStartp     interfaces.Timestamp\n\tMsgCntp    int\n\tMsgPerSecp int\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (m *MsgLog) Add2(fnode *FactomNode, out bool, peer string, where string, valid bool, msg interfaces.IMsg)\n```\n\n```go\nfunc (m *MsgLog) Init(enable bool, nodecnt int)\n```\n\n```go\nfunc (m *MsgLog) PrtMsgs(state interfaces.IState)\n```\n\n```go\ntype P2PProxy struct {\n\t// A connection to this node:\n\tToName   string\n\tFromName string\n\t// Channels that define the connection:\n\tBroadcastOut chan interface{} // FactomMessage ToNetwork from dcnt\n\tBroadcastIn  chan interface{} // FactomMessage FromNetwork for dcnt\n\n\tToNetwork   chan interface{} // p2p.Parcel From p2pProxy to the p2p Controller\n\tFromNetwork chan interface{} // p2p.Parcel Parcels from the network for the application\n\n\tNumPeers int\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (f *P2PProxy) BytesIn() int\n```\n\n```go\nfunc (f *P2PProxy) BytesOut() int\n```\n\n```go\nfunc (f *P2PProxy) Equals(ff interfaces.IPeer) bool\n```\nIs this connection equal to parm connection\n\n```go\nfunc (f *P2PProxy) GetNameFrom() string\n```\n\n```go\nfunc (f *P2PProxy) GetNameTo() string\n```\n\n```go\nfunc (f *P2PProxy) Init(fromName, toName string) interfaces.IPeer\n```\n\n```go\nfunc (f *P2PProxy) Len() int\n```\nReturns the number of messages waiting to be read\n\n```go\nfunc (f *P2PProxy) ManageInChannel()\n```\nmanageInChannel takes messages from the network and stuffs it in the f.BroadcastIn channel\n\n```go\nfunc (f *P2PProxy) ManageOutChannel()\n```\nmanageOutChannel takes messages from the f.broadcastOut channel and sends them to the network.\n\n```go\nfunc (f *P2PProxy) Receive() (interfaces.IMsg, error)\n```\nNon-blocking return value from channel.\n\n```go\nfunc (f *P2PProxy) Send(msg interfaces.IMsg) error\n```\n\n```go\nfunc (f *P2PProxy) SetWeight(w int)\n```\n\n```go\nfunc (p *P2PProxy) StartProxy()\n```\n\n```go\nfunc (p *P2PProxy) StopProxy()\n```\n\n```go\nfunc (f *P2PProxy) Weight() int\n```\n\n```go\ntype SimPacket struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype SimPeer struct {\n\t// A connection to this node:\n\tFromName string\n\tToName   string\n\t// Channels that define the connection:\n\tBroadcastOut chan *SimPacket\n\tBroadcastIn  chan *SimPacket\n\n\t// Delay in Milliseconds\n\tDelay    int64 // The maximum delay\n\tDelayUse int64 // We actually select a random delay for each data element.\n\t// Were we hold delayed packets\n\tDelayed *SimPacket\n\n\tLast int64 // Last time reset (nano seconds)\n\n\tRateOut int // Rate of Bytes output per ms\n\tRateIn  int // Rate of Bytes input per ms\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (f *SimPeer) BytesIn() int\n```\nBytes received per second from this peer\n\n```go\nfunc (f *SimPeer) BytesOut() int\n```\nBytes sent out per second from this peer\n\n```go\nfunc (f *SimPeer) Equals(ff interfaces.IPeer) bool\n```\n\n```go\nfunc (f *SimPeer) GetNameFrom() string\n```\n\n```go\nfunc (f *SimPeer) GetNameTo() string\n```\n\n```go\nfunc (f *SimPeer) Init(fromName, toName string) interfaces.IPeer\n```\n\n```go\nfunc (f *SimPeer) Len() int\n```\n\n```go\nfunc (f *SimPeer) Receive() (interfaces.IMsg, error)\n```\nNon-blocking return value from channel.\n\n```go\nfunc (f *SimPeer) Send(msg interfaces.IMsg) error\n```\n\n```go\nfunc (*SimPeer) Weight() int\n```\n\n```go\ntype UploadDBStateArgs struct {\n\tData []byte\n\tSign bool\n}\n```\n\n","path":"github.com/dcnt-developer/dcnt/engine","name":"engine","synopsis":"Interface that allows dcnt to offload the dbstate fetching to this plugin.","isRedistributable":true}
