Documentation ¶
Overview ¶
ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>
ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.
Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:
- You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
- Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.
ZooBC is architected by Roberto Capodieci & Barton Johnston
contact us at roberto.capodieci[at]blockchainzoo.com and barton.johnston[at]blockchainzoo.com
Core developers that contributed to the current implementation of the software are:
Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com Allan Bintoro allan.bintoro[at]blockchainzoo.com Andy Herman Gede Sukra Ketut Ariasa Nawi Kartini nawi.kartini[at]blockchainzoo.com Stefano Galassi stefano.galassi[at]blockchainzoo.com
IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>
ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.
Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:
- You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
- Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.
ZooBC is architected by Roberto Capodieci & Barton Johnston
contact us at roberto.capodieci[at]blockchainzoo.com and barton.johnston[at]blockchainzoo.com
Core developers that contributed to the current implementation of the software are:
Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com Allan Bintoro allan.bintoro[at]blockchainzoo.com Andy Herman Gede Sukra Ketut Ariasa Nawi Kartini nawi.kartini[at]blockchainzoo.com Stefano Galassi stefano.galassi[at]blockchainzoo.com
IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>
ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.
Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:
- You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
- Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.
ZooBC is architected by Roberto Capodieci & Barton Johnston
contact us at roberto.capodieci[at]blockchainzoo.com and barton.johnston[at]blockchainzoo.com
Core developers that contributed to the current implementation of the software are:
Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com Allan Bintoro allan.bintoro[at]blockchainzoo.com Andy Herman Gede Sukra Ketut Ariasa Nawi Kartini nawi.kartini[at]blockchainzoo.com Stefano Galassi stefano.galassi[at]blockchainzoo.com
IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Index ¶
- type AntiSpamStrategy
- func (ass *AntiSpamStrategy) DecrementVarCount(k string) interface{}
- func (ass *AntiSpamStrategy) GetFeedbackVar(k string) interface{}
- func (ass *AntiSpamStrategy) GetSuggestedActions() map[constant.FeedbackAction]bool
- func (ass *AntiSpamStrategy) IncrementVarCount(k string) interface{}
- func (ass *AntiSpamStrategy) IsCPULimitReached(numSamples int) (limitReached bool, limitLevel constant.FeedbackLimitLevel)
- func (ass *AntiSpamStrategy) IsGoroutineLimitReached(numSamples int) (limitReached bool, limitLevel constant.FeedbackLimitLevel)
- func (ass *AntiSpamStrategy) IsMemoryLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
- func (ass *AntiSpamStrategy) IsP2PRequestLimitReached(numSamples int) (limitReached bool, limitLevel constant.FeedbackLimitLevel)
- func (ass *AntiSpamStrategy) SetFeedbackVar(k string, v interface{})
- func (ass *AntiSpamStrategy) StartSampling(samplingInterval time.Duration)
- type DummyFeedbackStrategy
- func (dfs *DummyFeedbackStrategy) DecrementVarCount(k string) interface{}
- func (dfs *DummyFeedbackStrategy) GetFeedbackVar(k string) interface{}
- func (dfs *DummyFeedbackStrategy) GetSuggestedActions() map[constant.FeedbackAction]bool
- func (dfs *DummyFeedbackStrategy) IncrementVarCount(k string) interface{}
- func (dfs *DummyFeedbackStrategy) IsCPULimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
- func (dfs *DummyFeedbackStrategy) IsGoroutineLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
- func (dfs *DummyFeedbackStrategy) IsMemoryLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
- func (dfs *DummyFeedbackStrategy) IsP2PRequestLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
- func (dfs *DummyFeedbackStrategy) SetFeedbackVar(k string, v interface{})
- func (dfs *DummyFeedbackStrategy) StartSampling(samplingInterval time.Duration)
- type FeedbackStrategyInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AntiSpamStrategy ¶
type AntiSpamStrategy struct { CPUPercentageSamples []float64 MemUsageSamples []float64 GoRoutineSamples []int // RunningCliP2PAPIRequests number of running client p2p api requests (outgoing p2p requests) // RunningCliP2PAPIRequests number of running client p2p api requests (outgoing p2p requests) RunningCliP2PAPIRequests []int // RunningServerP2PAPIRequests number of running server p2p api requests (incoming p2p requests) RunningServerP2PAPIRequests []int // FeedbackVars variables relative to feedback system that can be used by the service where AntiSpamStrategy is injected into and/or // for internal calculations FeedbackVars map[string]interface{} FeedbackVarsLock sync.RWMutex CPUPercentageLimit int P2pRequestLimit int Logger *log.Logger }
AntiSpamStrategy implements an anti spam filter and it is used to reduce or inhibit number of api requests when the app reaches some hard limits on concurrent processes, memory and/or cpu
func NewAntiSpamStrategy ¶
func NewAntiSpamStrategy( logger *log.Logger, cpuPercentageLimit, p2pRequestLimit int, ) *AntiSpamStrategy
NewAntiSpamStrategy initialize system internal variables
func (*AntiSpamStrategy) DecrementVarCount ¶
func (ass *AntiSpamStrategy) DecrementVarCount(k string) interface{}
DecrementVarCount decrement k feedback map element (int) by one
func (*AntiSpamStrategy) GetFeedbackVar ¶
func (ass *AntiSpamStrategy) GetFeedbackVar(k string) interface{}
GetFeedbackVar get one of the variables useful to determine internal system state. if not set, return nil
func (*AntiSpamStrategy) GetSuggestedActions ¶
func (ass *AntiSpamStrategy) GetSuggestedActions() map[constant.FeedbackAction]bool
GetSuggestedActions given some internal state, return a list of actions that the node should undertake
func (*AntiSpamStrategy) IncrementVarCount ¶
func (ass *AntiSpamStrategy) IncrementVarCount(k string) interface{}
IncrementVarCount increment k feedback map element (int) by one
func (*AntiSpamStrategy) IsCPULimitReached ¶
func (ass *AntiSpamStrategy) IsCPULimitReached(numSamples int) (limitReached bool, limitLevel constant.FeedbackLimitLevel)
IsCPULimitReached to be implemented
func (*AntiSpamStrategy) IsGoroutineLimitReached ¶
func (ass *AntiSpamStrategy) IsGoroutineLimitReached(numSamples int) (limitReached bool, limitLevel constant.FeedbackLimitLevel)
IsGoroutineLimitReached return true if one of the limits has been reached, together with the feedback limit level (from none to critical)
func (*AntiSpamStrategy) IsMemoryLimitReached ¶
func (ass *AntiSpamStrategy) IsMemoryLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
IsMemoryLimitReached to be implemented
func (*AntiSpamStrategy) IsP2PRequestLimitReached ¶
func (ass *AntiSpamStrategy) IsP2PRequestLimitReached(numSamples int) (limitReached bool, limitLevel constant.FeedbackLimitLevel)
IsP2PRequestLimitReached check if P2P requests limit has been reached As of now we only check for incoming P2P transactions (transactions broadcast by other peers)
func (*AntiSpamStrategy) SetFeedbackVar ¶
func (ass *AntiSpamStrategy) SetFeedbackVar(k string, v interface{})
SetFeedbackVar set one of the variables useful to determine internal system state
func (*AntiSpamStrategy) StartSampling ¶
func (ass *AntiSpamStrategy) StartSampling(samplingInterval time.Duration)
StartSampling main feedback service loop to collect system stats
type DummyFeedbackStrategy ¶
type DummyFeedbackStrategy struct { FeedbackVars map[string]interface{} FeedbackVarsLock sync.RWMutex }
DummyFeedbackStrategy implements FeedbackStrategyInterface and it is used to switch AntiSpam filter off
func NewDummyFeedbackStrategy ¶
func NewDummyFeedbackStrategy() *DummyFeedbackStrategy
DummyFeedbackStrategy initialize system internal variables
func (*DummyFeedbackStrategy) DecrementVarCount ¶
func (dfs *DummyFeedbackStrategy) DecrementVarCount(k string) interface{}
func (*DummyFeedbackStrategy) GetFeedbackVar ¶
func (dfs *DummyFeedbackStrategy) GetFeedbackVar(k string) interface{}
func (*DummyFeedbackStrategy) GetSuggestedActions ¶
func (dfs *DummyFeedbackStrategy) GetSuggestedActions() map[constant.FeedbackAction]bool
func (*DummyFeedbackStrategy) IncrementVarCount ¶
func (dfs *DummyFeedbackStrategy) IncrementVarCount(k string) interface{}
func (*DummyFeedbackStrategy) IsCPULimitReached ¶
func (dfs *DummyFeedbackStrategy) IsCPULimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
func (*DummyFeedbackStrategy) IsGoroutineLimitReached ¶
func (dfs *DummyFeedbackStrategy) IsGoroutineLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
func (*DummyFeedbackStrategy) IsMemoryLimitReached ¶
func (dfs *DummyFeedbackStrategy) IsMemoryLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
func (*DummyFeedbackStrategy) IsP2PRequestLimitReached ¶
func (dfs *DummyFeedbackStrategy) IsP2PRequestLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel)
func (*DummyFeedbackStrategy) SetFeedbackVar ¶
func (dfs *DummyFeedbackStrategy) SetFeedbackVar(k string, v interface{})
func (*DummyFeedbackStrategy) StartSampling ¶
func (dfs *DummyFeedbackStrategy) StartSampling(samplingInterval time.Duration)
type FeedbackStrategyInterface ¶
type FeedbackStrategyInterface interface { StartSampling(samplingInterval time.Duration) IsGoroutineLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel) IsP2PRequestLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel) IsCPULimitReached(numSamples int) (bool, constant.FeedbackLimitLevel) IsMemoryLimitReached(numSamples int) (bool, constant.FeedbackLimitLevel) GetSuggestedActions() map[constant.FeedbackAction]bool SetFeedbackVar(k string, v interface{}) GetFeedbackVar(k string) interface{} IncrementVarCount(k string) interface{} DecrementVarCount(k string) interface{} }