id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
131,300 | tendermint/tendermint | tools/tm-monitor/rpc.go | RPCNodeStatus | func RPCNodeStatus(m *monitor.Monitor) interface{} {
return func(name string) (*monitor.Node, error) {
if i, n := m.NodeByName(name); i != -1 {
return n, nil
}
return nil, errors.New("Cannot find node with that name")
}
} | go | func RPCNodeStatus(m *monitor.Monitor) interface{} {
return func(name string) (*monitor.Node, error) {
if i, n := m.NodeByName(name); i != -1 {
return n, nil
}
return nil, errors.New("Cannot find node with that name")
}
} | [
"func",
"RPCNodeStatus",
"(",
"m",
"*",
"monitor",
".",
"Monitor",
")",
"interface",
"{",
"}",
"{",
"return",
"func",
"(",
"name",
"string",
")",
"(",
"*",
"monitor",
".",
"Node",
",",
"error",
")",
"{",
"if",
"i",
",",
"n",
":=",
"m",
".",
"Node... | // RPCNodeStatus returns statistics for the given node. | [
"RPCNodeStatus",
"returns",
"statistics",
"for",
"the",
"given",
"node",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/rpc.go#L58-L65 |
131,301 | tendermint/tendermint | tools/tm-monitor/rpc.go | RPCMonitor | func RPCMonitor(m *monitor.Monitor) interface{} {
return func(endpoint string) (*monitor.Node, error) {
i, n := m.NodeByName(endpoint)
if i == -1 {
n = monitor.NewNode(endpoint)
if err := m.Monitor(n); err != nil {
return nil, err
}
}
return n, nil
}
} | go | func RPCMonitor(m *monitor.Monitor) interface{} {
return func(endpoint string) (*monitor.Node, error) {
i, n := m.NodeByName(endpoint)
if i == -1 {
n = monitor.NewNode(endpoint)
if err := m.Monitor(n); err != nil {
return nil, err
}
}
return n, nil
}
} | [
"func",
"RPCMonitor",
"(",
"m",
"*",
"monitor",
".",
"Monitor",
")",
"interface",
"{",
"}",
"{",
"return",
"func",
"(",
"endpoint",
"string",
")",
"(",
"*",
"monitor",
".",
"Node",
",",
"error",
")",
"{",
"i",
",",
"n",
":=",
"m",
".",
"NodeByName"... | // RPCMonitor allows to dynamically add a endpoint to under the monitor. Safe
// to call multiple times. | [
"RPCMonitor",
"allows",
"to",
"dynamically",
"add",
"a",
"endpoint",
"to",
"under",
"the",
"monitor",
".",
"Safe",
"to",
"call",
"multiple",
"times",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/rpc.go#L69-L80 |
131,302 | tendermint/tendermint | tools/tm-monitor/rpc.go | RPCUnmonitor | func RPCUnmonitor(m *monitor.Monitor) interface{} {
return func(endpoint string) (bool, error) {
if i, n := m.NodeByName(endpoint); i != -1 {
m.Unmonitor(n)
return true, nil
}
return false, errors.New("Cannot find node with that name")
}
} | go | func RPCUnmonitor(m *monitor.Monitor) interface{} {
return func(endpoint string) (bool, error) {
if i, n := m.NodeByName(endpoint); i != -1 {
m.Unmonitor(n)
return true, nil
}
return false, errors.New("Cannot find node with that name")
}
} | [
"func",
"RPCUnmonitor",
"(",
"m",
"*",
"monitor",
".",
"Monitor",
")",
"interface",
"{",
"}",
"{",
"return",
"func",
"(",
"endpoint",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"i",
",",
"n",
":=",
"m",
".",
"NodeByName",
"(",
"endpo... | // RPCUnmonitor removes the given endpoint from under the monitor. | [
"RPCUnmonitor",
"removes",
"the",
"given",
"endpoint",
"from",
"under",
"the",
"monitor",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/rpc.go#L83-L91 |
131,303 | tendermint/tendermint | privval/signer_validator_endpoint.go | SignerValidatorEndpointSetHeartbeat | func SignerValidatorEndpointSetHeartbeat(period time.Duration) SignerValidatorEndpointOption {
return func(sc *SignerValidatorEndpoint) { sc.heartbeatPeriod = period }
} | go | func SignerValidatorEndpointSetHeartbeat(period time.Duration) SignerValidatorEndpointOption {
return func(sc *SignerValidatorEndpoint) { sc.heartbeatPeriod = period }
} | [
"func",
"SignerValidatorEndpointSetHeartbeat",
"(",
"period",
"time",
".",
"Duration",
")",
"SignerValidatorEndpointOption",
"{",
"return",
"func",
"(",
"sc",
"*",
"SignerValidatorEndpoint",
")",
"{",
"sc",
".",
"heartbeatPeriod",
"=",
"period",
"}",
"\n",
"}"
] | // SignerValidatorEndpointSetHeartbeat sets the period on which to check the liveness of the
// connected Signer connections. | [
"SignerValidatorEndpointSetHeartbeat",
"sets",
"the",
"period",
"on",
"which",
"to",
"check",
"the",
"liveness",
"of",
"the",
"connected",
"Signer",
"connections",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/signer_validator_endpoint.go#L29-L31 |
131,304 | tendermint/tendermint | privval/signer_validator_endpoint.go | NewSignerValidatorEndpoint | func NewSignerValidatorEndpoint(logger log.Logger, listener net.Listener) *SignerValidatorEndpoint {
sc := &SignerValidatorEndpoint{
listener: listener,
heartbeatPeriod: heartbeatPeriod,
}
sc.BaseService = *cmn.NewBaseService(logger, "SignerValidatorEndpoint", sc)
return sc
} | go | func NewSignerValidatorEndpoint(logger log.Logger, listener net.Listener) *SignerValidatorEndpoint {
sc := &SignerValidatorEndpoint{
listener: listener,
heartbeatPeriod: heartbeatPeriod,
}
sc.BaseService = *cmn.NewBaseService(logger, "SignerValidatorEndpoint", sc)
return sc
} | [
"func",
"NewSignerValidatorEndpoint",
"(",
"logger",
"log",
".",
"Logger",
",",
"listener",
"net",
".",
"Listener",
")",
"*",
"SignerValidatorEndpoint",
"{",
"sc",
":=",
"&",
"SignerValidatorEndpoint",
"{",
"listener",
":",
"listener",
",",
"heartbeatPeriod",
":",... | // NewSignerValidatorEndpoint returns an instance of SignerValidatorEndpoint. | [
"NewSignerValidatorEndpoint",
"returns",
"an",
"instance",
"of",
"SignerValidatorEndpoint",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/signer_validator_endpoint.go#L61-L70 |
131,305 | tendermint/tendermint | privval/signer_validator_endpoint.go | Close | func (ve *SignerValidatorEndpoint) Close() {
ve.mtx.Lock()
defer ve.mtx.Unlock()
if ve.signer != nil {
if err := ve.signer.Close(); err != nil {
ve.Logger.Error("OnStop", "err", err)
}
}
if ve.listener != nil {
if err := ve.listener.Close(); err != nil {
ve.Logger.Error("OnStop", "err", err)
}
}
} | go | func (ve *SignerValidatorEndpoint) Close() {
ve.mtx.Lock()
defer ve.mtx.Unlock()
if ve.signer != nil {
if err := ve.signer.Close(); err != nil {
ve.Logger.Error("OnStop", "err", err)
}
}
if ve.listener != nil {
if err := ve.listener.Close(); err != nil {
ve.Logger.Error("OnStop", "err", err)
}
}
} | [
"func",
"(",
"ve",
"*",
"SignerValidatorEndpoint",
")",
"Close",
"(",
")",
"{",
"ve",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ve",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"if",
"ve",
".",
"signer",
"!=",
"nil",
"{",
"if",
"err",
"... | // Close closes the underlying net.Conn. | [
"Close",
"closes",
"the",
"underlying",
"net",
".",
"Conn",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/signer_validator_endpoint.go#L107-L121 |
131,306 | tendermint/tendermint | privval/signer_validator_endpoint.go | acceptConnection | func (ve *SignerValidatorEndpoint) acceptConnection() (net.Conn, error) {
conn, err := ve.listener.Accept()
if err != nil {
if !ve.IsRunning() {
return nil, nil // Ignore error from listener closing.
}
return nil, err
}
return conn, nil
} | go | func (ve *SignerValidatorEndpoint) acceptConnection() (net.Conn, error) {
conn, err := ve.listener.Accept()
if err != nil {
if !ve.IsRunning() {
return nil, nil // Ignore error from listener closing.
}
return nil, err
}
return conn, nil
} | [
"func",
"(",
"ve",
"*",
"SignerValidatorEndpoint",
")",
"acceptConnection",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"ve",
".",
"listener",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"i... | // Attempt to accept a connection.
// Times out after the listener's timeoutAccept | [
"Attempt",
"to",
"accept",
"a",
"connection",
".",
"Times",
"out",
"after",
"the",
"listener",
"s",
"timeoutAccept"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/signer_validator_endpoint.go#L221-L230 |
131,307 | tendermint/tendermint | rpc/client/localclient.go | resubscribe | func (c *Local) resubscribe(subscriber string, q tmpubsub.Query) types.Subscription {
attempts := 0
for {
if !c.IsRunning() {
return nil
}
sub, err := c.EventBus.Subscribe(context.Background(), subscriber, q)
if err == nil {
return sub
}
attempts++
time.Sleep((10 << uint(attempts)) * time.Millis... | go | func (c *Local) resubscribe(subscriber string, q tmpubsub.Query) types.Subscription {
attempts := 0
for {
if !c.IsRunning() {
return nil
}
sub, err := c.EventBus.Subscribe(context.Background(), subscriber, q)
if err == nil {
return sub
}
attempts++
time.Sleep((10 << uint(attempts)) * time.Millis... | [
"func",
"(",
"c",
"*",
"Local",
")",
"resubscribe",
"(",
"subscriber",
"string",
",",
"q",
"tmpubsub",
".",
"Query",
")",
"types",
".",
"Subscription",
"{",
"attempts",
":=",
"0",
"\n",
"for",
"{",
"if",
"!",
"c",
".",
"IsRunning",
"(",
")",
"{",
"... | // Try to resubscribe with exponential backoff. | [
"Try",
"to",
"resubscribe",
"with",
"exponential",
"backoff",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/localclient.go#L212-L227 |
131,308 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | fillMetric | func (metric *EventMetric) fillMetric() *EventMetric {
metric.Count = metric.meter.Count()
metric.Rate1 = metric.meter.Rate1()
metric.Rate5 = metric.meter.Rate5()
metric.Rate15 = metric.meter.Rate15()
metric.RateMean = metric.meter.RateMean()
return metric
} | go | func (metric *EventMetric) fillMetric() *EventMetric {
metric.Count = metric.meter.Count()
metric.Rate1 = metric.meter.Rate1()
metric.Rate5 = metric.meter.Rate5()
metric.Rate15 = metric.meter.Rate15()
metric.RateMean = metric.meter.RateMean()
return metric
} | [
"func",
"(",
"metric",
"*",
"EventMetric",
")",
"fillMetric",
"(",
")",
"*",
"EventMetric",
"{",
"metric",
".",
"Count",
"=",
"metric",
".",
"meter",
".",
"Count",
"(",
")",
"\n",
"metric",
".",
"Rate1",
"=",
"metric",
".",
"meter",
".",
"Rate1",
"("... | // called on GetMetric | [
"called",
"on",
"GetMetric"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L56-L63 |
131,309 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | SetLogger | func (em *EventMeter) SetLogger(l log.Logger) {
em.logger = l
em.wsc.SetLogger(l.With("module", "rpcclient"))
} | go | func (em *EventMeter) SetLogger(l log.Logger) {
em.logger = l
em.wsc.SetLogger(l.With("module", "rpcclient"))
} | [
"func",
"(",
"em",
"*",
"EventMeter",
")",
"SetLogger",
"(",
"l",
"log",
".",
"Logger",
")",
"{",
"em",
".",
"logger",
"=",
"l",
"\n",
"em",
".",
"wsc",
".",
"SetLogger",
"(",
"l",
".",
"With",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
")",
"\n"... | // SetLogger lets you set your own logger. | [
"SetLogger",
"lets",
"you",
"set",
"your",
"own",
"logger",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L107-L110 |
131,310 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | Start | func (em *EventMeter) Start() error {
if err := em.wsc.Start(); err != nil {
return err
}
em.quit = make(chan struct{})
go em.receiveRoutine()
go em.disconnectRoutine()
err := em.subscribe()
if err != nil {
return err
}
em.subscribed = true
return nil
} | go | func (em *EventMeter) Start() error {
if err := em.wsc.Start(); err != nil {
return err
}
em.quit = make(chan struct{})
go em.receiveRoutine()
go em.disconnectRoutine()
err := em.subscribe()
if err != nil {
return err
}
em.subscribed = true
return nil
} | [
"func",
"(",
"em",
"*",
"EventMeter",
")",
"Start",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"em",
".",
"wsc",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"em",
".",
"quit",
"=",
"make",
"(",
"c... | // Start boots up event meter. | [
"Start",
"boots",
"up",
"event",
"meter",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L118-L133 |
131,311 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | Stop | func (em *EventMeter) Stop() {
close(em.quit)
if em.wsc.IsRunning() {
em.wsc.Stop()
}
} | go | func (em *EventMeter) Stop() {
close(em.quit)
if em.wsc.IsRunning() {
em.wsc.Stop()
}
} | [
"func",
"(",
"em",
"*",
"EventMeter",
")",
"Stop",
"(",
")",
"{",
"close",
"(",
"em",
".",
"quit",
")",
"\n\n",
"if",
"em",
".",
"wsc",
".",
"IsRunning",
"(",
")",
"{",
"em",
".",
"wsc",
".",
"Stop",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // Stop stops event meter. | [
"Stop",
"stops",
"event",
"meter",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L136-L142 |
131,312 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | Subscribe | func (em *EventMeter) Subscribe(query string, cb EventCallbackFunc) error {
em.mtx.Lock()
defer em.mtx.Unlock()
if err := em.wsc.Subscribe(context.TODO(), query); err != nil {
return err
}
metric := &EventMetric{
meter: metrics.NewMeter(),
callback: cb,
}
em.queryToMetricMap[query] = metric
return ni... | go | func (em *EventMeter) Subscribe(query string, cb EventCallbackFunc) error {
em.mtx.Lock()
defer em.mtx.Unlock()
if err := em.wsc.Subscribe(context.TODO(), query); err != nil {
return err
}
metric := &EventMetric{
meter: metrics.NewMeter(),
callback: cb,
}
em.queryToMetricMap[query] = metric
return ni... | [
"func",
"(",
"em",
"*",
"EventMeter",
")",
"Subscribe",
"(",
"query",
"string",
",",
"cb",
"EventCallbackFunc",
")",
"error",
"{",
"em",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"em",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err... | // Subscribe for the given query. Callback function will be called upon
// receiving an event. | [
"Subscribe",
"for",
"the",
"given",
"query",
".",
"Callback",
"function",
"will",
"be",
"called",
"upon",
"receiving",
"an",
"event",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L146-L160 |
131,313 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | Unsubscribe | func (em *EventMeter) Unsubscribe(query string) error {
em.mtx.Lock()
defer em.mtx.Unlock()
return em.wsc.Unsubscribe(context.TODO(), query)
} | go | func (em *EventMeter) Unsubscribe(query string) error {
em.mtx.Lock()
defer em.mtx.Unlock()
return em.wsc.Unsubscribe(context.TODO(), query)
} | [
"func",
"(",
"em",
"*",
"EventMeter",
")",
"Unsubscribe",
"(",
"query",
"string",
")",
"error",
"{",
"em",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"em",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"em",
".",
"wsc",
".",
"Unsu... | // Unsubscribe from the given query. | [
"Unsubscribe",
"from",
"the",
"given",
"query",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L163-L168 |
131,314 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | GetMetric | func (em *EventMeter) GetMetric(query string) (*EventMetric, error) {
em.mtx.Lock()
defer em.mtx.Unlock()
metric, ok := em.queryToMetricMap[query]
if !ok {
return nil, fmt.Errorf("unknown query: %s", query)
}
return metric.fillMetric().Copy(), nil
} | go | func (em *EventMeter) GetMetric(query string) (*EventMetric, error) {
em.mtx.Lock()
defer em.mtx.Unlock()
metric, ok := em.queryToMetricMap[query]
if !ok {
return nil, fmt.Errorf("unknown query: %s", query)
}
return metric.fillMetric().Copy(), nil
} | [
"func",
"(",
"em",
"*",
"EventMeter",
")",
"GetMetric",
"(",
"query",
"string",
")",
"(",
"*",
"EventMetric",
",",
"error",
")",
"{",
"em",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"em",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"metric... | // GetMetric fills in the latest data for an query and return a copy. | [
"GetMetric",
"fills",
"in",
"the",
"latest",
"data",
"for",
"an",
"query",
"and",
"return",
"a",
"copy",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L171-L179 |
131,315 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | RegisterLatencyCallback | func (em *EventMeter) RegisterLatencyCallback(f LatencyCallbackFunc) {
em.mtx.Lock()
defer em.mtx.Unlock()
em.latencyCallback = f
} | go | func (em *EventMeter) RegisterLatencyCallback(f LatencyCallbackFunc) {
em.mtx.Lock()
defer em.mtx.Unlock()
em.latencyCallback = f
} | [
"func",
"(",
"em",
"*",
"EventMeter",
")",
"RegisterLatencyCallback",
"(",
"f",
"LatencyCallbackFunc",
")",
"{",
"em",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"em",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"em",
".",
"latencyCallback",
"=",... | // RegisterLatencyCallback allows you to set latency callback. | [
"RegisterLatencyCallback",
"allows",
"you",
"to",
"set",
"latency",
"callback",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L182-L186 |
131,316 | tendermint/tendermint | tools/tm-monitor/eventmeter/eventmeter.go | RegisterDisconnectCallback | func (em *EventMeter) RegisterDisconnectCallback(f DisconnectCallbackFunc) {
em.mtx.Lock()
defer em.mtx.Unlock()
em.disconnectCallback = f
} | go | func (em *EventMeter) RegisterDisconnectCallback(f DisconnectCallbackFunc) {
em.mtx.Lock()
defer em.mtx.Unlock()
em.disconnectCallback = f
} | [
"func",
"(",
"em",
"*",
"EventMeter",
")",
"RegisterDisconnectCallback",
"(",
"f",
"DisconnectCallbackFunc",
")",
"{",
"em",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"em",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"em",
".",
"disconnectCallback... | // RegisterDisconnectCallback allows you to set disconnect callback. | [
"RegisterDisconnectCallback",
"allows",
"you",
"to",
"set",
"disconnect",
"callback",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/eventmeter/eventmeter.go#L189-L193 |
131,317 | tendermint/tendermint | crypto/secp256k1/secp256k1_cgo.go | Sign | func (privKey PrivKeySecp256k1) Sign(msg []byte) ([]byte, error) {
rsv, err := secp256k1.Sign(crypto.Sha256(msg), privKey[:])
if err != nil {
return nil, err
}
// we do not need v in r||s||v:
rs := rsv[:len(rsv)-1]
return rs, nil
} | go | func (privKey PrivKeySecp256k1) Sign(msg []byte) ([]byte, error) {
rsv, err := secp256k1.Sign(crypto.Sha256(msg), privKey[:])
if err != nil {
return nil, err
}
// we do not need v in r||s||v:
rs := rsv[:len(rsv)-1]
return rs, nil
} | [
"func",
"(",
"privKey",
"PrivKeySecp256k1",
")",
"Sign",
"(",
"msg",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"rsv",
",",
"err",
":=",
"secp256k1",
".",
"Sign",
"(",
"crypto",
".",
"Sha256",
"(",
"msg",
")",
",",
"pri... | // Sign creates an ECDSA signature on curve Secp256k1, using SHA256 on the msg. | [
"Sign",
"creates",
"an",
"ECDSA",
"signature",
"on",
"curve",
"Secp256k1",
"using",
"SHA256",
"on",
"the",
"msg",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/secp256k1/secp256k1_cgo.go#L11-L19 |
131,318 | tendermint/tendermint | libs/common/string.go | SplitAndTrim | func SplitAndTrim(s, sep, cutset string) []string {
if s == "" {
return []string{}
}
spl := strings.Split(s, sep)
for i := 0; i < len(spl); i++ {
spl[i] = strings.Trim(spl[i], cutset)
}
return spl
} | go | func SplitAndTrim(s, sep, cutset string) []string {
if s == "" {
return []string{}
}
spl := strings.Split(s, sep)
for i := 0; i < len(spl); i++ {
spl[i] = strings.Trim(spl[i], cutset)
}
return spl
} | [
"func",
"SplitAndTrim",
"(",
"s",
",",
"sep",
",",
"cutset",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"s",
"==",
"\"",
"\"",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
"\n",
"}",
"\n\n",
"spl",
":=",
"strings",
".",
"Split",
"(",
"s",
",... | // SplitAndTrim slices s into all subslices separated by sep and returns a
// slice of the string s with all leading and trailing Unicode code points
// contained in cutset removed. If sep is empty, SplitAndTrim splits after each
// UTF-8 sequence. First part is equivalent to strings.SplitN with a count of
// -1. | [
"SplitAndTrim",
"slices",
"s",
"into",
"all",
"subslices",
"separated",
"by",
"sep",
"and",
"returns",
"a",
"slice",
"of",
"the",
"string",
"s",
"with",
"all",
"leading",
"and",
"trailing",
"Unicode",
"code",
"points",
"contained",
"in",
"cutset",
"removed",
... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/string.go#L23-L33 |
131,319 | tendermint/tendermint | libs/common/string.go | IsASCIIText | func IsASCIIText(s string) bool {
if len(s) == 0 {
return false
}
for _, b := range []byte(s) {
if 32 <= b && b <= 126 {
// good
} else {
return false
}
}
return true
} | go | func IsASCIIText(s string) bool {
if len(s) == 0 {
return false
}
for _, b := range []byte(s) {
if 32 <= b && b <= 126 {
// good
} else {
return false
}
}
return true
} | [
"func",
"IsASCIIText",
"(",
"s",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"s",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"b",
":=",
"range",
"[",
"]",
"byte",
"(",
"s",
")",
"{",
"if",
"32",
"<=",
"b",
"... | // Returns true if s is a non-empty printable non-tab ascii character. | [
"Returns",
"true",
"if",
"s",
"is",
"a",
"non",
"-",
"empty",
"printable",
"non",
"-",
"tab",
"ascii",
"character",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/string.go#L36-L48 |
131,320 | tendermint/tendermint | libs/common/string.go | StringSliceEqual | func StringSliceEqual(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i := 0; i < len(a); i++ {
if a[i] != b[i] {
return false
}
}
return true
} | go | func StringSliceEqual(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i := 0; i < len(a); i++ {
if a[i] != b[i] {
return false
}
}
return true
} | [
"func",
"StringSliceEqual",
"(",
"a",
",",
"b",
"[",
"]",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"a",
")",
"!=",
"len",
"(",
"b",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"a",
")... | // StringSliceEqual checks if string slices a and b are equal | [
"StringSliceEqual",
"checks",
"if",
"string",
"slices",
"a",
"and",
"b",
"are",
"equal"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/string.go#L66-L76 |
131,321 | tendermint/tendermint | libs/db/prefix_db.go | IteratePrefix | func IteratePrefix(db DB, prefix []byte) Iterator {
var start, end []byte
if len(prefix) == 0 {
start = nil
end = nil
} else {
start = cp(prefix)
end = cpIncr(prefix)
}
return db.Iterator(start, end)
} | go | func IteratePrefix(db DB, prefix []byte) Iterator {
var start, end []byte
if len(prefix) == 0 {
start = nil
end = nil
} else {
start = cp(prefix)
end = cpIncr(prefix)
}
return db.Iterator(start, end)
} | [
"func",
"IteratePrefix",
"(",
"db",
"DB",
",",
"prefix",
"[",
"]",
"byte",
")",
"Iterator",
"{",
"var",
"start",
",",
"end",
"[",
"]",
"byte",
"\n",
"if",
"len",
"(",
"prefix",
")",
"==",
"0",
"{",
"start",
"=",
"nil",
"\n",
"end",
"=",
"nil",
... | // IteratePrefix is a convenience function for iterating over a key domain
// restricted by prefix. | [
"IteratePrefix",
"is",
"a",
"convenience",
"function",
"for",
"iterating",
"over",
"a",
"key",
"domain",
"restricted",
"by",
"prefix",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/prefix_db.go#L11-L21 |
131,322 | tendermint/tendermint | libs/db/prefix_db.go | NewPrefixDB | func NewPrefixDB(db DB, prefix []byte) *prefixDB {
return &prefixDB{
prefix: prefix,
db: db,
}
} | go | func NewPrefixDB(db DB, prefix []byte) *prefixDB {
return &prefixDB{
prefix: prefix,
db: db,
}
} | [
"func",
"NewPrefixDB",
"(",
"db",
"DB",
",",
"prefix",
"[",
"]",
"byte",
")",
"*",
"prefixDB",
"{",
"return",
"&",
"prefixDB",
"{",
"prefix",
":",
"prefix",
",",
"db",
":",
"db",
",",
"}",
"\n",
"}"
] | // NewPrefixDB lets you namespace multiple DBs within a single DB. | [
"NewPrefixDB",
"lets",
"you",
"namespace",
"multiple",
"DBs",
"within",
"a",
"single",
"DB",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/prefix_db.go#L42-L47 |
131,323 | tendermint/tendermint | libs/db/prefix_db.go | NewBatch | func (pdb *prefixDB) NewBatch() Batch {
pdb.mtx.Lock()
defer pdb.mtx.Unlock()
return newPrefixBatch(pdb.prefix, pdb.db.NewBatch())
} | go | func (pdb *prefixDB) NewBatch() Batch {
pdb.mtx.Lock()
defer pdb.mtx.Unlock()
return newPrefixBatch(pdb.prefix, pdb.db.NewBatch())
} | [
"func",
"(",
"pdb",
"*",
"prefixDB",
")",
"NewBatch",
"(",
")",
"Batch",
"{",
"pdb",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pdb",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"newPrefixBatch",
"(",
"pdb",
".",
"prefix",
",",
... | // Implements DB.
// Panics if the underlying DB is not an
// atomicSetDeleter. | [
"Implements",
"DB",
".",
"Panics",
"if",
"the",
"underlying",
"DB",
"is",
"not",
"an",
"atomicSetDeleter",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/prefix_db.go#L152-L157 |
131,324 | tendermint/tendermint | crypto/merkle/simple_proof.go | ComputeRootHash | func (sp *SimpleProof) ComputeRootHash() []byte {
return computeHashFromAunts(
sp.Index,
sp.Total,
sp.LeafHash,
sp.Aunts,
)
} | go | func (sp *SimpleProof) ComputeRootHash() []byte {
return computeHashFromAunts(
sp.Index,
sp.Total,
sp.LeafHash,
sp.Aunts,
)
} | [
"func",
"(",
"sp",
"*",
"SimpleProof",
")",
"ComputeRootHash",
"(",
")",
"[",
"]",
"byte",
"{",
"return",
"computeHashFromAunts",
"(",
"sp",
".",
"Index",
",",
"sp",
".",
"Total",
",",
"sp",
".",
"LeafHash",
",",
"sp",
".",
"Aunts",
",",
")",
"\n",
... | // Compute the root hash given a leaf hash. Does not verify the result. | [
"Compute",
"the",
"root",
"hash",
"given",
"a",
"leaf",
"hash",
".",
"Does",
"not",
"verify",
"the",
"result",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/merkle/simple_proof.go#L88-L95 |
131,325 | tendermint/tendermint | crypto/merkle/simple_proof.go | StringIndented | func (sp *SimpleProof) StringIndented(indent string) string {
return fmt.Sprintf(`SimpleProof{
%s Aunts: %X
%s}`,
indent, sp.Aunts,
indent)
} | go | func (sp *SimpleProof) StringIndented(indent string) string {
return fmt.Sprintf(`SimpleProof{
%s Aunts: %X
%s}`,
indent, sp.Aunts,
indent)
} | [
"func",
"(",
"sp",
"*",
"SimpleProof",
")",
"StringIndented",
"(",
"indent",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"`SimpleProof{\n%s Aunts: %X\n%s}`",
",",
"indent",
",",
"sp",
".",
"Aunts",
",",
"indent",
")",
"\n",
"}"
] | // StringIndented generates a canonical string representation of a SimpleProof. | [
"StringIndented",
"generates",
"a",
"canonical",
"string",
"representation",
"of",
"a",
"SimpleProof",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/merkle/simple_proof.go#L104-L110 |
131,326 | tendermint/tendermint | crypto/merkle/simple_proof.go | FlattenAunts | func (spn *SimpleProofNode) FlattenAunts() [][]byte {
// Nonrecursive impl.
innerHashes := [][]byte{}
for spn != nil {
if spn.Left != nil {
innerHashes = append(innerHashes, spn.Left.Hash)
} else if spn.Right != nil {
innerHashes = append(innerHashes, spn.Right.Hash)
} else {
break
}
spn = spn.Par... | go | func (spn *SimpleProofNode) FlattenAunts() [][]byte {
// Nonrecursive impl.
innerHashes := [][]byte{}
for spn != nil {
if spn.Left != nil {
innerHashes = append(innerHashes, spn.Left.Hash)
} else if spn.Right != nil {
innerHashes = append(innerHashes, spn.Right.Hash)
} else {
break
}
spn = spn.Par... | [
"func",
"(",
"spn",
"*",
"SimpleProofNode",
")",
"FlattenAunts",
"(",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"// Nonrecursive impl.",
"innerHashes",
":=",
"[",
"]",
"[",
"]",
"byte",
"{",
"}",
"\n",
"for",
"spn",
"!=",
"nil",
"{",
"if",
"spn",
".",
... | // FlattenAunts will return the inner hashes for the item corresponding to the leaf,
// starting from a leaf SimpleProofNode. | [
"FlattenAunts",
"will",
"return",
"the",
"inner",
"hashes",
"for",
"the",
"item",
"corresponding",
"to",
"the",
"leaf",
"starting",
"from",
"a",
"leaf",
"SimpleProofNode",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/merkle/simple_proof.go#L161-L175 |
131,327 | tendermint/tendermint | libs/common/tempfile.go | randWriteFileSuffix | func randWriteFileSuffix() string {
atomicWriteFileRandMu.Lock()
r := atomicWriteFileRand
if r == 0 {
r = writeFileRandReseed()
}
// Update randomness according to lcg
r = r*lcgA + lcgC
atomicWriteFileRand = r
atomicWriteFileRandMu.Unlock()
// Can have a negative name, replace this in the following
suffix... | go | func randWriteFileSuffix() string {
atomicWriteFileRandMu.Lock()
r := atomicWriteFileRand
if r == 0 {
r = writeFileRandReseed()
}
// Update randomness according to lcg
r = r*lcgA + lcgC
atomicWriteFileRand = r
atomicWriteFileRandMu.Unlock()
// Can have a negative name, replace this in the following
suffix... | [
"func",
"randWriteFileSuffix",
"(",
")",
"string",
"{",
"atomicWriteFileRandMu",
".",
"Lock",
"(",
")",
"\n",
"r",
":=",
"atomicWriteFileRand",
"\n",
"if",
"r",
"==",
"0",
"{",
"r",
"=",
"writeFileRandReseed",
"(",
")",
"\n",
"}",
"\n\n",
"// Update randomne... | // Use a fast thread safe LCG for atomic write file names.
// Returns a string corresponding to a 64 bit int.
// If it was a negative int, the leading number is a 0. | [
"Use",
"a",
"fast",
"thread",
"safe",
"LCG",
"for",
"atomic",
"write",
"file",
"names",
".",
"Returns",
"a",
"string",
"corresponding",
"to",
"a",
"64",
"bit",
"int",
".",
"If",
"it",
"was",
"a",
"negative",
"int",
"the",
"leading",
"number",
"is",
"a"... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/tempfile.go#L51-L71 |
131,328 | tendermint/tendermint | libs/common/tempfile.go | WriteFileAtomic | func WriteFileAtomic(filename string, data []byte, perm os.FileMode) (err error) {
// This implementation is inspired by the golang stdlibs method of creating
// tempfiles. Notable differences are that we use different flags, a 64 bit LCG
// and handle negatives differently.
// The core reason we can't use golang's... | go | func WriteFileAtomic(filename string, data []byte, perm os.FileMode) (err error) {
// This implementation is inspired by the golang stdlibs method of creating
// tempfiles. Notable differences are that we use different flags, a 64 bit LCG
// and handle negatives differently.
// The core reason we can't use golang's... | [
"func",
"WriteFileAtomic",
"(",
"filename",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"perm",
"os",
".",
"FileMode",
")",
"(",
"err",
"error",
")",
"{",
"// This implementation is inspired by the golang stdlibs method of creating",
"// tempfiles. Notable differences a... | // WriteFileAtomic creates a temporary file with data and provided perm and
// swaps it atomically with filename if successful. | [
"WriteFileAtomic",
"creates",
"a",
"temporary",
"file",
"with",
"data",
"and",
"provided",
"perm",
"and",
"swaps",
"it",
"atomically",
"with",
"filename",
"if",
"successful",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/tempfile.go#L75-L128 |
131,329 | tendermint/tendermint | types/params.go | Validate | func (params *ConsensusParams) Validate() error {
if params.Block.MaxBytes <= 0 {
return cmn.NewError("Block.MaxBytes must be greater than 0. Got %d",
params.Block.MaxBytes)
}
if params.Block.MaxBytes > MaxBlockSizeBytes {
return cmn.NewError("Block.MaxBytes is too big. %d > %d",
params.Block.MaxBytes, Max... | go | func (params *ConsensusParams) Validate() error {
if params.Block.MaxBytes <= 0 {
return cmn.NewError("Block.MaxBytes must be greater than 0. Got %d",
params.Block.MaxBytes)
}
if params.Block.MaxBytes > MaxBlockSizeBytes {
return cmn.NewError("Block.MaxBytes is too big. %d > %d",
params.Block.MaxBytes, Max... | [
"func",
"(",
"params",
"*",
"ConsensusParams",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"params",
".",
"Block",
".",
"MaxBytes",
"<=",
"0",
"{",
"return",
"cmn",
".",
"NewError",
"(",
"\"",
"\"",
",",
"params",
".",
"Block",
".",
"MaxBytes",
")... | // Validate validates the ConsensusParams to ensure all values are within their
// allowed limits, and returns an error if they are not. | [
"Validate",
"validates",
"the",
"ConsensusParams",
"to",
"ensure",
"all",
"values",
"are",
"within",
"their",
"allowed",
"limits",
"and",
"returns",
"an",
"error",
"if",
"they",
"are",
"not",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/params.go#L96-L135 |
131,330 | tendermint/tendermint | types/params.go | Hash | func (params *ConsensusParams) Hash() []byte {
hasher := tmhash.New()
bz := cdcEncode(HashedParams{
params.Block.MaxBytes,
params.Block.MaxGas,
})
if bz == nil {
panic("cannot fail to encode ConsensusParams")
}
hasher.Write(bz)
return hasher.Sum(nil)
} | go | func (params *ConsensusParams) Hash() []byte {
hasher := tmhash.New()
bz := cdcEncode(HashedParams{
params.Block.MaxBytes,
params.Block.MaxGas,
})
if bz == nil {
panic("cannot fail to encode ConsensusParams")
}
hasher.Write(bz)
return hasher.Sum(nil)
} | [
"func",
"(",
"params",
"*",
"ConsensusParams",
")",
"Hash",
"(",
")",
"[",
"]",
"byte",
"{",
"hasher",
":=",
"tmhash",
".",
"New",
"(",
")",
"\n",
"bz",
":=",
"cdcEncode",
"(",
"HashedParams",
"{",
"params",
".",
"Block",
".",
"MaxBytes",
",",
"param... | // Hash returns a hash of a subset of the parameters to store in the block header.
// Only the Block.MaxBytes and Block.MaxGas are included in the hash.
// This allows the ConsensusParams to evolve more without breaking the block
// protocol. No need for a Merkle tree here, just a small struct to hash. | [
"Hash",
"returns",
"a",
"hash",
"of",
"a",
"subset",
"of",
"the",
"parameters",
"to",
"store",
"in",
"the",
"block",
"header",
".",
"Only",
"the",
"Block",
".",
"MaxBytes",
"and",
"Block",
".",
"MaxGas",
"are",
"included",
"in",
"the",
"hash",
".",
"Th... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/params.go#L141-L152 |
131,331 | tendermint/tendermint | libs/common/os.go | GoPath | func GoPath() string {
if gopath != "" {
return gopath
}
path := os.Getenv("GOPATH")
if len(path) == 0 {
goCmd := exec.Command("go", "env", "GOPATH")
out, err := goCmd.Output()
if err != nil {
panic(fmt.Sprintf("failed to determine gopath: %v", err))
}
path = string(out)
}
gopath = path
return pa... | go | func GoPath() string {
if gopath != "" {
return gopath
}
path := os.Getenv("GOPATH")
if len(path) == 0 {
goCmd := exec.Command("go", "env", "GOPATH")
out, err := goCmd.Output()
if err != nil {
panic(fmt.Sprintf("failed to determine gopath: %v", err))
}
path = string(out)
}
gopath = path
return pa... | [
"func",
"GoPath",
"(",
")",
"string",
"{",
"if",
"gopath",
"!=",
"\"",
"\"",
"{",
"return",
"gopath",
"\n",
"}",
"\n\n",
"path",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"path",
")",
"==",
"0",
"{",
"goCmd",
":="... | // GoPath returns GOPATH env variable value. If it is not set, this function
// will try to call `go env GOPATH` subcommand. | [
"GoPath",
"returns",
"GOPATH",
"env",
"variable",
"value",
".",
"If",
"it",
"is",
"not",
"set",
"this",
"function",
"will",
"try",
"to",
"call",
"go",
"env",
"GOPATH",
"subcommand",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/os.go#L19-L35 |
131,332 | tendermint/tendermint | libs/common/os.go | Kill | func Kill() error {
p, err := os.FindProcess(os.Getpid())
if err != nil {
return err
}
return p.Signal(syscall.SIGTERM)
} | go | func Kill() error {
p, err := os.FindProcess(os.Getpid())
if err != nil {
return err
}
return p.Signal(syscall.SIGTERM)
} | [
"func",
"Kill",
"(",
")",
"error",
"{",
"p",
",",
"err",
":=",
"os",
".",
"FindProcess",
"(",
"os",
".",
"Getpid",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"p",
".",
"Signal",
"(",
"syscall... | // Kill the running process by sending itself SIGTERM. | [
"Kill",
"the",
"running",
"process",
"by",
"sending",
"itself",
"SIGTERM",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/os.go#L58-L64 |
131,333 | tendermint/tendermint | libs/db/debug_db.go | NewBatch | func (ddb debugDB) NewBatch() Batch {
fmt.Printf("%v.NewBatch()\n", ddb.label)
return NewDebugBatch(ddb.label, ddb.db.NewBatch())
} | go | func (ddb debugDB) NewBatch() Batch {
fmt.Printf("%v.NewBatch()\n", ddb.label)
return NewDebugBatch(ddb.label, ddb.db.NewBatch())
} | [
"func",
"(",
"ddb",
"debugDB",
")",
"NewBatch",
"(",
")",
"Batch",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"ddb",
".",
"label",
")",
"\n",
"return",
"NewDebugBatch",
"(",
"ddb",
".",
"label",
",",
"ddb",
".",
"db",
".",
"NewBatch",
... | // Implements DB.
// Panics if the underlying db is not an
// atomicSetDeleter. | [
"Implements",
"DB",
".",
"Panics",
"if",
"the",
"underlying",
"db",
"is",
"not",
"an",
"atomicSetDeleter",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/debug_db.go#L128-L131 |
131,334 | tendermint/tendermint | types/priv_validator.go | NewMockPVWithParams | func NewMockPVWithParams(privKey crypto.PrivKey, breakProposalSigning, breakVoteSigning bool) *MockPV {
return &MockPV{privKey, breakProposalSigning, breakVoteSigning}
} | go | func NewMockPVWithParams(privKey crypto.PrivKey, breakProposalSigning, breakVoteSigning bool) *MockPV {
return &MockPV{privKey, breakProposalSigning, breakVoteSigning}
} | [
"func",
"NewMockPVWithParams",
"(",
"privKey",
"crypto",
".",
"PrivKey",
",",
"breakProposalSigning",
",",
"breakVoteSigning",
"bool",
")",
"*",
"MockPV",
"{",
"return",
"&",
"MockPV",
"{",
"privKey",
",",
"breakProposalSigning",
",",
"breakVoteSigning",
"}",
"\n"... | // NewMockPVWithParams allows one to create a MockPV instance, but with finer
// grained control over the operation of the mock validator. This is useful for
// mocking test failures. | [
"NewMockPVWithParams",
"allows",
"one",
"to",
"create",
"a",
"MockPV",
"instance",
"but",
"with",
"finer",
"grained",
"control",
"over",
"the",
"operation",
"of",
"the",
"mock",
"validator",
".",
"This",
"is",
"useful",
"for",
"mocking",
"test",
"failures",
".... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/priv_validator.go#L58-L60 |
131,335 | tendermint/tendermint | types/priv_validator.go | String | func (pv *MockPV) String() string {
addr := pv.GetPubKey().Address()
return fmt.Sprintf("MockPV{%v}", addr)
} | go | func (pv *MockPV) String() string {
addr := pv.GetPubKey().Address()
return fmt.Sprintf("MockPV{%v}", addr)
} | [
"func",
"(",
"pv",
"*",
"MockPV",
")",
"String",
"(",
")",
"string",
"{",
"addr",
":=",
"pv",
".",
"GetPubKey",
"(",
")",
".",
"Address",
"(",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"addr",
")",
"\n",
"}"
] | // String returns a string representation of the MockPV. | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"the",
"MockPV",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/priv_validator.go#L98-L101 |
131,336 | tendermint/tendermint | crypto/multisig/multisignature.go | NewMultisig | func NewMultisig(n int) *Multisignature {
// Default the signature list to have a capacity of two, since we can
// expect that most multisigs will require multiple signers.
return &Multisignature{bitarray.NewCompactBitArray(n), make([][]byte, 0, 2)}
} | go | func NewMultisig(n int) *Multisignature {
// Default the signature list to have a capacity of two, since we can
// expect that most multisigs will require multiple signers.
return &Multisignature{bitarray.NewCompactBitArray(n), make([][]byte, 0, 2)}
} | [
"func",
"NewMultisig",
"(",
"n",
"int",
")",
"*",
"Multisignature",
"{",
"// Default the signature list to have a capacity of two, since we can",
"// expect that most multisigs will require multiple signers.",
"return",
"&",
"Multisignature",
"{",
"bitarray",
".",
"NewCompactBitArr... | // NewMultisig returns a new Multisignature of size n. | [
"NewMultisig",
"returns",
"a",
"new",
"Multisignature",
"of",
"size",
"n",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/multisig/multisignature.go#L18-L22 |
131,337 | tendermint/tendermint | crypto/multisig/multisignature.go | getIndex | func getIndex(pk crypto.PubKey, keys []crypto.PubKey) int {
for i := 0; i < len(keys); i++ {
if pk.Equals(keys[i]) {
return i
}
}
return -1
} | go | func getIndex(pk crypto.PubKey, keys []crypto.PubKey) int {
for i := 0; i < len(keys); i++ {
if pk.Equals(keys[i]) {
return i
}
}
return -1
} | [
"func",
"getIndex",
"(",
"pk",
"crypto",
".",
"PubKey",
",",
"keys",
"[",
"]",
"crypto",
".",
"PubKey",
")",
"int",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"keys",
")",
";",
"i",
"++",
"{",
"if",
"pk",
".",
"Equals",
"(",
"keys... | // GetIndex returns the index of pk in keys. Returns -1 if not found | [
"GetIndex",
"returns",
"the",
"index",
"of",
"pk",
"in",
"keys",
".",
"Returns",
"-",
"1",
"if",
"not",
"found"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/multisig/multisignature.go#L25-L32 |
131,338 | tendermint/tendermint | crypto/multisig/multisignature.go | AddSignature | func (mSig *Multisignature) AddSignature(sig []byte, index int) {
newSigIndex := mSig.BitArray.NumTrueBitsBefore(index)
// Signature already exists, just replace the value there
if mSig.BitArray.GetIndex(index) {
mSig.Sigs[newSigIndex] = sig
return
}
mSig.BitArray.SetIndex(index, true)
// Optimization if the ... | go | func (mSig *Multisignature) AddSignature(sig []byte, index int) {
newSigIndex := mSig.BitArray.NumTrueBitsBefore(index)
// Signature already exists, just replace the value there
if mSig.BitArray.GetIndex(index) {
mSig.Sigs[newSigIndex] = sig
return
}
mSig.BitArray.SetIndex(index, true)
// Optimization if the ... | [
"func",
"(",
"mSig",
"*",
"Multisignature",
")",
"AddSignature",
"(",
"sig",
"[",
"]",
"byte",
",",
"index",
"int",
")",
"{",
"newSigIndex",
":=",
"mSig",
".",
"BitArray",
".",
"NumTrueBitsBefore",
"(",
"index",
")",
"\n",
"// Signature already exists, just re... | // AddSignature adds a signature to the multisig, at the corresponding index.
// If the signature already exists, replace it. | [
"AddSignature",
"adds",
"a",
"signature",
"to",
"the",
"multisig",
"at",
"the",
"corresponding",
"index",
".",
"If",
"the",
"signature",
"already",
"exists",
"replace",
"it",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/multisig/multisignature.go#L36-L54 |
131,339 | tendermint/tendermint | crypto/multisig/multisignature.go | AddSignatureFromPubKey | func (mSig *Multisignature) AddSignatureFromPubKey(sig []byte, pubkey crypto.PubKey, keys []crypto.PubKey) error {
index := getIndex(pubkey, keys)
if index == -1 {
return errors.New("provided key didn't exist in pubkeys")
}
mSig.AddSignature(sig, index)
return nil
} | go | func (mSig *Multisignature) AddSignatureFromPubKey(sig []byte, pubkey crypto.PubKey, keys []crypto.PubKey) error {
index := getIndex(pubkey, keys)
if index == -1 {
return errors.New("provided key didn't exist in pubkeys")
}
mSig.AddSignature(sig, index)
return nil
} | [
"func",
"(",
"mSig",
"*",
"Multisignature",
")",
"AddSignatureFromPubKey",
"(",
"sig",
"[",
"]",
"byte",
",",
"pubkey",
"crypto",
".",
"PubKey",
",",
"keys",
"[",
"]",
"crypto",
".",
"PubKey",
")",
"error",
"{",
"index",
":=",
"getIndex",
"(",
"pubkey",
... | // AddSignatureFromPubKey adds a signature to the multisig,
// at the index in keys corresponding to the provided pubkey. | [
"AddSignatureFromPubKey",
"adds",
"a",
"signature",
"to",
"the",
"multisig",
"at",
"the",
"index",
"in",
"keys",
"corresponding",
"to",
"the",
"provided",
"pubkey",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/multisig/multisignature.go#L58-L65 |
131,340 | tendermint/tendermint | rpc/client/helpers.go | DefaultWaitStrategy | func DefaultWaitStrategy(delta int64) (abort error) {
if delta > 10 {
return errors.Errorf("Waiting for %d blocks... aborting", delta)
} else if delta > 0 {
// estimate of wait time....
// wait half a second for the next block (in progress)
// plus one second for every full block
delay := time.Duration(delt... | go | func DefaultWaitStrategy(delta int64) (abort error) {
if delta > 10 {
return errors.Errorf("Waiting for %d blocks... aborting", delta)
} else if delta > 0 {
// estimate of wait time....
// wait half a second for the next block (in progress)
// plus one second for every full block
delay := time.Duration(delt... | [
"func",
"DefaultWaitStrategy",
"(",
"delta",
"int64",
")",
"(",
"abort",
"error",
")",
"{",
"if",
"delta",
">",
"10",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"delta",
")",
"\n",
"}",
"else",
"if",
"delta",
">",
"0",
"{",
"// e... | // DefaultWaitStrategy is the standard backoff algorithm,
// but you can plug in another one | [
"DefaultWaitStrategy",
"is",
"the",
"standard",
"backoff",
"algorithm",
"but",
"you",
"can",
"plug",
"in",
"another",
"one"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/helpers.go#L16-L27 |
131,341 | tendermint/tendermint | rpc/client/helpers.go | WaitForHeight | func WaitForHeight(c StatusClient, h int64, waiter Waiter) error {
if waiter == nil {
waiter = DefaultWaitStrategy
}
delta := int64(1)
for delta > 0 {
s, err := c.Status()
if err != nil {
return err
}
delta = h - s.SyncInfo.LatestBlockHeight
// wait for the time, or abort early
if err := waiter(del... | go | func WaitForHeight(c StatusClient, h int64, waiter Waiter) error {
if waiter == nil {
waiter = DefaultWaitStrategy
}
delta := int64(1)
for delta > 0 {
s, err := c.Status()
if err != nil {
return err
}
delta = h - s.SyncInfo.LatestBlockHeight
// wait for the time, or abort early
if err := waiter(del... | [
"func",
"WaitForHeight",
"(",
"c",
"StatusClient",
",",
"h",
"int64",
",",
"waiter",
"Waiter",
")",
"error",
"{",
"if",
"waiter",
"==",
"nil",
"{",
"waiter",
"=",
"DefaultWaitStrategy",
"\n",
"}",
"\n",
"delta",
":=",
"int64",
"(",
"1",
")",
"\n",
"for... | // Wait for height will poll status at reasonable intervals until
// the block at the given height is available.
//
// If waiter is nil, we use DefaultWaitStrategy, but you can also
// provide your own implementation | [
"Wait",
"for",
"height",
"will",
"poll",
"status",
"at",
"reasonable",
"intervals",
"until",
"the",
"block",
"at",
"the",
"given",
"height",
"is",
"available",
".",
"If",
"waiter",
"is",
"nil",
"we",
"use",
"DefaultWaitStrategy",
"but",
"you",
"can",
"also",... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/helpers.go#L34-L51 |
131,342 | tendermint/tendermint | rpc/client/helpers.go | WaitForOneEvent | func WaitForOneEvent(c EventsClient, evtTyp string, timeout time.Duration) (types.TMEventData, error) {
const subscriber = "helpers"
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
// register for the next event of this type
eventCh, err := c.Subscribe(ctx, subscriber, types.Query... | go | func WaitForOneEvent(c EventsClient, evtTyp string, timeout time.Duration) (types.TMEventData, error) {
const subscriber = "helpers"
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
// register for the next event of this type
eventCh, err := c.Subscribe(ctx, subscriber, types.Query... | [
"func",
"WaitForOneEvent",
"(",
"c",
"EventsClient",
",",
"evtTyp",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"types",
".",
"TMEventData",
",",
"error",
")",
"{",
"const",
"subscriber",
"=",
"\"",
"\"",
"\n",
"ctx",
",",
"cancel",
":="... | // WaitForOneEvent subscribes to a websocket event for the given
// event time and returns upon receiving it one time, or
// when the timeout duration has expired.
//
// This handles subscribing and unsubscribing under the hood | [
"WaitForOneEvent",
"subscribes",
"to",
"a",
"websocket",
"event",
"for",
"the",
"given",
"event",
"time",
"and",
"returns",
"upon",
"receiving",
"it",
"one",
"time",
"or",
"when",
"the",
"timeout",
"duration",
"has",
"expired",
".",
"This",
"handles",
"subscri... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/helpers.go#L58-L77 |
131,343 | tendermint/tendermint | lite/proxy/errors.go | IsErrNoData | func IsErrNoData(err error) bool {
if err_, ok := err.(cmn.Error); ok {
_, ok := err_.Data().(errNoData)
return ok
}
return false
} | go | func IsErrNoData(err error) bool {
if err_, ok := err.(cmn.Error); ok {
_, ok := err_.Data().(errNoData)
return ok
}
return false
} | [
"func",
"IsErrNoData",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err_",
",",
"ok",
":=",
"err",
".",
"(",
"cmn",
".",
"Error",
")",
";",
"ok",
"{",
"_",
",",
"ok",
":=",
"err_",
".",
"Data",
"(",
")",
".",
"(",
"errNoData",
")",
"\n",
"re... | // IsErrNoData checks whether an error is due to a query returning empty data | [
"IsErrNoData",
"checks",
"whether",
"an",
"error",
"is",
"due",
"to",
"a",
"query",
"returning",
"empty",
"data"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/proxy/errors.go#L14-L20 |
131,344 | tendermint/tendermint | state/tx_filter.go | TxPreCheck | func TxPreCheck(state State) mempl.PreCheckFunc {
maxDataBytes := types.MaxDataBytesUnknownEvidence(
state.ConsensusParams.Block.MaxBytes,
state.Validators.Size(),
)
return mempl.PreCheckAminoMaxBytes(maxDataBytes)
} | go | func TxPreCheck(state State) mempl.PreCheckFunc {
maxDataBytes := types.MaxDataBytesUnknownEvidence(
state.ConsensusParams.Block.MaxBytes,
state.Validators.Size(),
)
return mempl.PreCheckAminoMaxBytes(maxDataBytes)
} | [
"func",
"TxPreCheck",
"(",
"state",
"State",
")",
"mempl",
".",
"PreCheckFunc",
"{",
"maxDataBytes",
":=",
"types",
".",
"MaxDataBytesUnknownEvidence",
"(",
"state",
".",
"ConsensusParams",
".",
"Block",
".",
"MaxBytes",
",",
"state",
".",
"Validators",
".",
"... | // TxPreCheck returns a function to filter transactions before processing.
// The function limits the size of a transaction to the block's maximum data size. | [
"TxPreCheck",
"returns",
"a",
"function",
"to",
"filter",
"transactions",
"before",
"processing",
".",
"The",
"function",
"limits",
"the",
"size",
"of",
"a",
"transaction",
"to",
"the",
"block",
"s",
"maximum",
"data",
"size",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/tx_filter.go#L10-L16 |
131,345 | tendermint/tendermint | state/tx_filter.go | TxPostCheck | func TxPostCheck(state State) mempl.PostCheckFunc {
return mempl.PostCheckMaxGas(state.ConsensusParams.Block.MaxGas)
} | go | func TxPostCheck(state State) mempl.PostCheckFunc {
return mempl.PostCheckMaxGas(state.ConsensusParams.Block.MaxGas)
} | [
"func",
"TxPostCheck",
"(",
"state",
"State",
")",
"mempl",
".",
"PostCheckFunc",
"{",
"return",
"mempl",
".",
"PostCheckMaxGas",
"(",
"state",
".",
"ConsensusParams",
".",
"Block",
".",
"MaxGas",
")",
"\n",
"}"
] | // TxPostCheck returns a function to filter transactions after processing.
// The function limits the gas wanted by a transaction to the block's maximum total gas. | [
"TxPostCheck",
"returns",
"a",
"function",
"to",
"filter",
"transactions",
"after",
"processing",
".",
"The",
"function",
"limits",
"the",
"gas",
"wanted",
"by",
"a",
"transaction",
"to",
"the",
"block",
"s",
"maximum",
"total",
"gas",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/tx_filter.go#L20-L22 |
131,346 | tendermint/tendermint | abci/server/grpc_server.go | NewGRPCServer | func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) cmn.Service {
proto, addr := cmn.ProtocolAndAddress(protoAddr)
s := &GRPCServer{
proto: proto,
addr: addr,
listener: nil,
app: app,
}
s.BaseService = *cmn.NewBaseService(nil, "ABCIServer", s)
return s
} | go | func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) cmn.Service {
proto, addr := cmn.ProtocolAndAddress(protoAddr)
s := &GRPCServer{
proto: proto,
addr: addr,
listener: nil,
app: app,
}
s.BaseService = *cmn.NewBaseService(nil, "ABCIServer", s)
return s
} | [
"func",
"NewGRPCServer",
"(",
"protoAddr",
"string",
",",
"app",
"types",
".",
"ABCIApplicationServer",
")",
"cmn",
".",
"Service",
"{",
"proto",
",",
"addr",
":=",
"cmn",
".",
"ProtocolAndAddress",
"(",
"protoAddr",
")",
"\n",
"s",
":=",
"&",
"GRPCServer",
... | // NewGRPCServer returns a new gRPC ABCI server | [
"NewGRPCServer",
"returns",
"a",
"new",
"gRPC",
"ABCI",
"server"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/server/grpc_server.go#L24-L34 |
131,347 | tendermint/tendermint | abci/server/grpc_server.go | OnStart | func (s *GRPCServer) OnStart() error {
if err := s.BaseService.OnStart(); err != nil {
return err
}
ln, err := net.Listen(s.proto, s.addr)
if err != nil {
return err
}
s.Logger.Info("Listening", "proto", s.proto, "addr", s.addr)
s.listener = ln
s.server = grpc.NewServer()
types.RegisterABCIApplicationServe... | go | func (s *GRPCServer) OnStart() error {
if err := s.BaseService.OnStart(); err != nil {
return err
}
ln, err := net.Listen(s.proto, s.addr)
if err != nil {
return err
}
s.Logger.Info("Listening", "proto", s.proto, "addr", s.addr)
s.listener = ln
s.server = grpc.NewServer()
types.RegisterABCIApplicationServe... | [
"func",
"(",
"s",
"*",
"GRPCServer",
")",
"OnStart",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"s",
".",
"BaseService",
".",
"OnStart",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"ln",
",",
"err",
":=",
"net",
".... | // OnStart starts the gRPC service | [
"OnStart",
"starts",
"the",
"gRPC",
"service"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/server/grpc_server.go#L37-L51 |
131,348 | tendermint/tendermint | libs/autofile/group.go | OpenGroup | func OpenGroup(headPath string, groupOptions ...func(*Group)) (g *Group, err error) {
dir := path.Dir(headPath)
head, err := OpenAutoFile(headPath)
if err != nil {
return nil, err
}
g = &Group{
ID: "group:" + head.ID,
Head: head,
headBuf: bufio.NewWriterSize(head, ... | go | func OpenGroup(headPath string, groupOptions ...func(*Group)) (g *Group, err error) {
dir := path.Dir(headPath)
head, err := OpenAutoFile(headPath)
if err != nil {
return nil, err
}
g = &Group{
ID: "group:" + head.ID,
Head: head,
headBuf: bufio.NewWriterSize(head, ... | [
"func",
"OpenGroup",
"(",
"headPath",
"string",
",",
"groupOptions",
"...",
"func",
"(",
"*",
"Group",
")",
")",
"(",
"g",
"*",
"Group",
",",
"err",
"error",
")",
"{",
"dir",
":=",
"path",
".",
"Dir",
"(",
"headPath",
")",
"\n",
"head",
",",
"err",... | // OpenGroup creates a new Group with head at headPath. It returns an error if
// it fails to open head file. | [
"OpenGroup",
"creates",
"a",
"new",
"Group",
"with",
"head",
"at",
"headPath",
".",
"It",
"returns",
"an",
"error",
"if",
"it",
"fails",
"to",
"open",
"head",
"file",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L81-L111 |
131,349 | tendermint/tendermint | libs/autofile/group.go | GroupCheckDuration | func GroupCheckDuration(duration time.Duration) func(*Group) {
return func(g *Group) {
g.groupCheckDuration = duration
}
} | go | func GroupCheckDuration(duration time.Duration) func(*Group) {
return func(g *Group) {
g.groupCheckDuration = duration
}
} | [
"func",
"GroupCheckDuration",
"(",
"duration",
"time",
".",
"Duration",
")",
"func",
"(",
"*",
"Group",
")",
"{",
"return",
"func",
"(",
"g",
"*",
"Group",
")",
"{",
"g",
".",
"groupCheckDuration",
"=",
"duration",
"\n",
"}",
"\n",
"}"
] | // GroupCheckDuration allows you to overwrite default groupCheckDuration. | [
"GroupCheckDuration",
"allows",
"you",
"to",
"overwrite",
"default",
"groupCheckDuration",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L114-L118 |
131,350 | tendermint/tendermint | libs/autofile/group.go | OnStart | func (g *Group) OnStart() error {
g.ticker = time.NewTicker(g.groupCheckDuration)
go g.processTicks()
return nil
} | go | func (g *Group) OnStart() error {
g.ticker = time.NewTicker(g.groupCheckDuration)
go g.processTicks()
return nil
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"OnStart",
"(",
")",
"error",
"{",
"g",
".",
"ticker",
"=",
"time",
".",
"NewTicker",
"(",
"g",
".",
"groupCheckDuration",
")",
"\n",
"go",
"g",
".",
"processTicks",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // OnStart implements cmn.Service by starting the goroutine that checks file
// and group limits. | [
"OnStart",
"implements",
"cmn",
".",
"Service",
"by",
"starting",
"the",
"goroutine",
"that",
"checks",
"file",
"and",
"group",
"limits",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L136-L140 |
131,351 | tendermint/tendermint | libs/autofile/group.go | Close | func (g *Group) Close() {
g.FlushAndSync()
g.mtx.Lock()
_ = g.Head.closeFile()
g.mtx.Unlock()
} | go | func (g *Group) Close() {
g.FlushAndSync()
g.mtx.Lock()
_ = g.Head.closeFile()
g.mtx.Unlock()
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"Close",
"(",
")",
"{",
"g",
".",
"FlushAndSync",
"(",
")",
"\n\n",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"_",
"=",
"g",
".",
"Head",
".",
"closeFile",
"(",
")",
"\n",
"g",
".",
"mtx",
".",
"Unlo... | // Close closes the head file. The group must be stopped by this moment. | [
"Close",
"closes",
"the",
"head",
"file",
".",
"The",
"group",
"must",
"be",
"stopped",
"by",
"this",
"moment",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L157-L163 |
131,352 | tendermint/tendermint | libs/autofile/group.go | HeadSizeLimit | func (g *Group) HeadSizeLimit() int64 {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.headSizeLimit
} | go | func (g *Group) HeadSizeLimit() int64 {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.headSizeLimit
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"HeadSizeLimit",
"(",
")",
"int64",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"g",
".",
"headSizeLimit",
"\n",
"}"
] | // HeadSizeLimit returns the current head size limit. | [
"HeadSizeLimit",
"returns",
"the",
"current",
"head",
"size",
"limit",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L166-L170 |
131,353 | tendermint/tendermint | libs/autofile/group.go | TotalSizeLimit | func (g *Group) TotalSizeLimit() int64 {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.totalSizeLimit
} | go | func (g *Group) TotalSizeLimit() int64 {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.totalSizeLimit
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"TotalSizeLimit",
"(",
")",
"int64",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"g",
".",
"totalSizeLimit",
"\n",
"}"
] | // TotalSizeLimit returns total size limit of the group. | [
"TotalSizeLimit",
"returns",
"total",
"size",
"limit",
"of",
"the",
"group",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L173-L177 |
131,354 | tendermint/tendermint | libs/autofile/group.go | MaxIndex | func (g *Group) MaxIndex() int {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.maxIndex
} | go | func (g *Group) MaxIndex() int {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.maxIndex
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"MaxIndex",
"(",
")",
"int",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"g",
".",
"maxIndex",
"\n",
"}"
] | // MaxIndex returns index of the last file in the group. | [
"MaxIndex",
"returns",
"index",
"of",
"the",
"last",
"file",
"in",
"the",
"group",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L180-L184 |
131,355 | tendermint/tendermint | libs/autofile/group.go | MinIndex | func (g *Group) MinIndex() int {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.minIndex
} | go | func (g *Group) MinIndex() int {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.minIndex
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"MinIndex",
"(",
")",
"int",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"g",
".",
"minIndex",
"\n",
"}"
] | // MinIndex returns index of the first file in the group. | [
"MinIndex",
"returns",
"index",
"of",
"the",
"first",
"file",
"in",
"the",
"group",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L187-L191 |
131,356 | tendermint/tendermint | libs/autofile/group.go | Buffered | func (g *Group) Buffered() int {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.headBuf.Buffered()
} | go | func (g *Group) Buffered() int {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.headBuf.Buffered()
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"Buffered",
"(",
")",
"int",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"g",
".",
"headBuf",
".",
"Buffered",
"(",
")",
"\n",
"}"
... | // Buffered returns the size of the currently buffered data. | [
"Buffered",
"returns",
"the",
"size",
"of",
"the",
"currently",
"buffered",
"data",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L215-L219 |
131,357 | tendermint/tendermint | libs/autofile/group.go | RotateFile | func (g *Group) RotateFile() {
g.mtx.Lock()
defer g.mtx.Unlock()
headPath := g.Head.Path
if err := g.headBuf.Flush(); err != nil {
panic(err)
}
if err := g.Head.Sync(); err != nil {
panic(err)
}
if err := g.Head.closeFile(); err != nil {
panic(err)
}
indexPath := filePathForIndex(headPath, g.maxInd... | go | func (g *Group) RotateFile() {
g.mtx.Lock()
defer g.mtx.Unlock()
headPath := g.Head.Path
if err := g.headBuf.Flush(); err != nil {
panic(err)
}
if err := g.Head.Sync(); err != nil {
panic(err)
}
if err := g.Head.closeFile(); err != nil {
panic(err)
}
indexPath := filePathForIndex(headPath, g.maxInd... | [
"func",
"(",
"g",
"*",
"Group",
")",
"RotateFile",
"(",
")",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"headPath",
":=",
"g",
".",
"Head",
".",
"Path",
"\n\n",
"if",
"err",
"... | // RotateFile causes group to close the current head and assign it some index.
// Note it does not create a new head. | [
"RotateFile",
"causes",
"group",
"to",
"close",
"the",
"current",
"head",
"and",
"assign",
"it",
"some",
"index",
".",
"Note",
"it",
"does",
"not",
"create",
"a",
"new",
"head",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L297-L321 |
131,358 | tendermint/tendermint | libs/autofile/group.go | ReadGroupInfo | func (g *Group) ReadGroupInfo() GroupInfo {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.readGroupInfo()
} | go | func (g *Group) ReadGroupInfo() GroupInfo {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.readGroupInfo()
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"ReadGroupInfo",
"(",
")",
"GroupInfo",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"g",
".",
"readGroupInfo",
"(",
")",
"\n",
"}"
] | // Returns info after scanning all files in g.Head's dir. | [
"Returns",
"info",
"after",
"scanning",
"all",
"files",
"in",
"g",
".",
"Head",
"s",
"dir",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L343-L347 |
131,359 | tendermint/tendermint | libs/autofile/group.go | Close | func (gr *GroupReader) Close() error {
gr.mtx.Lock()
defer gr.mtx.Unlock()
if gr.curReader != nil {
err := gr.curFile.Close()
gr.curIndex = 0
gr.curReader = nil
gr.curFile = nil
gr.curLine = nil
return err
}
return nil
} | go | func (gr *GroupReader) Close() error {
gr.mtx.Lock()
defer gr.mtx.Unlock()
if gr.curReader != nil {
err := gr.curFile.Close()
gr.curIndex = 0
gr.curReader = nil
gr.curFile = nil
gr.curLine = nil
return err
}
return nil
} | [
"func",
"(",
"gr",
"*",
"GroupReader",
")",
"Close",
"(",
")",
"error",
"{",
"gr",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"gr",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"gr",
".",
"curReader",
"!=",
"nil",
"{",
"err",
":=",... | // Close closes the GroupReader by closing the cursor file. | [
"Close",
"closes",
"the",
"GroupReader",
"by",
"closing",
"the",
"cursor",
"file",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L437-L450 |
131,360 | tendermint/tendermint | libs/autofile/group.go | Read | func (gr *GroupReader) Read(p []byte) (n int, err error) {
lenP := len(p)
if lenP == 0 {
return 0, errors.New("given empty slice")
}
gr.mtx.Lock()
defer gr.mtx.Unlock()
// Open file if not open yet
if gr.curReader == nil {
if err = gr.openFile(gr.curIndex); err != nil {
return 0, err
}
}
// Iterate... | go | func (gr *GroupReader) Read(p []byte) (n int, err error) {
lenP := len(p)
if lenP == 0 {
return 0, errors.New("given empty slice")
}
gr.mtx.Lock()
defer gr.mtx.Unlock()
// Open file if not open yet
if gr.curReader == nil {
if err = gr.openFile(gr.curIndex); err != nil {
return 0, err
}
}
// Iterate... | [
"func",
"(",
"gr",
"*",
"GroupReader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"lenP",
":=",
"len",
"(",
"p",
")",
"\n",
"if",
"lenP",
"==",
"0",
"{",
"return",
"0",
",",
"errors",
".",
... | // Read implements io.Reader, reading bytes from the current Reader
// incrementing index until enough bytes are read. | [
"Read",
"implements",
"io",
".",
"Reader",
"reading",
"bytes",
"from",
"the",
"current",
"Reader",
"incrementing",
"index",
"until",
"enough",
"bytes",
"are",
"read",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L454-L489 |
131,361 | tendermint/tendermint | libs/autofile/group.go | CurIndex | func (gr *GroupReader) CurIndex() int {
gr.mtx.Lock()
defer gr.mtx.Unlock()
return gr.curIndex
} | go | func (gr *GroupReader) CurIndex() int {
gr.mtx.Lock()
defer gr.mtx.Unlock()
return gr.curIndex
} | [
"func",
"(",
"gr",
"*",
"GroupReader",
")",
"CurIndex",
"(",
")",
"int",
"{",
"gr",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"gr",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"gr",
".",
"curIndex",
"\n",
"}"
] | // CurIndex returns cursor's file index. | [
"CurIndex",
"returns",
"cursor",
"s",
"file",
"index",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L521-L525 |
131,362 | tendermint/tendermint | libs/autofile/group.go | SetIndex | func (gr *GroupReader) SetIndex(index int) error {
gr.mtx.Lock()
defer gr.mtx.Unlock()
return gr.openFile(index)
} | go | func (gr *GroupReader) SetIndex(index int) error {
gr.mtx.Lock()
defer gr.mtx.Unlock()
return gr.openFile(index)
} | [
"func",
"(",
"gr",
"*",
"GroupReader",
")",
"SetIndex",
"(",
"index",
"int",
")",
"error",
"{",
"gr",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"gr",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"gr",
".",
"openFile",
"(",
"index"... | // SetIndex sets the cursor's file index to index by opening a file at this
// position. | [
"SetIndex",
"sets",
"the",
"cursor",
"s",
"file",
"index",
"to",
"index",
"by",
"opening",
"a",
"file",
"at",
"this",
"position",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/group.go#L529-L533 |
131,363 | tendermint/tendermint | crypto/ed25519/ed25519.go | Sign | func (privKey PrivKeyEd25519) Sign(msg []byte) ([]byte, error) {
signatureBytes := ed25519.Sign(privKey[:], msg)
return signatureBytes[:], nil
} | go | func (privKey PrivKeyEd25519) Sign(msg []byte) ([]byte, error) {
signatureBytes := ed25519.Sign(privKey[:], msg)
return signatureBytes[:], nil
} | [
"func",
"(",
"privKey",
"PrivKeyEd25519",
")",
"Sign",
"(",
"msg",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"signatureBytes",
":=",
"ed25519",
".",
"Sign",
"(",
"privKey",
"[",
":",
"]",
",",
"msg",
")",
"\n",
"return",... | // Sign produces a signature on the provided message.
// This assumes the privkey is wellformed in the golang format.
// The first 32 bytes should be random,
// corresponding to the normal ed25519 private key.
// The latter 32 bytes should be the compressed public key.
// If these conditions aren't met, Sign will panic... | [
"Sign",
"produces",
"a",
"signature",
"on",
"the",
"provided",
"message",
".",
"This",
"assumes",
"the",
"privkey",
"is",
"wellformed",
"in",
"the",
"golang",
"format",
".",
"The",
"first",
"32",
"bytes",
"should",
"be",
"random",
"corresponding",
"to",
"the... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/ed25519/ed25519.go#L55-L58 |
131,364 | tendermint/tendermint | crypto/ed25519/ed25519.go | PubKey | func (privKey PrivKeyEd25519) PubKey() crypto.PubKey {
privKeyBytes := [64]byte(privKey)
initialized := false
// If the latter 32 bytes of the privkey are all zero, compute the pubkey
// otherwise privkey is initialized and we can use the cached value inside
// of the private key.
for _, v := range privKeyBytes[3... | go | func (privKey PrivKeyEd25519) PubKey() crypto.PubKey {
privKeyBytes := [64]byte(privKey)
initialized := false
// If the latter 32 bytes of the privkey are all zero, compute the pubkey
// otherwise privkey is initialized and we can use the cached value inside
// of the private key.
for _, v := range privKeyBytes[3... | [
"func",
"(",
"privKey",
"PrivKeyEd25519",
")",
"PubKey",
"(",
")",
"crypto",
".",
"PubKey",
"{",
"privKeyBytes",
":=",
"[",
"64",
"]",
"byte",
"(",
"privKey",
")",
"\n",
"initialized",
":=",
"false",
"\n",
"// If the latter 32 bytes of the privkey are all zero, co... | // PubKey gets the corresponding public key from the private key. | [
"PubKey",
"gets",
"the",
"corresponding",
"public",
"key",
"from",
"the",
"private",
"key",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/ed25519/ed25519.go#L61-L81 |
131,365 | tendermint/tendermint | crypto/ed25519/ed25519.go | genPrivKey | func genPrivKey(rand io.Reader) PrivKeyEd25519 {
seed := make([]byte, 32)
_, err := io.ReadFull(rand, seed[:])
if err != nil {
panic(err)
}
privKey := ed25519.NewKeyFromSeed(seed)
var privKeyEd PrivKeyEd25519
copy(privKeyEd[:], privKey)
return privKeyEd
} | go | func genPrivKey(rand io.Reader) PrivKeyEd25519 {
seed := make([]byte, 32)
_, err := io.ReadFull(rand, seed[:])
if err != nil {
panic(err)
}
privKey := ed25519.NewKeyFromSeed(seed)
var privKeyEd PrivKeyEd25519
copy(privKeyEd[:], privKey)
return privKeyEd
} | [
"func",
"genPrivKey",
"(",
"rand",
"io",
".",
"Reader",
")",
"PrivKeyEd25519",
"{",
"seed",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"32",
")",
"\n",
"_",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"rand",
",",
"seed",
"[",
":",
"]",
")",
"... | // genPrivKey generates a new ed25519 private key using the provided reader. | [
"genPrivKey",
"generates",
"a",
"new",
"ed25519",
"private",
"key",
"using",
"the",
"provided",
"reader",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/ed25519/ed25519.go#L101-L112 |
131,366 | tendermint/tendermint | crypto/ed25519/ed25519.go | Address | func (pubKey PubKeyEd25519) Address() crypto.Address {
return crypto.Address(tmhash.SumTruncated(pubKey[:]))
} | go | func (pubKey PubKeyEd25519) Address() crypto.Address {
return crypto.Address(tmhash.SumTruncated(pubKey[:]))
} | [
"func",
"(",
"pubKey",
"PubKeyEd25519",
")",
"Address",
"(",
")",
"crypto",
".",
"Address",
"{",
"return",
"crypto",
".",
"Address",
"(",
"tmhash",
".",
"SumTruncated",
"(",
"pubKey",
"[",
":",
"]",
")",
")",
"\n",
"}"
] | // Address is the SHA256-20 of the raw pubkey bytes. | [
"Address",
"is",
"the",
"SHA256",
"-",
"20",
"of",
"the",
"raw",
"pubkey",
"bytes",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/ed25519/ed25519.go#L138-L140 |
131,367 | tendermint/tendermint | crypto/ed25519/ed25519.go | Bytes | func (pubKey PubKeyEd25519) Bytes() []byte {
bz, err := cdc.MarshalBinaryBare(pubKey)
if err != nil {
panic(err)
}
return bz
} | go | func (pubKey PubKeyEd25519) Bytes() []byte {
bz, err := cdc.MarshalBinaryBare(pubKey)
if err != nil {
panic(err)
}
return bz
} | [
"func",
"(",
"pubKey",
"PubKeyEd25519",
")",
"Bytes",
"(",
")",
"[",
"]",
"byte",
"{",
"bz",
",",
"err",
":=",
"cdc",
".",
"MarshalBinaryBare",
"(",
"pubKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"r... | // Bytes marshals the PubKey using amino encoding. | [
"Bytes",
"marshals",
"the",
"PubKey",
"using",
"amino",
"encoding",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/ed25519/ed25519.go#L143-L149 |
131,368 | tendermint/tendermint | p2p/pex/pex_reactor.go | NewPEXReactor | func NewPEXReactor(b AddrBook, config *PEXReactorConfig) *PEXReactor {
r := &PEXReactor{
book: b,
config: config,
ensurePeersPeriod: defaultEnsurePeersPeriod,
requestsSent: cmn.NewCMap(),
lastReceivedRequests: cmn.NewCMap(),
crawlPeerInfos: make(map[p2p.ID]cra... | go | func NewPEXReactor(b AddrBook, config *PEXReactorConfig) *PEXReactor {
r := &PEXReactor{
book: b,
config: config,
ensurePeersPeriod: defaultEnsurePeersPeriod,
requestsSent: cmn.NewCMap(),
lastReceivedRequests: cmn.NewCMap(),
crawlPeerInfos: make(map[p2p.ID]cra... | [
"func",
"NewPEXReactor",
"(",
"b",
"AddrBook",
",",
"config",
"*",
"PEXReactorConfig",
")",
"*",
"PEXReactor",
"{",
"r",
":=",
"&",
"PEXReactor",
"{",
"book",
":",
"b",
",",
"config",
":",
"config",
",",
"ensurePeersPeriod",
":",
"defaultEnsurePeersPeriod",
... | // NewPEXReactor creates new PEX reactor. | [
"NewPEXReactor",
"creates",
"new",
"PEX",
"reactor",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L106-L117 |
131,369 | tendermint/tendermint | p2p/pex/pex_reactor.go | Receive | func (r *PEXReactor) Receive(chID byte, src Peer, msgBytes []byte) {
msg, err := decodeMsg(msgBytes)
if err != nil {
r.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes)
r.Switch.StopPeerForError(src, err)
return
}
r.Logger.Debug("Received message", "sr... | go | func (r *PEXReactor) Receive(chID byte, src Peer, msgBytes []byte) {
msg, err := decodeMsg(msgBytes)
if err != nil {
r.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes)
r.Switch.StopPeerForError(src, err)
return
}
r.Logger.Debug("Received message", "sr... | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"Receive",
"(",
"chID",
"byte",
",",
"src",
"Peer",
",",
"msgBytes",
"[",
"]",
"byte",
")",
"{",
"msg",
",",
"err",
":=",
"decodeMsg",
"(",
"msgBytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r",
".",
... | // Receive implements Reactor by handling incoming PEX messages. | [
"Receive",
"implements",
"Reactor",
"by",
"handling",
"incoming",
"PEX",
"messages",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L209-L264 |
131,370 | tendermint/tendermint | p2p/pex/pex_reactor.go | receiveRequest | func (r *PEXReactor) receiveRequest(src Peer) error {
id := string(src.ID())
v := r.lastReceivedRequests.Get(id)
if v == nil {
// initialize with empty time
lastReceived := time.Time{}
r.lastReceivedRequests.Set(id, lastReceived)
return nil
}
lastReceived := v.(time.Time)
if lastReceived.Equal(time.Time{... | go | func (r *PEXReactor) receiveRequest(src Peer) error {
id := string(src.ID())
v := r.lastReceivedRequests.Get(id)
if v == nil {
// initialize with empty time
lastReceived := time.Time{}
r.lastReceivedRequests.Set(id, lastReceived)
return nil
}
lastReceived := v.(time.Time)
if lastReceived.Equal(time.Time{... | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"receiveRequest",
"(",
"src",
"Peer",
")",
"error",
"{",
"id",
":=",
"string",
"(",
"src",
".",
"ID",
"(",
")",
")",
"\n",
"v",
":=",
"r",
".",
"lastReceivedRequests",
".",
"Get",
"(",
"id",
")",
"\n",
"i... | // enforces a minimum amount of time between requests | [
"enforces",
"a",
"minimum",
"amount",
"of",
"time",
"between",
"requests"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L267-L297 |
131,371 | tendermint/tendermint | p2p/pex/pex_reactor.go | RequestAddrs | func (r *PEXReactor) RequestAddrs(p Peer) {
r.Logger.Debug("Request addrs", "from", p)
id := string(p.ID())
if r.requestsSent.Has(id) {
return
}
r.requestsSent.Set(id, struct{}{})
p.Send(PexChannel, cdc.MustMarshalBinaryBare(&pexRequestMessage{}))
} | go | func (r *PEXReactor) RequestAddrs(p Peer) {
r.Logger.Debug("Request addrs", "from", p)
id := string(p.ID())
if r.requestsSent.Has(id) {
return
}
r.requestsSent.Set(id, struct{}{})
p.Send(PexChannel, cdc.MustMarshalBinaryBare(&pexRequestMessage{}))
} | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"RequestAddrs",
"(",
"p",
"Peer",
")",
"{",
"r",
".",
"Logger",
".",
"Debug",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"p",
")",
"\n",
"id",
":=",
"string",
"(",
"p",
".",
"ID",
"(",
")",
")",
"\n",
"... | // RequestAddrs asks peer for more addresses if we do not already
// have a request out for this peer. | [
"RequestAddrs",
"asks",
"peer",
"for",
"more",
"addresses",
"if",
"we",
"do",
"not",
"already",
"have",
"a",
"request",
"out",
"for",
"this",
"peer",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L301-L309 |
131,372 | tendermint/tendermint | p2p/pex/pex_reactor.go | ReceiveAddrs | func (r *PEXReactor) ReceiveAddrs(addrs []*p2p.NetAddress, src Peer) error {
id := string(src.ID())
if !r.requestsSent.Has(id) {
return errors.New("Unsolicited pexAddrsMessage")
}
r.requestsSent.Delete(id)
srcAddr, err := src.NodeInfo().NetAddress()
if err != nil {
return err
}
for _, netAddr := range addr... | go | func (r *PEXReactor) ReceiveAddrs(addrs []*p2p.NetAddress, src Peer) error {
id := string(src.ID())
if !r.requestsSent.Has(id) {
return errors.New("Unsolicited pexAddrsMessage")
}
r.requestsSent.Delete(id)
srcAddr, err := src.NodeInfo().NetAddress()
if err != nil {
return err
}
for _, netAddr := range addr... | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"ReceiveAddrs",
"(",
"addrs",
"[",
"]",
"*",
"p2p",
".",
"NetAddress",
",",
"src",
"Peer",
")",
"error",
"{",
"id",
":=",
"string",
"(",
"src",
".",
"ID",
"(",
")",
")",
"\n",
"if",
"!",
"r",
".",
"requ... | // ReceiveAddrs adds the given addrs to the addrbook if theres an open
// request for this peer and deletes the open request.
// If there's no open request for the src peer, it returns an error. | [
"ReceiveAddrs",
"adds",
"the",
"given",
"addrs",
"to",
"the",
"addrbook",
"if",
"theres",
"an",
"open",
"request",
"for",
"this",
"peer",
"and",
"deletes",
"the",
"open",
"request",
".",
"If",
"there",
"s",
"no",
"open",
"request",
"for",
"the",
"src",
"... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L314-L358 |
131,373 | tendermint/tendermint | p2p/pex/pex_reactor.go | SendAddrs | func (r *PEXReactor) SendAddrs(p Peer, netAddrs []*p2p.NetAddress) {
p.Send(PexChannel, cdc.MustMarshalBinaryBare(&pexAddrsMessage{Addrs: netAddrs}))
} | go | func (r *PEXReactor) SendAddrs(p Peer, netAddrs []*p2p.NetAddress) {
p.Send(PexChannel, cdc.MustMarshalBinaryBare(&pexAddrsMessage{Addrs: netAddrs}))
} | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"SendAddrs",
"(",
"p",
"Peer",
",",
"netAddrs",
"[",
"]",
"*",
"p2p",
".",
"NetAddress",
")",
"{",
"p",
".",
"Send",
"(",
"PexChannel",
",",
"cdc",
".",
"MustMarshalBinaryBare",
"(",
"&",
"pexAddrsMessage",
"{"... | // SendAddrs sends addrs to the peer. | [
"SendAddrs",
"sends",
"addrs",
"to",
"the",
"peer",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L361-L363 |
131,374 | tendermint/tendermint | p2p/pex/pex_reactor.go | checkSeeds | func (r *PEXReactor) checkSeeds() (numOnline int, netAddrs []*p2p.NetAddress, err error) {
lSeeds := len(r.config.Seeds)
if lSeeds == 0 {
return -1, nil, nil
}
netAddrs, errs := p2p.NewNetAddressStrings(r.config.Seeds)
numOnline = lSeeds - len(errs)
for _, err := range errs {
switch e := err.(type) {
case p... | go | func (r *PEXReactor) checkSeeds() (numOnline int, netAddrs []*p2p.NetAddress, err error) {
lSeeds := len(r.config.Seeds)
if lSeeds == 0 {
return -1, nil, nil
}
netAddrs, errs := p2p.NewNetAddressStrings(r.config.Seeds)
numOnline = lSeeds - len(errs)
for _, err := range errs {
switch e := err.(type) {
case p... | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"checkSeeds",
"(",
")",
"(",
"numOnline",
"int",
",",
"netAddrs",
"[",
"]",
"*",
"p2p",
".",
"NetAddress",
",",
"err",
"error",
")",
"{",
"lSeeds",
":=",
"len",
"(",
"r",
".",
"config",
".",
"Seeds",
")",
... | // checkSeeds checks that addresses are well formed.
// Returns number of seeds we can connect to, along with all seeds addrs.
// return err if user provided any badly formatted seed addresses.
// Doesn't error if the seed node can't be reached.
// numOnline returns -1 if no seed nodes were in the initial configuration... | [
"checkSeeds",
"checks",
"that",
"addresses",
"are",
"well",
"formed",
".",
"Returns",
"number",
"of",
"seeds",
"we",
"can",
"connect",
"to",
"along",
"with",
"all",
"seeds",
"addrs",
".",
"return",
"err",
"if",
"user",
"provided",
"any",
"badly",
"formatted"... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L535-L551 |
131,375 | tendermint/tendermint | p2p/pex/pex_reactor.go | dialSeeds | func (r *PEXReactor) dialSeeds() {
perm := cmn.RandPerm(len(r.seedAddrs))
// perm := r.Switch.rng.Perm(lSeeds)
for _, i := range perm {
// dial a random seed
seedAddr := r.seedAddrs[i]
err := r.Switch.DialPeerWithAddress(seedAddr, false)
if err == nil {
return
}
r.Switch.Logger.Error("Error dialing se... | go | func (r *PEXReactor) dialSeeds() {
perm := cmn.RandPerm(len(r.seedAddrs))
// perm := r.Switch.rng.Perm(lSeeds)
for _, i := range perm {
// dial a random seed
seedAddr := r.seedAddrs[i]
err := r.Switch.DialPeerWithAddress(seedAddr, false)
if err == nil {
return
}
r.Switch.Logger.Error("Error dialing se... | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"dialSeeds",
"(",
")",
"{",
"perm",
":=",
"cmn",
".",
"RandPerm",
"(",
"len",
"(",
"r",
".",
"seedAddrs",
")",
")",
"\n",
"// perm := r.Switch.rng.Perm(lSeeds)",
"for",
"_",
",",
"i",
":=",
"range",
"perm",
"{"... | // randomly dial seeds until we connect to one or exhaust them | [
"randomly",
"dial",
"seeds",
"until",
"we",
"connect",
"to",
"one",
"or",
"exhaust",
"them"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L554-L567 |
131,376 | tendermint/tendermint | p2p/pex/pex_reactor.go | AttemptsToDial | func (r *PEXReactor) AttemptsToDial(addr *p2p.NetAddress) int {
lAttempts, attempted := r.attemptsToDial.Load(addr.DialString())
if attempted {
return lAttempts.(_attemptsToDial).number
}
return 0
} | go | func (r *PEXReactor) AttemptsToDial(addr *p2p.NetAddress) int {
lAttempts, attempted := r.attemptsToDial.Load(addr.DialString())
if attempted {
return lAttempts.(_attemptsToDial).number
}
return 0
} | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"AttemptsToDial",
"(",
"addr",
"*",
"p2p",
".",
"NetAddress",
")",
"int",
"{",
"lAttempts",
",",
"attempted",
":=",
"r",
".",
"attemptsToDial",
".",
"Load",
"(",
"addr",
".",
"DialString",
"(",
")",
")",
"\n",
... | // AttemptsToDial returns the number of attempts to dial specific address. It
// returns 0 if never attempted or successfully connected. | [
"AttemptsToDial",
"returns",
"the",
"number",
"of",
"attempts",
"to",
"dial",
"specific",
"address",
".",
"It",
"returns",
"0",
"if",
"never",
"attempted",
"or",
"successfully",
"connected",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L571-L577 |
131,377 | tendermint/tendermint | p2p/pex/pex_reactor.go | nodeHasSomePeersOrDialingAny | func (r *PEXReactor) nodeHasSomePeersOrDialingAny() bool {
out, in, dial := r.Switch.NumPeers()
return out+in+dial > 0
} | go | func (r *PEXReactor) nodeHasSomePeersOrDialingAny() bool {
out, in, dial := r.Switch.NumPeers()
return out+in+dial > 0
} | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"nodeHasSomePeersOrDialingAny",
"(",
")",
"bool",
"{",
"out",
",",
"in",
",",
"dial",
":=",
"r",
".",
"Switch",
".",
"NumPeers",
"(",
")",
"\n",
"return",
"out",
"+",
"in",
"+",
"dial",
">",
"0",
"\n",
"}"
... | // nodeHasSomePeersOrDialingAny returns true if the node is connected to some
// peers or dialing them currently. | [
"nodeHasSomePeersOrDialingAny",
"returns",
"true",
"if",
"the",
"node",
"is",
"connected",
"to",
"some",
"peers",
"or",
"dialing",
"them",
"currently",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L605-L608 |
131,378 | tendermint/tendermint | p2p/pex/pex_reactor.go | crawlPeers | func (r *PEXReactor) crawlPeers(addrs []*p2p.NetAddress) {
now := time.Now()
for _, addr := range addrs {
peerInfo, ok := r.crawlPeerInfos[addr.ID]
// Do not attempt to connect with peers we recently crawled.
if ok && now.Sub(peerInfo.LastCrawled) < minTimeBetweenCrawls {
continue
}
// Record crawling... | go | func (r *PEXReactor) crawlPeers(addrs []*p2p.NetAddress) {
now := time.Now()
for _, addr := range addrs {
peerInfo, ok := r.crawlPeerInfos[addr.ID]
// Do not attempt to connect with peers we recently crawled.
if ok && now.Sub(peerInfo.LastCrawled) < minTimeBetweenCrawls {
continue
}
// Record crawling... | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"crawlPeers",
"(",
"addrs",
"[",
"]",
"*",
"p2p",
".",
"NetAddress",
")",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"for",
"_",
",",
"addr",
":=",
"range",
"addrs",
"{",
"peerInfo",
",",
"ok... | // crawlPeers will crawl the network looking for new peer addresses. | [
"crawlPeers",
"will",
"crawl",
"the",
"network",
"looking",
"for",
"new",
"peer",
"addresses",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L619-L652 |
131,379 | tendermint/tendermint | p2p/pex/pex_reactor.go | attemptDisconnects | func (r *PEXReactor) attemptDisconnects() {
for _, peer := range r.Switch.Peers().List() {
if peer.Status().Duration < r.config.SeedDisconnectWaitPeriod {
continue
}
if peer.IsPersistent() {
continue
}
r.Switch.StopPeerGracefully(peer)
}
} | go | func (r *PEXReactor) attemptDisconnects() {
for _, peer := range r.Switch.Peers().List() {
if peer.Status().Duration < r.config.SeedDisconnectWaitPeriod {
continue
}
if peer.IsPersistent() {
continue
}
r.Switch.StopPeerGracefully(peer)
}
} | [
"func",
"(",
"r",
"*",
"PEXReactor",
")",
"attemptDisconnects",
"(",
")",
"{",
"for",
"_",
",",
"peer",
":=",
"range",
"r",
".",
"Switch",
".",
"Peers",
"(",
")",
".",
"List",
"(",
")",
"{",
"if",
"peer",
".",
"Status",
"(",
")",
".",
"Duration",... | // attemptDisconnects checks if we've been with each peer long enough to disconnect | [
"attemptDisconnects",
"checks",
"if",
"we",
"ve",
"been",
"with",
"each",
"peer",
"long",
"enough",
"to",
"disconnect"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/pex_reactor.go#L669-L679 |
131,380 | tendermint/tendermint | libs/flowrate/flowrate.go | SetREMA | func (m *Monitor) SetREMA(rEMA float64) {
m.mu.Lock()
m.rEMA = rEMA
m.samples++
m.mu.Unlock()
} | go | func (m *Monitor) SetREMA(rEMA float64) {
m.mu.Lock()
m.rEMA = rEMA
m.samples++
m.mu.Unlock()
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"SetREMA",
"(",
"rEMA",
"float64",
")",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"m",
".",
"rEMA",
"=",
"rEMA",
"\n",
"m",
".",
"samples",
"++",
"\n",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
... | // Hack to set the current rEMA. | [
"Hack",
"to",
"set",
"the",
"current",
"rEMA",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/flowrate/flowrate.go#L76-L81 |
131,381 | tendermint/tendermint | libs/flowrate/flowrate.go | Done | func (m *Monitor) Done() int64 {
m.mu.Lock()
if now := m.update(0); m.sBytes > 0 {
m.reset(now)
}
m.active = false
m.tLast = 0
n := m.bytes
m.mu.Unlock()
return n
} | go | func (m *Monitor) Done() int64 {
m.mu.Lock()
if now := m.update(0); m.sBytes > 0 {
m.reset(now)
}
m.active = false
m.tLast = 0
n := m.bytes
m.mu.Unlock()
return n
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Done",
"(",
")",
"int64",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"now",
":=",
"m",
".",
"update",
"(",
"0",
")",
";",
"m",
".",
"sBytes",
">",
"0",
"{",
"m",
".",
"reset",
"(",
"now... | // Done marks the transfer as finished and prevents any further updates or
// limiting. Instantaneous and current transfer rates drop to 0. Update, IO, and
// Limit methods become NOOPs. It returns the total number of bytes transferred. | [
"Done",
"marks",
"the",
"transfer",
"as",
"finished",
"and",
"prevents",
"any",
"further",
"updates",
"or",
"limiting",
".",
"Instantaneous",
"and",
"current",
"transfer",
"rates",
"drop",
"to",
"0",
".",
"Update",
"IO",
"and",
"Limit",
"methods",
"become",
... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/flowrate/flowrate.go#L92-L102 |
131,382 | tendermint/tendermint | libs/flowrate/flowrate.go | Status | func (m *Monitor) Status() Status {
m.mu.Lock()
now := m.update(0)
s := Status{
Active: m.active,
Start: clockToTime(m.start),
Duration: m.sLast - m.start,
Idle: now - m.tLast,
Bytes: m.bytes,
Samples: m.samples,
PeakRate: round(m.rPeak),
BytesRem: m.tBytes - m.bytes,
Progress: percent... | go | func (m *Monitor) Status() Status {
m.mu.Lock()
now := m.update(0)
s := Status{
Active: m.active,
Start: clockToTime(m.start),
Duration: m.sLast - m.start,
Idle: now - m.tLast,
Bytes: m.bytes,
Samples: m.samples,
PeakRate: round(m.rPeak),
BytesRem: m.tBytes - m.bytes,
Progress: percent... | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Status",
"(",
")",
"Status",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"now",
":=",
"m",
".",
"update",
"(",
"0",
")",
"\n",
"s",
":=",
"Status",
"{",
"Active",
":",
"m",
".",
"active",
",",
"... | // Status returns current transfer status information. The returned value
// becomes static after a call to Done. | [
"Status",
"returns",
"current",
"transfer",
"status",
"information",
".",
"The",
"returned",
"value",
"becomes",
"static",
"after",
"a",
"call",
"to",
"Done",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/flowrate/flowrate.go#L127-L163 |
131,383 | tendermint/tendermint | libs/flowrate/flowrate.go | SetTransferSize | func (m *Monitor) SetTransferSize(bytes int64) {
if bytes < 0 {
bytes = 0
}
m.mu.Lock()
m.tBytes = bytes
m.mu.Unlock()
} | go | func (m *Monitor) SetTransferSize(bytes int64) {
if bytes < 0 {
bytes = 0
}
m.mu.Lock()
m.tBytes = bytes
m.mu.Unlock()
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"SetTransferSize",
"(",
"bytes",
"int64",
")",
"{",
"if",
"bytes",
"<",
"0",
"{",
"bytes",
"=",
"0",
"\n",
"}",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"m",
".",
"tBytes",
"=",
"bytes",
"\n",
... | // SetTransferSize specifies the total size of the data transfer, which allows
// the Monitor to calculate the overall progress and time to completion. | [
"SetTransferSize",
"specifies",
"the",
"total",
"size",
"of",
"the",
"data",
"transfer",
"which",
"allows",
"the",
"Monitor",
"to",
"calculate",
"the",
"overall",
"progress",
"and",
"time",
"to",
"completion",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/flowrate/flowrate.go#L209-L216 |
131,384 | tendermint/tendermint | libs/flowrate/flowrate.go | reset | func (m *Monitor) reset(sampleTime time.Duration) {
m.bytes += m.sBytes
m.samples++
m.sBytes = 0
m.sLast = sampleTime
} | go | func (m *Monitor) reset(sampleTime time.Duration) {
m.bytes += m.sBytes
m.samples++
m.sBytes = 0
m.sLast = sampleTime
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"reset",
"(",
"sampleTime",
"time",
".",
"Duration",
")",
"{",
"m",
".",
"bytes",
"+=",
"m",
".",
"sBytes",
"\n",
"m",
".",
"samples",
"++",
"\n",
"m",
".",
"sBytes",
"=",
"0",
"\n",
"m",
".",
"sLast",
"="... | // reset clears the current sample state in preparation for the next sample. | [
"reset",
"clears",
"the",
"current",
"sample",
"state",
"in",
"preparation",
"for",
"the",
"next",
"sample",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/flowrate/flowrate.go#L249-L254 |
131,385 | tendermint/tendermint | libs/flowrate/flowrate.go | waitNextSample | func (m *Monitor) waitNextSample(now time.Duration) time.Duration {
const minWait = 5 * time.Millisecond
current := m.sLast
// sleep until the last sample time changes (ideally, just one iteration)
for m.sLast == current && m.active {
d := current + m.sRate - now
m.mu.Unlock()
if d < minWait {
d = minWait... | go | func (m *Monitor) waitNextSample(now time.Duration) time.Duration {
const minWait = 5 * time.Millisecond
current := m.sLast
// sleep until the last sample time changes (ideally, just one iteration)
for m.sLast == current && m.active {
d := current + m.sRate - now
m.mu.Unlock()
if d < minWait {
d = minWait... | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"waitNextSample",
"(",
"now",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"const",
"minWait",
"=",
"5",
"*",
"time",
".",
"Millisecond",
"\n",
"current",
":=",
"m",
".",
"sLast",
"\n\n",
"// sleep ... | // waitNextSample sleeps for the remainder of the current sample. The lock is
// released and reacquired during the actual sleep period, so it's possible for
// the transfer to be inactive when this method returns. | [
"waitNextSample",
"sleeps",
"for",
"the",
"remainder",
"of",
"the",
"current",
"sample",
".",
"The",
"lock",
"is",
"released",
"and",
"reacquired",
"during",
"the",
"actual",
"sleep",
"period",
"so",
"it",
"s",
"possible",
"for",
"the",
"transfer",
"to",
"be... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/flowrate/flowrate.go#L259-L275 |
131,386 | tendermint/tendermint | abci/client/socket_client.go | StopForError | func (cli *socketClient) StopForError(err error) {
if !cli.IsRunning() {
return
}
cli.mtx.Lock()
if cli.err == nil {
cli.err = err
}
cli.mtx.Unlock()
cli.Logger.Error(fmt.Sprintf("Stopping abci.socketClient for error: %v", err.Error()))
cli.Stop()
} | go | func (cli *socketClient) StopForError(err error) {
if !cli.IsRunning() {
return
}
cli.mtx.Lock()
if cli.err == nil {
cli.err = err
}
cli.mtx.Unlock()
cli.Logger.Error(fmt.Sprintf("Stopping abci.socketClient for error: %v", err.Error()))
cli.Stop()
} | [
"func",
"(",
"cli",
"*",
"socketClient",
")",
"StopForError",
"(",
"err",
"error",
")",
"{",
"if",
"!",
"cli",
".",
"IsRunning",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"cli",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"if",
"cli",
".",
"err",
... | // Stop the client and set the error | [
"Stop",
"the",
"client",
"and",
"set",
"the",
"error"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/client/socket_client.go#L98-L111 |
131,387 | tendermint/tendermint | p2p/switch.go | MConnConfig | func MConnConfig(cfg *config.P2PConfig) conn.MConnConfig {
mConfig := conn.DefaultMConnConfig()
mConfig.FlushThrottle = cfg.FlushThrottleTimeout
mConfig.SendRate = cfg.SendRate
mConfig.RecvRate = cfg.RecvRate
mConfig.MaxPacketMsgPayloadSize = cfg.MaxPacketMsgPayloadSize
return mConfig
} | go | func MConnConfig(cfg *config.P2PConfig) conn.MConnConfig {
mConfig := conn.DefaultMConnConfig()
mConfig.FlushThrottle = cfg.FlushThrottleTimeout
mConfig.SendRate = cfg.SendRate
mConfig.RecvRate = cfg.RecvRate
mConfig.MaxPacketMsgPayloadSize = cfg.MaxPacketMsgPayloadSize
return mConfig
} | [
"func",
"MConnConfig",
"(",
"cfg",
"*",
"config",
".",
"P2PConfig",
")",
"conn",
".",
"MConnConfig",
"{",
"mConfig",
":=",
"conn",
".",
"DefaultMConnConfig",
"(",
")",
"\n",
"mConfig",
".",
"FlushThrottle",
"=",
"cfg",
".",
"FlushThrottleTimeout",
"\n",
"mCo... | // MConnConfig returns an MConnConfig with fields updated
// from the P2PConfig. | [
"MConnConfig",
"returns",
"an",
"MConnConfig",
"with",
"fields",
"updated",
"from",
"the",
"P2PConfig",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L34-L41 |
131,388 | tendermint/tendermint | p2p/switch.go | NewSwitch | func NewSwitch(
cfg *config.P2PConfig,
transport Transport,
options ...SwitchOption,
) *Switch {
sw := &Switch{
config: cfg,
reactors: make(map[string]Reactor),
chDescs: make([]*conn.ChannelDescriptor, 0),
reactorsByCh: make(map[byte]Reactor),
peers: NewPeerSet(),
dialing: ... | go | func NewSwitch(
cfg *config.P2PConfig,
transport Transport,
options ...SwitchOption,
) *Switch {
sw := &Switch{
config: cfg,
reactors: make(map[string]Reactor),
chDescs: make([]*conn.ChannelDescriptor, 0),
reactorsByCh: make(map[byte]Reactor),
peers: NewPeerSet(),
dialing: ... | [
"func",
"NewSwitch",
"(",
"cfg",
"*",
"config",
".",
"P2PConfig",
",",
"transport",
"Transport",
",",
"options",
"...",
"SwitchOption",
",",
")",
"*",
"Switch",
"{",
"sw",
":=",
"&",
"Switch",
"{",
"config",
":",
"cfg",
",",
"reactors",
":",
"make",
"(... | // NewSwitch creates a new Switch with the given config. | [
"NewSwitch",
"creates",
"a",
"new",
"Switch",
"with",
"the",
"given",
"config",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L101-L129 |
131,389 | tendermint/tendermint | p2p/switch.go | SwitchFilterTimeout | func SwitchFilterTimeout(timeout time.Duration) SwitchOption {
return func(sw *Switch) { sw.filterTimeout = timeout }
} | go | func SwitchFilterTimeout(timeout time.Duration) SwitchOption {
return func(sw *Switch) { sw.filterTimeout = timeout }
} | [
"func",
"SwitchFilterTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"SwitchOption",
"{",
"return",
"func",
"(",
"sw",
"*",
"Switch",
")",
"{",
"sw",
".",
"filterTimeout",
"=",
"timeout",
"}",
"\n",
"}"
] | // SwitchFilterTimeout sets the timeout used for peer filters. | [
"SwitchFilterTimeout",
"sets",
"the",
"timeout",
"used",
"for",
"peer",
"filters",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L132-L134 |
131,390 | tendermint/tendermint | p2p/switch.go | OnStop | func (sw *Switch) OnStop() {
// Stop peers
for _, p := range sw.peers.List() {
sw.transport.Cleanup(p)
p.Stop()
if sw.peers.Remove(p) {
sw.metrics.Peers.Add(float64(-1))
}
}
// Stop reactors
sw.Logger.Debug("Switch: Stopping reactors")
for _, reactor := range sw.reactors {
reactor.Stop()
}
} | go | func (sw *Switch) OnStop() {
// Stop peers
for _, p := range sw.peers.List() {
sw.transport.Cleanup(p)
p.Stop()
if sw.peers.Remove(p) {
sw.metrics.Peers.Add(float64(-1))
}
}
// Stop reactors
sw.Logger.Debug("Switch: Stopping reactors")
for _, reactor := range sw.reactors {
reactor.Stop()
}
} | [
"func",
"(",
"sw",
"*",
"Switch",
")",
"OnStop",
"(",
")",
"{",
"// Stop peers",
"for",
"_",
",",
"p",
":=",
"range",
"sw",
".",
"peers",
".",
"List",
"(",
")",
"{",
"sw",
".",
"transport",
".",
"Cleanup",
"(",
"p",
")",
"\n",
"p",
".",
"Stop",... | // OnStop implements BaseService. It stops all peers and reactors. | [
"OnStop",
"implements",
"BaseService",
".",
"It",
"stops",
"all",
"peers",
"and",
"reactors",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L218-L233 |
131,391 | tendermint/tendermint | p2p/switch.go | MarkPeerAsGood | func (sw *Switch) MarkPeerAsGood(peer Peer) {
if sw.addrBook != nil {
sw.addrBook.MarkGood(peer.ID())
}
} | go | func (sw *Switch) MarkPeerAsGood(peer Peer) {
if sw.addrBook != nil {
sw.addrBook.MarkGood(peer.ID())
}
} | [
"func",
"(",
"sw",
"*",
"Switch",
")",
"MarkPeerAsGood",
"(",
"peer",
"Peer",
")",
"{",
"if",
"sw",
".",
"addrBook",
"!=",
"nil",
"{",
"sw",
".",
"addrBook",
".",
"MarkGood",
"(",
"peer",
".",
"ID",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
] | // MarkPeerAsGood marks the given peer as good when it did something useful
// like contributed to consensus. | [
"MarkPeerAsGood",
"marks",
"the",
"given",
"peer",
"as",
"good",
"when",
"it",
"did",
"something",
"useful",
"like",
"contributed",
"to",
"consensus",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L386-L390 |
131,392 | tendermint/tendermint | p2p/switch.go | DialPeerWithAddress | func (sw *Switch) DialPeerWithAddress(addr *NetAddress, persistent bool) error {
if sw.IsDialingOrExistingAddress(addr) {
return ErrCurrentlyDialingOrExistingAddress{addr.String()}
}
sw.dialing.Set(string(addr.ID), addr)
defer sw.dialing.Delete(string(addr.ID))
return sw.addOutboundPeerWithConfig(addr, sw.conf... | go | func (sw *Switch) DialPeerWithAddress(addr *NetAddress, persistent bool) error {
if sw.IsDialingOrExistingAddress(addr) {
return ErrCurrentlyDialingOrExistingAddress{addr.String()}
}
sw.dialing.Set(string(addr.ID), addr)
defer sw.dialing.Delete(string(addr.ID))
return sw.addOutboundPeerWithConfig(addr, sw.conf... | [
"func",
"(",
"sw",
"*",
"Switch",
")",
"DialPeerWithAddress",
"(",
"addr",
"*",
"NetAddress",
",",
"persistent",
"bool",
")",
"error",
"{",
"if",
"sw",
".",
"IsDialingOrExistingAddress",
"(",
"addr",
")",
"{",
"return",
"ErrCurrentlyDialingOrExistingAddress",
"{... | // DialPeerWithAddress dials the given peer and runs sw.addPeer if it connects
// and authenticates successfully.
// If `persistent == true`, the switch will always try to reconnect to this
// peer if the connection ever fails.
// If we're currently dialing this address or it belongs to an existing peer,
// ErrCurrentl... | [
"DialPeerWithAddress",
"dials",
"the",
"given",
"peer",
"and",
"runs",
"sw",
".",
"addPeer",
"if",
"it",
"connects",
"and",
"authenticates",
"successfully",
".",
"If",
"persistent",
"==",
"true",
"the",
"switch",
"will",
"always",
"try",
"to",
"reconnect",
"to... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L473-L482 |
131,393 | tendermint/tendermint | p2p/switch.go | IsDialingOrExistingAddress | func (sw *Switch) IsDialingOrExistingAddress(addr *NetAddress) bool {
return sw.dialing.Has(string(addr.ID)) ||
sw.peers.Has(addr.ID) ||
(!sw.config.AllowDuplicateIP && sw.peers.HasIP(addr.IP))
} | go | func (sw *Switch) IsDialingOrExistingAddress(addr *NetAddress) bool {
return sw.dialing.Has(string(addr.ID)) ||
sw.peers.Has(addr.ID) ||
(!sw.config.AllowDuplicateIP && sw.peers.HasIP(addr.IP))
} | [
"func",
"(",
"sw",
"*",
"Switch",
")",
"IsDialingOrExistingAddress",
"(",
"addr",
"*",
"NetAddress",
")",
"bool",
"{",
"return",
"sw",
".",
"dialing",
".",
"Has",
"(",
"string",
"(",
"addr",
".",
"ID",
")",
")",
"||",
"sw",
".",
"peers",
".",
"Has",
... | // IsDialingOrExistingAddress returns true if switch has a peer with the given
// address or dialing it at the moment. | [
"IsDialingOrExistingAddress",
"returns",
"true",
"if",
"switch",
"has",
"a",
"peer",
"with",
"the",
"given",
"address",
"or",
"dialing",
"it",
"at",
"the",
"moment",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L492-L496 |
131,394 | tendermint/tendermint | p2p/switch.go | addOutboundPeerWithConfig | func (sw *Switch) addOutboundPeerWithConfig(
addr *NetAddress,
cfg *config.P2PConfig,
persistent bool,
) error {
sw.Logger.Info("Dialing peer", "address", addr)
// XXX(xla): Remove the leakage of test concerns in implementation.
if cfg.TestDialFail {
go sw.reconnectToPeer(addr)
return fmt.Errorf("dial err (p... | go | func (sw *Switch) addOutboundPeerWithConfig(
addr *NetAddress,
cfg *config.P2PConfig,
persistent bool,
) error {
sw.Logger.Info("Dialing peer", "address", addr)
// XXX(xla): Remove the leakage of test concerns in implementation.
if cfg.TestDialFail {
go sw.reconnectToPeer(addr)
return fmt.Errorf("dial err (p... | [
"func",
"(",
"sw",
"*",
"Switch",
")",
"addOutboundPeerWithConfig",
"(",
"addr",
"*",
"NetAddress",
",",
"cfg",
"*",
"config",
".",
"P2PConfig",
",",
"persistent",
"bool",
",",
")",
"error",
"{",
"sw",
".",
"Logger",
".",
"Info",
"(",
"\"",
"\"",
",",
... | // dial the peer; make secret connection; authenticate against the dialed ID;
// add the peer.
// if dialing fails, start the reconnect loop. If handhsake fails, its over.
// If peer is started succesffuly, reconnectLoop will start when
// StopPeerForError is called | [
"dial",
"the",
"peer",
";",
"make",
"secret",
"connection",
";",
"authenticate",
"against",
"the",
"dialed",
"ID",
";",
"add",
"the",
"peer",
".",
"if",
"dialing",
"fails",
"start",
"the",
"reconnect",
"loop",
".",
"If",
"handhsake",
"fails",
"its",
"over"... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L587-L638 |
131,395 | tendermint/tendermint | p2p/switch.go | addPeer | func (sw *Switch) addPeer(p Peer) error {
if err := sw.filterPeer(p); err != nil {
return err
}
p.SetLogger(sw.Logger.With("peer", p.SocketAddr()))
// Handle the shut down case where the switch has stopped but we're
// concurrently trying to add a peer.
if !sw.IsRunning() {
// XXX should this return an erro... | go | func (sw *Switch) addPeer(p Peer) error {
if err := sw.filterPeer(p); err != nil {
return err
}
p.SetLogger(sw.Logger.With("peer", p.SocketAddr()))
// Handle the shut down case where the switch has stopped but we're
// concurrently trying to add a peer.
if !sw.IsRunning() {
// XXX should this return an erro... | [
"func",
"(",
"sw",
"*",
"Switch",
")",
"addPeer",
"(",
"p",
"Peer",
")",
"error",
"{",
"if",
"err",
":=",
"sw",
".",
"filterPeer",
"(",
"p",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"p",
".",
"SetLogger",
"(",
"sw"... | // addPeer starts up the Peer and adds it to the Switch. Error is returned if
// the peer is filtered out or failed to start or can't be added. | [
"addPeer",
"starts",
"up",
"the",
"Peer",
"and",
"adds",
"it",
"to",
"the",
"Switch",
".",
"Error",
"is",
"returned",
"if",
"the",
"peer",
"is",
"filtered",
"out",
"or",
"failed",
"to",
"start",
"or",
"can",
"t",
"be",
"added",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/switch.go#L670-L711 |
131,396 | tendermint/tendermint | libs/events/event_cache.go | FireEvent | func (evc *EventCache) FireEvent(event string, data EventData) {
// append to list (go will grow our backing array exponentially)
evc.events = append(evc.events, eventInfo{event, data})
} | go | func (evc *EventCache) FireEvent(event string, data EventData) {
// append to list (go will grow our backing array exponentially)
evc.events = append(evc.events, eventInfo{event, data})
} | [
"func",
"(",
"evc",
"*",
"EventCache",
")",
"FireEvent",
"(",
"event",
"string",
",",
"data",
"EventData",
")",
"{",
"// append to list (go will grow our backing array exponentially)",
"evc",
".",
"events",
"=",
"append",
"(",
"evc",
".",
"events",
",",
"eventInfo... | // Cache an event to be fired upon finality. | [
"Cache",
"an",
"event",
"to",
"be",
"fired",
"upon",
"finality",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/events/event_cache.go#L24-L27 |
131,397 | tendermint/tendermint | libs/events/event_cache.go | Flush | func (evc *EventCache) Flush() {
for _, ei := range evc.events {
evc.evsw.FireEvent(ei.event, ei.data)
}
// Clear the buffer, since we only add to it with append it's safe to just set it to nil and maybe safe an allocation
evc.events = nil
} | go | func (evc *EventCache) Flush() {
for _, ei := range evc.events {
evc.evsw.FireEvent(ei.event, ei.data)
}
// Clear the buffer, since we only add to it with append it's safe to just set it to nil and maybe safe an allocation
evc.events = nil
} | [
"func",
"(",
"evc",
"*",
"EventCache",
")",
"Flush",
"(",
")",
"{",
"for",
"_",
",",
"ei",
":=",
"range",
"evc",
".",
"events",
"{",
"evc",
".",
"evsw",
".",
"FireEvent",
"(",
"ei",
".",
"event",
",",
"ei",
".",
"data",
")",
"\n",
"}",
"\n",
... | // Fire events by running evsw.FireEvent on all cached events. Blocks.
// Clears cached events | [
"Fire",
"events",
"by",
"running",
"evsw",
".",
"FireEvent",
"on",
"all",
"cached",
"events",
".",
"Blocks",
".",
"Clears",
"cached",
"events"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/events/event_cache.go#L31-L37 |
131,398 | tendermint/tendermint | state/txindex/null/null.go | Get | func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
return nil, errors.New(`Indexing is disabled (set 'tx_index = "kv"' in config)`)
} | go | func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
return nil, errors.New(`Indexing is disabled (set 'tx_index = "kv"' in config)`)
} | [
"func",
"(",
"txi",
"*",
"TxIndex",
")",
"Get",
"(",
"hash",
"[",
"]",
"byte",
")",
"(",
"*",
"types",
".",
"TxResult",
",",
"error",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"`Indexing is disabled (set 'tx_index = \"kv\"' in config)`",
"... | // Get on a TxIndex is disabled and panics when invoked. | [
"Get",
"on",
"a",
"TxIndex",
"is",
"disabled",
"and",
"panics",
"when",
"invoked",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/txindex/null/null.go#L17-L19 |
131,399 | tendermint/tendermint | p2p/trust/config.go | DefaultConfig | func DefaultConfig() TrustMetricConfig {
return TrustMetricConfig{
ProportionalWeight: 0.4,
IntegralWeight: 0.6,
TrackingWindow: (time.Minute * 60 * 24) * 14, // 14 days.
IntervalLength: 1 * time.Minute,
}
} | go | func DefaultConfig() TrustMetricConfig {
return TrustMetricConfig{
ProportionalWeight: 0.4,
IntegralWeight: 0.6,
TrackingWindow: (time.Minute * 60 * 24) * 14, // 14 days.
IntervalLength: 1 * time.Minute,
}
} | [
"func",
"DefaultConfig",
"(",
")",
"TrustMetricConfig",
"{",
"return",
"TrustMetricConfig",
"{",
"ProportionalWeight",
":",
"0.4",
",",
"IntegralWeight",
":",
"0.6",
",",
"TrackingWindow",
":",
"(",
"time",
".",
"Minute",
"*",
"60",
"*",
"24",
")",
"*",
"14"... | // DefaultConfig returns a config with values that have been tested and produce desirable results | [
"DefaultConfig",
"returns",
"a",
"config",
"with",
"values",
"that",
"have",
"been",
"tested",
"and",
"produce",
"desirable",
"results"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/config.go#L24-L31 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.