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,000
tendermint/tendermint
types/results.go
ProveResult
func (a ABCIResults) ProveResult(i int) merkle.SimpleProof { _, proofs := merkle.SimpleProofsFromByteSlices(a.toByteSlices()) return *proofs[i] }
go
func (a ABCIResults) ProveResult(i int) merkle.SimpleProof { _, proofs := merkle.SimpleProofsFromByteSlices(a.toByteSlices()) return *proofs[i] }
[ "func", "(", "a", "ABCIResults", ")", "ProveResult", "(", "i", "int", ")", "merkle", ".", "SimpleProof", "{", "_", ",", "proofs", ":=", "merkle", ".", "SimpleProofsFromByteSlices", "(", "a", ".", "toByteSlices", "(", ")", ")", "\n", "return", "*", "proof...
// ProveResult returns a merkle proof of one result from the set
[ "ProveResult", "returns", "a", "merkle", "proof", "of", "one", "result", "from", "the", "set" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/results.go#L61-L64
131,001
tendermint/tendermint
libs/pubsub/subscription.go
NewSubscription
func NewSubscription(outCapacity int) *Subscription { return &Subscription{ out: make(chan Message, outCapacity), cancelled: make(chan struct{}), } }
go
func NewSubscription(outCapacity int) *Subscription { return &Subscription{ out: make(chan Message, outCapacity), cancelled: make(chan struct{}), } }
[ "func", "NewSubscription", "(", "outCapacity", "int", ")", "*", "Subscription", "{", "return", "&", "Subscription", "{", "out", ":", "make", "(", "chan", "Message", ",", "outCapacity", ")", ",", "cancelled", ":", "make", "(", "chan", "struct", "{", "}", ...
// NewSubscription returns a new subscription with the given outCapacity.
[ "NewSubscription", "returns", "a", "new", "subscription", "with", "the", "given", "outCapacity", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/pubsub/subscription.go#L31-L36
131,002
tendermint/tendermint
node/node.go
DefaultDBProvider
func DefaultDBProvider(ctx *DBContext) (dbm.DB, error) { dbType := dbm.DBBackendType(ctx.Config.DBBackend) return dbm.NewDB(ctx.ID, dbType, ctx.Config.DBDir()), nil }
go
func DefaultDBProvider(ctx *DBContext) (dbm.DB, error) { dbType := dbm.DBBackendType(ctx.Config.DBBackend) return dbm.NewDB(ctx.ID, dbType, ctx.Config.DBDir()), nil }
[ "func", "DefaultDBProvider", "(", "ctx", "*", "DBContext", ")", "(", "dbm", ".", "DB", ",", "error", ")", "{", "dbType", ":=", "dbm", ".", "DBBackendType", "(", "ctx", ".", "Config", ".", "DBBackend", ")", "\n", "return", "dbm", ".", "NewDB", "(", "c...
// DefaultDBProvider returns a database using the DBBackend and DBDir // specified in the ctx.Config.
[ "DefaultDBProvider", "returns", "a", "database", "using", "the", "DBBackend", "and", "DBDir", "specified", "in", "the", "ctx", ".", "Config", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L61-L64
131,003
tendermint/tendermint
node/node.go
DefaultNewNode
func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) { // Generate node PrivKey nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { return nil, err } // Convert old PrivValidator if it exists. oldPrivVal := config.OldPrivValidatorFile() newPrivValKey := config.PrivV...
go
func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) { // Generate node PrivKey nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { return nil, err } // Convert old PrivValidator if it exists. oldPrivVal := config.OldPrivValidatorFile() newPrivValKey := config.PrivV...
[ "func", "DefaultNewNode", "(", "config", "*", "cfg", ".", "Config", ",", "logger", "log", ".", "Logger", ")", "(", "*", "Node", ",", "error", ")", "{", "// Generate node PrivKey", "nodeKey", ",", "err", ":=", "p2p", ".", "LoadOrGenNodeKey", "(", "config", ...
// DefaultNewNode returns a Tendermint node with default settings for the // PrivValidator, ClientCreator, GenesisDoc, and DBProvider. // It implements NodeProvider.
[ "DefaultNewNode", "returns", "a", "Tendermint", "node", "with", "default", "settings", "for", "the", "PrivValidator", "ClientCreator", "GenesisDoc", "and", "DBProvider", ".", "It", "implements", "NodeProvider", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L85-L118
131,004
tendermint/tendermint
node/node.go
DefaultMetricsProvider
func DefaultMetricsProvider(config *cfg.InstrumentationConfig) MetricsProvider { return func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics) { if config.Prometheus { return cs.PrometheusMetrics(config.Namespace, "chain_id", chainID), p2p.PrometheusMetrics(config.Namespace, "chain_id",...
go
func DefaultMetricsProvider(config *cfg.InstrumentationConfig) MetricsProvider { return func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics) { if config.Prometheus { return cs.PrometheusMetrics(config.Namespace, "chain_id", chainID), p2p.PrometheusMetrics(config.Namespace, "chain_id",...
[ "func", "DefaultMetricsProvider", "(", "config", "*", "cfg", ".", "InstrumentationConfig", ")", "MetricsProvider", "{", "return", "func", "(", "chainID", "string", ")", "(", "*", "cs", ".", "Metrics", ",", "*", "p2p", ".", "Metrics", ",", "*", "mempl", "."...
// DefaultMetricsProvider returns Metrics build using Prometheus client library // if Prometheus is enabled. Otherwise, it returns no-op Metrics.
[ "DefaultMetricsProvider", "returns", "Metrics", "build", "using", "Prometheus", "client", "library", "if", "Prometheus", "is", "enabled", ".", "Otherwise", "it", "returns", "no", "-", "op", "Metrics", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L125-L135
131,005
tendermint/tendermint
node/node.go
OnStart
func (n *Node) OnStart() error { now := tmtime.Now() genTime := n.genesisDoc.GenesisTime if genTime.After(now) { n.Logger.Info("Genesis time is in the future. Sleeping until then...", "genTime", genTime) time.Sleep(genTime.Sub(now)) } // Add private IDs to addrbook to block those peers being added n.addrBook...
go
func (n *Node) OnStart() error { now := tmtime.Now() genTime := n.genesisDoc.GenesisTime if genTime.After(now) { n.Logger.Info("Genesis time is in the future. Sleeping until then...", "genTime", genTime) time.Sleep(genTime.Sub(now)) } // Add private IDs to addrbook to block those peers being added n.addrBook...
[ "func", "(", "n", "*", "Node", ")", "OnStart", "(", ")", "error", "{", "now", ":=", "tmtime", ".", "Now", "(", ")", "\n", "genTime", ":=", "n", ".", "genesisDoc", ".", "GenesisTime", "\n", "if", "genTime", ".", "After", "(", "now", ")", "{", "n",...
// OnStart starts the Node. It implements cmn.Service.
[ "OnStart", "starts", "the", "Node", ".", "It", "implements", "cmn", ".", "Service", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L550-L602
131,006
tendermint/tendermint
node/node.go
OnStop
func (n *Node) OnStop() { n.BaseService.OnStop() n.Logger.Info("Stopping Node") // first stop the non-reactor services n.eventBus.Stop() n.indexerService.Stop() // now stop the reactors // TODO: gracefully disconnect from peers. n.sw.Stop() // stop mempool WAL if n.config.Mempool.WalEnabled() { n.mempoo...
go
func (n *Node) OnStop() { n.BaseService.OnStop() n.Logger.Info("Stopping Node") // first stop the non-reactor services n.eventBus.Stop() n.indexerService.Stop() // now stop the reactors // TODO: gracefully disconnect from peers. n.sw.Stop() // stop mempool WAL if n.config.Mempool.WalEnabled() { n.mempoo...
[ "func", "(", "n", "*", "Node", ")", "OnStop", "(", ")", "{", "n", ".", "BaseService", ".", "OnStop", "(", ")", "\n\n", "n", ".", "Logger", ".", "Info", "(", "\"", "\"", ")", "\n\n", "// first stop the non-reactor services", "n", ".", "eventBus", ".", ...
// OnStop stops the Node. It implements cmn.Service.
[ "OnStop", "stops", "the", "Node", ".", "It", "implements", "cmn", ".", "Service", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L605-L647
131,007
tendermint/tendermint
node/node.go
ConfigureRPC
func (n *Node) ConfigureRPC() { rpccore.SetStateDB(n.stateDB) rpccore.SetBlockStore(n.blockStore) rpccore.SetConsensusState(n.consensusState) rpccore.SetMempool(n.mempoolReactor.Mempool) rpccore.SetEvidencePool(n.evidencePool) rpccore.SetP2PPeers(n.sw) rpccore.SetP2PTransport(n) pubKey := n.privValidator.GetPub...
go
func (n *Node) ConfigureRPC() { rpccore.SetStateDB(n.stateDB) rpccore.SetBlockStore(n.blockStore) rpccore.SetConsensusState(n.consensusState) rpccore.SetMempool(n.mempoolReactor.Mempool) rpccore.SetEvidencePool(n.evidencePool) rpccore.SetP2PPeers(n.sw) rpccore.SetP2PTransport(n) pubKey := n.privValidator.GetPub...
[ "func", "(", "n", "*", "Node", ")", "ConfigureRPC", "(", ")", "{", "rpccore", ".", "SetStateDB", "(", "n", ".", "stateDB", ")", "\n", "rpccore", ".", "SetBlockStore", "(", "n", ".", "blockStore", ")", "\n", "rpccore", ".", "SetConsensusState", "(", "n"...
// ConfigureRPC sets all variables in rpccore so they will serve // rpc calls from this node
[ "ConfigureRPC", "sets", "all", "variables", "in", "rpccore", "so", "they", "will", "serve", "rpc", "calls", "from", "this", "node" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L651-L669
131,008
tendermint/tendermint
node/node.go
startPrometheusServer
func (n *Node) startPrometheusServer(addr string) *http.Server { srv := &http.Server{ Addr: addr, Handler: promhttp.InstrumentMetricHandler( prometheus.DefaultRegisterer, promhttp.HandlerFor( prometheus.DefaultGatherer, promhttp.HandlerOpts{MaxRequestsInFlight: n.config.Instrumentation.MaxOpenConnection...
go
func (n *Node) startPrometheusServer(addr string) *http.Server { srv := &http.Server{ Addr: addr, Handler: promhttp.InstrumentMetricHandler( prometheus.DefaultRegisterer, promhttp.HandlerFor( prometheus.DefaultGatherer, promhttp.HandlerOpts{MaxRequestsInFlight: n.config.Instrumentation.MaxOpenConnection...
[ "func", "(", "n", "*", "Node", ")", "startPrometheusServer", "(", "addr", "string", ")", "*", "http", ".", "Server", "{", "srv", ":=", "&", "http", ".", "Server", "{", "Addr", ":", "addr", ",", "Handler", ":", "promhttp", ".", "InstrumentMetricHandler", ...
// startPrometheusServer starts a Prometheus HTTP server, listening for metrics // collectors on addr.
[ "startPrometheusServer", "starts", "a", "Prometheus", "HTTP", "server", "listening", "for", "metrics", "collectors", "on", "addr", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L763-L780
131,009
tendermint/tendermint
node/node.go
loadGenesisDoc
func loadGenesisDoc(db dbm.DB) (*types.GenesisDoc, error) { bytes := db.Get(genesisDocKey) if len(bytes) == 0 { return nil, errors.New("Genesis doc not found") } var genDoc *types.GenesisDoc err := cdc.UnmarshalJSON(bytes, &genDoc) if err != nil { cmn.PanicCrisis(fmt.Sprintf("Failed to load genesis doc due to...
go
func loadGenesisDoc(db dbm.DB) (*types.GenesisDoc, error) { bytes := db.Get(genesisDocKey) if len(bytes) == 0 { return nil, errors.New("Genesis doc not found") } var genDoc *types.GenesisDoc err := cdc.UnmarshalJSON(bytes, &genDoc) if err != nil { cmn.PanicCrisis(fmt.Sprintf("Failed to load genesis doc due to...
[ "func", "loadGenesisDoc", "(", "db", "dbm", ".", "DB", ")", "(", "*", "types", ".", "GenesisDoc", ",", "error", ")", "{", "bytes", ":=", "db", ".", "Get", "(", "genesisDocKey", ")", "\n", "if", "len", "(", "bytes", ")", "==", "0", "{", "return", ...
// panics if failed to unmarshal bytes
[ "panics", "if", "failed", "to", "unmarshal", "bytes" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L907-L918
131,010
tendermint/tendermint
node/node.go
saveGenesisDoc
func saveGenesisDoc(db dbm.DB, genDoc *types.GenesisDoc) { bytes, err := cdc.MarshalJSON(genDoc) if err != nil { cmn.PanicCrisis(fmt.Sprintf("Failed to save genesis doc due to marshaling error: %v", err)) } db.SetSync(genesisDocKey, bytes) }
go
func saveGenesisDoc(db dbm.DB, genDoc *types.GenesisDoc) { bytes, err := cdc.MarshalJSON(genDoc) if err != nil { cmn.PanicCrisis(fmt.Sprintf("Failed to save genesis doc due to marshaling error: %v", err)) } db.SetSync(genesisDocKey, bytes) }
[ "func", "saveGenesisDoc", "(", "db", "dbm", ".", "DB", ",", "genDoc", "*", "types", ".", "GenesisDoc", ")", "{", "bytes", ",", "err", ":=", "cdc", ".", "MarshalJSON", "(", "genDoc", ")", "\n", "if", "err", "!=", "nil", "{", "cmn", ".", "PanicCrisis",...
// panics if failed to marshal the given genesis document
[ "panics", "if", "failed", "to", "marshal", "the", "given", "genesis", "document" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L921-L927
131,011
tendermint/tendermint
node/node.go
splitAndTrimEmpty
func splitAndTrimEmpty(s, sep, cutset string) []string { if s == "" { return []string{} } spl := strings.Split(s, sep) nonEmptyStrings := make([]string, 0, len(spl)) for i := 0; i < len(spl); i++ { element := strings.Trim(spl[i], cutset) if element != "" { nonEmptyStrings = append(nonEmptyStrings, elemen...
go
func splitAndTrimEmpty(s, sep, cutset string) []string { if s == "" { return []string{} } spl := strings.Split(s, sep) nonEmptyStrings := make([]string, 0, len(spl)) for i := 0; i < len(spl); i++ { element := strings.Trim(spl[i], cutset) if element != "" { nonEmptyStrings = append(nonEmptyStrings, elemen...
[ "func", "splitAndTrimEmpty", "(", "s", ",", "sep", ",", "cutset", "string", ")", "[", "]", "string", "{", "if", "s", "==", "\"", "\"", "{", "return", "[", "]", "string", "{", "}", "\n", "}", "\n\n", "spl", ":=", "strings", ".", "Split", "(", "s",...
// splitAndTrimEmpty 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. ...
[ "splitAndTrimEmpty", "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", "remove...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/node/node.go#L967-L981
131,012
tendermint/tendermint
tools/tm-monitor/monitor/node.go
SetCheckIsValidatorInterval
func SetCheckIsValidatorInterval(d time.Duration) func(n *Node) { return func(n *Node) { n.checkIsValidatorInterval = d } }
go
func SetCheckIsValidatorInterval(d time.Duration) func(n *Node) { return func(n *Node) { n.checkIsValidatorInterval = d } }
[ "func", "SetCheckIsValidatorInterval", "(", "d", "time", ".", "Duration", ")", "func", "(", "n", "*", "Node", ")", "{", "return", "func", "(", "n", "*", "Node", ")", "{", "n", ".", "checkIsValidatorInterval", "=", "d", "\n", "}", "\n", "}" ]
// SetCheckIsValidatorInterval lets you change interval for checking whenever // node is still a validator or not.
[ "SetCheckIsValidatorInterval", "lets", "you", "change", "interval", "for", "checking", "whenever", "node", "is", "still", "a", "validator", "or", "not", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/monitor/node.go#L76-L80
131,013
tendermint/tendermint
tools/tm-monitor/monitor/node.go
SetLogger
func (n *Node) SetLogger(l log.Logger) { n.logger = l n.em.SetLogger(l) }
go
func (n *Node) SetLogger(l log.Logger) { n.logger = l n.em.SetLogger(l) }
[ "func", "(", "n", "*", "Node", ")", "SetLogger", "(", "l", "log", ".", "Logger", ")", "{", "n", ".", "logger", "=", "l", "\n", "n", ".", "em", ".", "SetLogger", "(", "l", ")", "\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/monitor/node.go#L95-L98
131,014
tendermint/tendermint
tools/tm-monitor/monitor/node.go
newBlockCallback
func newBlockCallback(n *Node) em.EventCallbackFunc { return func(metric *em.EventMetric, data interface{}) { block := data.(tmtypes.TMEventData).(tmtypes.EventDataNewBlockHeader).Header n.Height = block.Height n.logger.Info("new block", "height", block.Height, "numTxs", block.NumTxs) if n.blockCh != nil { ...
go
func newBlockCallback(n *Node) em.EventCallbackFunc { return func(metric *em.EventMetric, data interface{}) { block := data.(tmtypes.TMEventData).(tmtypes.EventDataNewBlockHeader).Header n.Height = block.Height n.logger.Info("new block", "height", block.Height, "numTxs", block.NumTxs) if n.blockCh != nil { ...
[ "func", "newBlockCallback", "(", "n", "*", "Node", ")", "em", ".", "EventCallbackFunc", "{", "return", "func", "(", "metric", "*", "em", ".", "EventMetric", ",", "data", "interface", "{", "}", ")", "{", "block", ":=", "data", ".", "(", "tmtypes", ".", ...
// implements eventmeter.EventCallbackFunc
[ "implements", "eventmeter", ".", "EventCallbackFunc" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/monitor/node.go#L129-L140
131,015
tendermint/tendermint
tools/tm-monitor/monitor/node.go
latencyCallback
func latencyCallback(n *Node) em.LatencyCallbackFunc { return func(latency float64) { n.BlockLatency = latency / 1000000.0 // ns to ms n.logger.Info("new block latency", "latency", n.BlockLatency) if n.blockLatencyCh != nil { n.blockLatencyCh <- latency } } }
go
func latencyCallback(n *Node) em.LatencyCallbackFunc { return func(latency float64) { n.BlockLatency = latency / 1000000.0 // ns to ms n.logger.Info("new block latency", "latency", n.BlockLatency) if n.blockLatencyCh != nil { n.blockLatencyCh <- latency } } }
[ "func", "latencyCallback", "(", "n", "*", "Node", ")", "em", ".", "LatencyCallbackFunc", "{", "return", "func", "(", "latency", "float64", ")", "{", "n", ".", "BlockLatency", "=", "latency", "/", "1000000.0", "// ns to ms", "\n", "n", ".", "logger", ".", ...
// implements eventmeter.EventLatencyFunc
[ "implements", "eventmeter", ".", "EventLatencyFunc" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/monitor/node.go#L143-L152
131,016
tendermint/tendermint
tools/tm-monitor/monitor/node.go
disconnectCallback
func disconnectCallback(n *Node) em.DisconnectCallbackFunc { return func() { n.Online = false n.logger.Info("status", "down") if n.disconnectCh != nil { n.disconnectCh <- true } } }
go
func disconnectCallback(n *Node) em.DisconnectCallbackFunc { return func() { n.Online = false n.logger.Info("status", "down") if n.disconnectCh != nil { n.disconnectCh <- true } } }
[ "func", "disconnectCallback", "(", "n", "*", "Node", ")", "em", ".", "DisconnectCallbackFunc", "{", "return", "func", "(", ")", "{", "n", ".", "Online", "=", "false", "\n", "n", ".", "logger", ".", "Info", "(", "\"", "\"", ",", "\"", "\"", ")", "\n...
// implements eventmeter.DisconnectCallbackFunc
[ "implements", "eventmeter", ".", "DisconnectCallbackFunc" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/monitor/node.go#L155-L164
131,017
tendermint/tendermint
tools/tm-monitor/monitor/node.go
UnmarshalEvent
func UnmarshalEvent(b json.RawMessage) (string, events.EventData, error) { event := new(ctypes.ResultEvent) if err := cdc.UnmarshalJSON(b, event); err != nil { return "", nil, err } return event.Query, event.Data, nil }
go
func UnmarshalEvent(b json.RawMessage) (string, events.EventData, error) { event := new(ctypes.ResultEvent) if err := cdc.UnmarshalJSON(b, event); err != nil { return "", nil, err } return event.Query, event.Data, nil }
[ "func", "UnmarshalEvent", "(", "b", "json", ".", "RawMessage", ")", "(", "string", ",", "events", ".", "EventData", ",", "error", ")", "{", "event", ":=", "new", "(", "ctypes", ".", "ResultEvent", ")", "\n", "if", "err", ":=", "cdc", ".", "UnmarshalJSO...
// UnmarshalEvent unmarshals a json event
[ "UnmarshalEvent", "unmarshals", "a", "json", "event" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/tools/tm-monitor/monitor/node.go#L254-L260
131,018
tendermint/tendermint
libs/db/util.go
IsKeyInDomain
func IsKeyInDomain(key, start, end []byte) bool { if bytes.Compare(key, start) < 0 { return false } if end != nil && bytes.Compare(end, key) <= 0 { return false } return true }
go
func IsKeyInDomain(key, start, end []byte) bool { if bytes.Compare(key, start) < 0 { return false } if end != nil && bytes.Compare(end, key) <= 0 { return false } return true }
[ "func", "IsKeyInDomain", "(", "key", ",", "start", ",", "end", "[", "]", "byte", ")", "bool", "{", "if", "bytes", ".", "Compare", "(", "key", ",", "start", ")", "<", "0", "{", "return", "false", "\n", "}", "\n", "if", "end", "!=", "nil", "&&", ...
// See DB interface documentation for more information.
[ "See", "DB", "interface", "documentation", "for", "more", "information", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/util.go#L37-L45
131,019
tendermint/tendermint
types/event_bus.go
NewEventBusWithBufferCapacity
func NewEventBusWithBufferCapacity(cap int) *EventBus { // capacity could be exposed later if needed pubsub := tmpubsub.NewServer(tmpubsub.BufferCapacity(cap)) b := &EventBus{pubsub: pubsub} b.BaseService = *cmn.NewBaseService(nil, "EventBus", b) return b }
go
func NewEventBusWithBufferCapacity(cap int) *EventBus { // capacity could be exposed later if needed pubsub := tmpubsub.NewServer(tmpubsub.BufferCapacity(cap)) b := &EventBus{pubsub: pubsub} b.BaseService = *cmn.NewBaseService(nil, "EventBus", b) return b }
[ "func", "NewEventBusWithBufferCapacity", "(", "cap", "int", ")", "*", "EventBus", "{", "// capacity could be exposed later if needed", "pubsub", ":=", "tmpubsub", ".", "NewServer", "(", "tmpubsub", ".", "BufferCapacity", "(", "cap", ")", ")", "\n", "b", ":=", "&",...
// NewEventBusWithBufferCapacity returns a new event bus with the given buffer capacity.
[ "NewEventBusWithBufferCapacity", "returns", "a", "new", "event", "bus", "with", "the", "given", "buffer", "capacity", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/event_bus.go#L43-L49
131,020
tendermint/tendermint
consensus/wal_generator.go
WALWithNBlocks
func WALWithNBlocks(t *testing.T, numBlocks int) (data []byte, err error) { var b bytes.Buffer wr := bufio.NewWriter(&b) if err := WALGenerateNBlocks(t, wr, numBlocks); err != nil { return []byte{}, err } wr.Flush() return b.Bytes(), nil }
go
func WALWithNBlocks(t *testing.T, numBlocks int) (data []byte, err error) { var b bytes.Buffer wr := bufio.NewWriter(&b) if err := WALGenerateNBlocks(t, wr, numBlocks); err != nil { return []byte{}, err } wr.Flush() return b.Bytes(), nil }
[ "func", "WALWithNBlocks", "(", "t", "*", "testing", ".", "T", ",", "numBlocks", "int", ")", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "var", "b", "bytes", ".", "Buffer", "\n", "wr", ":=", "bufio", ".", "NewWriter", "(", "&", "...
//WALWithNBlocks returns a WAL content with numBlocks.
[ "WALWithNBlocks", "returns", "a", "WAL", "content", "with", "numBlocks", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/wal_generator.go#L103-L113
131,021
tendermint/tendermint
consensus/wal_generator.go
getConfig
func getConfig(t *testing.T) *cfg.Config { c := cfg.ResetTestRoot(t.Name()) // and we use random ports to run in parallel tm, rpc, grpc := makeAddrs() c.P2P.ListenAddress = tm c.RPC.ListenAddress = rpc c.RPC.GRPCListenAddress = grpc return c }
go
func getConfig(t *testing.T) *cfg.Config { c := cfg.ResetTestRoot(t.Name()) // and we use random ports to run in parallel tm, rpc, grpc := makeAddrs() c.P2P.ListenAddress = tm c.RPC.ListenAddress = rpc c.RPC.GRPCListenAddress = grpc return c }
[ "func", "getConfig", "(", "t", "*", "testing", ".", "T", ")", "*", "cfg", ".", "Config", "{", "c", ":=", "cfg", ".", "ResetTestRoot", "(", "t", ".", "Name", "(", ")", ")", "\n\n", "// and we use random ports to run in parallel", "tm", ",", "rpc", ",", ...
// getConfig returns a config for test cases
[ "getConfig", "returns", "a", "config", "for", "test", "cases" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/wal_generator.go#L129-L138
131,022
tendermint/tendermint
consensus/wal_generator.go
Write
func (w *byteBufferWAL) Write(m WALMessage) { if w.stopped { w.logger.Debug("WAL already stopped. Not writing message", "msg", m) return } if endMsg, ok := m.(EndHeightMessage); ok { w.logger.Debug("WAL write end height message", "height", endMsg.Height, "stopHeight", w.heightToStop) if endMsg.Height == w.h...
go
func (w *byteBufferWAL) Write(m WALMessage) { if w.stopped { w.logger.Debug("WAL already stopped. Not writing message", "msg", m) return } if endMsg, ok := m.(EndHeightMessage); ok { w.logger.Debug("WAL write end height message", "height", endMsg.Height, "stopHeight", w.heightToStop) if endMsg.Height == w.h...
[ "func", "(", "w", "*", "byteBufferWAL", ")", "Write", "(", "m", "WALMessage", ")", "{", "if", "w", ".", "stopped", "{", "w", ".", "logger", ".", "Debug", "(", "\"", "\"", ",", "\"", "\"", ",", "m", ")", "\n", "return", "\n", "}", "\n\n", "if", ...
// Save writes message to the internal buffer except when heightToStop is // reached, in which case it will signal the caller via signalWhenStopsTo and // skip writing.
[ "Save", "writes", "message", "to", "the", "internal", "buffer", "except", "when", "heightToStop", "is", "reached", "in", "which", "case", "it", "will", "signal", "the", "caller", "via", "signalWhenStopsTo", "and", "skip", "writing", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/wal_generator.go#L167-L188
131,023
tendermint/tendermint
state/execution.go
NewBlockExecutor
func NewBlockExecutor(db dbm.DB, logger log.Logger, proxyApp proxy.AppConnConsensus, mempool Mempool, evpool EvidencePool, options ...BlockExecutorOption) *BlockExecutor { res := &BlockExecutor{ db: db, proxyApp: proxyApp, eventBus: types.NopEventBus{}, mempool: mempool, evpool: evpool, logger: ...
go
func NewBlockExecutor(db dbm.DB, logger log.Logger, proxyApp proxy.AppConnConsensus, mempool Mempool, evpool EvidencePool, options ...BlockExecutorOption) *BlockExecutor { res := &BlockExecutor{ db: db, proxyApp: proxyApp, eventBus: types.NopEventBus{}, mempool: mempool, evpool: evpool, logger: ...
[ "func", "NewBlockExecutor", "(", "db", "dbm", ".", "DB", ",", "logger", "log", ".", "Logger", ",", "proxyApp", "proxy", ".", "AppConnConsensus", ",", "mempool", "Mempool", ",", "evpool", "EvidencePool", ",", "options", "...", "BlockExecutorOption", ")", "*", ...
// NewBlockExecutor returns a new BlockExecutor with a NopEventBus. // Call SetEventBus to provide one.
[ "NewBlockExecutor", "returns", "a", "new", "BlockExecutor", "with", "a", "NopEventBus", ".", "Call", "SetEventBus", "to", "provide", "one", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/execution.go#L51-L67
131,024
tendermint/tendermint
state/execution.go
ValidateBlock
func (blockExec *BlockExecutor) ValidateBlock(state State, block *types.Block) error { return validateBlock(blockExec.evpool, blockExec.db, state, block) }
go
func (blockExec *BlockExecutor) ValidateBlock(state State, block *types.Block) error { return validateBlock(blockExec.evpool, blockExec.db, state, block) }
[ "func", "(", "blockExec", "*", "BlockExecutor", ")", "ValidateBlock", "(", "state", "State", ",", "block", "*", "types", ".", "Block", ")", "error", "{", "return", "validateBlock", "(", "blockExec", ".", "evpool", ",", "blockExec", ".", "db", ",", "state",...
// ValidateBlock validates the given block against the given state. // If the block is invalid, it returns an error. // Validation does not mutate state, but does require historical information from the stateDB, // ie. to verify evidence from a validator at an old height.
[ "ValidateBlock", "validates", "the", "given", "block", "against", "the", "given", "state", ".", "If", "the", "block", "is", "invalid", "it", "returns", "an", "error", ".", "Validation", "does", "not", "mutate", "state", "but", "does", "require", "historical", ...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/execution.go#L103-L105
131,025
tendermint/tendermint
state/execution.go
ApplyBlock
func (blockExec *BlockExecutor) ApplyBlock(state State, blockID types.BlockID, block *types.Block) (State, error) { if err := blockExec.ValidateBlock(state, block); err != nil { return state, ErrInvalidBlock(err) } startTime := time.Now().UnixNano() abciResponses, err := execBlockOnProxyApp(blockExec.logger, bl...
go
func (blockExec *BlockExecutor) ApplyBlock(state State, blockID types.BlockID, block *types.Block) (State, error) { if err := blockExec.ValidateBlock(state, block); err != nil { return state, ErrInvalidBlock(err) } startTime := time.Now().UnixNano() abciResponses, err := execBlockOnProxyApp(blockExec.logger, bl...
[ "func", "(", "blockExec", "*", "BlockExecutor", ")", "ApplyBlock", "(", "state", "State", ",", "blockID", "types", ".", "BlockID", ",", "block", "*", "types", ".", "Block", ")", "(", "State", ",", "error", ")", "{", "if", "err", ":=", "blockExec", ".",...
// ApplyBlock validates the block against the state, executes it against the app, // fires the relevant events, commits the app, and saves the new state and responses. // It's the only function that needs to be called // from outside this package to process and commit an entire block. // It takes a blockID to avoid rec...
[ "ApplyBlock", "validates", "the", "block", "against", "the", "state", "executes", "it", "against", "the", "app", "fires", "the", "relevant", "events", "commits", "the", "app", "and", "saves", "the", "new", "state", "and", "responses", ".", "It", "s", "the", ...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/execution.go#L112-L175
131,026
tendermint/tendermint
state/execution.go
updateState
func updateState( state State, blockID types.BlockID, header *types.Header, abciResponses *ABCIResponses, validatorUpdates []*types.Validator, ) (State, error) { // Copy the valset so we can apply changes from EndBlock // and update s.LastValidators and s.Validators. nValSet := state.NextValidators.Copy() //...
go
func updateState( state State, blockID types.BlockID, header *types.Header, abciResponses *ABCIResponses, validatorUpdates []*types.Validator, ) (State, error) { // Copy the valset so we can apply changes from EndBlock // and update s.LastValidators and s.Validators. nValSet := state.NextValidators.Copy() //...
[ "func", "updateState", "(", "state", "State", ",", "blockID", "types", ".", "BlockID", ",", "header", "*", "types", ".", "Header", ",", "abciResponses", "*", "ABCIResponses", ",", "validatorUpdates", "[", "]", "*", "types", ".", "Validator", ",", ")", "(",...
// updateState returns a new State updated according to the header and responses.
[ "updateState", "returns", "a", "new", "State", "updated", "according", "to", "the", "header", "and", "responses", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/execution.go#L370-L431
131,027
tendermint/tendermint
consensus/ticker.go
NewTimeoutTicker
func NewTimeoutTicker() TimeoutTicker { tt := &timeoutTicker{ timer: time.NewTimer(0), tickChan: make(chan timeoutInfo, tickTockBufferSize), tockChan: make(chan timeoutInfo, tickTockBufferSize), } tt.BaseService = *cmn.NewBaseService(nil, "TimeoutTicker", tt) tt.stopTimer() // don't want to fire until the ...
go
func NewTimeoutTicker() TimeoutTicker { tt := &timeoutTicker{ timer: time.NewTimer(0), tickChan: make(chan timeoutInfo, tickTockBufferSize), tockChan: make(chan timeoutInfo, tickTockBufferSize), } tt.BaseService = *cmn.NewBaseService(nil, "TimeoutTicker", tt) tt.stopTimer() // don't want to fire until the ...
[ "func", "NewTimeoutTicker", "(", ")", "TimeoutTicker", "{", "tt", ":=", "&", "timeoutTicker", "{", "timer", ":", "time", ".", "NewTimer", "(", "0", ")", ",", "tickChan", ":", "make", "(", "chan", "timeoutInfo", ",", "tickTockBufferSize", ")", ",", "tockCha...
// NewTimeoutTicker returns a new TimeoutTicker.
[ "NewTimeoutTicker", "returns", "a", "new", "TimeoutTicker", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/ticker.go#L40-L49
131,028
tendermint/tendermint
consensus/ticker.go
timeoutRoutine
func (t *timeoutTicker) timeoutRoutine() { t.Logger.Debug("Starting timeout routine") var ti timeoutInfo for { select { case newti := <-t.tickChan: t.Logger.Debug("Received tick", "old_ti", ti, "new_ti", newti) // ignore tickers for old height/round/step if newti.Height < ti.Height { continue } ...
go
func (t *timeoutTicker) timeoutRoutine() { t.Logger.Debug("Starting timeout routine") var ti timeoutInfo for { select { case newti := <-t.tickChan: t.Logger.Debug("Received tick", "old_ti", ti, "new_ti", newti) // ignore tickers for old height/round/step if newti.Height < ti.Height { continue } ...
[ "func", "(", "t", "*", "timeoutTicker", ")", "timeoutRoutine", "(", ")", "{", "t", ".", "Logger", ".", "Debug", "(", "\"", "\"", ")", "\n", "var", "ti", "timeoutInfo", "\n", "for", "{", "select", "{", "case", "newti", ":=", "<-", "t", ".", "tickCha...
// send on tickChan to start a new timer. // timers are interupted and replaced by new ticks from later steps // timeouts of 0 on the tickChan will be immediately relayed to the tockChan
[ "send", "on", "tickChan", "to", "start", "a", "new", "timer", ".", "timers", "are", "interupted", "and", "replaced", "by", "new", "ticks", "from", "later", "steps", "timeouts", "of", "0", "on", "the", "tickChan", "will", "be", "immediately", "relayed", "to...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/ticker.go#L94-L134
131,029
tendermint/tendermint
p2p/peer.go
RemoteIP
func (pc peerConn) RemoteIP() net.IP { if pc.ip != nil { return pc.ip } host, _, err := net.SplitHostPort(pc.conn.RemoteAddr().String()) if err != nil { panic(err) } ips, err := net.LookupIP(host) if err != nil { panic(err) } pc.ip = ips[0] return pc.ip }
go
func (pc peerConn) RemoteIP() net.IP { if pc.ip != nil { return pc.ip } host, _, err := net.SplitHostPort(pc.conn.RemoteAddr().String()) if err != nil { panic(err) } ips, err := net.LookupIP(host) if err != nil { panic(err) } pc.ip = ips[0] return pc.ip }
[ "func", "(", "pc", "peerConn", ")", "RemoteIP", "(", ")", "net", ".", "IP", "{", "if", "pc", ".", "ip", "!=", "nil", "{", "return", "pc", ".", "ip", "\n", "}", "\n\n", "host", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "pc", ...
// Return the IP from the connection RemoteAddr
[ "Return", "the", "IP", "from", "the", "connection", "RemoteAddr" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer.go#L76-L94
131,030
tendermint/tendermint
p2p/peer.go
String
func (p *peer) String() string { if p.outbound { return fmt.Sprintf("Peer{%v %v out}", p.mconn, p.ID()) } return fmt.Sprintf("Peer{%v %v in}", p.mconn, p.ID()) }
go
func (p *peer) String() string { if p.outbound { return fmt.Sprintf("Peer{%v %v out}", p.mconn, p.ID()) } return fmt.Sprintf("Peer{%v %v in}", p.mconn, p.ID()) }
[ "func", "(", "p", "*", "peer", ")", "String", "(", ")", "string", "{", "if", "p", ".", "outbound", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "mconn", ",", "p", ".", "ID", "(", ")", ")", "\n", "}", "\n\n", "return",...
// String representation.
[ "String", "representation", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer.go#L156-L162
131,031
tendermint/tendermint
p2p/peer.go
OnStart
func (p *peer) OnStart() error { if err := p.BaseService.OnStart(); err != nil { return err } if err := p.mconn.Start(); err != nil { return err } go p.metricsReporter() return nil }
go
func (p *peer) OnStart() error { if err := p.BaseService.OnStart(); err != nil { return err } if err := p.mconn.Start(); err != nil { return err } go p.metricsReporter() return nil }
[ "func", "(", "p", "*", "peer", ")", "OnStart", "(", ")", "error", "{", "if", "err", ":=", "p", ".", "BaseService", ".", "OnStart", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err", ":=", "p", ".", "mconn",...
// OnStart implements BaseService.
[ "OnStart", "implements", "BaseService", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer.go#L174-L185
131,032
tendermint/tendermint
p2p/peer.go
Send
func (p *peer) Send(chID byte, msgBytes []byte) bool { if !p.IsRunning() { // see Switch#Broadcast, where we fetch the list of peers and loop over // them - while we're looping, one peer may be removed and stopped. return false } else if !p.hasChannel(chID) { return false } res := p.mconn.Send(chID, msgByte...
go
func (p *peer) Send(chID byte, msgBytes []byte) bool { if !p.IsRunning() { // see Switch#Broadcast, where we fetch the list of peers and loop over // them - while we're looping, one peer may be removed and stopped. return false } else if !p.hasChannel(chID) { return false } res := p.mconn.Send(chID, msgByte...
[ "func", "(", "p", "*", "peer", ")", "Send", "(", "chID", "byte", ",", "msgBytes", "[", "]", "byte", ")", "bool", "{", "if", "!", "p", ".", "IsRunning", "(", ")", "{", "// see Switch#Broadcast, where we fetch the list of peers and loop over", "// them - while we'...
// Send msg bytes to the channel identified by chID byte. Returns false if the // send queue is full after timeout, specified by MConnection.
[ "Send", "msg", "bytes", "to", "the", "channel", "identified", "by", "chID", "byte", ".", "Returns", "false", "if", "the", "send", "queue", "is", "full", "after", "timeout", "specified", "by", "MConnection", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer.go#L241-L254
131,033
tendermint/tendermint
p2p/peer.go
Set
func (p *peer) Set(key string, data interface{}) { p.Data.Set(key, data) }
go
func (p *peer) Set(key string, data interface{}) { p.Data.Set(key, data) }
[ "func", "(", "p", "*", "peer", ")", "Set", "(", "key", "string", ",", "data", "interface", "{", "}", ")", "{", "p", ".", "Data", ".", "Set", "(", "key", ",", "data", ")", "\n", "}" ]
// Set sets the data for the given key.
[ "Set", "sets", "the", "data", "for", "the", "given", "key", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer.go#L277-L279
131,034
tendermint/tendermint
p2p/peer.go
hasChannel
func (p *peer) hasChannel(chID byte) bool { for _, ch := range p.channels { if ch == chID { return true } } // NOTE: probably will want to remove this // but could be helpful while the feature is new p.Logger.Debug( "Unknown channel for peer", "channel", chID, "channels", p.channels, ) return fa...
go
func (p *peer) hasChannel(chID byte) bool { for _, ch := range p.channels { if ch == chID { return true } } // NOTE: probably will want to remove this // but could be helpful while the feature is new p.Logger.Debug( "Unknown channel for peer", "channel", chID, "channels", p.channels, ) return fa...
[ "func", "(", "p", "*", "peer", ")", "hasChannel", "(", "chID", "byte", ")", "bool", "{", "for", "_", ",", "ch", ":=", "range", "p", ".", "channels", "{", "if", "ch", "==", "chID", "{", "return", "true", "\n", "}", "\n", "}", "\n", "// NOTE: proba...
// hasChannel returns true if the peer reported // knowing about the given chID.
[ "hasChannel", "returns", "true", "if", "the", "peer", "reported", "knowing", "about", "the", "given", "chID", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer.go#L283-L299
131,035
tendermint/tendermint
p2p/peer.go
CanSend
func (p *peer) CanSend(chID byte) bool { if !p.IsRunning() { return false } return p.mconn.CanSend(chID) }
go
func (p *peer) CanSend(chID byte) bool { if !p.IsRunning() { return false } return p.mconn.CanSend(chID) }
[ "func", "(", "p", "*", "peer", ")", "CanSend", "(", "chID", "byte", ")", "bool", "{", "if", "!", "p", ".", "IsRunning", "(", ")", "{", "return", "false", "\n", "}", "\n", "return", "p", ".", "mconn", ".", "CanSend", "(", "chID", ")", "\n", "}" ...
// CanSend returns true if the send queue is not full, false otherwise.
[ "CanSend", "returns", "true", "if", "the", "send", "queue", "is", "not", "full", "false", "otherwise", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer.go#L321-L326
131,036
tendermint/tendermint
types/canonical.go
CanonicalTime
func CanonicalTime(t time.Time) string { // Note that sending time over amino resets it to // local time, we need to force UTC here, so the // signatures match return tmtime.Canonical(t).Format(TimeFormat) }
go
func CanonicalTime(t time.Time) string { // Note that sending time over amino resets it to // local time, we need to force UTC here, so the // signatures match return tmtime.Canonical(t).Format(TimeFormat) }
[ "func", "CanonicalTime", "(", "t", "time", ".", "Time", ")", "string", "{", "// Note that sending time over amino resets it to", "// local time, we need to force UTC here, so the", "// signatures match", "return", "tmtime", ".", "Canonical", "(", "t", ")", ".", "Format", ...
// CanonicalTime can be used to stringify time in a canonical way.
[ "CanonicalTime", "can", "be", "used", "to", "stringify", "time", "in", "a", "canonical", "way", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/canonical.go#L85-L90
131,037
tendermint/tendermint
lite/proxy/query.go
GetWithProof
func GetWithProof(prt *merkle.ProofRuntime, key []byte, reqHeight int64, node rpcclient.Client, cert lite.Verifier) ( val cmn.HexBytes, height int64, proof *merkle.Proof, err error) { if reqHeight < 0 { err = cmn.NewError("Height cannot be negative") return } res, err := GetWithProofOptions(prt, "/key", key,...
go
func GetWithProof(prt *merkle.ProofRuntime, key []byte, reqHeight int64, node rpcclient.Client, cert lite.Verifier) ( val cmn.HexBytes, height int64, proof *merkle.Proof, err error) { if reqHeight < 0 { err = cmn.NewError("Height cannot be negative") return } res, err := GetWithProofOptions(prt, "/key", key,...
[ "func", "GetWithProof", "(", "prt", "*", "merkle", ".", "ProofRuntime", ",", "key", "[", "]", "byte", ",", "reqHeight", "int64", ",", "node", "rpcclient", ".", "Client", ",", "cert", "lite", ".", "Verifier", ")", "(", "val", "cmn", ".", "HexBytes", ","...
// GetWithProof will query the key on the given node, and verify it has // a valid proof, as defined by the Verifier. // // If there is any error in checking, returns an error.
[ "GetWithProof", "will", "query", "the", "key", "on", "the", "given", "node", "and", "verify", "it", "has", "a", "valid", "proof", "as", "defined", "by", "the", "Verifier", ".", "If", "there", "is", "any", "error", "in", "checking", "returns", "an", "erro...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/proxy/query.go#L21-L40
131,038
tendermint/tendermint
lite/proxy/query.go
GetCertifiedCommit
func GetCertifiedCommit(h int64, client rpcclient.Client, cert lite.Verifier) (types.SignedHeader, error) { // FIXME: cannot use cert.GetByHeight for now, as it also requires // Validators and will fail on querying tendermint for non-current height. // When this is supported, we should use it instead... rpcclient....
go
func GetCertifiedCommit(h int64, client rpcclient.Client, cert lite.Verifier) (types.SignedHeader, error) { // FIXME: cannot use cert.GetByHeight for now, as it also requires // Validators and will fail on querying tendermint for non-current height. // When this is supported, we should use it instead... rpcclient....
[ "func", "GetCertifiedCommit", "(", "h", "int64", ",", "client", "rpcclient", ".", "Client", ",", "cert", "lite", ".", "Verifier", ")", "(", "types", ".", "SignedHeader", ",", "error", ")", "{", "// FIXME: cannot use cert.GetByHeight for now, as it also requires", "/...
// GetCertifiedCommit gets the signed header for a given height and certifies // it. Returns error if unable to get a proven header.
[ "GetCertifiedCommit", "gets", "the", "signed", "header", "for", "a", "given", "height", "and", "certifies", "it", ".", "Returns", "error", "if", "unable", "to", "get", "a", "proven", "header", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/proxy/query.go#L121-L144
131,039
tendermint/tendermint
libs/log/filter.go
NewFilter
func NewFilter(next Logger, options ...Option) Logger { l := &filter{ next: next, allowedKeyvals: make(map[keyval]level), } for _, option := range options { option(l) } l.initiallyAllowed = l.allowed return l }
go
func NewFilter(next Logger, options ...Option) Logger { l := &filter{ next: next, allowedKeyvals: make(map[keyval]level), } for _, option := range options { option(l) } l.initiallyAllowed = l.allowed return l }
[ "func", "NewFilter", "(", "next", "Logger", ",", "options", "...", "Option", ")", "Logger", "{", "l", ":=", "&", "filter", "{", "next", ":", "next", ",", "allowedKeyvals", ":", "make", "(", "map", "[", "keyval", "]", "level", ")", ",", "}", "\n", "...
// NewFilter wraps next and implements filtering. See the commentary on the // Option functions for a detailed description of how to configure levels. If // no options are provided, all leveled log events created with Debug, Info or // Error helper methods are squelched.
[ "NewFilter", "wraps", "next", "and", "implements", "filtering", ".", "See", "the", "commentary", "on", "the", "Option", "functions", "for", "a", "detailed", "description", "of", "how", "to", "configure", "levels", ".", "If", "no", "options", "are", "provided",...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/filter.go#L29-L39
131,040
tendermint/tendermint
libs/log/filter.go
AllowLevel
func AllowLevel(lvl string) (Option, error) { switch lvl { case "debug": return AllowDebug(), nil case "info": return AllowInfo(), nil case "error": return AllowError(), nil case "none": return AllowNone(), nil default: return nil, fmt.Errorf("Expected either \"info\", \"debug\", \"error\" or \"none\" l...
go
func AllowLevel(lvl string) (Option, error) { switch lvl { case "debug": return AllowDebug(), nil case "info": return AllowInfo(), nil case "error": return AllowError(), nil case "none": return AllowNone(), nil default: return nil, fmt.Errorf("Expected either \"info\", \"debug\", \"error\" or \"none\" l...
[ "func", "AllowLevel", "(", "lvl", "string", ")", "(", "Option", ",", "error", ")", "{", "switch", "lvl", "{", "case", "\"", "\"", ":", "return", "AllowDebug", "(", ")", ",", "nil", "\n", "case", "\"", "\"", ":", "return", "AllowInfo", "(", ")", ","...
// AllowLevel returns an option for the given level or error if no option exist // for such level.
[ "AllowLevel", "returns", "an", "option", "for", "the", "given", "level", "or", "error", "if", "no", "option", "exist", "for", "such", "level", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/filter.go#L129-L142
131,041
tendermint/tendermint
libs/log/filter.go
AllowDebugWith
func AllowDebugWith(key interface{}, value interface{}) Option { return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError | levelInfo | levelDebug } }
go
func AllowDebugWith(key interface{}, value interface{}) Option { return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError | levelInfo | levelDebug } }
[ "func", "AllowDebugWith", "(", "key", "interface", "{", "}", ",", "value", "interface", "{", "}", ")", "Option", "{", "return", "func", "(", "l", "*", "filter", ")", "{", "l", ".", "allowedKeyvals", "[", "keyval", "{", "key", ",", "value", "}", "]", ...
// AllowDebugWith allows error, info and debug level log events to pass for a specific key value pair.
[ "AllowDebugWith", "allows", "error", "info", "and", "debug", "level", "log", "events", "to", "pass", "for", "a", "specific", "key", "value", "pair", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/filter.go#L174-L176
131,042
tendermint/tendermint
libs/log/filter.go
AllowInfoWith
func AllowInfoWith(key interface{}, value interface{}) Option { return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError | levelInfo } }
go
func AllowInfoWith(key interface{}, value interface{}) Option { return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError | levelInfo } }
[ "func", "AllowInfoWith", "(", "key", "interface", "{", "}", ",", "value", "interface", "{", "}", ")", "Option", "{", "return", "func", "(", "l", "*", "filter", ")", "{", "l", ".", "allowedKeyvals", "[", "keyval", "{", "key", ",", "value", "}", "]", ...
// AllowInfoWith allows error and info level log events to pass for a specific key value pair.
[ "AllowInfoWith", "allows", "error", "and", "info", "level", "log", "events", "to", "pass", "for", "a", "specific", "key", "value", "pair", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/filter.go#L179-L181
131,043
tendermint/tendermint
libs/log/filter.go
AllowErrorWith
func AllowErrorWith(key interface{}, value interface{}) Option { return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError } }
go
func AllowErrorWith(key interface{}, value interface{}) Option { return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError } }
[ "func", "AllowErrorWith", "(", "key", "interface", "{", "}", ",", "value", "interface", "{", "}", ")", "Option", "{", "return", "func", "(", "l", "*", "filter", ")", "{", "l", ".", "allowedKeyvals", "[", "keyval", "{", "key", ",", "value", "}", "]", ...
// AllowErrorWith allows only error level log events to pass for a specific key value pair.
[ "AllowErrorWith", "allows", "only", "error", "level", "log", "events", "to", "pass", "for", "a", "specific", "key", "value", "pair", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/filter.go#L184-L186
131,044
tendermint/tendermint
libs/log/filter.go
AllowNoneWith
func AllowNoneWith(key interface{}, value interface{}) Option { return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = 0 } }
go
func AllowNoneWith(key interface{}, value interface{}) Option { return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = 0 } }
[ "func", "AllowNoneWith", "(", "key", "interface", "{", "}", ",", "value", "interface", "{", "}", ")", "Option", "{", "return", "func", "(", "l", "*", "filter", ")", "{", "l", ".", "allowedKeyvals", "[", "keyval", "{", "key", ",", "value", "}", "]", ...
// AllowNoneWith allows no leveled log events to pass for a specific key value pair.
[ "AllowNoneWith", "allows", "no", "leveled", "log", "events", "to", "pass", "for", "a", "specific", "key", "value", "pair", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/filter.go#L189-L191
131,045
tendermint/tendermint
config/toml.go
WriteConfigFile
func WriteConfigFile(configFilePath string, config *Config) { var buffer bytes.Buffer if err := configTemplate.Execute(&buffer, config); err != nil { panic(err) } cmn.MustWriteFile(configFilePath, buffer.Bytes(), 0644) }
go
func WriteConfigFile(configFilePath string, config *Config) { var buffer bytes.Buffer if err := configTemplate.Execute(&buffer, config); err != nil { panic(err) } cmn.MustWriteFile(configFilePath, buffer.Bytes(), 0644) }
[ "func", "WriteConfigFile", "(", "configFilePath", "string", ",", "config", "*", "Config", ")", "{", "var", "buffer", "bytes", ".", "Buffer", "\n\n", "if", "err", ":=", "configTemplate", ".", "Execute", "(", "&", "buffer", ",", "config", ")", ";", "err", ...
// WriteConfigFile renders config using the template and writes it to configFilePath.
[ "WriteConfigFile", "renders", "config", "using", "the", "template", "and", "writes", "it", "to", "configFilePath", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/config/toml.go#L55-L63
131,046
tendermint/tendermint
libs/common/random.go
Str
func (r *Rand) Str(length int) string { chars := []byte{} MAIN_LOOP: for { val := r.Int63() for i := 0; i < 10; i++ { v := int(val & 0x3f) // rightmost 6 bits if v >= 62 { // only 62 characters in strChars val >>= 6 continue } else { chars = append(chars, strChars[v]) if len(chars...
go
func (r *Rand) Str(length int) string { chars := []byte{} MAIN_LOOP: for { val := r.Int63() for i := 0; i < 10; i++ { v := int(val & 0x3f) // rightmost 6 bits if v >= 62 { // only 62 characters in strChars val >>= 6 continue } else { chars = append(chars, strChars[v]) if len(chars...
[ "func", "(", "r", "*", "Rand", ")", "Str", "(", "length", "int", ")", "string", "{", "chars", ":=", "[", "]", "byte", "{", "}", "\n", "MAIN_LOOP", ":", "for", "{", "val", ":=", "r", ".", "Int63", "(", ")", "\n", "for", "i", ":=", "0", ";", ...
// Str constructs a random alphanumeric string of given length.
[ "Str", "constructs", "a", "random", "alphanumeric", "string", "of", "given", "length", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/random.go#L150-L171
131,047
tendermint/tendermint
libs/common/random.go
Bytes
func (r *Rand) Bytes(n int) []byte { // cRandBytes isn't guaranteed to be fast so instead // use random bytes generated from the internal PRNG bs := make([]byte, n) for i := 0; i < len(bs); i++ { bs[i] = byte(r.Int() & 0xFF) } return bs }
go
func (r *Rand) Bytes(n int) []byte { // cRandBytes isn't guaranteed to be fast so instead // use random bytes generated from the internal PRNG bs := make([]byte, n) for i := 0; i < len(bs); i++ { bs[i] = byte(r.Int() & 0xFF) } return bs }
[ "func", "(", "r", "*", "Rand", ")", "Bytes", "(", "n", "int", ")", "[", "]", "byte", "{", "// cRandBytes isn't guaranteed to be fast so instead", "// use random bytes generated from the internal PRNG", "bs", ":=", "make", "(", "[", "]", "byte", ",", "n", ")", "\...
// Bytes returns n random bytes generated from the internal // prng.
[ "Bytes", "returns", "n", "random", "bytes", "generated", "from", "the", "internal", "prng", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/random.go#L262-L270
131,048
tendermint/tendermint
libs/common/random.go
Intn
func (r *Rand) Intn(n int) int { r.Lock() i := r.rand.Intn(n) r.Unlock() return i }
go
func (r *Rand) Intn(n int) int { r.Lock() i := r.rand.Intn(n) r.Unlock() return i }
[ "func", "(", "r", "*", "Rand", ")", "Intn", "(", "n", "int", ")", "int", "{", "r", ".", "Lock", "(", ")", "\n", "i", ":=", "r", ".", "rand", ".", "Intn", "(", "n", ")", "\n", "r", ".", "Unlock", "(", ")", "\n", "return", "i", "\n", "}" ]
// Intn returns, as an int, a uniform pseudo-random number in the range [0, n). // It panics if n <= 0.
[ "Intn", "returns", "as", "an", "int", "a", "uniform", "pseudo", "-", "random", "number", "in", "the", "range", "[", "0", "n", ")", ".", "It", "panics", "if", "n", "<", "=", "0", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/random.go#L274-L279
131,049
tendermint/tendermint
libs/common/random.go
Perm
func (r *Rand) Perm(n int) []int { r.Lock() perm := r.rand.Perm(n) r.Unlock() return perm }
go
func (r *Rand) Perm(n int) []int { r.Lock() perm := r.rand.Perm(n) r.Unlock() return perm }
[ "func", "(", "r", "*", "Rand", ")", "Perm", "(", "n", "int", ")", "[", "]", "int", "{", "r", ".", "Lock", "(", ")", "\n", "perm", ":=", "r", ".", "rand", ".", "Perm", "(", "n", ")", "\n", "r", ".", "Unlock", "(", ")", "\n", "return", "per...
// Perm returns a pseudo-random permutation of n integers in [0, n).
[ "Perm", "returns", "a", "pseudo", "-", "random", "permutation", "of", "n", "integers", "in", "[", "0", "n", ")", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/random.go#L289-L294
131,050
tendermint/tendermint
types/block_meta.go
NewBlockMeta
func NewBlockMeta(block *Block, blockParts *PartSet) *BlockMeta { return &BlockMeta{ BlockID: BlockID{block.Hash(), blockParts.Header()}, Header: block.Header, } }
go
func NewBlockMeta(block *Block, blockParts *PartSet) *BlockMeta { return &BlockMeta{ BlockID: BlockID{block.Hash(), blockParts.Header()}, Header: block.Header, } }
[ "func", "NewBlockMeta", "(", "block", "*", "Block", ",", "blockParts", "*", "PartSet", ")", "*", "BlockMeta", "{", "return", "&", "BlockMeta", "{", "BlockID", ":", "BlockID", "{", "block", ".", "Hash", "(", ")", ",", "blockParts", ".", "Header", "(", "...
// NewBlockMeta returns a new BlockMeta from the block and its blockParts.
[ "NewBlockMeta", "returns", "a", "new", "BlockMeta", "from", "the", "block", "and", "its", "blockParts", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block_meta.go#L10-L15
131,051
tendermint/tendermint
consensus/types/height_vote_set.go
SetRound
func (hvs *HeightVoteSet) SetRound(round int) { hvs.mtx.Lock() defer hvs.mtx.Unlock() if hvs.round != 0 && (round < hvs.round+1) { cmn.PanicSanity("SetRound() must increment hvs.round") } for r := hvs.round + 1; r <= round; r++ { if _, ok := hvs.roundVoteSets[r]; ok { continue // Already exists because peer...
go
func (hvs *HeightVoteSet) SetRound(round int) { hvs.mtx.Lock() defer hvs.mtx.Unlock() if hvs.round != 0 && (round < hvs.round+1) { cmn.PanicSanity("SetRound() must increment hvs.round") } for r := hvs.round + 1; r <= round; r++ { if _, ok := hvs.roundVoteSets[r]; ok { continue // Already exists because peer...
[ "func", "(", "hvs", "*", "HeightVoteSet", ")", "SetRound", "(", "round", "int", ")", "{", "hvs", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "hvs", ".", "mtx", ".", "Unlock", "(", ")", "\n", "if", "hvs", ".", "round", "!=", "0", "&&", "("...
// Create more RoundVoteSets up to round.
[ "Create", "more", "RoundVoteSets", "up", "to", "round", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/height_vote_set.go#L82-L95
131,052
tendermint/tendermint
consensus/types/height_vote_set.go
AddVote
func (hvs *HeightVoteSet) AddVote(vote *types.Vote, peerID p2p.ID) (added bool, err error) { hvs.mtx.Lock() defer hvs.mtx.Unlock() if !types.IsVoteTypeValid(vote.Type) { return } voteSet := hvs.getVoteSet(vote.Round, vote.Type) if voteSet == nil { if rndz := hvs.peerCatchupRounds[peerID]; len(rndz) < 2 { h...
go
func (hvs *HeightVoteSet) AddVote(vote *types.Vote, peerID p2p.ID) (added bool, err error) { hvs.mtx.Lock() defer hvs.mtx.Unlock() if !types.IsVoteTypeValid(vote.Type) { return } voteSet := hvs.getVoteSet(vote.Round, vote.Type) if voteSet == nil { if rndz := hvs.peerCatchupRounds[peerID]; len(rndz) < 2 { h...
[ "func", "(", "hvs", "*", "HeightVoteSet", ")", "AddVote", "(", "vote", "*", "types", ".", "Vote", ",", "peerID", "p2p", ".", "ID", ")", "(", "added", "bool", ",", "err", "error", ")", "{", "hvs", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", ...
// Duplicate votes return added=false, err=nil. // By convention, peerID is "" if origin is self.
[ "Duplicate", "votes", "return", "added", "=", "false", "err", "=", "nil", ".", "By", "convention", "peerID", "is", "if", "origin", "is", "self", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/height_vote_set.go#L112-L132
131,053
tendermint/tendermint
p2p/fuzz.go
FuzzConn
func FuzzConn(conn net.Conn) net.Conn { return FuzzConnFromConfig(conn, config.DefaultFuzzConnConfig()) }
go
func FuzzConn(conn net.Conn) net.Conn { return FuzzConnFromConfig(conn, config.DefaultFuzzConnConfig()) }
[ "func", "FuzzConn", "(", "conn", "net", ".", "Conn", ")", "net", ".", "Conn", "{", "return", "FuzzConnFromConfig", "(", "conn", ",", "config", ".", "DefaultFuzzConnConfig", "(", ")", ")", "\n", "}" ]
// FuzzConn creates a new FuzzedConnection. Fuzzing starts immediately.
[ "FuzzConn", "creates", "a", "new", "FuzzedConnection", ".", "Fuzzing", "starts", "immediately", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/fuzz.go#L25-L27
131,054
tendermint/tendermint
p2p/fuzz.go
FuzzConnFromConfig
func FuzzConnFromConfig(conn net.Conn, config *config.FuzzConnConfig) net.Conn { return &FuzzedConnection{ conn: conn, start: make(<-chan time.Time), active: true, config: config, } }
go
func FuzzConnFromConfig(conn net.Conn, config *config.FuzzConnConfig) net.Conn { return &FuzzedConnection{ conn: conn, start: make(<-chan time.Time), active: true, config: config, } }
[ "func", "FuzzConnFromConfig", "(", "conn", "net", ".", "Conn", ",", "config", "*", "config", ".", "FuzzConnConfig", ")", "net", ".", "Conn", "{", "return", "&", "FuzzedConnection", "{", "conn", ":", "conn", ",", "start", ":", "make", "(", "<-", "chan", ...
// FuzzConnFromConfig creates a new FuzzedConnection from a config. Fuzzing // starts immediately.
[ "FuzzConnFromConfig", "creates", "a", "new", "FuzzedConnection", "from", "a", "config", ".", "Fuzzing", "starts", "immediately", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/fuzz.go#L31-L38
131,055
tendermint/tendermint
p2p/fuzz.go
FuzzConnAfterFromConfig
func FuzzConnAfterFromConfig( conn net.Conn, d time.Duration, config *config.FuzzConnConfig, ) net.Conn { return &FuzzedConnection{ conn: conn, start: time.After(d), active: false, config: config, } }
go
func FuzzConnAfterFromConfig( conn net.Conn, d time.Duration, config *config.FuzzConnConfig, ) net.Conn { return &FuzzedConnection{ conn: conn, start: time.After(d), active: false, config: config, } }
[ "func", "FuzzConnAfterFromConfig", "(", "conn", "net", ".", "Conn", ",", "d", "time", ".", "Duration", ",", "config", "*", "config", ".", "FuzzConnConfig", ",", ")", "net", ".", "Conn", "{", "return", "&", "FuzzedConnection", "{", "conn", ":", "conn", ",...
// FuzzConnAfterFromConfig creates a new FuzzedConnection from a config. // Fuzzing starts when the duration elapses.
[ "FuzzConnAfterFromConfig", "creates", "a", "new", "FuzzedConnection", "from", "a", "config", ".", "Fuzzing", "starts", "when", "the", "duration", "elapses", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/fuzz.go#L48-L59
131,056
tendermint/tendermint
p2p/fuzz.go
SetReadDeadline
func (fc *FuzzedConnection) SetReadDeadline(t time.Time) error { return fc.conn.SetReadDeadline(t) }
go
func (fc *FuzzedConnection) SetReadDeadline(t time.Time) error { return fc.conn.SetReadDeadline(t) }
[ "func", "(", "fc", "*", "FuzzedConnection", ")", "SetReadDeadline", "(", "t", "time", ".", "Time", ")", "error", "{", "return", "fc", ".", "conn", ".", "SetReadDeadline", "(", "t", ")", "\n", "}" ]
// SetReadDeadline implements net.Conn.
[ "SetReadDeadline", "implements", "net", ".", "Conn", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/fuzz.go#L95-L97
131,057
tendermint/tendermint
p2p/fuzz.go
SetWriteDeadline
func (fc *FuzzedConnection) SetWriteDeadline(t time.Time) error { return fc.conn.SetWriteDeadline(t) }
go
func (fc *FuzzedConnection) SetWriteDeadline(t time.Time) error { return fc.conn.SetWriteDeadline(t) }
[ "func", "(", "fc", "*", "FuzzedConnection", ")", "SetWriteDeadline", "(", "t", "time", ".", "Time", ")", "error", "{", "return", "fc", ".", "conn", ".", "SetWriteDeadline", "(", "t", ")", "\n", "}" ]
// SetWriteDeadline implements net.Conn.
[ "SetWriteDeadline", "implements", "net", ".", "Conn", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/fuzz.go#L100-L102
131,058
tendermint/tendermint
p2p/mock/peer.go
NewPeer
func NewPeer(ip net.IP) *Peer { var netAddr *p2p.NetAddress if ip == nil { _, netAddr = p2p.CreateRoutableAddr() } else { netAddr = p2p.NewNetAddressIPPort(ip, 26656) } nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()} netAddr.ID = nodeKey.ID() mp := &Peer{ ip: ip, id: nodeKey.ID(), addr: netAd...
go
func NewPeer(ip net.IP) *Peer { var netAddr *p2p.NetAddress if ip == nil { _, netAddr = p2p.CreateRoutableAddr() } else { netAddr = p2p.NewNetAddressIPPort(ip, 26656) } nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()} netAddr.ID = nodeKey.ID() mp := &Peer{ ip: ip, id: nodeKey.ID(), addr: netAd...
[ "func", "NewPeer", "(", "ip", "net", ".", "IP", ")", "*", "Peer", "{", "var", "netAddr", "*", "p2p", ".", "NetAddress", "\n", "if", "ip", "==", "nil", "{", "_", ",", "netAddr", "=", "p2p", ".", "CreateRoutableAddr", "(", ")", "\n", "}", "else", "...
// NewPeer creates and starts a new mock peer. If the ip // is nil, random routable address is used.
[ "NewPeer", "creates", "and", "starts", "a", "new", "mock", "peer", ".", "If", "the", "ip", "is", "nil", "random", "routable", "address", "is", "used", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/mock/peer.go#L23-L41
131,059
tendermint/tendermint
types/part_set.go
NewPartSetFromData
func NewPartSetFromData(data []byte, partSize int) *PartSet { // divide data into 4kb parts. total := (len(data) + partSize - 1) / partSize parts := make([]*Part, total) partsBytes := make([][]byte, total) partsBitArray := cmn.NewBitArray(total) for i := 0; i < total; i++ { part := &Part{ Index: i, Bytes:...
go
func NewPartSetFromData(data []byte, partSize int) *PartSet { // divide data into 4kb parts. total := (len(data) + partSize - 1) / partSize parts := make([]*Part, total) partsBytes := make([][]byte, total) partsBitArray := cmn.NewBitArray(total) for i := 0; i < total; i++ { part := &Part{ Index: i, Bytes:...
[ "func", "NewPartSetFromData", "(", "data", "[", "]", "byte", ",", "partSize", "int", ")", "*", "PartSet", "{", "// divide data into 4kb parts.", "total", ":=", "(", "len", "(", "data", ")", "+", "partSize", "-", "1", ")", "/", "partSize", "\n", "parts", ...
// Returns an immutable, full PartSet from the data bytes. // The data bytes are split into "partSize" chunks, and merkle tree computed.
[ "Returns", "an", "immutable", "full", "PartSet", "from", "the", "data", "bytes", ".", "The", "data", "bytes", "are", "split", "into", "partSize", "chunks", "and", "merkle", "tree", "computed", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/part_set.go#L97-L124
131,060
tendermint/tendermint
types/part_set.go
NewPartSetFromHeader
func NewPartSetFromHeader(header PartSetHeader) *PartSet { return &PartSet{ total: header.Total, hash: header.Hash, parts: make([]*Part, header.Total), partsBitArray: cmn.NewBitArray(header.Total), count: 0, } }
go
func NewPartSetFromHeader(header PartSetHeader) *PartSet { return &PartSet{ total: header.Total, hash: header.Hash, parts: make([]*Part, header.Total), partsBitArray: cmn.NewBitArray(header.Total), count: 0, } }
[ "func", "NewPartSetFromHeader", "(", "header", "PartSetHeader", ")", "*", "PartSet", "{", "return", "&", "PartSet", "{", "total", ":", "header", ".", "Total", ",", "hash", ":", "header", ".", "Hash", ",", "parts", ":", "make", "(", "[", "]", "*", "Part...
// Returns an empty PartSet ready to be populated.
[ "Returns", "an", "empty", "PartSet", "ready", "to", "be", "populated", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/part_set.go#L127-L135
131,061
tendermint/tendermint
libs/common/byteslice.go
Fingerprint
func Fingerprint(slice []byte) []byte { fingerprint := make([]byte, 6) copy(fingerprint, slice) return fingerprint }
go
func Fingerprint(slice []byte) []byte { fingerprint := make([]byte, 6) copy(fingerprint, slice) return fingerprint }
[ "func", "Fingerprint", "(", "slice", "[", "]", "byte", ")", "[", "]", "byte", "{", "fingerprint", ":=", "make", "(", "[", "]", "byte", ",", "6", ")", "\n", "copy", "(", "fingerprint", ",", "slice", ")", "\n", "return", "fingerprint", "\n", "}" ]
// Fingerprint returns the first 6 bytes of a byte slice. // If the slice is less than 6 bytes, the fingerprint // contains trailing zeroes.
[ "Fingerprint", "returns", "the", "first", "6", "bytes", "of", "a", "byte", "slice", ".", "If", "the", "slice", "is", "less", "than", "6", "bytes", "the", "fingerprint", "contains", "trailing", "zeroes", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/byteslice.go#L6-L10
131,062
tendermint/tendermint
privval/file.go
Save
func (pvKey FilePVKey) Save() { outFile := pvKey.filePath if outFile == "" { panic("cannot save PrivValidator key: filePath not set") } jsonBytes, err := cdc.MarshalJSONIndent(pvKey, "", " ") if err != nil { panic(err) } err = cmn.WriteFileAtomic(outFile, jsonBytes, 0600) if err != nil { panic(err) } ...
go
func (pvKey FilePVKey) Save() { outFile := pvKey.filePath if outFile == "" { panic("cannot save PrivValidator key: filePath not set") } jsonBytes, err := cdc.MarshalJSONIndent(pvKey, "", " ") if err != nil { panic(err) } err = cmn.WriteFileAtomic(outFile, jsonBytes, 0600) if err != nil { panic(err) } ...
[ "func", "(", "pvKey", "FilePVKey", ")", "Save", "(", ")", "{", "outFile", ":=", "pvKey", ".", "filePath", "\n", "if", "outFile", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "jsonBytes", ",", "err", ":=", "cdc", ".", "...
// Save persists the FilePVKey to its filePath.
[ "Save", "persists", "the", "FilePVKey", "to", "its", "filePath", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/file.go#L49-L64
131,063
tendermint/tendermint
privval/file.go
Save
func (lss *FilePVLastSignState) Save() { outFile := lss.filePath if outFile == "" { panic("cannot save FilePVLastSignState: filePath not set") } jsonBytes, err := cdc.MarshalJSONIndent(lss, "", " ") if err != nil { panic(err) } err = cmn.WriteFileAtomic(outFile, jsonBytes, 0600) if err != nil { panic(err...
go
func (lss *FilePVLastSignState) Save() { outFile := lss.filePath if outFile == "" { panic("cannot save FilePVLastSignState: filePath not set") } jsonBytes, err := cdc.MarshalJSONIndent(lss, "", " ") if err != nil { panic(err) } err = cmn.WriteFileAtomic(outFile, jsonBytes, 0600) if err != nil { panic(err...
[ "func", "(", "lss", "*", "FilePVLastSignState", ")", "Save", "(", ")", "{", "outFile", ":=", "lss", ".", "filePath", "\n", "if", "outFile", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "jsonBytes", ",", "err", ":=", "cdc",...
// Save persists the FilePvLastSignState to its filePath.
[ "Save", "persists", "the", "FilePvLastSignState", "to", "its", "filePath", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/file.go#L115-L128
131,064
tendermint/tendermint
privval/file.go
loadFilePV
func loadFilePV(keyFilePath, stateFilePath string, loadState bool) *FilePV { keyJSONBytes, err := ioutil.ReadFile(keyFilePath) if err != nil { cmn.Exit(err.Error()) } pvKey := FilePVKey{} err = cdc.UnmarshalJSON(keyJSONBytes, &pvKey) if err != nil { cmn.Exit(fmt.Sprintf("Error reading PrivValidator key from %...
go
func loadFilePV(keyFilePath, stateFilePath string, loadState bool) *FilePV { keyJSONBytes, err := ioutil.ReadFile(keyFilePath) if err != nil { cmn.Exit(err.Error()) } pvKey := FilePVKey{} err = cdc.UnmarshalJSON(keyJSONBytes, &pvKey) if err != nil { cmn.Exit(fmt.Sprintf("Error reading PrivValidator key from %...
[ "func", "loadFilePV", "(", "keyFilePath", ",", "stateFilePath", "string", ",", "loadState", "bool", ")", "*", "FilePV", "{", "keyJSONBytes", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "keyFilePath", ")", "\n", "if", "err", "!=", "nil", "{", "cmn", ...
// If loadState is true, we load from the stateFilePath. Otherwise, we use an empty LastSignState.
[ "If", "loadState", "is", "true", "we", "load", "from", "the", "stateFilePath", ".", "Otherwise", "we", "use", "an", "empty", "LastSignState", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/file.go#L175-L209
131,065
tendermint/tendermint
privval/file.go
LoadOrGenFilePV
func LoadOrGenFilePV(keyFilePath, stateFilePath string) *FilePV { var pv *FilePV if cmn.FileExists(keyFilePath) { pv = LoadFilePV(keyFilePath, stateFilePath) } else { pv = GenFilePV(keyFilePath, stateFilePath) pv.Save() } return pv }
go
func LoadOrGenFilePV(keyFilePath, stateFilePath string) *FilePV { var pv *FilePV if cmn.FileExists(keyFilePath) { pv = LoadFilePV(keyFilePath, stateFilePath) } else { pv = GenFilePV(keyFilePath, stateFilePath) pv.Save() } return pv }
[ "func", "LoadOrGenFilePV", "(", "keyFilePath", ",", "stateFilePath", "string", ")", "*", "FilePV", "{", "var", "pv", "*", "FilePV", "\n", "if", "cmn", ".", "FileExists", "(", "keyFilePath", ")", "{", "pv", "=", "LoadFilePV", "(", "keyFilePath", ",", "state...
// LoadOrGenFilePV loads a FilePV from the given filePaths // or else generates a new one and saves it to the filePaths.
[ "LoadOrGenFilePV", "loads", "a", "FilePV", "from", "the", "given", "filePaths", "or", "else", "generates", "a", "new", "one", "and", "saves", "it", "to", "the", "filePaths", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/file.go#L213-L222
131,066
tendermint/tendermint
privval/file.go
String
func (pv *FilePV) String() string { return fmt.Sprintf("PrivValidator{%v LH:%v, LR:%v, LS:%v}", pv.GetAddress(), pv.LastSignState.Height, pv.LastSignState.Round, pv.LastSignState.Step) }
go
func (pv *FilePV) String() string { return fmt.Sprintf("PrivValidator{%v LH:%v, LR:%v, LS:%v}", pv.GetAddress(), pv.LastSignState.Height, pv.LastSignState.Round, pv.LastSignState.Step) }
[ "func", "(", "pv", "*", "FilePV", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "pv", ".", "GetAddress", "(", ")", ",", "pv", ".", "LastSignState", ".", "Height", ",", "pv", ".", "LastSignState", "."...
// String returns a string representation of the FilePV.
[ "String", "returns", "a", "string", "representation", "of", "the", "FilePV", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/file.go#L273-L275
131,067
tendermint/tendermint
privval/file.go
checkProposalsOnlyDifferByTimestamp
func checkProposalsOnlyDifferByTimestamp(lastSignBytes, newSignBytes []byte) (time.Time, bool) { var lastProposal, newProposal types.CanonicalProposal if err := cdc.UnmarshalBinaryLengthPrefixed(lastSignBytes, &lastProposal); err != nil { panic(fmt.Sprintf("LastSignBytes cannot be unmarshalled into proposal: %v", e...
go
func checkProposalsOnlyDifferByTimestamp(lastSignBytes, newSignBytes []byte) (time.Time, bool) { var lastProposal, newProposal types.CanonicalProposal if err := cdc.UnmarshalBinaryLengthPrefixed(lastSignBytes, &lastProposal); err != nil { panic(fmt.Sprintf("LastSignBytes cannot be unmarshalled into proposal: %v", e...
[ "func", "checkProposalsOnlyDifferByTimestamp", "(", "lastSignBytes", ",", "newSignBytes", "[", "]", "byte", ")", "(", "time", ".", "Time", ",", "bool", ")", "{", "var", "lastProposal", ",", "newProposal", "types", ".", "CanonicalProposal", "\n", "if", "err", "...
// returns the timestamp from the lastSignBytes. // returns true if the only difference in the proposals is their timestamp
[ "returns", "the", "timestamp", "from", "the", "lastSignBytes", ".", "returns", "true", "if", "the", "only", "difference", "in", "the", "proposals", "is", "their", "timestamp" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/file.go#L402-L420
131,068
tendermint/tendermint
privval/utils.go
IsConnTimeout
func IsConnTimeout(err error) bool { if cmnErr, ok := err.(cmn.Error); ok { if cmnErr.Data() == ErrConnTimeout { return true } } if _, ok := err.(timeoutError); ok { return true } return false }
go
func IsConnTimeout(err error) bool { if cmnErr, ok := err.(cmn.Error); ok { if cmnErr.Data() == ErrConnTimeout { return true } } if _, ok := err.(timeoutError); ok { return true } return false }
[ "func", "IsConnTimeout", "(", "err", "error", ")", "bool", "{", "if", "cmnErr", ",", "ok", ":=", "err", ".", "(", "cmn", ".", "Error", ")", ";", "ok", "{", "if", "cmnErr", ".", "Data", "(", ")", "==", "ErrConnTimeout", "{", "return", "true", "\n", ...
// IsConnTimeout returns a boolean indicating whether the error is known to // report that a connection timeout occurred. This detects both fundamental // network timeouts, as well as ErrConnTimeout errors.
[ "IsConnTimeout", "returns", "a", "boolean", "indicating", "whether", "the", "error", "is", "known", "to", "report", "that", "a", "connection", "timeout", "occurred", ".", "This", "detects", "both", "fundamental", "network", "timeouts", "as", "well", "as", "ErrCo...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/utils.go#L10-L20
131,069
tendermint/tendermint
abci/example/kvstore/kvstore.go
DeliverTx
func (app *KVStoreApplication) DeliverTx(tx []byte) types.ResponseDeliverTx { var key, value []byte parts := bytes.Split(tx, []byte("=")) if len(parts) == 2 { key, value = parts[0], parts[1] } else { key, value = tx, tx } app.state.db.Set(prefixKey(key), value) app.state.Size += 1 tags := []cmn.KVPair{ {...
go
func (app *KVStoreApplication) DeliverTx(tx []byte) types.ResponseDeliverTx { var key, value []byte parts := bytes.Split(tx, []byte("=")) if len(parts) == 2 { key, value = parts[0], parts[1] } else { key, value = tx, tx } app.state.db.Set(prefixKey(key), value) app.state.Size += 1 tags := []cmn.KVPair{ {...
[ "func", "(", "app", "*", "KVStoreApplication", ")", "DeliverTx", "(", "tx", "[", "]", "byte", ")", "types", ".", "ResponseDeliverTx", "{", "var", "key", ",", "value", "[", "]", "byte", "\n", "parts", ":=", "bytes", ".", "Split", "(", "tx", ",", "[", ...
// tx is either "key=value" or just arbitrary bytes
[ "tx", "is", "either", "key", "=", "value", "or", "just", "arbitrary", "bytes" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/example/kvstore/kvstore.go#L79-L95
131,070
tendermint/tendermint
types/block.go
MakeBlock
func MakeBlock(height int64, txs []Tx, lastCommit *Commit, evidence []Evidence) *Block { block := &Block{ Header: Header{ Height: height, NumTxs: int64(len(txs)), }, Data: Data{ Txs: txs, }, Evidence: EvidenceData{Evidence: evidence}, LastCommit: lastCommit, } block.fillHeader() return block ...
go
func MakeBlock(height int64, txs []Tx, lastCommit *Commit, evidence []Evidence) *Block { block := &Block{ Header: Header{ Height: height, NumTxs: int64(len(txs)), }, Data: Data{ Txs: txs, }, Evidence: EvidenceData{Evidence: evidence}, LastCommit: lastCommit, } block.fillHeader() return block ...
[ "func", "MakeBlock", "(", "height", "int64", ",", "txs", "[", "]", "Tx", ",", "lastCommit", "*", "Commit", ",", "evidence", "[", "]", "Evidence", ")", "*", "Block", "{", "block", ":=", "&", "Block", "{", "Header", ":", "Header", "{", "Height", ":", ...
// MakeBlock returns a new block with an empty header, except what can be // computed from itself. // It populates the same set of fields validated by ValidateBasic.
[ "MakeBlock", "returns", "a", "new", "block", "with", "an", "empty", "header", "except", "what", "can", "be", "computed", "from", "itself", ".", "It", "populates", "the", "same", "set", "of", "fields", "validated", "by", "ValidateBasic", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L47-L61
131,071
tendermint/tendermint
types/block.go
fillHeader
func (b *Block) fillHeader() { if b.LastCommitHash == nil { b.LastCommitHash = b.LastCommit.Hash() } if b.DataHash == nil { b.DataHash = b.Data.Hash() } if b.EvidenceHash == nil { b.EvidenceHash = b.Evidence.Hash() } }
go
func (b *Block) fillHeader() { if b.LastCommitHash == nil { b.LastCommitHash = b.LastCommit.Hash() } if b.DataHash == nil { b.DataHash = b.Data.Hash() } if b.EvidenceHash == nil { b.EvidenceHash = b.Evidence.Hash() } }
[ "func", "(", "b", "*", "Block", ")", "fillHeader", "(", ")", "{", "if", "b", ".", "LastCommitHash", "==", "nil", "{", "b", ".", "LastCommitHash", "=", "b", ".", "LastCommit", ".", "Hash", "(", ")", "\n", "}", "\n", "if", "b", ".", "DataHash", "==...
// fillHeader fills in any remaining header fields that are a function of the block data
[ "fillHeader", "fills", "in", "any", "remaining", "header", "fields", "that", "are", "a", "function", "of", "the", "block", "data" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L180-L190
131,072
tendermint/tendermint
types/block.go
Hash
func (b *Block) Hash() cmn.HexBytes { if b == nil { return nil } b.mtx.Lock() defer b.mtx.Unlock() if b == nil || b.LastCommit == nil { return nil } b.fillHeader() return b.Header.Hash() }
go
func (b *Block) Hash() cmn.HexBytes { if b == nil { return nil } b.mtx.Lock() defer b.mtx.Unlock() if b == nil || b.LastCommit == nil { return nil } b.fillHeader() return b.Header.Hash() }
[ "func", "(", "b", "*", "Block", ")", "Hash", "(", ")", "cmn", ".", "HexBytes", "{", "if", "b", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "b", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mtx", ".", "Unlock", "(", "...
// Hash computes and returns the block hash. // If the block is incomplete, block hash is nil for safety.
[ "Hash", "computes", "and", "returns", "the", "block", "hash", ".", "If", "the", "block", "is", "incomplete", "block", "hash", "is", "nil", "for", "safety", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L194-L206
131,073
tendermint/tendermint
types/block.go
HashesTo
func (b *Block) HashesTo(hash []byte) bool { if len(hash) == 0 { return false } if b == nil { return false } return bytes.Equal(b.Hash(), hash) }
go
func (b *Block) HashesTo(hash []byte) bool { if len(hash) == 0 { return false } if b == nil { return false } return bytes.Equal(b.Hash(), hash) }
[ "func", "(", "b", "*", "Block", ")", "HashesTo", "(", "hash", "[", "]", "byte", ")", "bool", "{", "if", "len", "(", "hash", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "if", "b", "==", "nil", "{", "return", "false", "\n", "}", "\...
// HashesTo is a convenience function that checks if a block hashes to the given argument. // Returns false if the block is nil or the hash is empty.
[ "HashesTo", "is", "a", "convenience", "function", "that", "checks", "if", "a", "block", "hashes", "to", "the", "given", "argument", ".", "Returns", "false", "if", "the", "block", "is", "nil", "or", "the", "hash", "is", "empty", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L229-L237
131,074
tendermint/tendermint
types/block.go
Size
func (b *Block) Size() int { bz, err := cdc.MarshalBinaryBare(b) if err != nil { return 0 } return len(bz) }
go
func (b *Block) Size() int { bz, err := cdc.MarshalBinaryBare(b) if err != nil { return 0 } return len(bz) }
[ "func", "(", "b", "*", "Block", ")", "Size", "(", ")", "int", "{", "bz", ",", "err", ":=", "cdc", ".", "MarshalBinaryBare", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", "\n", "}", "\n", "return", "len", "(", "bz", ")", "...
// Size returns size of the block in bytes.
[ "Size", "returns", "size", "of", "the", "block", "in", "bytes", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L240-L246
131,075
tendermint/tendermint
types/block.go
StringIndented
func (b *Block) StringIndented(indent string) string { if b == nil { return "nil-Block" } return fmt.Sprintf(`Block{ %s %v %s %v %s %v %s %v %s}#%v`, indent, b.Header.StringIndented(indent+" "), indent, b.Data.StringIndented(indent+" "), indent, b.Evidence.StringIndented(indent+" "), indent, b.LastC...
go
func (b *Block) StringIndented(indent string) string { if b == nil { return "nil-Block" } return fmt.Sprintf(`Block{ %s %v %s %v %s %v %s %v %s}#%v`, indent, b.Header.StringIndented(indent+" "), indent, b.Data.StringIndented(indent+" "), indent, b.Evidence.StringIndented(indent+" "), indent, b.LastC...
[ "func", "(", "b", "*", "Block", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "if", "b", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "`Block{\n%s %v\n%s %v\n%s %v\n%s %v\n%s}#%v`", ...
// StringIndented returns a string representation of the block
[ "StringIndented", "returns", "a", "string", "representation", "of", "the", "block" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L254-L269
131,076
tendermint/tendermint
types/block.go
StringShort
func (b *Block) StringShort() string { if b == nil { return "nil-Block" } return fmt.Sprintf("Block#%v", b.Hash()) }
go
func (b *Block) StringShort() string { if b == nil { return "nil-Block" } return fmt.Sprintf("Block#%v", b.Hash()) }
[ "func", "(", "b", "*", "Block", ")", "StringShort", "(", ")", "string", "{", "if", "b", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "b", ".", "Hash", "(", ")", ")", "\n", "}"...
// StringShort returns a shortened string representation of the block
[ "StringShort", "returns", "a", "shortened", "string", "representation", "of", "the", "block" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L272-L277
131,077
tendermint/tendermint
types/block.go
Populate
func (h *Header) Populate( version version.Consensus, chainID string, timestamp time.Time, lastBlockID BlockID, totalTxs int64, valHash, nextValHash []byte, consensusHash, appHash, lastResultsHash []byte, proposerAddress Address, ) { h.Version = version h.ChainID = chainID h.Time = timestamp h.LastBlockID = la...
go
func (h *Header) Populate( version version.Consensus, chainID string, timestamp time.Time, lastBlockID BlockID, totalTxs int64, valHash, nextValHash []byte, consensusHash, appHash, lastResultsHash []byte, proposerAddress Address, ) { h.Version = version h.ChainID = chainID h.Time = timestamp h.LastBlockID = la...
[ "func", "(", "h", "*", "Header", ")", "Populate", "(", "version", "version", ".", "Consensus", ",", "chainID", "string", ",", "timestamp", "time", ".", "Time", ",", "lastBlockID", "BlockID", ",", "totalTxs", "int64", ",", "valHash", ",", "nextValHash", "["...
// Populate the Header with state-derived data. // Call this after MakeBlock to complete the Header.
[ "Populate", "the", "Header", "with", "state", "-", "derived", "data", ".", "Call", "this", "after", "MakeBlock", "to", "complete", "the", "Header", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L386-L404
131,078
tendermint/tendermint
types/block.go
StringIndented
func (h *Header) StringIndented(indent string) string { if h == nil { return "nil-Header" } return fmt.Sprintf(`Header{ %s Version: %v %s ChainID: %v %s Height: %v %s Time: %v %s NumTxs: %v %s TotalTxs: %v %s LastBlockID: %v %s LastCommit: %v %s Data: ...
go
func (h *Header) StringIndented(indent string) string { if h == nil { return "nil-Header" } return fmt.Sprintf(`Header{ %s Version: %v %s ChainID: %v %s Height: %v %s Time: %v %s NumTxs: %v %s TotalTxs: %v %s LastBlockID: %v %s LastCommit: %v %s Data: ...
[ "func", "(", "h", "*", "Header", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "if", "h", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "`Header{\n%s Version: %v\n%s ChainID: ...
// StringIndented returns a string representation of the header
[ "StringIndented", "returns", "a", "string", "representation", "of", "the", "header" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L437-L476
131,079
tendermint/tendermint
types/block.go
VoteSignBytes
func (commit *Commit) VoteSignBytes(chainID string, cs *CommitSig) []byte { return commit.ToVote(cs).SignBytes(chainID) }
go
func (commit *Commit) VoteSignBytes(chainID string, cs *CommitSig) []byte { return commit.ToVote(cs).SignBytes(chainID) }
[ "func", "(", "commit", "*", "Commit", ")", "VoteSignBytes", "(", "chainID", "string", ",", "cs", "*", "CommitSig", ")", "[", "]", "byte", "{", "return", "commit", ".", "ToVote", "(", "cs", ")", ".", "SignBytes", "(", "chainID", ")", "\n", "}" ]
// VoteSignBytes constructs the SignBytes for the given CommitSig. // The only unique part of the SignBytes is the Timestamp - all other fields // signed over are otherwise the same for all validators.
[ "VoteSignBytes", "constructs", "the", "SignBytes", "for", "the", "given", "CommitSig", ".", "The", "only", "unique", "part", "of", "the", "SignBytes", "is", "the", "Timestamp", "-", "all", "other", "fields", "signed", "over", "are", "otherwise", "the", "same",...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L534-L536
131,080
tendermint/tendermint
types/block.go
memoizeHeightRound
func (commit *Commit) memoizeHeightRound() { if len(commit.Precommits) == 0 { return } if commit.height > 0 { return } for _, precommit := range commit.Precommits { if precommit != nil { commit.height = precommit.Height commit.round = precommit.Round return } } }
go
func (commit *Commit) memoizeHeightRound() { if len(commit.Precommits) == 0 { return } if commit.height > 0 { return } for _, precommit := range commit.Precommits { if precommit != nil { commit.height = precommit.Height commit.round = precommit.Round return } } }
[ "func", "(", "commit", "*", "Commit", ")", "memoizeHeightRound", "(", ")", "{", "if", "len", "(", "commit", ".", "Precommits", ")", "==", "0", "{", "return", "\n", "}", "\n", "if", "commit", ".", "height", ">", "0", "{", "return", "\n", "}", "\n", ...
// memoizeHeightRound memoizes the height and round of the commit using // the first non-nil vote.
[ "memoizeHeightRound", "memoizes", "the", "height", "and", "round", "of", "the", "commit", "using", "the", "first", "non", "-", "nil", "vote", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L540-L554
131,081
tendermint/tendermint
types/block.go
BitArray
func (commit *Commit) BitArray() *cmn.BitArray { if commit.bitArray == nil { commit.bitArray = cmn.NewBitArray(len(commit.Precommits)) for i, precommit := range commit.Precommits { // TODO: need to check the BlockID otherwise we could be counting conflicts, // not just the one with +2/3 ! commit.bitArray....
go
func (commit *Commit) BitArray() *cmn.BitArray { if commit.bitArray == nil { commit.bitArray = cmn.NewBitArray(len(commit.Precommits)) for i, precommit := range commit.Precommits { // TODO: need to check the BlockID otherwise we could be counting conflicts, // not just the one with +2/3 ! commit.bitArray....
[ "func", "(", "commit", "*", "Commit", ")", "BitArray", "(", ")", "*", "cmn", ".", "BitArray", "{", "if", "commit", ".", "bitArray", "==", "nil", "{", "commit", ".", "bitArray", "=", "cmn", ".", "NewBitArray", "(", "len", "(", "commit", ".", "Precommi...
// BitArray returns a BitArray of which validators voted in this commit
[ "BitArray", "returns", "a", "BitArray", "of", "which", "validators", "voted", "in", "this", "commit" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L590-L600
131,082
tendermint/tendermint
types/block.go
ValidateBasic
func (commit *Commit) ValidateBasic() error { if commit.BlockID.IsZero() { return errors.New("Commit cannot be for nil block") } if len(commit.Precommits) == 0 { return errors.New("No precommits in commit") } height, round := commit.Height(), commit.Round() // Validate the precommits. for _, precommit := ra...
go
func (commit *Commit) ValidateBasic() error { if commit.BlockID.IsZero() { return errors.New("Commit cannot be for nil block") } if len(commit.Precommits) == 0 { return errors.New("No precommits in commit") } height, round := commit.Height(), commit.Round() // Validate the precommits. for _, precommit := ra...
[ "func", "(", "commit", "*", "Commit", ")", "ValidateBasic", "(", ")", "error", "{", "if", "commit", ".", "BlockID", ".", "IsZero", "(", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "commit", "...
// ValidateBasic performs basic validation that doesn't involve state data. // Does not actually check the cryptographic signatures.
[ "ValidateBasic", "performs", "basic", "validation", "that", "doesn", "t", "involve", "state", "data", ".", "Does", "not", "actually", "check", "the", "cryptographic", "signatures", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L616-L648
131,083
tendermint/tendermint
types/block.go
Hash
func (commit *Commit) Hash() cmn.HexBytes { if commit == nil { return nil } if commit.hash == nil { bs := make([][]byte, len(commit.Precommits)) for i, precommit := range commit.Precommits { bs[i] = cdcEncode(precommit) } commit.hash = merkle.SimpleHashFromByteSlices(bs) } return commit.hash }
go
func (commit *Commit) Hash() cmn.HexBytes { if commit == nil { return nil } if commit.hash == nil { bs := make([][]byte, len(commit.Precommits)) for i, precommit := range commit.Precommits { bs[i] = cdcEncode(precommit) } commit.hash = merkle.SimpleHashFromByteSlices(bs) } return commit.hash }
[ "func", "(", "commit", "*", "Commit", ")", "Hash", "(", ")", "cmn", ".", "HexBytes", "{", "if", "commit", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "commit", ".", "hash", "==", "nil", "{", "bs", ":=", "make", "(", "[", "]", "[",...
// Hash returns the hash of the commit
[ "Hash", "returns", "the", "hash", "of", "the", "commit" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L651-L663
131,084
tendermint/tendermint
types/block.go
StringIndented
func (commit *Commit) StringIndented(indent string) string { if commit == nil { return "nil-Commit" } precommitStrings := make([]string, len(commit.Precommits)) for i, precommit := range commit.Precommits { precommitStrings[i] = precommit.String() } return fmt.Sprintf(`Commit{ %s BlockID: %v %s Precommit...
go
func (commit *Commit) StringIndented(indent string) string { if commit == nil { return "nil-Commit" } precommitStrings := make([]string, len(commit.Precommits)) for i, precommit := range commit.Precommits { precommitStrings[i] = precommit.String() } return fmt.Sprintf(`Commit{ %s BlockID: %v %s Precommit...
[ "func", "(", "commit", "*", "Commit", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "if", "commit", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "precommitStrings", ":=", "make", "(", "[", "]", "string", ",", "len", ...
// StringIndented returns a string representation of the commit
[ "StringIndented", "returns", "a", "string", "representation", "of", "the", "commit" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L666-L683
131,085
tendermint/tendermint
types/block.go
StringIndented
func (sh SignedHeader) StringIndented(indent string) string { return fmt.Sprintf(`SignedHeader{ %s %v %s %v %s}`, indent, sh.Header.StringIndented(indent+" "), indent, sh.Commit.StringIndented(indent+" "), indent) }
go
func (sh SignedHeader) StringIndented(indent string) string { return fmt.Sprintf(`SignedHeader{ %s %v %s %v %s}`, indent, sh.Header.StringIndented(indent+" "), indent, sh.Commit.StringIndented(indent+" "), indent) }
[ "func", "(", "sh", "SignedHeader", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "`SignedHeader{\n%s %v\n%s %v\n%s}`", ",", "indent", ",", "sh", ".", "Header", ".", "StringIndented", "(", "indent", ...
// StringIndented returns a string representation of the SignedHeader.
[ "StringIndented", "returns", "a", "string", "representation", "of", "the", "SignedHeader", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L740-L748
131,086
tendermint/tendermint
types/block.go
Hash
func (data *Data) Hash() cmn.HexBytes { if data == nil { return (Txs{}).Hash() } if data.hash == nil { data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs } return data.hash }
go
func (data *Data) Hash() cmn.HexBytes { if data == nil { return (Txs{}).Hash() } if data.hash == nil { data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs } return data.hash }
[ "func", "(", "data", "*", "Data", ")", "Hash", "(", ")", "cmn", ".", "HexBytes", "{", "if", "data", "==", "nil", "{", "return", "(", "Txs", "{", "}", ")", ".", "Hash", "(", ")", "\n", "}", "\n", "if", "data", ".", "hash", "==", "nil", "{", ...
// Hash returns the hash of the data
[ "Hash", "returns", "the", "hash", "of", "the", "data" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L765-L773
131,087
tendermint/tendermint
types/block.go
StringIndented
func (data *Data) StringIndented(indent string) string { if data == nil { return "nil-Data" } txStrings := make([]string, cmn.MinInt(len(data.Txs), 21)) for i, tx := range data.Txs { if i == 20 { txStrings[i] = fmt.Sprintf("... (%v total)", len(data.Txs)) break } txStrings[i] = fmt.Sprintf("%X (%d byt...
go
func (data *Data) StringIndented(indent string) string { if data == nil { return "nil-Data" } txStrings := make([]string, cmn.MinInt(len(data.Txs), 21)) for i, tx := range data.Txs { if i == 20 { txStrings[i] = fmt.Sprintf("... (%v total)", len(data.Txs)) break } txStrings[i] = fmt.Sprintf("%X (%d byt...
[ "func", "(", "data", "*", "Data", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "if", "data", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "txStrings", ":=", "make", "(", "[", "]", "string", ",", "cmn", ".", "MinIn...
// StringIndented returns a string representation of the transactions
[ "StringIndented", "returns", "a", "string", "representation", "of", "the", "transactions" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L776-L793
131,088
tendermint/tendermint
types/block.go
Hash
func (data *EvidenceData) Hash() cmn.HexBytes { if data.hash == nil { data.hash = data.Evidence.Hash() } return data.hash }
go
func (data *EvidenceData) Hash() cmn.HexBytes { if data.hash == nil { data.hash = data.Evidence.Hash() } return data.hash }
[ "func", "(", "data", "*", "EvidenceData", ")", "Hash", "(", ")", "cmn", ".", "HexBytes", "{", "if", "data", ".", "hash", "==", "nil", "{", "data", ".", "hash", "=", "data", ".", "Evidence", ".", "Hash", "(", ")", "\n", "}", "\n", "return", "data"...
// Hash returns the hash of the data.
[ "Hash", "returns", "the", "hash", "of", "the", "data", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L806-L811
131,089
tendermint/tendermint
types/block.go
StringIndented
func (data *EvidenceData) StringIndented(indent string) string { if data == nil { return "nil-Evidence" } evStrings := make([]string, cmn.MinInt(len(data.Evidence), 21)) for i, ev := range data.Evidence { if i == 20 { evStrings[i] = fmt.Sprintf("... (%v total)", len(data.Evidence)) break } evStrings[i...
go
func (data *EvidenceData) StringIndented(indent string) string { if data == nil { return "nil-Evidence" } evStrings := make([]string, cmn.MinInt(len(data.Evidence), 21)) for i, ev := range data.Evidence { if i == 20 { evStrings[i] = fmt.Sprintf("... (%v total)", len(data.Evidence)) break } evStrings[i...
[ "func", "(", "data", "*", "EvidenceData", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "if", "data", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "evStrings", ":=", "make", "(", "[", "]", "string", ",", "cmn", ".", ...
// StringIndented returns a string representation of the evidence.
[ "StringIndented", "returns", "a", "string", "representation", "of", "the", "evidence", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L814-L831
131,090
tendermint/tendermint
types/block.go
Equals
func (blockID BlockID) Equals(other BlockID) bool { return bytes.Equal(blockID.Hash, other.Hash) && blockID.PartsHeader.Equals(other.PartsHeader) }
go
func (blockID BlockID) Equals(other BlockID) bool { return bytes.Equal(blockID.Hash, other.Hash) && blockID.PartsHeader.Equals(other.PartsHeader) }
[ "func", "(", "blockID", "BlockID", ")", "Equals", "(", "other", "BlockID", ")", "bool", "{", "return", "bytes", ".", "Equal", "(", "blockID", ".", "Hash", ",", "other", ".", "Hash", ")", "&&", "blockID", ".", "PartsHeader", ".", "Equals", "(", "other",...
// Equals returns true if the BlockID matches the given BlockID
[ "Equals", "returns", "true", "if", "the", "BlockID", "matches", "the", "given", "BlockID" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L842-L845
131,091
tendermint/tendermint
types/block.go
Key
func (blockID BlockID) Key() string { bz, err := cdc.MarshalBinaryBare(blockID.PartsHeader) if err != nil { panic(err) } return string(blockID.Hash) + string(bz) }
go
func (blockID BlockID) Key() string { bz, err := cdc.MarshalBinaryBare(blockID.PartsHeader) if err != nil { panic(err) } return string(blockID.Hash) + string(bz) }
[ "func", "(", "blockID", "BlockID", ")", "Key", "(", ")", "string", "{", "bz", ",", "err", ":=", "cdc", ".", "MarshalBinaryBare", "(", "blockID", ".", "PartsHeader", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n"...
// Key returns a machine-readable string representation of the BlockID
[ "Key", "returns", "a", "machine", "-", "readable", "string", "representation", "of", "the", "BlockID" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L848-L854
131,092
tendermint/tendermint
types/block.go
IsZero
func (blockID BlockID) IsZero() bool { return len(blockID.Hash) == 0 && blockID.PartsHeader.IsZero() }
go
func (blockID BlockID) IsZero() bool { return len(blockID.Hash) == 0 && blockID.PartsHeader.IsZero() }
[ "func", "(", "blockID", "BlockID", ")", "IsZero", "(", ")", "bool", "{", "return", "len", "(", "blockID", ".", "Hash", ")", "==", "0", "&&", "blockID", ".", "PartsHeader", ".", "IsZero", "(", ")", "\n", "}" ]
// IsZero returns true if this is the BlockID of a nil block.
[ "IsZero", "returns", "true", "if", "this", "is", "the", "BlockID", "of", "a", "nil", "block", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L869-L872
131,093
tendermint/tendermint
types/block.go
IsComplete
func (blockID BlockID) IsComplete() bool { return len(blockID.Hash) == tmhash.Size && blockID.PartsHeader.Total > 0 && len(blockID.PartsHeader.Hash) == tmhash.Size }
go
func (blockID BlockID) IsComplete() bool { return len(blockID.Hash) == tmhash.Size && blockID.PartsHeader.Total > 0 && len(blockID.PartsHeader.Hash) == tmhash.Size }
[ "func", "(", "blockID", "BlockID", ")", "IsComplete", "(", ")", "bool", "{", "return", "len", "(", "blockID", ".", "Hash", ")", "==", "tmhash", ".", "Size", "&&", "blockID", ".", "PartsHeader", ".", "Total", ">", "0", "&&", "len", "(", "blockID", "."...
// IsComplete returns true if this is a valid BlockID of a non-nil block.
[ "IsComplete", "returns", "true", "if", "this", "is", "a", "valid", "BlockID", "of", "a", "non", "-", "nil", "block", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L875-L879
131,094
tendermint/tendermint
types/block.go
String
func (blockID BlockID) String() string { return fmt.Sprintf(`%v:%v`, blockID.Hash, blockID.PartsHeader) }
go
func (blockID BlockID) String() string { return fmt.Sprintf(`%v:%v`, blockID.Hash, blockID.PartsHeader) }
[ "func", "(", "blockID", "BlockID", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "`%v:%v`", ",", "blockID", ".", "Hash", ",", "blockID", ".", "PartsHeader", ")", "\n", "}" ]
// String returns a human readable string representation of the BlockID
[ "String", "returns", "a", "human", "readable", "string", "representation", "of", "the", "BlockID" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/block.go#L882-L884
131,095
tendermint/tendermint
crypto/multisig/bitarray/compact_bit_array.go
NewCompactBitArray
func NewCompactBitArray(bits int) *CompactBitArray { if bits <= 0 { return nil } return &CompactBitArray{ ExtraBitsStored: byte(bits % 8), Elems: make([]byte, (bits+7)/8), } }
go
func NewCompactBitArray(bits int) *CompactBitArray { if bits <= 0 { return nil } return &CompactBitArray{ ExtraBitsStored: byte(bits % 8), Elems: make([]byte, (bits+7)/8), } }
[ "func", "NewCompactBitArray", "(", "bits", "int", ")", "*", "CompactBitArray", "{", "if", "bits", "<=", "0", "{", "return", "nil", "\n", "}", "\n", "return", "&", "CompactBitArray", "{", "ExtraBitsStored", ":", "byte", "(", "bits", "%", "8", ")", ",", ...
// NewCompactBitArray returns a new compact bit array. // It returns nil if the number of bits is zero.
[ "NewCompactBitArray", "returns", "a", "new", "compact", "bit", "array", ".", "It", "returns", "nil", "if", "the", "number", "of", "bits", "is", "zero", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/multisig/bitarray/compact_bit_array.go#L23-L31
131,096
tendermint/tendermint
crypto/multisig/bitarray/compact_bit_array.go
Size
func (bA *CompactBitArray) Size() int { if bA == nil { return 0 } else if bA.ExtraBitsStored == byte(0) { return len(bA.Elems) * 8 } // num_bits = 8*num_full_bytes + overflow_in_last_byte // num_full_bytes = (len(bA.Elems)-1) return (len(bA.Elems)-1)*8 + int(bA.ExtraBitsStored) }
go
func (bA *CompactBitArray) Size() int { if bA == nil { return 0 } else if bA.ExtraBitsStored == byte(0) { return len(bA.Elems) * 8 } // num_bits = 8*num_full_bytes + overflow_in_last_byte // num_full_bytes = (len(bA.Elems)-1) return (len(bA.Elems)-1)*8 + int(bA.ExtraBitsStored) }
[ "func", "(", "bA", "*", "CompactBitArray", ")", "Size", "(", ")", "int", "{", "if", "bA", "==", "nil", "{", "return", "0", "\n", "}", "else", "if", "bA", ".", "ExtraBitsStored", "==", "byte", "(", "0", ")", "{", "return", "len", "(", "bA", ".", ...
// Size returns the number of bits in the bitarray
[ "Size", "returns", "the", "number", "of", "bits", "in", "the", "bitarray" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/multisig/bitarray/compact_bit_array.go#L34-L43
131,097
tendermint/tendermint
crypto/multisig/bitarray/compact_bit_array.go
CompactMarshal
func (bA *CompactBitArray) CompactMarshal() []byte { size := bA.Size() if size <= 0 { return []byte("null") } bz := make([]byte, 0, size/8) // length prefix number of bits, not number of bytes. This difference // takes 3-4 bits in encoding, as opposed to instead encoding the number of // bytes (saving 3-4 bits...
go
func (bA *CompactBitArray) CompactMarshal() []byte { size := bA.Size() if size <= 0 { return []byte("null") } bz := make([]byte, 0, size/8) // length prefix number of bits, not number of bytes. This difference // takes 3-4 bits in encoding, as opposed to instead encoding the number of // bytes (saving 3-4 bits...
[ "func", "(", "bA", "*", "CompactBitArray", ")", "CompactMarshal", "(", ")", "[", "]", "byte", "{", "size", ":=", "bA", ".", "Size", "(", ")", "\n", "if", "size", "<=", "0", "{", "return", "[", "]", "byte", "(", "\"", "\"", ")", "\n", "}", "\n",...
// CompactMarshal is a space efficient encoding for CompactBitArray. // It is not amino compatible.
[ "CompactMarshal", "is", "a", "space", "efficient", "encoding", "for", "CompactBitArray", ".", "It", "is", "not", "amino", "compatible", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/multisig/bitarray/compact_bit_array.go#L197-L209
131,098
tendermint/tendermint
crypto/multisig/bitarray/compact_bit_array.go
CompactUnmarshal
func CompactUnmarshal(bz []byte) (*CompactBitArray, error) { if len(bz) < 2 { return nil, errors.New("compact bit array: invalid compact unmarshal size") } else if bytes.Equal(bz, []byte("null")) { return NewCompactBitArray(0), nil } size, n := binary.Uvarint(bz) bz = bz[n:] if len(bz) != int(size+7)/8 { re...
go
func CompactUnmarshal(bz []byte) (*CompactBitArray, error) { if len(bz) < 2 { return nil, errors.New("compact bit array: invalid compact unmarshal size") } else if bytes.Equal(bz, []byte("null")) { return NewCompactBitArray(0), nil } size, n := binary.Uvarint(bz) bz = bz[n:] if len(bz) != int(size+7)/8 { re...
[ "func", "CompactUnmarshal", "(", "bz", "[", "]", "byte", ")", "(", "*", "CompactBitArray", ",", "error", ")", "{", "if", "len", "(", "bz", ")", "<", "2", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "else", ...
// CompactUnmarshal is a space efficient decoding for CompactBitArray. // It is not amino compatible.
[ "CompactUnmarshal", "is", "a", "space", "efficient", "decoding", "for", "CompactBitArray", ".", "It", "is", "not", "amino", "compatible", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/multisig/bitarray/compact_bit_array.go#L213-L227
131,099
tendermint/tendermint
libs/bech32/bech32.go
ConvertAndEncode
func ConvertAndEncode(hrp string, data []byte) (string, error) { converted, err := bech32.ConvertBits(data, 8, 5, true) if err != nil { return "", errors.Wrap(err, "encoding bech32 failed") } return bech32.Encode(hrp, converted) }
go
func ConvertAndEncode(hrp string, data []byte) (string, error) { converted, err := bech32.ConvertBits(data, 8, 5, true) if err != nil { return "", errors.Wrap(err, "encoding bech32 failed") } return bech32.Encode(hrp, converted) }
[ "func", "ConvertAndEncode", "(", "hrp", "string", ",", "data", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "converted", ",", "err", ":=", "bech32", ".", "ConvertBits", "(", "data", ",", "8", ",", "5", ",", "true", ")", "\n", "if",...
//ConvertAndEncode converts from a base64 encoded byte string to base32 encoded byte string and then to bech32
[ "ConvertAndEncode", "converts", "from", "a", "base64", "encoded", "byte", "string", "to", "base32", "encoded", "byte", "string", "and", "then", "to", "bech32" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/bech32/bech32.go#L9-L16