github.com/supragya/TendermintConnector@v0.0.0-20210619045051-113e32b84fb1/chains/tm34/structsMarlin.go (about) 1 package tm34 2 3 import ( 4 "bufio" 5 "net" 6 "sync" 7 "time" 8 9 lru "github.com/hashicorp/golang-lru" 10 "github.com/supragya/TendermintConnector/chains/tm34/conn" 11 "github.com/supragya/TendermintConnector/chains/tm34/crypto/ed25519" 12 flow "github.com/supragya/TendermintConnector/chains/tm34/libs/flowrate" 13 "github.com/supragya/TendermintConnector/chains/tm34/libs/timer" 14 tmp2p "github.com/supragya/TendermintConnector/chains/tm34/proto/tendermint/p2p" 15 marlinTypes "github.com/supragya/TendermintConnector/types" 16 // "github.com/tendermint/go-amino" 17 ) 18 19 type TendermintHandler struct { 20 servicedChainId uint32 21 listenPort int 22 isConnectionOutgoing bool 23 peerAddr string 24 rpcAddr string 25 privateKey ed25519.PrivKey 26 baseConnection net.Conn 27 validatorCache *lru.TwoQueueCache 28 maxValidHeight int64 29 secretConnection *conn.SecretConnection 30 marlinTo chan marlinTypes.MarlinMessage 31 marlinFrom chan marlinTypes.MarlinMessage 32 channelBuffer map[byte][]marlinTypes.PacketMsg 33 peerNodeInfo tmp2p.DefaultNodeInfo 34 p2pConnection P2PConnection 35 throughput throughPutData 36 signalConnError chan struct{} 37 signalShutSend chan struct{} 38 signalShutRecv chan struct{} 39 signalShutThroughput chan struct{} 40 } 41 42 type P2PConnection struct { 43 conn net.Conn 44 bufConnReader *bufio.Reader 45 bufConnWriter *bufio.Writer 46 sendMonitor *flow.Monitor 47 recvMonitor *flow.Monitor 48 send chan struct{} 49 pong chan struct{} 50 // channels []*Channel 51 // channelsIdx map[byte]*Channel 52 errored uint32 53 54 // Closing quitSendRoutine will cause the sendRoutine to eventually quit. 55 // doneSendRoutine is closed when the sendRoutine actually quits. 56 quitSendRoutine chan struct{} 57 doneSendRoutine chan struct{} 58 59 // Closing quitRecvRouting will cause the recvRouting to eventually quit. 60 quitRecvRoutine chan struct{} 61 62 // used to ensure FlushStop and OnStop 63 // are safe to call concurrently. 64 stopMtx sync.Mutex 65 66 flushTimer *timer.ThrottleTimer // flush writes as necessary but throttled. 67 pingTimer *time.Ticker // send pings periodically 68 69 // close conn if pong is not received in pongTimeout 70 pongTimer *time.Timer 71 pongTimeoutCh chan bool // true - timeout, false - peer sent pong 72 73 chStatsTimer *time.Ticker // update channel stats periodically 74 75 created time.Time // time of creation 76 77 _maxPacketMsgSize int 78 } 79 80 type throughPutData struct { 81 isDataConnect bool 82 toTMCore map[string]uint32 83 fromTMCore map[string]uint32 84 spam map[string]uint32 85 mu sync.Mutex 86 }