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
130,900
tendermint/tendermint
p2p/conn/connection.go
loadSendQueueSize
func (ch *Channel) loadSendQueueSize() (size int) { return int(atomic.LoadInt32(&ch.sendQueueSize)) }
go
func (ch *Channel) loadSendQueueSize() (size int) { return int(atomic.LoadInt32(&ch.sendQueueSize)) }
[ "func", "(", "ch", "*", "Channel", ")", "loadSendQueueSize", "(", ")", "(", "size", "int", ")", "{", "return", "int", "(", "atomic", ".", "LoadInt32", "(", "&", "ch", ".", "sendQueueSize", ")", ")", "\n", "}" ]
// Goroutine-safe
[ "Goroutine", "-", "safe" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L752-L754
130,901
tendermint/tendermint
p2p/conn/connection.go
nextPacketMsg
func (ch *Channel) nextPacketMsg() PacketMsg { packet := PacketMsg{} packet.ChannelID = byte(ch.desc.ID) maxSize := ch.maxPacketMsgPayloadSize packet.Bytes = ch.sending[:cmn.MinInt(maxSize, len(ch.sending))] if len(ch.sending) <= maxSize { packet.EOF = byte(0x01) ch.sending = nil atomic.AddInt32(&ch.sendQueu...
go
func (ch *Channel) nextPacketMsg() PacketMsg { packet := PacketMsg{} packet.ChannelID = byte(ch.desc.ID) maxSize := ch.maxPacketMsgPayloadSize packet.Bytes = ch.sending[:cmn.MinInt(maxSize, len(ch.sending))] if len(ch.sending) <= maxSize { packet.EOF = byte(0x01) ch.sending = nil atomic.AddInt32(&ch.sendQueu...
[ "func", "(", "ch", "*", "Channel", ")", "nextPacketMsg", "(", ")", "PacketMsg", "{", "packet", ":=", "PacketMsg", "{", "}", "\n", "packet", ".", "ChannelID", "=", "byte", "(", "ch", ".", "desc", ".", "ID", ")", "\n", "maxSize", ":=", "ch", ".", "ma...
// Creates a new PacketMsg to send. // Not goroutine-safe
[ "Creates", "a", "new", "PacketMsg", "to", "send", ".", "Not", "goroutine", "-", "safe" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L777-L791
130,902
tendermint/tendermint
p2p/conn/connection.go
writePacketMsgTo
func (ch *Channel) writePacketMsgTo(w io.Writer) (n int64, err error) { var packet = ch.nextPacketMsg() n, err = cdc.MarshalBinaryLengthPrefixedWriter(w, packet) atomic.AddInt64(&ch.recentlySent, n) return }
go
func (ch *Channel) writePacketMsgTo(w io.Writer) (n int64, err error) { var packet = ch.nextPacketMsg() n, err = cdc.MarshalBinaryLengthPrefixedWriter(w, packet) atomic.AddInt64(&ch.recentlySent, n) return }
[ "func", "(", "ch", "*", "Channel", ")", "writePacketMsgTo", "(", "w", "io", ".", "Writer", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "var", "packet", "=", "ch", ".", "nextPacketMsg", "(", ")", "\n", "n", ",", "err", "=", "cdc", ".", ...
// Writes next PacketMsg to w and updates c.recentlySent. // Not goroutine-safe
[ "Writes", "next", "PacketMsg", "to", "w", "and", "updates", "c", ".", "recentlySent", ".", "Not", "goroutine", "-", "safe" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L795-L800
130,903
tendermint/tendermint
p2p/conn/connection.go
recvPacketMsg
func (ch *Channel) recvPacketMsg(packet PacketMsg) ([]byte, error) { ch.Logger.Debug("Read PacketMsg", "conn", ch.conn, "packet", packet) var recvCap, recvReceived = ch.desc.RecvMessageCapacity, len(ch.recving) + len(packet.Bytes) if recvCap < recvReceived { return nil, fmt.Errorf("Received message exceeds availab...
go
func (ch *Channel) recvPacketMsg(packet PacketMsg) ([]byte, error) { ch.Logger.Debug("Read PacketMsg", "conn", ch.conn, "packet", packet) var recvCap, recvReceived = ch.desc.RecvMessageCapacity, len(ch.recving) + len(packet.Bytes) if recvCap < recvReceived { return nil, fmt.Errorf("Received message exceeds availab...
[ "func", "(", "ch", "*", "Channel", ")", "recvPacketMsg", "(", "packet", "PacketMsg", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ch", ".", "Logger", ".", "Debug", "(", "\"", "\"", ",", "\"", "\"", ",", "ch", ".", "conn", ",", "\"", "\"...
// Handles incoming PacketMsgs. It returns a message bytes if message is // complete. NOTE message bytes may change on next call to recvPacketMsg. // Not goroutine-safe
[ "Handles", "incoming", "PacketMsgs", ".", "It", "returns", "a", "message", "bytes", "if", "message", "is", "complete", ".", "NOTE", "message", "bytes", "may", "change", "on", "next", "call", "to", "recvPacketMsg", ".", "Not", "goroutine", "-", "safe" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L805-L823
130,904
tendermint/tendermint
p2p/conn/connection.go
updateStats
func (ch *Channel) updateStats() { // Exponential decay of stats. // TODO: optimize. atomic.StoreInt64(&ch.recentlySent, int64(float64(atomic.LoadInt64(&ch.recentlySent))*0.8)) }
go
func (ch *Channel) updateStats() { // Exponential decay of stats. // TODO: optimize. atomic.StoreInt64(&ch.recentlySent, int64(float64(atomic.LoadInt64(&ch.recentlySent))*0.8)) }
[ "func", "(", "ch", "*", "Channel", ")", "updateStats", "(", ")", "{", "// Exponential decay of stats.", "// TODO: optimize.", "atomic", ".", "StoreInt64", "(", "&", "ch", ".", "recentlySent", ",", "int64", "(", "float64", "(", "atomic", ".", "LoadInt64", "(", ...
// Call this periodically to update stats for throttling purposes. // Not goroutine-safe
[ "Call", "this", "periodically", "to", "update", "stats", "for", "throttling", "purposes", ".", "Not", "goroutine", "-", "safe" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L827-L831
130,905
tendermint/tendermint
libs/clist/clist.go
PrevWaitChan
func (e *CElement) PrevWaitChan() <-chan struct{} { e.mtx.RLock() defer e.mtx.RUnlock() return e.prevWaitCh }
go
func (e *CElement) PrevWaitChan() <-chan struct{} { e.mtx.RLock() defer e.mtx.RUnlock() return e.prevWaitCh }
[ "func", "(", "e", "*", "CElement", ")", "PrevWaitChan", "(", ")", "<-", "chan", "struct", "{", "}", "{", "e", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "e", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "return", "e", ".", "prevWaitCh", ...
// PrevWaitChan can be used to wait until Prev becomes not nil. Once it does, // channel will be closed.
[ "PrevWaitChan", "can", "be", "used", "to", "wait", "until", "Prev", "becomes", "not", "nil", ".", "Once", "it", "does", "channel", "will", "be", "closed", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/clist/clist.go#L97-L102
130,906
tendermint/tendermint
libs/clist/clist.go
NextWaitChan
func (e *CElement) NextWaitChan() <-chan struct{} { e.mtx.RLock() defer e.mtx.RUnlock() return e.nextWaitCh }
go
func (e *CElement) NextWaitChan() <-chan struct{} { e.mtx.RLock() defer e.mtx.RUnlock() return e.nextWaitCh }
[ "func", "(", "e", "*", "CElement", ")", "NextWaitChan", "(", ")", "<-", "chan", "struct", "{", "}", "{", "e", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "e", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "return", "e", ".", "nextWaitCh", ...
// NextWaitChan can be used to wait until Next becomes not nil. Once it does, // channel will be closed.
[ "NextWaitChan", "can", "be", "used", "to", "wait", "until", "Next", "becomes", "not", "nil", ".", "Once", "it", "does", "channel", "will", "be", "closed", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/clist/clist.go#L106-L111
130,907
tendermint/tendermint
libs/clist/clist.go
newWithMax
func newWithMax(maxLength int) *CList { l := new(CList) l.maxLen = maxLength return l.Init() }
go
func newWithMax(maxLength int) *CList { l := new(CList) l.maxLen = maxLength return l.Init() }
[ "func", "newWithMax", "(", "maxLength", "int", ")", "*", "CList", "{", "l", ":=", "new", "(", "CList", ")", "\n", "l", ".", "maxLen", "=", "maxLength", "\n", "return", "l", ".", "Init", "(", ")", "\n", "}" ]
// Return CList with given maxLength. // Will panic if list exceeds given maxLength.
[ "Return", "CList", "with", "given", "maxLength", ".", "Will", "panic", "if", "list", "exceeds", "given", "maxLength", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/clist/clist.go#L247-L251
130,908
tendermint/tendermint
libs/clist/clist.go
WaitChan
func (l *CList) WaitChan() <-chan struct{} { l.mtx.Lock() defer l.mtx.Unlock() return l.waitCh }
go
func (l *CList) WaitChan() <-chan struct{} { l.mtx.Lock() defer l.mtx.Unlock() return l.waitCh }
[ "func", "(", "l", "*", "CList", ")", "WaitChan", "(", ")", "<-", "chan", "struct", "{", "}", "{", "l", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "return", "l", ".", "waitCh", "\n", "}"...
// WaitChan can be used to wait until Front or Back becomes not nil. Once it // does, channel will be closed.
[ "WaitChan", "can", "be", "used", "to", "wait", "until", "Front", "or", "Back", "becomes", "not", "nil", ".", "Once", "it", "does", "channel", "will", "be", "closed", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/clist/clist.go#L308-L313
130,909
tendermint/tendermint
libs/clist/clist.go
PushBack
func (l *CList) PushBack(v interface{}) *CElement { l.mtx.Lock() // Construct a new element e := &CElement{ prev: nil, prevWg: waitGroup1(), prevWaitCh: make(chan struct{}), next: nil, nextWg: waitGroup1(), nextWaitCh: make(chan struct{}), removed: false, Value: v, } /...
go
func (l *CList) PushBack(v interface{}) *CElement { l.mtx.Lock() // Construct a new element e := &CElement{ prev: nil, prevWg: waitGroup1(), prevWaitCh: make(chan struct{}), next: nil, nextWg: waitGroup1(), nextWaitCh: make(chan struct{}), removed: false, Value: v, } /...
[ "func", "(", "l", "*", "CList", ")", "PushBack", "(", "v", "interface", "{", "}", ")", "*", "CElement", "{", "l", ".", "mtx", ".", "Lock", "(", ")", "\n\n", "// Construct a new element", "e", ":=", "&", "CElement", "{", "prev", ":", "nil", ",", "pr...
// Panics if list grows beyond its max length.
[ "Panics", "if", "list", "grows", "beyond", "its", "max", "length", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/clist/clist.go#L316-L352
130,910
tendermint/tendermint
libs/autofile/autofile.go
Close
func (af *AutoFile) Close() error { af.closeTicker.Stop() close(af.closeTickerStopc) if af.hupc != nil { close(af.hupc) } return af.closeFile() }
go
func (af *AutoFile) Close() error { af.closeTicker.Stop() close(af.closeTickerStopc) if af.hupc != nil { close(af.hupc) } return af.closeFile() }
[ "func", "(", "af", "*", "AutoFile", ")", "Close", "(", ")", "error", "{", "af", ".", "closeTicker", ".", "Stop", "(", ")", "\n", "close", "(", "af", ".", "closeTickerStopc", ")", "\n", "if", "af", ".", "hupc", "!=", "nil", "{", "close", "(", "af"...
// Close shuts down the closing goroutine, SIGHUP handler and closes the // AutoFile.
[ "Close", "shuts", "down", "the", "closing", "goroutine", "SIGHUP", "handler", "and", "closes", "the", "AutoFile", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/autofile.go#L87-L94
130,911
tendermint/tendermint
libs/autofile/autofile.go
Sync
func (af *AutoFile) Sync() error { af.mtx.Lock() defer af.mtx.Unlock() if af.file == nil { if err := af.openFile(); err != nil { return err } } return af.file.Sync() }
go
func (af *AutoFile) Sync() error { af.mtx.Lock() defer af.mtx.Unlock() if af.file == nil { if err := af.openFile(); err != nil { return err } } return af.file.Sync() }
[ "func", "(", "af", "*", "AutoFile", ")", "Sync", "(", ")", "error", "{", "af", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "af", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "af", ".", "file", "==", "nil", "{", "if", "err", ":=", ...
// Sync commits the current contents of the file to stable storage. Typically, // this means flushing the file system's in-memory copy of recently written // data to disk. // Opens AutoFile if needed.
[ "Sync", "commits", "the", "current", "contents", "of", "the", "file", "to", "stable", "storage", ".", "Typically", "this", "means", "flushing", "the", "file", "system", "s", "in", "-", "memory", "copy", "of", "recently", "written", "data", "to", "disk", "....
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/autofile.go#L142-L152
130,912
tendermint/tendermint
libs/autofile/autofile.go
Size
func (af *AutoFile) Size() (int64, error) { af.mtx.Lock() defer af.mtx.Unlock() if af.file == nil { if err := af.openFile(); err != nil { return -1, err } } stat, err := af.file.Stat() if err != nil { return -1, err } return stat.Size(), nil }
go
func (af *AutoFile) Size() (int64, error) { af.mtx.Lock() defer af.mtx.Unlock() if af.file == nil { if err := af.openFile(); err != nil { return -1, err } } stat, err := af.file.Stat() if err != nil { return -1, err } return stat.Size(), nil }
[ "func", "(", "af", "*", "AutoFile", ")", "Size", "(", ")", "(", "int64", ",", "error", ")", "{", "af", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "af", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "af", ".", "file", "==", "nil", ...
// Size returns the size of the AutoFile. It returns -1 and an error if fails // get stats or open file. // Opens AutoFile if needed.
[ "Size", "returns", "the", "size", "of", "the", "AutoFile", ".", "It", "returns", "-", "1", "and", "an", "error", "if", "fails", "get", "stats", "or", "open", "file", ".", "Opens", "AutoFile", "if", "needed", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/autofile.go#L173-L188
130,913
tendermint/tendermint
consensus/reactor.go
NewConsensusReactor
func NewConsensusReactor(consensusState *ConsensusState, fastSync bool, options ...ReactorOption) *ConsensusReactor { conR := &ConsensusReactor{ conS: consensusState, fastSync: fastSync, metrics: NopMetrics(), } conR.updateFastSyncingMetric() conR.BaseReactor = *p2p.NewBaseReactor("ConsensusReactor", con...
go
func NewConsensusReactor(consensusState *ConsensusState, fastSync bool, options ...ReactorOption) *ConsensusReactor { conR := &ConsensusReactor{ conS: consensusState, fastSync: fastSync, metrics: NopMetrics(), } conR.updateFastSyncingMetric() conR.BaseReactor = *p2p.NewBaseReactor("ConsensusReactor", con...
[ "func", "NewConsensusReactor", "(", "consensusState", "*", "ConsensusState", ",", "fastSync", "bool", ",", "options", "...", "ReactorOption", ")", "*", "ConsensusReactor", "{", "conR", ":=", "&", "ConsensusReactor", "{", "conS", ":", "consensusState", ",", "fastSy...
// NewConsensusReactor returns a new ConsensusReactor with the given // consensusState.
[ "NewConsensusReactor", "returns", "a", "new", "ConsensusReactor", "with", "the", "given", "consensusState", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L53-L67
130,914
tendermint/tendermint
consensus/reactor.go
OnStart
func (conR *ConsensusReactor) OnStart() error { conR.Logger.Info("ConsensusReactor ", "fastSync", conR.FastSync()) // start routine that computes peer statistics for evaluating peer quality go conR.peerStatsRoutine() conR.subscribeToBroadcastEvents() if !conR.FastSync() { err := conR.conS.Start() if err != ...
go
func (conR *ConsensusReactor) OnStart() error { conR.Logger.Info("ConsensusReactor ", "fastSync", conR.FastSync()) // start routine that computes peer statistics for evaluating peer quality go conR.peerStatsRoutine() conR.subscribeToBroadcastEvents() if !conR.FastSync() { err := conR.conS.Start() if err != ...
[ "func", "(", "conR", "*", "ConsensusReactor", ")", "OnStart", "(", ")", "error", "{", "conR", ".", "Logger", ".", "Info", "(", "\"", "\"", ",", "\"", "\"", ",", "conR", ".", "FastSync", "(", ")", ")", "\n\n", "// start routine that computes peer statistics...
// OnStart implements BaseService by subscribing to events, which later will be // broadcasted to other peers and starting state if we're not in fast sync.
[ "OnStart", "implements", "BaseService", "by", "subscribing", "to", "events", "which", "later", "will", "be", "broadcasted", "to", "other", "peers", "and", "starting", "state", "if", "we", "re", "not", "in", "fast", "sync", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L71-L87
130,915
tendermint/tendermint
consensus/reactor.go
OnStop
func (conR *ConsensusReactor) OnStop() { conR.unsubscribeFromBroadcastEvents() conR.conS.Stop() if !conR.FastSync() { conR.conS.Wait() } }
go
func (conR *ConsensusReactor) OnStop() { conR.unsubscribeFromBroadcastEvents() conR.conS.Stop() if !conR.FastSync() { conR.conS.Wait() } }
[ "func", "(", "conR", "*", "ConsensusReactor", ")", "OnStop", "(", ")", "{", "conR", ".", "unsubscribeFromBroadcastEvents", "(", ")", "\n", "conR", ".", "conS", ".", "Stop", "(", ")", "\n", "if", "!", "conR", ".", "FastSync", "(", ")", "{", "conR", "....
// OnStop implements BaseService by unsubscribing from events and stopping // state.
[ "OnStop", "implements", "BaseService", "by", "unsubscribing", "from", "events", "and", "stopping", "state", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L91-L97
130,916
tendermint/tendermint
consensus/reactor.go
SwitchToConsensus
func (conR *ConsensusReactor) SwitchToConsensus(state sm.State, blocksSynced int) { conR.Logger.Info("SwitchToConsensus") conR.conS.reconstructLastCommit(state) // NOTE: The line below causes broadcastNewRoundStepRoutine() to // broadcast a NewRoundStepMessage. conR.conS.updateToState(state) conR.mtx.Lock() con...
go
func (conR *ConsensusReactor) SwitchToConsensus(state sm.State, blocksSynced int) { conR.Logger.Info("SwitchToConsensus") conR.conS.reconstructLastCommit(state) // NOTE: The line below causes broadcastNewRoundStepRoutine() to // broadcast a NewRoundStepMessage. conR.conS.updateToState(state) conR.mtx.Lock() con...
[ "func", "(", "conR", "*", "ConsensusReactor", ")", "SwitchToConsensus", "(", "state", "sm", ".", "State", ",", "blocksSynced", "int", ")", "{", "conR", ".", "Logger", ".", "Info", "(", "\"", "\"", ")", "\n", "conR", ".", "conS", ".", "reconstructLastComm...
// SwitchToConsensus switches from fast_sync mode to consensus mode. // It resets the state, turns off fast_sync, and starts the consensus state-machine
[ "SwitchToConsensus", "switches", "from", "fast_sync", "mode", "to", "consensus", "mode", ".", "It", "resets", "the", "state", "turns", "off", "fast_sync", "and", "starts", "the", "consensus", "state", "-", "machine" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L101-L122
130,917
tendermint/tendermint
consensus/reactor.go
AddPeer
func (conR *ConsensusReactor) AddPeer(peer p2p.Peer) { if !conR.IsRunning() { return } // Create peerState for peer peerState := NewPeerState(peer).SetLogger(conR.Logger) peer.Set(types.PeerStateKey, peerState) // Begin routines for this peer. go conR.gossipDataRoutine(peer, peerState) go conR.gossipVotesRo...
go
func (conR *ConsensusReactor) AddPeer(peer p2p.Peer) { if !conR.IsRunning() { return } // Create peerState for peer peerState := NewPeerState(peer).SetLogger(conR.Logger) peer.Set(types.PeerStateKey, peerState) // Begin routines for this peer. go conR.gossipDataRoutine(peer, peerState) go conR.gossipVotesRo...
[ "func", "(", "conR", "*", "ConsensusReactor", ")", "AddPeer", "(", "peer", "p2p", ".", "Peer", ")", "{", "if", "!", "conR", ".", "IsRunning", "(", ")", "{", "return", "\n", "}", "\n\n", "// Create peerState for peer", "peerState", ":=", "NewPeerState", "("...
// AddPeer implements Reactor
[ "AddPeer", "implements", "Reactor" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L159-L178
130,918
tendermint/tendermint
consensus/reactor.go
FastSync
func (conR *ConsensusReactor) FastSync() bool { conR.mtx.RLock() defer conR.mtx.RUnlock() return conR.fastSync }
go
func (conR *ConsensusReactor) FastSync() bool { conR.mtx.RLock() defer conR.mtx.RUnlock() return conR.fastSync }
[ "func", "(", "conR", "*", "ConsensusReactor", ")", "FastSync", "(", ")", "bool", "{", "conR", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "conR", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "conR", ".", "fastSync", "\n", "}" ]
// FastSync returns whether the consensus reactor is in fast-sync mode.
[ "FastSync", "returns", "whether", "the", "consensus", "reactor", "is", "in", "fast", "-", "sync", "mode", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L359-L363
130,919
tendermint/tendermint
consensus/reactor.go
broadcastHasVoteMessage
func (conR *ConsensusReactor) broadcastHasVoteMessage(vote *types.Vote) { msg := &HasVoteMessage{ Height: vote.Height, Round: vote.Round, Type: vote.Type, Index: vote.ValidatorIndex, } conR.Switch.Broadcast(StateChannel, cdc.MustMarshalBinaryBare(msg)) /* // TODO: Make this broadcast more selective. ...
go
func (conR *ConsensusReactor) broadcastHasVoteMessage(vote *types.Vote) { msg := &HasVoteMessage{ Height: vote.Height, Round: vote.Round, Type: vote.Type, Index: vote.ValidatorIndex, } conR.Switch.Broadcast(StateChannel, cdc.MustMarshalBinaryBare(msg)) /* // TODO: Make this broadcast more selective. ...
[ "func", "(", "conR", "*", "ConsensusReactor", ")", "broadcastHasVoteMessage", "(", "vote", "*", "types", ".", "Vote", ")", "{", "msg", ":=", "&", "HasVoteMessage", "{", "Height", ":", "vote", ".", "Height", ",", "Round", ":", "vote", ".", "Round", ",", ...
// Broadcasts HasVoteMessage to peers that care.
[ "Broadcasts", "HasVoteMessage", "to", "peers", "that", "care", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L411-L437
130,920
tendermint/tendermint
consensus/reactor.go
StringIndented
func (conR *ConsensusReactor) StringIndented(indent string) string { s := "ConsensusReactor{\n" s += indent + " " + conR.conS.StringIndented(indent+" ") + "\n" for _, peer := range conR.Switch.Peers().List() { ps, ok := peer.Get(types.PeerStateKey).(*PeerState) if !ok { panic(fmt.Sprintf("Peer %v has no sta...
go
func (conR *ConsensusReactor) StringIndented(indent string) string { s := "ConsensusReactor{\n" s += indent + " " + conR.conS.StringIndented(indent+" ") + "\n" for _, peer := range conR.Switch.Peers().List() { ps, ok := peer.Get(types.PeerStateKey).(*PeerState) if !ok { panic(fmt.Sprintf("Peer %v has no sta...
[ "func", "(", "conR", "*", "ConsensusReactor", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "s", ":=", "\"", "\\n", "\"", "\n", "s", "+=", "indent", "+", "\"", "\"", "+", "conR", ".", "conS", ".", "StringIndented", "(", "indent", ...
// StringIndented returns an indented string representation of the ConsensusReactor
[ "StringIndented", "returns", "an", "indented", "string", "representation", "of", "the", "ConsensusReactor" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L855-L867
130,921
tendermint/tendermint
consensus/reactor.go
NewPeerState
func NewPeerState(peer p2p.Peer) *PeerState { return &PeerState{ peer: peer, logger: log.NewNopLogger(), PRS: cstypes.PeerRoundState{ Round: -1, ProposalPOLRound: -1, LastCommitRound: -1, CatchupCommitRound: -1, }, Stats: &peerStateStats{}, } }
go
func NewPeerState(peer p2p.Peer) *PeerState { return &PeerState{ peer: peer, logger: log.NewNopLogger(), PRS: cstypes.PeerRoundState{ Round: -1, ProposalPOLRound: -1, LastCommitRound: -1, CatchupCommitRound: -1, }, Stats: &peerStateStats{}, } }
[ "func", "NewPeerState", "(", "peer", "p2p", ".", "Peer", ")", "*", "PeerState", "{", "return", "&", "PeerState", "{", "peer", ":", "peer", ",", "logger", ":", "log", ".", "NewNopLogger", "(", ")", ",", "PRS", ":", "cstypes", ".", "PeerRoundState", "{",...
// NewPeerState returns a new PeerState for the given Peer
[ "NewPeerState", "returns", "a", "new", "PeerState", "for", "the", "given", "Peer" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L916-L928
130,922
tendermint/tendermint
consensus/reactor.go
SetLogger
func (ps *PeerState) SetLogger(logger log.Logger) *PeerState { ps.logger = logger return ps }
go
func (ps *PeerState) SetLogger(logger log.Logger) *PeerState { ps.logger = logger return ps }
[ "func", "(", "ps", "*", "PeerState", ")", "SetLogger", "(", "logger", "log", ".", "Logger", ")", "*", "PeerState", "{", "ps", ".", "logger", "=", "logger", "\n", "return", "ps", "\n", "}" ]
// SetLogger allows to set a logger on the peer state. Returns the peer state // itself.
[ "SetLogger", "allows", "to", "set", "a", "logger", "on", "the", "peer", "state", ".", "Returns", "the", "peer", "state", "itself", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L932-L935
130,923
tendermint/tendermint
consensus/reactor.go
GetRoundState
func (ps *PeerState) GetRoundState() *cstypes.PeerRoundState { ps.mtx.Lock() defer ps.mtx.Unlock() prs := ps.PRS // copy return &prs }
go
func (ps *PeerState) GetRoundState() *cstypes.PeerRoundState { ps.mtx.Lock() defer ps.mtx.Unlock() prs := ps.PRS // copy return &prs }
[ "func", "(", "ps", "*", "PeerState", ")", "GetRoundState", "(", ")", "*", "cstypes", ".", "PeerRoundState", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "prs", ":=", "ps", ".", "P...
// GetRoundState returns an shallow copy of the PeerRoundState. // There's no point in mutating it since it won't change PeerState.
[ "GetRoundState", "returns", "an", "shallow", "copy", "of", "the", "PeerRoundState", ".", "There", "s", "no", "point", "in", "mutating", "it", "since", "it", "won", "t", "change", "PeerState", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L939-L945
130,924
tendermint/tendermint
consensus/reactor.go
ToJSON
func (ps *PeerState) ToJSON() ([]byte, error) { ps.mtx.Lock() defer ps.mtx.Unlock() return cdc.MarshalJSON(ps) }
go
func (ps *PeerState) ToJSON() ([]byte, error) { ps.mtx.Lock() defer ps.mtx.Unlock() return cdc.MarshalJSON(ps) }
[ "func", "(", "ps", "*", "PeerState", ")", "ToJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "return", "cdc", ".", "Mar...
// ToJSON returns a json of PeerState, marshalled using go-amino.
[ "ToJSON", "returns", "a", "json", "of", "PeerState", "marshalled", "using", "go", "-", "amino", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L948-L953
130,925
tendermint/tendermint
consensus/reactor.go
GetHeight
func (ps *PeerState) GetHeight() int64 { ps.mtx.Lock() defer ps.mtx.Unlock() return ps.PRS.Height }
go
func (ps *PeerState) GetHeight() int64 { ps.mtx.Lock() defer ps.mtx.Unlock() return ps.PRS.Height }
[ "func", "(", "ps", "*", "PeerState", ")", "GetHeight", "(", ")", "int64", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n", "return", "ps", ".", "PRS", ".", "Height", "\n", "}" ]
// GetHeight returns an atomic snapshot of the PeerRoundState's height // used by the mempool to ensure peers are caught up before broadcasting new txs
[ "GetHeight", "returns", "an", "atomic", "snapshot", "of", "the", "PeerRoundState", "s", "height", "used", "by", "the", "mempool", "to", "ensure", "peers", "are", "caught", "up", "before", "broadcasting", "new", "txs" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L957-L961
130,926
tendermint/tendermint
consensus/reactor.go
SetHasProposal
func (ps *PeerState) SetHasProposal(proposal *types.Proposal) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != proposal.Height || ps.PRS.Round != proposal.Round { return } if ps.PRS.Proposal { return } ps.PRS.Proposal = true // ps.PRS.ProposalBlockParts is set due to NewValidBlockMessage if ps...
go
func (ps *PeerState) SetHasProposal(proposal *types.Proposal) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != proposal.Height || ps.PRS.Round != proposal.Round { return } if ps.PRS.Proposal { return } ps.PRS.Proposal = true // ps.PRS.ProposalBlockParts is set due to NewValidBlockMessage if ps...
[ "func", "(", "ps", "*", "PeerState", ")", "SetHasProposal", "(", "proposal", "*", "types", ".", "Proposal", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "ps", ".", "PRS...
// SetHasProposal sets the given proposal as known for the peer.
[ "SetHasProposal", "sets", "the", "given", "proposal", "as", "known", "for", "the", "peer", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L964-L987
130,927
tendermint/tendermint
consensus/reactor.go
InitProposalBlockParts
func (ps *PeerState) InitProposalBlockParts(partsHeader types.PartSetHeader) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.ProposalBlockParts != nil { return } ps.PRS.ProposalBlockPartsHeader = partsHeader ps.PRS.ProposalBlockParts = cmn.NewBitArray(partsHeader.Total) }
go
func (ps *PeerState) InitProposalBlockParts(partsHeader types.PartSetHeader) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.ProposalBlockParts != nil { return } ps.PRS.ProposalBlockPartsHeader = partsHeader ps.PRS.ProposalBlockParts = cmn.NewBitArray(partsHeader.Total) }
[ "func", "(", "ps", "*", "PeerState", ")", "InitProposalBlockParts", "(", "partsHeader", "types", ".", "PartSetHeader", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "ps", "....
// InitProposalBlockParts initializes the peer's proposal block parts header and bit array.
[ "InitProposalBlockParts", "initializes", "the", "peer", "s", "proposal", "block", "parts", "header", "and", "bit", "array", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L990-L1000
130,928
tendermint/tendermint
consensus/reactor.go
SetHasProposalBlockPart
func (ps *PeerState) SetHasProposalBlockPart(height int64, round int, index int) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != height || ps.PRS.Round != round { return } ps.PRS.ProposalBlockParts.SetIndex(index, true) }
go
func (ps *PeerState) SetHasProposalBlockPart(height int64, round int, index int) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != height || ps.PRS.Round != round { return } ps.PRS.ProposalBlockParts.SetIndex(index, true) }
[ "func", "(", "ps", "*", "PeerState", ")", "SetHasProposalBlockPart", "(", "height", "int64", ",", "round", "int", ",", "index", "int", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\...
// SetHasProposalBlockPart sets the given block part index as known for the peer.
[ "SetHasProposalBlockPart", "sets", "the", "given", "block", "part", "index", "as", "known", "for", "the", "peer", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1003-L1012
130,929
tendermint/tendermint
consensus/reactor.go
PickSendVote
func (ps *PeerState) PickSendVote(votes types.VoteSetReader) bool { if vote, ok := ps.PickVoteToSend(votes); ok { msg := &VoteMessage{vote} ps.logger.Debug("Sending vote message", "ps", ps, "vote", vote) if ps.peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(msg)) { ps.SetHasVote(vote) return true } re...
go
func (ps *PeerState) PickSendVote(votes types.VoteSetReader) bool { if vote, ok := ps.PickVoteToSend(votes); ok { msg := &VoteMessage{vote} ps.logger.Debug("Sending vote message", "ps", ps, "vote", vote) if ps.peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(msg)) { ps.SetHasVote(vote) return true } re...
[ "func", "(", "ps", "*", "PeerState", ")", "PickSendVote", "(", "votes", "types", ".", "VoteSetReader", ")", "bool", "{", "if", "vote", ",", "ok", ":=", "ps", ".", "PickVoteToSend", "(", "votes", ")", ";", "ok", "{", "msg", ":=", "&", "VoteMessage", "...
// PickSendVote picks a vote and sends it to the peer. // Returns true if vote was sent.
[ "PickSendVote", "picks", "a", "vote", "and", "sends", "it", "to", "the", "peer", ".", "Returns", "true", "if", "vote", "was", "sent", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1016-L1027
130,930
tendermint/tendermint
consensus/reactor.go
RecordVote
func (ps *PeerState) RecordVote() int { ps.mtx.Lock() defer ps.mtx.Unlock() ps.Stats.Votes++ return ps.Stats.Votes }
go
func (ps *PeerState) RecordVote() int { ps.mtx.Lock() defer ps.mtx.Unlock() ps.Stats.Votes++ return ps.Stats.Votes }
[ "func", "(", "ps", "*", "PeerState", ")", "RecordVote", "(", ")", "int", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "ps", ".", "Stats", ".", "Votes", "++", "\n\n", "return", "...
// RecordVote increments internal votes related statistics for this peer. // It returns the total number of added votes.
[ "RecordVote", "increments", "internal", "votes", "related", "statistics", "for", "this", "peer", ".", "It", "returns", "the", "total", "number", "of", "added", "votes", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1160-L1167
130,931
tendermint/tendermint
consensus/reactor.go
RecordBlockPart
func (ps *PeerState) RecordBlockPart() int { ps.mtx.Lock() defer ps.mtx.Unlock() ps.Stats.BlockParts++ return ps.Stats.BlockParts }
go
func (ps *PeerState) RecordBlockPart() int { ps.mtx.Lock() defer ps.mtx.Unlock() ps.Stats.BlockParts++ return ps.Stats.BlockParts }
[ "func", "(", "ps", "*", "PeerState", ")", "RecordBlockPart", "(", ")", "int", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "ps", ".", "Stats", ".", "BlockParts", "++", "\n", "retu...
// RecordBlockPart increments internal block part related statistics for this peer. // It returns the total number of added block parts.
[ "RecordBlockPart", "increments", "internal", "block", "part", "related", "statistics", "for", "this", "peer", ".", "It", "returns", "the", "total", "number", "of", "added", "block", "parts", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1180-L1186
130,932
tendermint/tendermint
consensus/reactor.go
SetHasVote
func (ps *PeerState) SetHasVote(vote *types.Vote) { ps.mtx.Lock() defer ps.mtx.Unlock() ps.setHasVote(vote.Height, vote.Round, vote.Type, vote.ValidatorIndex) }
go
func (ps *PeerState) SetHasVote(vote *types.Vote) { ps.mtx.Lock() defer ps.mtx.Unlock() ps.setHasVote(vote.Height, vote.Round, vote.Type, vote.ValidatorIndex) }
[ "func", "(", "ps", "*", "PeerState", ")", "SetHasVote", "(", "vote", "*", "types", ".", "Vote", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "ps", ".", "setHasVote", "(", "...
// SetHasVote sets the given vote as known by the peer
[ "SetHasVote", "sets", "the", "given", "vote", "as", "known", "by", "the", "peer" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1197-L1202
130,933
tendermint/tendermint
consensus/reactor.go
ApplyNewRoundStepMessage
func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage) { ps.mtx.Lock() defer ps.mtx.Unlock() // Ignore duplicates or decreases if CompareHRS(msg.Height, msg.Round, msg.Step, ps.PRS.Height, ps.PRS.Round, ps.PRS.Step) <= 0 { return } // Just remember these values. psHeight := ps.PRS.Height ps...
go
func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage) { ps.mtx.Lock() defer ps.mtx.Unlock() // Ignore duplicates or decreases if CompareHRS(msg.Height, msg.Round, msg.Step, ps.PRS.Height, ps.PRS.Round, ps.PRS.Step) <= 0 { return } // Just remember these values. psHeight := ps.PRS.Height ps...
[ "func", "(", "ps", "*", "PeerState", ")", "ApplyNewRoundStepMessage", "(", "msg", "*", "NewRoundStepMessage", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "// Ignore duplicates or decr...
// ApplyNewRoundStepMessage updates the peer state for the new round.
[ "ApplyNewRoundStepMessage", "updates", "the", "peer", "state", "for", "the", "new", "round", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1216-L1266
130,934
tendermint/tendermint
consensus/reactor.go
ApplyNewValidBlockMessage
func (ps *PeerState) ApplyNewValidBlockMessage(msg *NewValidBlockMessage) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != msg.Height { return } if ps.PRS.Round != msg.Round && !msg.IsCommit { return } ps.PRS.ProposalBlockPartsHeader = msg.BlockPartsHeader ps.PRS.ProposalBlockParts = msg.BlockPa...
go
func (ps *PeerState) ApplyNewValidBlockMessage(msg *NewValidBlockMessage) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != msg.Height { return } if ps.PRS.Round != msg.Round && !msg.IsCommit { return } ps.PRS.ProposalBlockPartsHeader = msg.BlockPartsHeader ps.PRS.ProposalBlockParts = msg.BlockPa...
[ "func", "(", "ps", "*", "PeerState", ")", "ApplyNewValidBlockMessage", "(", "msg", "*", "NewValidBlockMessage", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "ps", ".", "PRS...
// ApplyNewValidBlockMessage updates the peer state for the new valid block.
[ "ApplyNewValidBlockMessage", "updates", "the", "peer", "state", "for", "the", "new", "valid", "block", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1269-L1283
130,935
tendermint/tendermint
consensus/reactor.go
ApplyProposalPOLMessage
func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != msg.Height { return } if ps.PRS.ProposalPOLRound != msg.ProposalPOLRound { return } // TODO: Merge onto existing ps.PRS.ProposalPOL? // We might have sent some prevotes in the me...
go
func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != msg.Height { return } if ps.PRS.ProposalPOLRound != msg.ProposalPOLRound { return } // TODO: Merge onto existing ps.PRS.ProposalPOL? // We might have sent some prevotes in the me...
[ "func", "(", "ps", "*", "PeerState", ")", "ApplyProposalPOLMessage", "(", "msg", "*", "ProposalPOLMessage", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "ps", ".", "PRS", ...
// ApplyProposalPOLMessage updates the peer state for the new proposal POL.
[ "ApplyProposalPOLMessage", "updates", "the", "peer", "state", "for", "the", "new", "proposal", "POL", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1286-L1300
130,936
tendermint/tendermint
consensus/reactor.go
ApplyHasVoteMessage
func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != msg.Height { return } ps.setHasVote(msg.Height, msg.Round, msg.Type, msg.Index) }
go
func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage) { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.PRS.Height != msg.Height { return } ps.setHasVote(msg.Height, msg.Round, msg.Type, msg.Index) }
[ "func", "(", "ps", "*", "PeerState", ")", "ApplyHasVoteMessage", "(", "msg", "*", "HasVoteMessage", ")", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "ps", ".", "PRS", ".", ...
// ApplyHasVoteMessage updates the peer state for the new vote.
[ "ApplyHasVoteMessage", "updates", "the", "peer", "state", "for", "the", "new", "vote", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1303-L1312
130,937
tendermint/tendermint
consensus/reactor.go
StringIndented
func (ps *PeerState) StringIndented(indent string) string { ps.mtx.Lock() defer ps.mtx.Unlock() return fmt.Sprintf(`PeerState{ %s Key %v %s RoundState %v %s Stats %v %s}`, indent, ps.peer.ID(), indent, ps.PRS.StringIndented(indent+" "), indent, ps.Stats, indent) }
go
func (ps *PeerState) StringIndented(indent string) string { ps.mtx.Lock() defer ps.mtx.Unlock() return fmt.Sprintf(`PeerState{ %s Key %v %s RoundState %v %s Stats %v %s}`, indent, ps.peer.ID(), indent, ps.PRS.StringIndented(indent+" "), indent, ps.Stats, indent) }
[ "func", "(", "ps", "*", "PeerState", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n", "return", "fmt", ".", "Sprintf", "(", ...
// StringIndented returns a string representation of the PeerState
[ "StringIndented", "returns", "a", "string", "representation", "of", "the", "PeerState" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/reactor.go#L1341-L1353
130,938
tendermint/tendermint
libs/common/colors.go
treat
func treat(s string, color string) string { if len(s) > 2 && s[:2] == "\x1b[" { return s } return color + s + ANSIReset }
go
func treat(s string, color string) string { if len(s) > 2 && s[:2] == "\x1b[" { return s } return color + s + ANSIReset }
[ "func", "treat", "(", "s", "string", ",", "color", "string", ")", "string", "{", "if", "len", "(", "s", ")", ">", "2", "&&", "s", "[", ":", "2", "]", "==", "\"", "\\x1b", "\"", "{", "return", "s", "\n", "}", "\n", "return", "color", "+", "s",...
// color the string s with color 'color' // unless s is already colored
[ "color", "the", "string", "s", "with", "color", "color", "unless", "s", "is", "already", "colored" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/colors.go#L38-L43
130,939
tendermint/tendermint
lite/proxy/proxy.go
RPCRoutes
func RPCRoutes(c rpcclient.Client) map[string]*rpcserver.RPCFunc { return map[string]*rpcserver.RPCFunc{ // Subscribe/unsubscribe are reserved for websocket events. "subscribe": rpcserver.NewWSRPCFunc(c.(Wrapper).SubscribeWS, "query"), "unsubscribe": rpcserver.NewWSRPCFunc(c.(Wrapper).UnsubscribeWS, "q...
go
func RPCRoutes(c rpcclient.Client) map[string]*rpcserver.RPCFunc { return map[string]*rpcserver.RPCFunc{ // Subscribe/unsubscribe are reserved for websocket events. "subscribe": rpcserver.NewWSRPCFunc(c.(Wrapper).SubscribeWS, "query"), "unsubscribe": rpcserver.NewWSRPCFunc(c.(Wrapper).UnsubscribeWS, "q...
[ "func", "RPCRoutes", "(", "c", "rpcclient", ".", "Client", ")", "map", "[", "string", "]", "*", "rpcserver", ".", "RPCFunc", "{", "return", "map", "[", "string", "]", "*", "rpcserver", ".", "RPCFunc", "{", "// Subscribe/unsubscribe are reserved for websocket eve...
// RPCRoutes just routes everything to the given client, as if it were // a tendermint fullnode. // // if we want security, the client must implement it as a secure client
[ "RPCRoutes", "just", "routes", "everything", "to", "the", "given", "client", "as", "if", "it", "were", "a", "tendermint", "fullnode", ".", "if", "we", "want", "security", "the", "client", "must", "implement", "it", "as", "a", "secure", "client" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/proxy/proxy.go#L61-L86
130,940
tendermint/tendermint
libs/log/tm_logger.go
NewTMLogger
func NewTMLogger(w io.Writer) Logger { // Color by level value colorFn := func(keyvals ...interface{}) term.FgBgColor { if keyvals[0] != kitlevel.Key() { panic(fmt.Sprintf("expected level key to be first, got %v", keyvals[0])) } switch keyvals[1].(kitlevel.Value).String() { case "debug": return term.FgB...
go
func NewTMLogger(w io.Writer) Logger { // Color by level value colorFn := func(keyvals ...interface{}) term.FgBgColor { if keyvals[0] != kitlevel.Key() { panic(fmt.Sprintf("expected level key to be first, got %v", keyvals[0])) } switch keyvals[1].(kitlevel.Value).String() { case "debug": return term.FgB...
[ "func", "NewTMLogger", "(", "w", "io", ".", "Writer", ")", "Logger", "{", "// Color by level value", "colorFn", ":=", "func", "(", "keyvals", "...", "interface", "{", "}", ")", "term", ".", "FgBgColor", "{", "if", "keyvals", "[", "0", "]", "!=", "kitleve...
// NewTMTermLogger returns a logger that encodes msg and keyvals to the Writer // using go-kit's log as an underlying logger and our custom formatter. Note // that underlying logger could be swapped with something else.
[ "NewTMTermLogger", "returns", "a", "logger", "that", "encodes", "msg", "and", "keyvals", "to", "the", "Writer", "using", "go", "-", "kit", "s", "log", "as", "an", "underlying", "logger", "and", "our", "custom", "formatter", ".", "Note", "that", "underlying",...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/tm_logger.go#L27-L44
130,941
tendermint/tendermint
libs/log/tm_logger.go
NewTMLoggerWithColorFn
func NewTMLoggerWithColorFn(w io.Writer, colorFn func(keyvals ...interface{}) term.FgBgColor) Logger { return &tmLogger{term.NewLogger(w, NewTMFmtLogger, colorFn)} }
go
func NewTMLoggerWithColorFn(w io.Writer, colorFn func(keyvals ...interface{}) term.FgBgColor) Logger { return &tmLogger{term.NewLogger(w, NewTMFmtLogger, colorFn)} }
[ "func", "NewTMLoggerWithColorFn", "(", "w", "io", ".", "Writer", ",", "colorFn", "func", "(", "keyvals", "...", "interface", "{", "}", ")", "term", ".", "FgBgColor", ")", "Logger", "{", "return", "&", "tmLogger", "{", "term", ".", "NewLogger", "(", "w", ...
// NewTMLoggerWithColorFn allows you to provide your own color function. See // NewTMLogger for documentation.
[ "NewTMLoggerWithColorFn", "allows", "you", "to", "provide", "your", "own", "color", "function", ".", "See", "NewTMLogger", "for", "documentation", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/tm_logger.go#L48-L50
130,942
tendermint/tendermint
libs/log/tm_logger.go
Debug
func (l *tmLogger) Debug(msg string, keyvals ...interface{}) { lWithLevel := kitlevel.Debug(l.srcLogger) if err := kitlog.With(lWithLevel, msgKey, msg).Log(keyvals...); err != nil { errLogger := kitlevel.Error(l.srcLogger) kitlog.With(errLogger, msgKey, msg).Log("err", err) } }
go
func (l *tmLogger) Debug(msg string, keyvals ...interface{}) { lWithLevel := kitlevel.Debug(l.srcLogger) if err := kitlog.With(lWithLevel, msgKey, msg).Log(keyvals...); err != nil { errLogger := kitlevel.Error(l.srcLogger) kitlog.With(errLogger, msgKey, msg).Log("err", err) } }
[ "func", "(", "l", "*", "tmLogger", ")", "Debug", "(", "msg", "string", ",", "keyvals", "...", "interface", "{", "}", ")", "{", "lWithLevel", ":=", "kitlevel", ".", "Debug", "(", "l", ".", "srcLogger", ")", "\n", "if", "err", ":=", "kitlog", ".", "W...
// Debug logs a message at level Debug.
[ "Debug", "logs", "a", "message", "at", "level", "Debug", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/tm_logger.go#L62-L68
130,943
tendermint/tendermint
libs/log/tm_logger.go
Error
func (l *tmLogger) Error(msg string, keyvals ...interface{}) { lWithLevel := kitlevel.Error(l.srcLogger) lWithMsg := kitlog.With(lWithLevel, msgKey, msg) if err := lWithMsg.Log(keyvals...); err != nil { lWithMsg.Log("err", err) } }
go
func (l *tmLogger) Error(msg string, keyvals ...interface{}) { lWithLevel := kitlevel.Error(l.srcLogger) lWithMsg := kitlog.With(lWithLevel, msgKey, msg) if err := lWithMsg.Log(keyvals...); err != nil { lWithMsg.Log("err", err) } }
[ "func", "(", "l", "*", "tmLogger", ")", "Error", "(", "msg", "string", ",", "keyvals", "...", "interface", "{", "}", ")", "{", "lWithLevel", ":=", "kitlevel", ".", "Error", "(", "l", ".", "srcLogger", ")", "\n", "lWithMsg", ":=", "kitlog", ".", "With...
// Error logs a message at level Error.
[ "Error", "logs", "a", "message", "at", "level", "Error", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/tm_logger.go#L71-L77
130,944
tendermint/tendermint
libs/log/tm_logger.go
With
func (l *tmLogger) With(keyvals ...interface{}) Logger { return &tmLogger{kitlog.With(l.srcLogger, keyvals...)} }
go
func (l *tmLogger) With(keyvals ...interface{}) Logger { return &tmLogger{kitlog.With(l.srcLogger, keyvals...)} }
[ "func", "(", "l", "*", "tmLogger", ")", "With", "(", "keyvals", "...", "interface", "{", "}", ")", "Logger", "{", "return", "&", "tmLogger", "{", "kitlog", ".", "With", "(", "l", ".", "srcLogger", ",", "keyvals", "...", ")", "}", "\n", "}" ]
// With returns a new contextual logger with keyvals prepended to those passed // to calls to Info, Debug or Error.
[ "With", "returns", "a", "new", "contextual", "logger", "with", "keyvals", "prepended", "to", "those", "passed", "to", "calls", "to", "Info", "Debug", "or", "Error", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/log/tm_logger.go#L81-L83
130,945
tendermint/tendermint
crypto/xchacha20poly1305/xchachapoly.go
New
func New(key []byte) (cipher.AEAD, error) { if len(key) != KeySize { return nil, errors.New("xchacha20poly1305: bad key length") } ret := new(xchacha20poly1305) copy(ret.key[:], key) return ret, nil }
go
func New(key []byte) (cipher.AEAD, error) { if len(key) != KeySize { return nil, errors.New("xchacha20poly1305: bad key length") } ret := new(xchacha20poly1305) copy(ret.key[:], key) return ret, nil }
[ "func", "New", "(", "key", "[", "]", "byte", ")", "(", "cipher", ".", "AEAD", ",", "error", ")", "{", "if", "len", "(", "key", ")", "!=", "KeySize", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "ret"...
// New returns a new xchachapoly1305 AEAD
[ "New", "returns", "a", "new", "xchachapoly1305", "AEAD" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/xchacha20poly1305/xchachapoly.go#L41-L48
130,946
tendermint/tendermint
lite/commit.go
NewFullCommit
func NewFullCommit(signedHeader types.SignedHeader, valset, nextValset *types.ValidatorSet) FullCommit { return FullCommit{ SignedHeader: signedHeader, Validators: valset, NextValidators: nextValset, } }
go
func NewFullCommit(signedHeader types.SignedHeader, valset, nextValset *types.ValidatorSet) FullCommit { return FullCommit{ SignedHeader: signedHeader, Validators: valset, NextValidators: nextValset, } }
[ "func", "NewFullCommit", "(", "signedHeader", "types", ".", "SignedHeader", ",", "valset", ",", "nextValset", "*", "types", ".", "ValidatorSet", ")", "FullCommit", "{", "return", "FullCommit", "{", "SignedHeader", ":", "signedHeader", ",", "Validators", ":", "va...
// NewFullCommit returns a new FullCommit.
[ "NewFullCommit", "returns", "a", "new", "FullCommit", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/commit.go#L23-L29
130,947
tendermint/tendermint
lite/commit.go
Height
func (fc FullCommit) Height() int64 { if fc.SignedHeader.Header == nil { panic("should not happen") } return fc.SignedHeader.Height }
go
func (fc FullCommit) Height() int64 { if fc.SignedHeader.Header == nil { panic("should not happen") } return fc.SignedHeader.Height }
[ "func", "(", "fc", "FullCommit", ")", "Height", "(", ")", "int64", "{", "if", "fc", ".", "SignedHeader", ".", "Header", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "fc", ".", "SignedHeader", ".", "Height", "\n", "}" ...
// Height returns the height of the header.
[ "Height", "returns", "the", "height", "of", "the", "header", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/commit.go#L74-L79
130,948
tendermint/tendermint
lite/commit.go
ChainID
func (fc FullCommit) ChainID() string { if fc.SignedHeader.Header == nil { panic("should not happen") } return fc.SignedHeader.ChainID }
go
func (fc FullCommit) ChainID() string { if fc.SignedHeader.Header == nil { panic("should not happen") } return fc.SignedHeader.ChainID }
[ "func", "(", "fc", "FullCommit", ")", "ChainID", "(", ")", "string", "{", "if", "fc", ".", "SignedHeader", ".", "Header", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "fc", ".", "SignedHeader", ".", "ChainID", "\n", "...
// ChainID returns the chainID of the header.
[ "ChainID", "returns", "the", "chainID", "of", "the", "header", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/commit.go#L82-L87
130,949
tendermint/tendermint
libs/common/errors.go
NewError
func NewError(format string, args ...interface{}) Error { err := FmtError{format, args} return newCmnError(err) }
go
func NewError(format string, args ...interface{}) Error { err := FmtError{format, args} return newCmnError(err) }
[ "func", "NewError", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "Error", "{", "err", ":=", "FmtError", "{", "format", ",", "args", "}", "\n", "return", "newCmnError", "(", "err", ")", "\n", "}" ]
// New Error with formatted message. // The Error's Data will be a FmtError type.
[ "New", "Error", "with", "formatted", "message", ".", "The", "Error", "s", "Data", "will", "be", "a", "FmtError", "type", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/errors.go#L56-L59
130,950
tendermint/tendermint
libs/common/errors.go
Stacktrace
func (err *cmnError) Stacktrace() Error { if err.stacktrace == nil { var offset = 3 var depth = 32 err.stacktrace = captureStacktrace(offset, depth) } return err }
go
func (err *cmnError) Stacktrace() Error { if err.stacktrace == nil { var offset = 3 var depth = 32 err.stacktrace = captureStacktrace(offset, depth) } return err }
[ "func", "(", "err", "*", "cmnError", ")", "Stacktrace", "(", ")", "Error", "{", "if", "err", ".", "stacktrace", "==", "nil", "{", "var", "offset", "=", "3", "\n", "var", "depth", "=", "32", "\n", "err", ".", "stacktrace", "=", "captureStacktrace", "(...
// Captures a stacktrace if one was not already captured.
[ "Captures", "a", "stacktrace", "if", "one", "was", "not", "already", "captured", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/errors.go#L89-L96
130,951
tendermint/tendermint
libs/common/errors.go
Trace
func (err *cmnError) Trace(offset int, format string, args ...interface{}) Error { msg := fmt.Sprintf(format, args...) return err.doTrace(msg, offset) }
go
func (err *cmnError) Trace(offset int, format string, args ...interface{}) Error { msg := fmt.Sprintf(format, args...) return err.doTrace(msg, offset) }
[ "func", "(", "err", "*", "cmnError", ")", "Trace", "(", "offset", "int", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "Error", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "args", "...", ")", "\n", "retur...
// Add tracing information with msg. // Set n=0 unless wrapped with some function, then n > 0.
[ "Add", "tracing", "information", "with", "msg", ".", "Set", "n", "=", "0", "unless", "wrapped", "with", "some", "function", "then", "n", ">", "0", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/errors.go#L100-L103
130,952
tendermint/tendermint
blockchain/pool.go
NewBlockPool
func NewBlockPool(start int64, requestsCh chan<- BlockRequest, errorsCh chan<- peerError) *BlockPool { bp := &BlockPool{ peers: make(map[p2p.ID]*bpPeer), requesters: make(map[int64]*bpRequester), height: start, numPending: 0, requestsCh: requestsCh, errorsCh: errorsCh, } bp.BaseService = *cmn.New...
go
func NewBlockPool(start int64, requestsCh chan<- BlockRequest, errorsCh chan<- peerError) *BlockPool { bp := &BlockPool{ peers: make(map[p2p.ID]*bpPeer), requesters: make(map[int64]*bpRequester), height: start, numPending: 0, requestsCh: requestsCh, errorsCh: errorsCh, } bp.BaseService = *cmn.New...
[ "func", "NewBlockPool", "(", "start", "int64", ",", "requestsCh", "chan", "<-", "BlockRequest", ",", "errorsCh", "chan", "<-", "peerError", ")", "*", "BlockPool", "{", "bp", ":=", "&", "BlockPool", "{", "peers", ":", "make", "(", "map", "[", "p2p", ".", ...
// NewBlockPool returns a new BlockPool with the height equal to start. Block // requests and errors will be sent to requestsCh and errorsCh accordingly.
[ "NewBlockPool", "returns", "a", "new", "BlockPool", "with", "the", "height", "equal", "to", "start", ".", "Block", "requests", "and", "errors", "will", "be", "sent", "to", "requestsCh", "and", "errorsCh", "accordingly", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L83-L96
130,953
tendermint/tendermint
blockchain/pool.go
OnStart
func (pool *BlockPool) OnStart() error { go pool.makeRequestersRoutine() pool.startTime = time.Now() return nil }
go
func (pool *BlockPool) OnStart() error { go pool.makeRequestersRoutine() pool.startTime = time.Now() return nil }
[ "func", "(", "pool", "*", "BlockPool", ")", "OnStart", "(", ")", "error", "{", "go", "pool", ".", "makeRequestersRoutine", "(", ")", "\n", "pool", ".", "startTime", "=", "time", ".", "Now", "(", ")", "\n", "return", "nil", "\n", "}" ]
// OnStart implements cmn.Service by spawning requesters routine and recording // pool's start time.
[ "OnStart", "implements", "cmn", ".", "Service", "by", "spawning", "requesters", "routine", "and", "recording", "pool", "s", "start", "time", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L100-L104
130,954
tendermint/tendermint
blockchain/pool.go
makeRequestersRoutine
func (pool *BlockPool) makeRequestersRoutine() { for { if !pool.IsRunning() { break } _, numPending, lenRequesters := pool.GetStatus() if numPending >= maxPendingRequests { // sleep for a bit. time.Sleep(requestIntervalMS * time.Millisecond) // check for timed out peers pool.removeTimedoutPeers...
go
func (pool *BlockPool) makeRequestersRoutine() { for { if !pool.IsRunning() { break } _, numPending, lenRequesters := pool.GetStatus() if numPending >= maxPendingRequests { // sleep for a bit. time.Sleep(requestIntervalMS * time.Millisecond) // check for timed out peers pool.removeTimedoutPeers...
[ "func", "(", "pool", "*", "BlockPool", ")", "makeRequestersRoutine", "(", ")", "{", "for", "{", "if", "!", "pool", ".", "IsRunning", "(", ")", "{", "break", "\n", "}", "\n\n", "_", ",", "numPending", ",", "lenRequesters", ":=", "pool", ".", "GetStatus"...
// spawns requesters as needed
[ "spawns", "requesters", "as", "needed" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L107-L129
130,955
tendermint/tendermint
blockchain/pool.go
GetStatus
func (pool *BlockPool) GetStatus() (height int64, numPending int32, lenRequesters int) { pool.mtx.Lock() defer pool.mtx.Unlock() return pool.height, atomic.LoadInt32(&pool.numPending), len(pool.requesters) }
go
func (pool *BlockPool) GetStatus() (height int64, numPending int32, lenRequesters int) { pool.mtx.Lock() defer pool.mtx.Unlock() return pool.height, atomic.LoadInt32(&pool.numPending), len(pool.requesters) }
[ "func", "(", "pool", "*", "BlockPool", ")", "GetStatus", "(", ")", "(", "height", "int64", ",", "numPending", "int32", ",", "lenRequesters", "int", ")", "{", "pool", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "pool", ".", "mtx", ".", "Unlock",...
// GetStatus returns pool's height, numPending requests and the number of // requesters.
[ "GetStatus", "returns", "pool", "s", "height", "numPending", "requests", "and", "the", "number", "of", "requesters", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L157-L162
130,956
tendermint/tendermint
blockchain/pool.go
PeekTwoBlocks
func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block) { pool.mtx.Lock() defer pool.mtx.Unlock() if r := pool.requesters[pool.height]; r != nil { first = r.getBlock() } if r := pool.requesters[pool.height+1]; r != nil { second = r.getBlock() } return }
go
func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block) { pool.mtx.Lock() defer pool.mtx.Unlock() if r := pool.requesters[pool.height]; r != nil { first = r.getBlock() } if r := pool.requesters[pool.height+1]; r != nil { second = r.getBlock() } return }
[ "func", "(", "pool", "*", "BlockPool", ")", "PeekTwoBlocks", "(", ")", "(", "first", "*", "types", ".", "Block", ",", "second", "*", "types", ".", "Block", ")", "{", "pool", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "pool", ".", "mtx", "....
// We need to see the second block's Commit to validate the first block. // So we peek two blocks at a time. // The caller will verify the commit.
[ "We", "need", "to", "see", "the", "second", "block", "s", "Commit", "to", "validate", "the", "first", "block", ".", "So", "we", "peek", "two", "blocks", "at", "a", "time", ".", "The", "caller", "will", "verify", "the", "commit", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L190-L201
130,957
tendermint/tendermint
blockchain/pool.go
RedoRequest
func (pool *BlockPool) RedoRequest(height int64) p2p.ID { pool.mtx.Lock() defer pool.mtx.Unlock() request := pool.requesters[height] peerID := request.getPeerID() if peerID != p2p.ID("") { // RemovePeer will redo all requesters associated with this peer. pool.removePeer(peerID) } return peerID }
go
func (pool *BlockPool) RedoRequest(height int64) p2p.ID { pool.mtx.Lock() defer pool.mtx.Unlock() request := pool.requesters[height] peerID := request.getPeerID() if peerID != p2p.ID("") { // RemovePeer will redo all requesters associated with this peer. pool.removePeer(peerID) } return peerID }
[ "func", "(", "pool", "*", "BlockPool", ")", "RedoRequest", "(", "height", "int64", ")", "p2p", ".", "ID", "{", "pool", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "pool", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "request", ":=", "pool", ...
// Invalidates the block at pool.height, // Remove the peer and redo request from others. // Returns the ID of the removed peer.
[ "Invalidates", "the", "block", "at", "pool", ".", "height", "Remove", "the", "peer", "and", "redo", "request", "from", "others", ".", "Returns", "the", "ID", "of", "the", "removed", "peer", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L226-L237
130,958
tendermint/tendermint
blockchain/pool.go
MaxPeerHeight
func (pool *BlockPool) MaxPeerHeight() int64 { pool.mtx.Lock() defer pool.mtx.Unlock() return pool.maxPeerHeight }
go
func (pool *BlockPool) MaxPeerHeight() int64 { pool.mtx.Lock() defer pool.mtx.Unlock() return pool.maxPeerHeight }
[ "func", "(", "pool", "*", "BlockPool", ")", "MaxPeerHeight", "(", ")", "int64", "{", "pool", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "pool", ".", "mtx", ".", "Unlock", "(", ")", "\n", "return", "pool", ".", "maxPeerHeight", "\n", "}" ]
// MaxPeerHeight returns the highest reported height.
[ "MaxPeerHeight", "returns", "the", "highest", "reported", "height", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L270-L274
130,959
tendermint/tendermint
blockchain/pool.go
SetPeerHeight
func (pool *BlockPool) SetPeerHeight(peerID p2p.ID, height int64) { pool.mtx.Lock() defer pool.mtx.Unlock() peer := pool.peers[peerID] if peer != nil { peer.height = height } else { peer = newBPPeer(pool, peerID, height) peer.setLogger(pool.Logger.With("peer", peerID)) pool.peers[peerID] = peer } if he...
go
func (pool *BlockPool) SetPeerHeight(peerID p2p.ID, height int64) { pool.mtx.Lock() defer pool.mtx.Unlock() peer := pool.peers[peerID] if peer != nil { peer.height = height } else { peer = newBPPeer(pool, peerID, height) peer.setLogger(pool.Logger.With("peer", peerID)) pool.peers[peerID] = peer } if he...
[ "func", "(", "pool", "*", "BlockPool", ")", "SetPeerHeight", "(", "peerID", "p2p", ".", "ID", ",", "height", "int64", ")", "{", "pool", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "pool", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "peer", ...
// SetPeerHeight sets the peer's alleged blockchain height.
[ "SetPeerHeight", "sets", "the", "peer", "s", "alleged", "blockchain", "height", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L277-L293
130,960
tendermint/tendermint
blockchain/pool.go
RemovePeer
func (pool *BlockPool) RemovePeer(peerID p2p.ID) { pool.mtx.Lock() defer pool.mtx.Unlock() pool.removePeer(peerID) }
go
func (pool *BlockPool) RemovePeer(peerID p2p.ID) { pool.mtx.Lock() defer pool.mtx.Unlock() pool.removePeer(peerID) }
[ "func", "(", "pool", "*", "BlockPool", ")", "RemovePeer", "(", "peerID", "p2p", ".", "ID", ")", "{", "pool", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "pool", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "pool", ".", "removePeer", "(", "p...
// RemovePeer removes the peer with peerID from the pool. If there's no peer // with peerID, function is a no-op.
[ "RemovePeer", "removes", "the", "peer", "with", "peerID", "from", "the", "pool", ".", "If", "there", "s", "no", "peer", "with", "peerID", "function", "is", "a", "no", "-", "op", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L297-L302
130,961
tendermint/tendermint
blockchain/pool.go
updateMaxPeerHeight
func (pool *BlockPool) updateMaxPeerHeight() { var max int64 for _, peer := range pool.peers { if peer.height > max { max = peer.height } } pool.maxPeerHeight = max }
go
func (pool *BlockPool) updateMaxPeerHeight() { var max int64 for _, peer := range pool.peers { if peer.height > max { max = peer.height } } pool.maxPeerHeight = max }
[ "func", "(", "pool", "*", "BlockPool", ")", "updateMaxPeerHeight", "(", ")", "{", "var", "max", "int64", "\n", "for", "_", ",", "peer", ":=", "range", "pool", ".", "peers", "{", "if", "peer", ".", "height", ">", "max", "{", "max", "=", "peer", ".",...
// If no peers are left, maxPeerHeight is set to 0.
[ "If", "no", "peers", "are", "left", "maxPeerHeight", "is", "set", "to", "0", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L328-L336
130,962
tendermint/tendermint
blockchain/pool.go
pickIncrAvailablePeer
func (pool *BlockPool) pickIncrAvailablePeer(minHeight int64) *bpPeer { pool.mtx.Lock() defer pool.mtx.Unlock() for _, peer := range pool.peers { if peer.didTimeout { pool.removePeer(peer.id) continue } if peer.numPending >= maxPendingRequestsPerPeer { continue } if peer.height < minHeight { c...
go
func (pool *BlockPool) pickIncrAvailablePeer(minHeight int64) *bpPeer { pool.mtx.Lock() defer pool.mtx.Unlock() for _, peer := range pool.peers { if peer.didTimeout { pool.removePeer(peer.id) continue } if peer.numPending >= maxPendingRequestsPerPeer { continue } if peer.height < minHeight { c...
[ "func", "(", "pool", "*", "BlockPool", ")", "pickIncrAvailablePeer", "(", "minHeight", "int64", ")", "*", "bpPeer", "{", "pool", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "pool", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", ...
// Pick an available peer with at least the given minHeight. // If no peers are available, returns nil.
[ "Pick", "an", "available", "peer", "with", "at", "least", "the", "given", "minHeight", ".", "If", "no", "peers", "are", "available", "returns", "nil", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L340-L359
130,963
tendermint/tendermint
blockchain/pool.go
setBlock
func (bpr *bpRequester) setBlock(block *types.Block, peerID p2p.ID) bool { bpr.mtx.Lock() if bpr.block != nil || bpr.peerID != peerID { bpr.mtx.Unlock() return false } bpr.block = block bpr.mtx.Unlock() select { case bpr.gotBlockCh <- struct{}{}: default: } return true }
go
func (bpr *bpRequester) setBlock(block *types.Block, peerID p2p.ID) bool { bpr.mtx.Lock() if bpr.block != nil || bpr.peerID != peerID { bpr.mtx.Unlock() return false } bpr.block = block bpr.mtx.Unlock() select { case bpr.gotBlockCh <- struct{}{}: default: } return true }
[ "func", "(", "bpr", "*", "bpRequester", ")", "setBlock", "(", "block", "*", "types", ".", "Block", ",", "peerID", "p2p", ".", "ID", ")", "bool", "{", "bpr", ".", "mtx", ".", "Lock", "(", ")", "\n", "if", "bpr", ".", "block", "!=", "nil", "||", ...
// Returns true if the peer matches and block doesn't already exist.
[ "Returns", "true", "if", "the", "peer", "matches", "and", "block", "doesn", "t", "already", "exist", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/pool.go#L524-L538
130,964
tendermint/tendermint
types/validator_set.go
NewValidatorSet
func NewValidatorSet(valz []*Validator) *ValidatorSet { vals := &ValidatorSet{} err := vals.updateWithChangeSet(valz, false) if err != nil { panic(fmt.Sprintf("cannot create validator set: %s", err)) } if len(valz) > 0 { vals.IncrementProposerPriority(1) } return vals }
go
func NewValidatorSet(valz []*Validator) *ValidatorSet { vals := &ValidatorSet{} err := vals.updateWithChangeSet(valz, false) if err != nil { panic(fmt.Sprintf("cannot create validator set: %s", err)) } if len(valz) > 0 { vals.IncrementProposerPriority(1) } return vals }
[ "func", "NewValidatorSet", "(", "valz", "[", "]", "*", "Validator", ")", "*", "ValidatorSet", "{", "vals", ":=", "&", "ValidatorSet", "{", "}", "\n", "err", ":=", "vals", ".", "updateWithChangeSet", "(", "valz", ",", "false", ")", "\n", "if", "err", "!...
// NewValidatorSet initializes a ValidatorSet by copying over the // values from `valz`, a list of Validators. If valz is nil or empty, // the new ValidatorSet will have an empty list of Validators. // The addresses of validators in `valz` must be unique otherwise the // function panics.
[ "NewValidatorSet", "initializes", "a", "ValidatorSet", "by", "copying", "over", "the", "values", "from", "valz", "a", "list", "of", "Validators", ".", "If", "valz", "is", "nil", "or", "empty", "the", "new", "ValidatorSet", "will", "have", "an", "empty", "lis...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L55-L65
130,965
tendermint/tendermint
types/validator_set.go
CopyIncrementProposerPriority
func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet { copy := vals.Copy() copy.IncrementProposerPriority(times) return copy }
go
func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet { copy := vals.Copy() copy.IncrementProposerPriority(times) return copy }
[ "func", "(", "vals", "*", "ValidatorSet", ")", "CopyIncrementProposerPriority", "(", "times", "int", ")", "*", "ValidatorSet", "{", "copy", ":=", "vals", ".", "Copy", "(", ")", "\n", "copy", ".", "IncrementProposerPriority", "(", "times", ")", "\n", "return"...
// Increment ProposerPriority and update the proposer on a copy, and return it.
[ "Increment", "ProposerPriority", "and", "update", "the", "proposer", "on", "a", "copy", "and", "return", "it", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L73-L77
130,966
tendermint/tendermint
types/validator_set.go
IncrementProposerPriority
func (vals *ValidatorSet) IncrementProposerPriority(times int) { if vals.IsNilOrEmpty() { panic("empty validator set") } if times <= 0 { panic("Cannot call IncrementProposerPriority with non-positive times") } // Cap the difference between priorities to be proportional to 2*totalPower by // re-normalizing pr...
go
func (vals *ValidatorSet) IncrementProposerPriority(times int) { if vals.IsNilOrEmpty() { panic("empty validator set") } if times <= 0 { panic("Cannot call IncrementProposerPriority with non-positive times") } // Cap the difference between priorities to be proportional to 2*totalPower by // re-normalizing pr...
[ "func", "(", "vals", "*", "ValidatorSet", ")", "IncrementProposerPriority", "(", "times", "int", ")", "{", "if", "vals", ".", "IsNilOrEmpty", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "times", "<=", "0", "{", "panic", "(", ...
// IncrementProposerPriority increments ProposerPriority of each validator and updates the // proposer. Panics if validator set is empty. // `times` must be positive.
[ "IncrementProposerPriority", "increments", "ProposerPriority", "of", "each", "validator", "and", "updates", "the", "proposer", ".", "Panics", "if", "validator", "set", "is", "empty", ".", "times", "must", "be", "positive", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L82-L104
130,967
tendermint/tendermint
types/validator_set.go
computeAvgProposerPriority
func (vals *ValidatorSet) computeAvgProposerPriority() int64 { n := int64(len(vals.Validators)) sum := big.NewInt(0) for _, val := range vals.Validators { sum.Add(sum, big.NewInt(val.ProposerPriority)) } avg := sum.Div(sum, big.NewInt(n)) if avg.IsInt64() { return avg.Int64() } // This should never happen:...
go
func (vals *ValidatorSet) computeAvgProposerPriority() int64 { n := int64(len(vals.Validators)) sum := big.NewInt(0) for _, val := range vals.Validators { sum.Add(sum, big.NewInt(val.ProposerPriority)) } avg := sum.Div(sum, big.NewInt(n)) if avg.IsInt64() { return avg.Int64() } // This should never happen:...
[ "func", "(", "vals", "*", "ValidatorSet", ")", "computeAvgProposerPriority", "(", ")", "int64", "{", "n", ":=", "int64", "(", "len", "(", "vals", ".", "Validators", ")", ")", "\n", "sum", ":=", "big", ".", "NewInt", "(", "0", ")", "\n", "for", "_", ...
// Should not be called on an empty validator set.
[ "Should", "not", "be", "called", "on", "an", "empty", "validator", "set", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L144-L157
130,968
tendermint/tendermint
types/validator_set.go
computeMaxMinPriorityDiff
func computeMaxMinPriorityDiff(vals *ValidatorSet) int64 { if vals.IsNilOrEmpty() { panic("empty validator set") } max := int64(math.MinInt64) min := int64(math.MaxInt64) for _, v := range vals.Validators { if v.ProposerPriority < min { min = v.ProposerPriority } if v.ProposerPriority > max { max = v...
go
func computeMaxMinPriorityDiff(vals *ValidatorSet) int64 { if vals.IsNilOrEmpty() { panic("empty validator set") } max := int64(math.MinInt64) min := int64(math.MaxInt64) for _, v := range vals.Validators { if v.ProposerPriority < min { min = v.ProposerPriority } if v.ProposerPriority > max { max = v...
[ "func", "computeMaxMinPriorityDiff", "(", "vals", "*", "ValidatorSet", ")", "int64", "{", "if", "vals", ".", "IsNilOrEmpty", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "max", ":=", "int64", "(", "math", ".", "MinInt64", ")", "\n", ...
// Compute the difference between the max and min ProposerPriority of that set.
[ "Compute", "the", "difference", "between", "the", "max", "and", "min", "ProposerPriority", "of", "that", "set", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L160-L180
130,969
tendermint/tendermint
types/validator_set.go
validatorListCopy
func validatorListCopy(valsList []*Validator) []*Validator { if valsList == nil { return nil } valsCopy := make([]*Validator, len(valsList)) for i, val := range valsList { valsCopy[i] = val.Copy() } return valsCopy }
go
func validatorListCopy(valsList []*Validator) []*Validator { if valsList == nil { return nil } valsCopy := make([]*Validator, len(valsList)) for i, val := range valsList { valsCopy[i] = val.Copy() } return valsCopy }
[ "func", "validatorListCopy", "(", "valsList", "[", "]", "*", "Validator", ")", "[", "]", "*", "Validator", "{", "if", "valsList", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "valsCopy", ":=", "make", "(", "[", "]", "*", "Validator", ",", "len...
// Makes a copy of the validator list.
[ "Makes", "a", "copy", "of", "the", "validator", "list", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L201-L210
130,970
tendermint/tendermint
types/validator_set.go
Copy
func (vals *ValidatorSet) Copy() *ValidatorSet { return &ValidatorSet{ Validators: validatorListCopy(vals.Validators), Proposer: vals.Proposer, totalVotingPower: vals.totalVotingPower, } }
go
func (vals *ValidatorSet) Copy() *ValidatorSet { return &ValidatorSet{ Validators: validatorListCopy(vals.Validators), Proposer: vals.Proposer, totalVotingPower: vals.totalVotingPower, } }
[ "func", "(", "vals", "*", "ValidatorSet", ")", "Copy", "(", ")", "*", "ValidatorSet", "{", "return", "&", "ValidatorSet", "{", "Validators", ":", "validatorListCopy", "(", "vals", ".", "Validators", ")", ",", "Proposer", ":", "vals", ".", "Proposer", ",", ...
// Copy each validator into a new ValidatorSet.
[ "Copy", "each", "validator", "into", "a", "new", "ValidatorSet", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L213-L219
130,971
tendermint/tendermint
types/validator_set.go
HasAddress
func (vals *ValidatorSet) HasAddress(address []byte) bool { idx := sort.Search(len(vals.Validators), func(i int) bool { return bytes.Compare(address, vals.Validators[i].Address) <= 0 }) return idx < len(vals.Validators) && bytes.Equal(vals.Validators[idx].Address, address) }
go
func (vals *ValidatorSet) HasAddress(address []byte) bool { idx := sort.Search(len(vals.Validators), func(i int) bool { return bytes.Compare(address, vals.Validators[i].Address) <= 0 }) return idx < len(vals.Validators) && bytes.Equal(vals.Validators[idx].Address, address) }
[ "func", "(", "vals", "*", "ValidatorSet", ")", "HasAddress", "(", "address", "[", "]", "byte", ")", "bool", "{", "idx", ":=", "sort", ".", "Search", "(", "len", "(", "vals", ".", "Validators", ")", ",", "func", "(", "i", "int", ")", "bool", "{", ...
// HasAddress returns true if address given is in the validator set, false - // otherwise.
[ "HasAddress", "returns", "true", "if", "address", "given", "is", "in", "the", "validator", "set", "false", "-", "otherwise", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L223-L228
130,972
tendermint/tendermint
types/validator_set.go
GetByAddress
func (vals *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator) { idx := sort.Search(len(vals.Validators), func(i int) bool { return bytes.Compare(address, vals.Validators[i].Address) <= 0 }) if idx < len(vals.Validators) && bytes.Equal(vals.Validators[idx].Address, address) { return idx, vals...
go
func (vals *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator) { idx := sort.Search(len(vals.Validators), func(i int) bool { return bytes.Compare(address, vals.Validators[i].Address) <= 0 }) if idx < len(vals.Validators) && bytes.Equal(vals.Validators[idx].Address, address) { return idx, vals...
[ "func", "(", "vals", "*", "ValidatorSet", ")", "GetByAddress", "(", "address", "[", "]", "byte", ")", "(", "index", "int", ",", "val", "*", "Validator", ")", "{", "idx", ":=", "sort", ".", "Search", "(", "len", "(", "vals", ".", "Validators", ")", ...
// GetByAddress returns an index of the validator with address and validator // itself if found. Otherwise, -1 and nil are returned.
[ "GetByAddress", "returns", "an", "index", "of", "the", "validator", "with", "address", "and", "validator", "itself", "if", "found", ".", "Otherwise", "-", "1", "and", "nil", "are", "returned", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L232-L240
130,973
tendermint/tendermint
types/validator_set.go
updateTotalVotingPower
func (vals *ValidatorSet) updateTotalVotingPower() { sum := int64(0) for _, val := range vals.Validators { // mind overflow sum = safeAddClip(sum, val.VotingPower) if sum > MaxTotalVotingPower { panic(fmt.Sprintf( "Total voting power should be guarded to not exceed %v; got: %v", MaxTotalVotingPower,...
go
func (vals *ValidatorSet) updateTotalVotingPower() { sum := int64(0) for _, val := range vals.Validators { // mind overflow sum = safeAddClip(sum, val.VotingPower) if sum > MaxTotalVotingPower { panic(fmt.Sprintf( "Total voting power should be guarded to not exceed %v; got: %v", MaxTotalVotingPower,...
[ "func", "(", "vals", "*", "ValidatorSet", ")", "updateTotalVotingPower", "(", ")", "{", "sum", ":=", "int64", "(", "0", ")", "\n", "for", "_", ",", "val", ":=", "range", "vals", ".", "Validators", "{", "// mind overflow", "sum", "=", "safeAddClip", "(", ...
// Force recalculation of the set's total voting power.
[ "Force", "recalculation", "of", "the", "set", "s", "total", "voting", "power", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L259-L274
130,974
tendermint/tendermint
types/validator_set.go
TotalVotingPower
func (vals *ValidatorSet) TotalVotingPower() int64 { if vals.totalVotingPower == 0 { vals.updateTotalVotingPower() } return vals.totalVotingPower }
go
func (vals *ValidatorSet) TotalVotingPower() int64 { if vals.totalVotingPower == 0 { vals.updateTotalVotingPower() } return vals.totalVotingPower }
[ "func", "(", "vals", "*", "ValidatorSet", ")", "TotalVotingPower", "(", ")", "int64", "{", "if", "vals", ".", "totalVotingPower", "==", "0", "{", "vals", ".", "updateTotalVotingPower", "(", ")", "\n", "}", "\n", "return", "vals", ".", "totalVotingPower", "...
// TotalVotingPower returns the sum of the voting powers of all validators. // It recomputes the total voting power if required.
[ "TotalVotingPower", "returns", "the", "sum", "of", "the", "voting", "powers", "of", "all", "validators", ".", "It", "recomputes", "the", "total", "voting", "power", "if", "required", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L278-L283
130,975
tendermint/tendermint
types/validator_set.go
GetProposer
func (vals *ValidatorSet) GetProposer() (proposer *Validator) { if len(vals.Validators) == 0 { return nil } if vals.Proposer == nil { vals.Proposer = vals.findProposer() } return vals.Proposer.Copy() }
go
func (vals *ValidatorSet) GetProposer() (proposer *Validator) { if len(vals.Validators) == 0 { return nil } if vals.Proposer == nil { vals.Proposer = vals.findProposer() } return vals.Proposer.Copy() }
[ "func", "(", "vals", "*", "ValidatorSet", ")", "GetProposer", "(", ")", "(", "proposer", "*", "Validator", ")", "{", "if", "len", "(", "vals", ".", "Validators", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "if", "vals", ".", "Proposer", ...
// GetProposer returns the current proposer. If the validator set is empty, nil // is returned.
[ "GetProposer", "returns", "the", "current", "proposer", ".", "If", "the", "validator", "set", "is", "empty", "nil", "is", "returned", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L287-L295
130,976
tendermint/tendermint
types/validator_set.go
Iterate
func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool) { for i, val := range vals.Validators { stop := fn(i, val.Copy()) if stop { break } } }
go
func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool) { for i, val := range vals.Validators { stop := fn(i, val.Copy()) if stop { break } } }
[ "func", "(", "vals", "*", "ValidatorSet", ")", "Iterate", "(", "fn", "func", "(", "index", "int", ",", "val", "*", "Validator", ")", "bool", ")", "{", "for", "i", ",", "val", ":=", "range", "vals", ".", "Validators", "{", "stop", ":=", "fn", "(", ...
// Iterate will run the given function over the set.
[ "Iterate", "will", "run", "the", "given", "function", "over", "the", "set", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L321-L328
130,977
tendermint/tendermint
types/validator_set.go
computeNewPriorities
func computeNewPriorities(updates []*Validator, vals *ValidatorSet, updatedTotalVotingPower int64) { for _, valUpdate := range updates { address := valUpdate.Address _, val := vals.GetByAddress(address) if val == nil { // add val // Set ProposerPriority to -C*totalVotingPower (with C ~= 1.125) to make sur...
go
func computeNewPriorities(updates []*Validator, vals *ValidatorSet, updatedTotalVotingPower int64) { for _, valUpdate := range updates { address := valUpdate.Address _, val := vals.GetByAddress(address) if val == nil { // add val // Set ProposerPriority to -C*totalVotingPower (with C ~= 1.125) to make sur...
[ "func", "computeNewPriorities", "(", "updates", "[", "]", "*", "Validator", ",", "vals", "*", "ValidatorSet", ",", "updatedTotalVotingPower", "int64", ")", "{", "for", "_", ",", "valUpdate", ":=", "range", "updates", "{", "address", ":=", "valUpdate", ".", "...
// Computes the proposer priority for the validators not present in the set based on 'updatedTotalVotingPower'. // Leaves unchanged the priorities of validators that are changed. // // 'updates' parameter must be a list of unique validators to be added or updated. // No changes are made to the validator set 'vals'.
[ "Computes", "the", "proposer", "priority", "for", "the", "validators", "not", "present", "in", "the", "set", "based", "on", "updatedTotalVotingPower", ".", "Leaves", "unchanged", "the", "priorities", "of", "validators", "that", "are", "changed", ".", "updates", ...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L414-L434
130,978
tendermint/tendermint
types/validator_set.go
verifyRemovals
func verifyRemovals(deletes []*Validator, vals *ValidatorSet) error { for _, valUpdate := range deletes { address := valUpdate.Address _, val := vals.GetByAddress(address) if val == nil { return fmt.Errorf("failed to find validator %X to remove", address) } } if len(deletes) > len(vals.Validators) { pa...
go
func verifyRemovals(deletes []*Validator, vals *ValidatorSet) error { for _, valUpdate := range deletes { address := valUpdate.Address _, val := vals.GetByAddress(address) if val == nil { return fmt.Errorf("failed to find validator %X to remove", address) } } if len(deletes) > len(vals.Validators) { pa...
[ "func", "verifyRemovals", "(", "deletes", "[", "]", "*", "Validator", ",", "vals", "*", "ValidatorSet", ")", "error", "{", "for", "_", ",", "valUpdate", ":=", "range", "deletes", "{", "address", ":=", "valUpdate", ".", "Address", "\n", "_", ",", "val", ...
// Checks that the validators to be removed are part of the validator set. // No changes are made to the validator set 'vals'.
[ "Checks", "that", "the", "validators", "to", "be", "removed", "are", "part", "of", "the", "validator", "set", ".", "No", "changes", "are", "made", "to", "the", "validator", "set", "vals", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L478-L491
130,979
tendermint/tendermint
types/validator_set.go
applyRemovals
func (vals *ValidatorSet) applyRemovals(deletes []*Validator) { existing := vals.Validators merged := make([]*Validator, len(existing)-len(deletes)) i := 0 // Loop over deletes until we removed all of them. for len(deletes) > 0 { if bytes.Equal(existing[0].Address, deletes[0].Address) { deletes = deletes[1...
go
func (vals *ValidatorSet) applyRemovals(deletes []*Validator) { existing := vals.Validators merged := make([]*Validator, len(existing)-len(deletes)) i := 0 // Loop over deletes until we removed all of them. for len(deletes) > 0 { if bytes.Equal(existing[0].Address, deletes[0].Address) { deletes = deletes[1...
[ "func", "(", "vals", "*", "ValidatorSet", ")", "applyRemovals", "(", "deletes", "[", "]", "*", "Validator", ")", "{", "existing", ":=", "vals", ".", "Validators", "\n\n", "merged", ":=", "make", "(", "[", "]", "*", "Validator", ",", "len", "(", "existi...
// Removes the validators specified in 'deletes' from validator set 'vals'. // Should not fail as verification has been done before.
[ "Removes", "the", "validators", "specified", "in", "deletes", "from", "validator", "set", "vals", ".", "Should", "not", "fail", "as", "verification", "has", "been", "done", "before", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator_set.go#L495-L520
130,980
tendermint/tendermint
p2p/transport.go
ConnDuplicateIPFilter
func ConnDuplicateIPFilter() ConnFilterFunc { return func(cs ConnSet, c net.Conn, ips []net.IP) error { for _, ip := range ips { if cs.HasIP(ip) { return ErrRejected{ conn: c, err: fmt.Errorf("IP<%v> already connected", ip), isDuplicate: true, } } } return nil } }
go
func ConnDuplicateIPFilter() ConnFilterFunc { return func(cs ConnSet, c net.Conn, ips []net.IP) error { for _, ip := range ips { if cs.HasIP(ip) { return ErrRejected{ conn: c, err: fmt.Errorf("IP<%v> already connected", ip), isDuplicate: true, } } } return nil } }
[ "func", "ConnDuplicateIPFilter", "(", ")", "ConnFilterFunc", "{", "return", "func", "(", "cs", "ConnSet", ",", "c", "net", ".", "Conn", ",", "ips", "[", "]", "net", ".", "IP", ")", "error", "{", "for", "_", ",", "ip", ":=", "range", "ips", "{", "if...
// ConnDuplicateIPFilter resolves and keeps all ips for an incoming connection // and refuses new ones if they come from a known ip.
[ "ConnDuplicateIPFilter", "resolves", "and", "keeps", "all", "ips", "for", "an", "incoming", "connection", "and", "refuses", "new", "ones", "if", "they", "come", "from", "a", "known", "ip", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/transport.go#L78-L92
130,981
tendermint/tendermint
p2p/transport.go
MultiplexTransportFilterTimeout
func MultiplexTransportFilterTimeout( timeout time.Duration, ) MultiplexTransportOption { return func(mt *MultiplexTransport) { mt.filterTimeout = timeout } }
go
func MultiplexTransportFilterTimeout( timeout time.Duration, ) MultiplexTransportOption { return func(mt *MultiplexTransport) { mt.filterTimeout = timeout } }
[ "func", "MultiplexTransportFilterTimeout", "(", "timeout", "time", ".", "Duration", ",", ")", "MultiplexTransportOption", "{", "return", "func", "(", "mt", "*", "MultiplexTransport", ")", "{", "mt", ".", "filterTimeout", "=", "timeout", "}", "\n", "}" ]
// MultiplexTransportFilterTimeout sets the timeout waited for filter calls to // return.
[ "MultiplexTransportFilterTimeout", "sets", "the", "timeout", "waited", "for", "filter", "calls", "to", "return", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/transport.go#L107-L111
130,982
tendermint/tendermint
p2p/transport.go
NewMultiplexTransport
func NewMultiplexTransport( nodeInfo NodeInfo, nodeKey NodeKey, mConfig conn.MConnConfig, ) *MultiplexTransport { return &MultiplexTransport{ acceptc: make(chan accept), closec: make(chan struct{}), dialTimeout: defaultDialTimeout, filterTimeout: defaultFilterTimeout, handshakeT...
go
func NewMultiplexTransport( nodeInfo NodeInfo, nodeKey NodeKey, mConfig conn.MConnConfig, ) *MultiplexTransport { return &MultiplexTransport{ acceptc: make(chan accept), closec: make(chan struct{}), dialTimeout: defaultDialTimeout, filterTimeout: defaultFilterTimeout, handshakeT...
[ "func", "NewMultiplexTransport", "(", "nodeInfo", "NodeInfo", ",", "nodeKey", "NodeKey", ",", "mConfig", "conn", ".", "MConnConfig", ",", ")", "*", "MultiplexTransport", "{", "return", "&", "MultiplexTransport", "{", "acceptc", ":", "make", "(", "chan", "accept"...
// NewMultiplexTransport returns a tcp connected multiplexed peer.
[ "NewMultiplexTransport", "returns", "a", "tcp", "connected", "multiplexed", "peer", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/transport.go#L150-L167
130,983
tendermint/tendermint
p2p/transport.go
Accept
func (mt *MultiplexTransport) Accept(cfg peerConfig) (Peer, error) { select { // This case should never have any side-effectful/blocking operations to // ensure that quality peers are ready to be used. case a := <-mt.acceptc: if a.err != nil { return nil, a.err } cfg.outbound = false return mt.wrapPeer...
go
func (mt *MultiplexTransport) Accept(cfg peerConfig) (Peer, error) { select { // This case should never have any side-effectful/blocking operations to // ensure that quality peers are ready to be used. case a := <-mt.acceptc: if a.err != nil { return nil, a.err } cfg.outbound = false return mt.wrapPeer...
[ "func", "(", "mt", "*", "MultiplexTransport", ")", "Accept", "(", "cfg", "peerConfig", ")", "(", "Peer", ",", "error", ")", "{", "select", "{", "// This case should never have any side-effectful/blocking operations to", "// ensure that quality peers are ready to be used.", ...
// Accept implements Transport.
[ "Accept", "implements", "Transport", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/transport.go#L175-L190
130,984
tendermint/tendermint
p2p/transport.go
Dial
func (mt *MultiplexTransport) Dial( addr NetAddress, cfg peerConfig, ) (Peer, error) { c, err := addr.DialTimeout(mt.dialTimeout) if err != nil { return nil, err } // TODO(xla): Evaluate if we should apply filters if we explicitly dial. if err := mt.filterConn(c); err != nil { return nil, err } secretCon...
go
func (mt *MultiplexTransport) Dial( addr NetAddress, cfg peerConfig, ) (Peer, error) { c, err := addr.DialTimeout(mt.dialTimeout) if err != nil { return nil, err } // TODO(xla): Evaluate if we should apply filters if we explicitly dial. if err := mt.filterConn(c); err != nil { return nil, err } secretCon...
[ "func", "(", "mt", "*", "MultiplexTransport", ")", "Dial", "(", "addr", "NetAddress", ",", "cfg", "peerConfig", ",", ")", "(", "Peer", ",", "error", ")", "{", "c", ",", "err", ":=", "addr", ".", "DialTimeout", "(", "mt", ".", "dialTimeout", ")", "\n"...
// Dial implements Transport.
[ "Dial", "implements", "Transport", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/transport.go#L193-L217
130,985
tendermint/tendermint
p2p/transport.go
Close
func (mt *MultiplexTransport) Close() error { close(mt.closec) if mt.listener != nil { return mt.listener.Close() } return nil }
go
func (mt *MultiplexTransport) Close() error { close(mt.closec) if mt.listener != nil { return mt.listener.Close() } return nil }
[ "func", "(", "mt", "*", "MultiplexTransport", ")", "Close", "(", ")", "error", "{", "close", "(", "mt", ".", "closec", ")", "\n\n", "if", "mt", ".", "listener", "!=", "nil", "{", "return", "mt", ".", "listener", ".", "Close", "(", ")", "\n", "}", ...
// Close implements transportLifecycle.
[ "Close", "implements", "transportLifecycle", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/transport.go#L220-L228
130,986
tendermint/tendermint
p2p/transport.go
Listen
func (mt *MultiplexTransport) Listen(addr NetAddress) error { ln, err := net.Listen("tcp", addr.DialString()) if err != nil { return err } mt.netAddr = addr mt.listener = ln go mt.acceptPeers() return nil }
go
func (mt *MultiplexTransport) Listen(addr NetAddress) error { ln, err := net.Listen("tcp", addr.DialString()) if err != nil { return err } mt.netAddr = addr mt.listener = ln go mt.acceptPeers() return nil }
[ "func", "(", "mt", "*", "MultiplexTransport", ")", "Listen", "(", "addr", "NetAddress", ")", "error", "{", "ln", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "addr", ".", "DialString", "(", ")", ")", "\n", "if", "err", "!=", "nil",...
// Listen implements transportLifecycle.
[ "Listen", "implements", "transportLifecycle", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/transport.go#L231-L243
130,987
tendermint/tendermint
p2p/transport.go
Cleanup
func (mt *MultiplexTransport) Cleanup(p Peer) { mt.conns.RemoveAddr(p.RemoteAddr()) _ = p.CloseConn() }
go
func (mt *MultiplexTransport) Cleanup(p Peer) { mt.conns.RemoveAddr(p.RemoteAddr()) _ = p.CloseConn() }
[ "func", "(", "mt", "*", "MultiplexTransport", ")", "Cleanup", "(", "p", "Peer", ")", "{", "mt", ".", "conns", ".", "RemoveAddr", "(", "p", ".", "RemoteAddr", "(", ")", ")", "\n", "_", "=", "p", ".", "CloseConn", "(", ")", "\n", "}" ]
// Cleanup removes the given address from the connections set and // closes the connection.
[ "Cleanup", "removes", "the", "given", "address", "from", "the", "connections", "set", "and", "closes", "the", "connection", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/transport.go#L299-L302
130,988
tendermint/tendermint
lite/client/provider.go
NewHTTPProvider
func NewHTTPProvider(chainID, remote string) lite.Provider { return NewProvider(chainID, rpcclient.NewHTTP(remote, "/websocket")) }
go
func NewHTTPProvider(chainID, remote string) lite.Provider { return NewProvider(chainID, rpcclient.NewHTTP(remote, "/websocket")) }
[ "func", "NewHTTPProvider", "(", "chainID", ",", "remote", "string", ")", "lite", ".", "Provider", "{", "return", "NewProvider", "(", "chainID", ",", "rpcclient", ".", "NewHTTP", "(", "remote", ",", "\"", "\"", ")", ")", "\n", "}" ]
// NewHTTPProvider can connect to a tendermint json-rpc endpoint // at the given url, and uses that as a read-only provider.
[ "NewHTTPProvider", "can", "connect", "to", "a", "tendermint", "json", "-", "rpc", "endpoint", "at", "the", "given", "url", "and", "uses", "that", "as", "a", "read", "-", "only", "provider", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/client/provider.go#L42-L44
130,989
tendermint/tendermint
lite/client/provider.go
fillFullCommit
func (p *provider) fillFullCommit(signedHeader types.SignedHeader) (fc lite.FullCommit, err error) { // Get the validators. valset, err := p.getValidatorSet(signedHeader.ChainID, signedHeader.Height) if err != nil { return lite.FullCommit{}, err } // Get the next validators. nextValset, err := p.getValidatorS...
go
func (p *provider) fillFullCommit(signedHeader types.SignedHeader) (fc lite.FullCommit, err error) { // Get the validators. valset, err := p.getValidatorSet(signedHeader.ChainID, signedHeader.Height) if err != nil { return lite.FullCommit{}, err } // Get the next validators. nextValset, err := p.getValidatorS...
[ "func", "(", "p", "*", "provider", ")", "fillFullCommit", "(", "signedHeader", "types", ".", "SignedHeader", ")", "(", "fc", "lite", ".", "FullCommit", ",", "err", "error", ")", "{", "// Get the validators.", "valset", ",", "err", ":=", "p", ".", "getValid...
// This does no validation.
[ "This", "does", "no", "validation", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/client/provider.go#L119-L134
130,990
tendermint/tendermint
libs/autofile/cmd/logjack.go
parseFlags
func parseFlags() (headPath string, chopSize int64, limitSize int64, version bool) { var flagSet = flag.NewFlagSet(os.Args[0], flag.ExitOnError) var chopSizeStr, limitSizeStr string flagSet.StringVar(&headPath, "head", "logjack.out", "Destination (head) file.") flagSet.StringVar(&chopSizeStr, "chop", "100M", "Move ...
go
func parseFlags() (headPath string, chopSize int64, limitSize int64, version bool) { var flagSet = flag.NewFlagSet(os.Args[0], flag.ExitOnError) var chopSizeStr, limitSizeStr string flagSet.StringVar(&headPath, "head", "logjack.out", "Destination (head) file.") flagSet.StringVar(&chopSizeStr, "chop", "100M", "Move ...
[ "func", "parseFlags", "(", ")", "(", "headPath", "string", ",", "chopSize", "int64", ",", "limitSize", "int64", ",", "version", "bool", ")", "{", "var", "flagSet", "=", "flag", ".", "NewFlagSet", "(", "os", ".", "Args", "[", "0", "]", ",", "flag", "....
// Parse command-line options
[ "Parse", "command", "-", "line", "options" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/autofile/cmd/logjack.go#L19-L30
130,991
tendermint/tendermint
libs/cli/setup.go
PrepareBaseCmd
func PrepareBaseCmd(cmd *cobra.Command, envPrefix, defaultHome string) Executor { cobra.OnInitialize(func() { initEnv(envPrefix) }) cmd.PersistentFlags().StringP(HomeFlag, "", defaultHome, "directory for config and data") cmd.PersistentFlags().Bool(TraceFlag, false, "print out full stack trace on errors") cmd.Persi...
go
func PrepareBaseCmd(cmd *cobra.Command, envPrefix, defaultHome string) Executor { cobra.OnInitialize(func() { initEnv(envPrefix) }) cmd.PersistentFlags().StringP(HomeFlag, "", defaultHome, "directory for config and data") cmd.PersistentFlags().Bool(TraceFlag, false, "print out full stack trace on errors") cmd.Persi...
[ "func", "PrepareBaseCmd", "(", "cmd", "*", "cobra", ".", "Command", ",", "envPrefix", ",", "defaultHome", "string", ")", "Executor", "{", "cobra", ".", "OnInitialize", "(", "func", "(", ")", "{", "initEnv", "(", "envPrefix", ")", "}", ")", "\n", "cmd", ...
// PrepareBaseCmd is meant for tendermint and other servers
[ "PrepareBaseCmd", "is", "meant", "for", "tendermint", "and", "other", "servers" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/cli/setup.go#L28-L34
130,992
tendermint/tendermint
libs/cli/setup.go
initEnv
func initEnv(prefix string) { copyEnvVars(prefix) // env variables with TM prefix (eg. TM_ROOT) viper.SetEnvPrefix(prefix) viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_")) viper.AutomaticEnv() }
go
func initEnv(prefix string) { copyEnvVars(prefix) // env variables with TM prefix (eg. TM_ROOT) viper.SetEnvPrefix(prefix) viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_")) viper.AutomaticEnv() }
[ "func", "initEnv", "(", "prefix", "string", ")", "{", "copyEnvVars", "(", "prefix", ")", "\n\n", "// env variables with TM prefix (eg. TM_ROOT)", "viper", ".", "SetEnvPrefix", "(", "prefix", ")", "\n", "viper", ".", "SetEnvKeyReplacer", "(", "strings", ".", "NewRe...
// initEnv sets to use ENV variables if set.
[ "initEnv", "sets", "to", "use", "ENV", "variables", "if", "set", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/cli/setup.go#L48-L55
130,993
tendermint/tendermint
libs/cli/setup.go
copyEnvVars
func copyEnvVars(prefix string) { prefix = strings.ToUpper(prefix) ps := prefix + "_" for _, e := range os.Environ() { kv := strings.SplitN(e, "=", 2) if len(kv) == 2 { k, v := kv[0], kv[1] if strings.HasPrefix(k, prefix) && !strings.HasPrefix(k, ps) { k2 := strings.Replace(k, prefix, ps, 1) os.Set...
go
func copyEnvVars(prefix string) { prefix = strings.ToUpper(prefix) ps := prefix + "_" for _, e := range os.Environ() { kv := strings.SplitN(e, "=", 2) if len(kv) == 2 { k, v := kv[0], kv[1] if strings.HasPrefix(k, prefix) && !strings.HasPrefix(k, ps) { k2 := strings.Replace(k, prefix, ps, 1) os.Set...
[ "func", "copyEnvVars", "(", "prefix", "string", ")", "{", "prefix", "=", "strings", ".", "ToUpper", "(", "prefix", ")", "\n", "ps", ":=", "prefix", "+", "\"", "\"", "\n", "for", "_", ",", "e", ":=", "range", "os", ".", "Environ", "(", ")", "{", "...
// This copies all variables like TMROOT to TM_ROOT, // so we can support both formats for the user
[ "This", "copies", "all", "variables", "like", "TMROOT", "to", "TM_ROOT", "so", "we", "can", "support", "both", "formats", "for", "the", "user" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/cli/setup.go#L59-L72
130,994
tendermint/tendermint
libs/cli/setup.go
concatCobraCmdFuncs
func concatCobraCmdFuncs(fs ...cobraCmdFunc) cobraCmdFunc { return func(cmd *cobra.Command, args []string) error { for _, f := range fs { if f != nil { if err := f(cmd, args); err != nil { return err } } } return nil } }
go
func concatCobraCmdFuncs(fs ...cobraCmdFunc) cobraCmdFunc { return func(cmd *cobra.Command, args []string) error { for _, f := range fs { if f != nil { if err := f(cmd, args); err != nil { return err } } } return nil } }
[ "func", "concatCobraCmdFuncs", "(", "fs", "...", "cobraCmdFunc", ")", "cobraCmdFunc", "{", "return", "func", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "for", "_", ",", "f", ":=", "range", "fs", "{", ...
// Returns a single function that calls each argument function in sequence // RunE, PreRunE, PersistentPreRunE, etc. all have this same signature
[ "Returns", "a", "single", "function", "that", "calls", "each", "argument", "function", "in", "sequence", "RunE", "PreRunE", "PersistentPreRunE", "etc", ".", "all", "have", "this", "same", "signature" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/cli/setup.go#L111-L122
130,995
tendermint/tendermint
libs/cli/setup.go
bindFlagsLoadViper
func bindFlagsLoadViper(cmd *cobra.Command, args []string) error { // cmd.Flags() includes flags from this command and all persistent flags from the parent if err := viper.BindPFlags(cmd.Flags()); err != nil { return err } homeDir := viper.GetString(HomeFlag) viper.Set(HomeFlag, homeDir) viper.SetConfigName("c...
go
func bindFlagsLoadViper(cmd *cobra.Command, args []string) error { // cmd.Flags() includes flags from this command and all persistent flags from the parent if err := viper.BindPFlags(cmd.Flags()); err != nil { return err } homeDir := viper.GetString(HomeFlag) viper.Set(HomeFlag, homeDir) viper.SetConfigName("c...
[ "func", "bindFlagsLoadViper", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "// cmd.Flags() includes flags from this command and all persistent flags from the parent", "if", "err", ":=", "viper", ".", "BindPFlags", "(", ...
// Bind all flags and read the config into viper
[ "Bind", "all", "flags", "and", "read", "the", "config", "into", "viper" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/cli/setup.go#L125-L146
130,996
tendermint/tendermint
types/vote.go
CommitSig
func (vote *Vote) CommitSig() *CommitSig { if vote == nil { return nil } cs := CommitSig(*vote) return &cs }
go
func (vote *Vote) CommitSig() *CommitSig { if vote == nil { return nil } cs := CommitSig(*vote) return &cs }
[ "func", "(", "vote", "*", "Vote", ")", "CommitSig", "(", ")", "*", "CommitSig", "{", "if", "vote", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "cs", ":=", "CommitSig", "(", "*", "vote", ")", "\n", "return", "&", "cs", "\n", "}" ]
// CommitSig converts the Vote to a CommitSig. // If the Vote is nil, the CommitSig will be nil.
[ "CommitSig", "converts", "the", "Vote", "to", "a", "CommitSig", ".", "If", "the", "Vote", "is", "nil", "the", "CommitSig", "will", "be", "nil", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/vote.go#L64-L70
130,997
tendermint/tendermint
types/results.go
NewResults
func NewResults(responses []*abci.ResponseDeliverTx) ABCIResults { res := make(ABCIResults, len(responses)) for i, d := range responses { res[i] = NewResultFromResponse(d) } return res }
go
func NewResults(responses []*abci.ResponseDeliverTx) ABCIResults { res := make(ABCIResults, len(responses)) for i, d := range responses { res[i] = NewResultFromResponse(d) } return res }
[ "func", "NewResults", "(", "responses", "[", "]", "*", "abci", ".", "ResponseDeliverTx", ")", "ABCIResults", "{", "res", ":=", "make", "(", "ABCIResults", ",", "len", "(", "responses", ")", ")", "\n", "for", "i", ",", "d", ":=", "range", "responses", "...
// NewResults creates ABCIResults from the list of ResponseDeliverTx.
[ "NewResults", "creates", "ABCIResults", "from", "the", "list", "of", "ResponseDeliverTx", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/results.go#L28-L34
130,998
tendermint/tendermint
types/results.go
NewResultFromResponse
func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult { return ABCIResult{ Code: response.Code, Data: response.Data, } }
go
func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult { return ABCIResult{ Code: response.Code, Data: response.Data, } }
[ "func", "NewResultFromResponse", "(", "response", "*", "abci", ".", "ResponseDeliverTx", ")", "ABCIResult", "{", "return", "ABCIResult", "{", "Code", ":", "response", ".", "Code", ",", "Data", ":", "response", ".", "Data", ",", "}", "\n", "}" ]
// NewResultFromResponse creates ABCIResult from ResponseDeliverTx.
[ "NewResultFromResponse", "creates", "ABCIResult", "from", "ResponseDeliverTx", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/results.go#L37-L42
130,999
tendermint/tendermint
types/results.go
Bytes
func (a ABCIResults) Bytes() []byte { bz, err := cdc.MarshalBinaryLengthPrefixed(a) if err != nil { panic(err) } return bz }
go
func (a ABCIResults) Bytes() []byte { bz, err := cdc.MarshalBinaryLengthPrefixed(a) if err != nil { panic(err) } return bz }
[ "func", "(", "a", "ABCIResults", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "bz", ",", "err", ":=", "cdc", ".", "MarshalBinaryLengthPrefixed", "(", "a", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "ret...
// Bytes serializes the ABCIResponse using wire
[ "Bytes", "serializes", "the", "ABCIResponse", "using", "wire" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/results.go#L45-L51