engine

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 60 Imported by: 20

Documentation

Overview

Interface that allows factomd to offload the dbstate fetching to this plugin. If offloaded, factomd will need to drain the buffer by launching a drain go routine

Index

Constants

This section is empty.

Variables

View Source
var (
	// Messages
	RepeatMsgs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_msg_replay_toss_total",
		Help: "Number of repeated msgs.",
	})

	BroadInCastQueue = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_broadcast_in_current",
		Help: "Number of msgs in broadcastin queue.",
	})

	BroadCastInQueueDrop = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_broadcast_in_drop_total",
		Help: "How many messages are dropped due to full queues",
	})

	// NetworkReplayFilter
	TotalNetworkReplayFilter = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_network_replay_filter_total",
		Help: "Tally of total messages gone into NetworkReplayFilter",
	})
	TotalNetworkAckReplayFilter = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_network_ack_replay_filter_total",
		Help: "Tally of total messages gone into NetworkAckReplayFilter",
	})

	// Network Out Queue
	NetworkOutTotalDequeue = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_queue_netoutmsg_total_general",
		Help: "Count of all messages being dequeued",
	})

	// Send/Receive Times
	TotalSendTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_total_send_time",
		Help: "Time spent sending (nanoseconds)",
	})
	TotalReceiveTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_total_receive_time",
		Help: "Time spent receiving (nanoseconds)",
	})
)
View Source
var Build string

Build sets the factomd build id using git's SHA Version sets the semantic version number of the build $ go install -ldflags "-X github.com/FactomProject/factomd/engine.Build=`git rev-parse HEAD` -X github.com/FactomProject/factomd/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

View Source
var CHECK_BUFFER time.Duration = 2 * time.Second

How often to check the plugin if it has messages ready

View Source
var FactomdVersion string = "BuiltWithoutVersion"
View Source
var LOCAL_NET_PRIV_KEY string = "4c38c72fc5cdad68f13b74674d3ffb1f3d63a112710868c9b08946553448d26d"

Used for signing messages

View Source
var ListenTo int
View Source
var (
	STACK_HEIGHT = 100
)
View Source
var SortByID bool
View Source
var VerboseAuthorityDeltas = false
View Source
var VerboseAuthoritySet = false
View Source
var VerboseFaultOutput = false

Functions

func AddInterruptHandler

func AddInterruptHandler(handler func())

AddInterruptHandler adds a handler to call when a SIGINT (Ctrl+C) is received.

func AddNode

func AddNode()

func AddSimPeer

func AddSimPeer(fnodes []*FactomNode, i1 int, i2 int)

func BlockFreeChannelSend

func BlockFreeChannelSend(channel chan interface{}, message interface{}) int

BlockFreeChannelSend will remove things from the queue to make room for new messages if the queue is full. This prevents channel blocking on full.

Returns: The number of elements cleared from the channel to make room

func ComposeEcTransaction

func ComposeEcTransaction(inSec interfaces.IHash, outEC interfaces.IHash, timeInMilliseconds *primitives.Timestamp, amt uint64, ecPrice uint64) (*factoid.Transaction, error)

create a transaction to buy Entry Credits this adds the EC fee on top of the input amount

func ComposeFctTransaction

func ComposeFctTransaction(amt uint64, inSec interfaces.IHash, outPub interfaces.IHash, ecPrice uint64) (*factoid.Transaction, error)

create a transaction to transfer FCT between addresses adds EC fee on top of input amount

func DataQ

func DataQ(fnode *FactomNode, source string, msg interfaces.IMsg)

func Factomd

func Factomd(params *FactomParams) interfaces.IState

func FaultSummary

func FaultSummary() string

func FundECWallet

func FundECWallet(st *state.State, inSec interfaces.IHash, outEC interfaces.IHash, amt uint64) (error, string)

FundECWallet get the current time in ms, add to it the offset provided (usually zero, except for tests)

func FundWallet

func FundWallet(st *state.State, amt uint64) (error, string)

FundWallet() Entry Point for no time offset on the transaction.

func FundWalletTOFF

func FundWalletTOFF(st *state.State, timeOffsetInMilliseconds int64, amt uint64) (error, string)

FundWalletTOFF() Entry Point where test code allows the transaction to have a time offset from the current time.

func GetBalance

func GetBalance(s *state.State, userStr string) int64

func GetBalanceEC

func GetBalanceEC(s *state.State, userStr string) int64

func GetLine

func GetLine(listenToStdin bool) string

var InputChan = make(chan string)

func GetSystemStatus

func GetSystemStatus(listenTo int, wsapiNode int) string

func HandleLogfiles

func HandleLogfiles(stdoutlog string, stderrlog string)

func InvalidOutputs

func InvalidOutputs(fnode *FactomNode)

Just throw away the trash

func LaunchDBStateManagePlugin

func LaunchDBStateManagePlugin(path string, inQueue interfaces.IQueue, s *state.State, sigKey *primitives.PrivateKey, memProfileRate int) (interfaces.IManagerController, error)

LaunchDBStateManagePlugin 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

func LaunchDebugServer

func LaunchDebugServer(service string)

func LoadJournal

func LoadJournal(s interfaces.IState, journal string)

func LoadJournalFromReader

func LoadJournalFromReader(s interfaces.IState, r *bufio.Reader)

func LoadJournalFromString

func LoadJournalFromString(s interfaces.IState, journalStr string)

func MissingData

func MissingData(fnode *FactomNode)

Handle requests for missing data

func NetStart

func NetStart(s *state.State, p *FactomParams)

func NetworkOutputs

func NetworkOutputs(fnode *FactomNode)

func NetworkProcessorNet

func NetworkProcessorNet(fnode *FactomNode)

func NewTransaction

func NewTransaction(amt uint64, userSecretIn string, userPublicOut string, ecPrice uint64) (*factoid.Transaction, error)

construct a new factoid transaction

func ParseCmdLine

func ParseCmdLine(args []string) *globals.FactomParams

func Peers

func Peers(fnode *FactomNode)

func PostTransaction

func PostTransaction(st *state.State, trans *factoid.Transaction) (error, string)

create wsapi Post and invoke v2Request handler

func PrintOneStatus

func PrintOneStatus(listenTo int, wsapiNode int)

func Q1

func Q1(fnode *FactomNode, source string, msg interfaces.IMsg)

func Q2

func Q2(fnode *FactomNode, source string, msg interfaces.IMsg)

func RandomEntry

func RandomEntry() *entryBlock.Entry

func RandomFctAddressPair

func RandomFctAddressPair() (string, string)

generate a pair of user-strings Fs.., FA..

func RegisterPrometheus

func RegisterPrometheus()

RegisterPrometheus 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

func SendTxn

func SendTxn(s *state.State, amt uint64, userSecretIn string, userPubOut string, ecPrice uint64) (*factoid.Transaction, error)

SendTxn() adds transaction to APIQueue bypassing the wsapi / json encoding

func SimControl

func SimControl(listenTo int, listenStdin bool)

func StartProfiler

func StartProfiler(mpr int, expose bool)

StartProfiler runs the go pprof tool `go tool pprof http://localhost:6060/debug/pprof/profile` https://golang.org/pkg/net/http/pprof/

func SystemFaults

func SystemFaults(f *FactomNode) string

func Timer

func Timer(stateI interfaces.IState)

Timer Provides a tick add inserts it into the TickerQueue to trigger EOM generation by leaders.

Types

type CompletedHeightsManager

type CompletedHeightsManager struct {
	Completed []int64
	Base      int
}

CompletedHeightsManager ensures the same height is not processed many times

func NewCompletedHeightManager

func NewCompletedHeightManager() *CompletedHeightsManager

func (*CompletedHeightsManager) ClearTo

func (c *CompletedHeightsManager) ClearTo(height int)

ClearTo will indicate anything below this height is no longer needed

func (*CompletedHeightsManager) CompleteHeight

func (c *CompletedHeightsManager) CompleteHeight(height int) bool

CompleteHeight 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

type FactomMessage

type FactomMessage struct {
	Message  []byte
	PeerHash string
	AppHash  string
	AppType  string
	// contains filtered or unexported fields
}

func (*FactomMessage) JSONByte

func (e *FactomMessage) JSONByte() ([]byte, error)

func (*FactomMessage) JSONString

func (e *FactomMessage) JSONString() (string, error)

func (*FactomMessage) String

func (e *FactomMessage) String() string

type FactomNode

type FactomNode struct {
	Index    int
	State    *state.State
	Peers    []interfaces.IPeer
	MLog     *MsgLog
	P2PIndex int
}

func GetFnodes

func GetFnodes() []*FactomNode

func GetFocus

func GetFocus() *FactomNode

type IManagerPlugin

type IManagerPlugin struct {
	// Impl Injection
	Impl interfaces.IManagerController
}

This is the implementation of plugin.Plugin so we can serve/consume this

This has two methods: Server must return an RPC server for this plugin type. We construct a IManagerPluginRPCServer for this.

Client must return an implementation of our interface that communicates over an RPC client. We return IManagerPluginRPC for this.

Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.

func (IManagerPlugin) Client

func (IManagerPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*IManagerPlugin) Server

func (p *IManagerPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type IManagerPluginRPC

type IManagerPluginRPC struct {
	// contains filtered or unexported fields
}

Here is an implementation that talks over RPC

func (*IManagerPluginRPC) Alive

func (g *IManagerPluginRPC) Alive() error

func (*IManagerPluginRPC) CompletedHeightTo

func (g *IManagerPluginRPC) CompletedHeightTo(height uint32) error

func (*IManagerPluginRPC) FetchFromBuffer

func (g *IManagerPluginRPC) FetchFromBuffer() []byte

func (*IManagerPluginRPC) IsBufferEmpty

func (g *IManagerPluginRPC) IsBufferEmpty() bool

func (*IManagerPluginRPC) RetrieveDBStateByHeight

func (g *IManagerPluginRPC) RetrieveDBStateByHeight(height uint32) error

func (*IManagerPluginRPC) SetSigningKey

func (g *IManagerPluginRPC) SetSigningKey(sec []byte) error

func (*IManagerPluginRPC) UploadDBStateBytes

func (g *IManagerPluginRPC) UploadDBStateBytes(data []byte, sign bool) error

func (*IManagerPluginRPC) UploadIfOnDisk

func (g *IManagerPluginRPC) UploadIfOnDisk(height uint32) bool

type IManagerPluginRPCServer

type IManagerPluginRPCServer struct {
	// This is the real implementation
	Impl interfaces.IManagerController
}

Here is the RPC server that IManagerPluginRPC talks to, conforming to the requirements of net/rpc

func (*IManagerPluginRPCServer) Alive

func (s *IManagerPluginRPCServer) Alive(args interface{}, resp *error) error

func (*IManagerPluginRPCServer) CompletedHeightTo

func (s *IManagerPluginRPCServer) CompletedHeightTo(height uint32, resp *error) error

func (*IManagerPluginRPCServer) FetchFromBuffer

func (s *IManagerPluginRPCServer) FetchFromBuffer(args interface{}, resp *[]byte) error

func (*IManagerPluginRPCServer) IsBufferEmpty

func (s *IManagerPluginRPCServer) IsBufferEmpty(args interface{}, resp *bool) error

func (*IManagerPluginRPCServer) RetrieveDBStateByHeight

func (s *IManagerPluginRPCServer) RetrieveDBStateByHeight(height uint32, resp *error) error

func (*IManagerPluginRPCServer) SetSigningKey

func (s *IManagerPluginRPCServer) SetSigningKey(key []byte, resp *error) error

func (*IManagerPluginRPCServer) UploadDBStateBytes

func (s *IManagerPluginRPCServer) UploadDBStateBytes(args *UploadDBStateArgs, resp *error) error

func (*IManagerPluginRPCServer) UploadIfOnDisk

func (s *IManagerPluginRPCServer) UploadIfOnDisk(height uint32, resp *bool) error

type LoadGenerator

type LoadGenerator struct {
	ECKey     *primitives.PrivateKey // Entry Credit private key
	ToSend    int                    // How much to send
	PerSecond atomic.AtomicInt       // How much per second
	// contains filtered or unexported fields
}

func NewLoadGenerator

func NewLoadGenerator(s *state.State) *LoadGenerator

NewLoadGenerator makes a new load generator. The state is used for funding the transaction

func (*LoadGenerator) KeepUsFunded

func (lg *LoadGenerator) KeepUsFunded()

func (*LoadGenerator) NewCommitChain

func (lg *LoadGenerator) NewCommitChain(entry *entryBlock.Entry) *messages.CommitChainMsg

func (*LoadGenerator) NewCommitEntry

func (lg *LoadGenerator) NewCommitEntry(entry *entryBlock.Entry) *messages.CommitEntryMsg

func (*LoadGenerator) NewRevealEntry

func (lg *LoadGenerator) NewRevealEntry(entry *entryBlock.Entry) *messages.RevealEntryMsg

func (*LoadGenerator) Run

func (lg *LoadGenerator) Run()

func (*LoadGenerator) Stop

func (lg *LoadGenerator) Stop()

type MsgLog

type MsgLog struct {
	Enable bool

	MsgList []*msglist
	Last    interfaces.Timestamp

	// The last period (msg rate over the last period, so msg changes can be seen)
	Period     int64
	Startp     interfaces.Timestamp
	MsgCntp    int
	MsgPerSecp int
	// contains filtered or unexported fields
}

func (*MsgLog) Add2

func (m *MsgLog) Add2(fnode *FactomNode, out bool, peer string, where string, valid bool, msg interfaces.IMsg)

func (*MsgLog) Init

func (m *MsgLog) Init(enable bool, nodecnt int)

func (*MsgLog) PrtMsgs

func (m *MsgLog) PrtMsgs(state interfaces.IState)

type P2PProxy

type P2PProxy struct {
	// A connection to this node:
	ToName   string
	FromName string
	// Channels that define the connection:
	BroadcastOut chan interface{} // FactomMessage ToNetwork from factomd
	BroadcastIn  chan interface{} // FactomMessage FromNetwork for Factomd

	Network     *p2p.Network
	ToNetwork   chan interface{} // p2p.Parcel From p2pProxy to the p2p Controller
	FromNetwork chan interface{} // p2p.Parcel Parcels from the network for the application

	NumPeers int
	// contains filtered or unexported fields
}

func (*P2PProxy) BytesIn

func (f *P2PProxy) BytesIn() int

func (*P2PProxy) BytesOut

func (f *P2PProxy) BytesOut() int

func (*P2PProxy) Equals

func (f *P2PProxy) Equals(ff interfaces.IPeer) bool

Is this connection equal to parm connection

func (*P2PProxy) GetNameFrom

func (f *P2PProxy) GetNameFrom() string

func (*P2PProxy) GetNameTo

func (f *P2PProxy) GetNameTo() string

func (*P2PProxy) Init

func (f *P2PProxy) Init(fromName, toName string) interfaces.IPeer

func (*P2PProxy) Len

func (f *P2PProxy) Len() int

Returns the number of messages waiting to be read

func (*P2PProxy) ManageInChannel

func (f *P2PProxy) ManageInChannel()

manageInChannel takes messages from the network and stuffs it in the f.BroadcastIn channel

func (*P2PProxy) ManageOutChannel

func (f *P2PProxy) ManageOutChannel()

manageOutChannel takes messages from the f.broadcastOut channel and sends them to the network.

func (*P2PProxy) Receive

func (f *P2PProxy) Receive() (interfaces.IMsg, error)

Non-blocking return value from channel.

func (*P2PProxy) Send

func (f *P2PProxy) Send(msg interfaces.IMsg) error

func (*P2PProxy) SetWeight

func (f *P2PProxy) SetWeight(w int)

func (*P2PProxy) StartProxy

func (p *P2PProxy) StartProxy()

func (*P2PProxy) StopProxy

func (p *P2PProxy) StopProxy()

func (*P2PProxy) Weight

func (f *P2PProxy) Weight() int

type SimPacket

type SimPacket struct {
	// contains filtered or unexported fields
}

type SimPeer

type SimPeer struct {
	// A connection to this node:
	FromName string
	ToName   string
	// Channels that define the connection:
	BroadcastOut chan *SimPacket
	BroadcastIn  chan *SimPacket

	// Delay in Milliseconds
	Delay    int64 // The maximum delay
	DelayUse int64 // We actually select a random delay for each data element.
	// Were we hold delayed packets
	Delayed *SimPacket

	Last int64 // Last time reset (nano seconds)

	RateOut int // Rate of Bytes output per ms
	RateIn  int // Rate of Bytes input per ms
	// contains filtered or unexported fields
}

func (*SimPeer) BytesIn

func (f *SimPeer) BytesIn() int

Bytes received per second from this peer

func (*SimPeer) BytesOut

func (f *SimPeer) BytesOut() int

Bytes sent out per second from this peer

func (*SimPeer) Equals

func (f *SimPeer) Equals(ff interfaces.IPeer) bool

func (*SimPeer) GetNameFrom

func (f *SimPeer) GetNameFrom() string

func (*SimPeer) GetNameTo

func (f *SimPeer) GetNameTo() string

func (*SimPeer) Init

func (f *SimPeer) Init(fromName, toName string) interfaces.IPeer

func (*SimPeer) Len

func (f *SimPeer) Len() int

func (*SimPeer) Receive

func (f *SimPeer) Receive() (interfaces.IMsg, error)

Non-blocking return value from channel.

func (*SimPeer) Send

func (f *SimPeer) Send(msg interfaces.IMsg) error

func (*SimPeer) Weight

func (*SimPeer) Weight() int

type UploadDBStateArgs

type UploadDBStateArgs struct {
	Data []byte
	Sign bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL