Source code help

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 7 01:42 [raw]

Hi Peter, devs, Can someone please explain the difference between the variables in shared.py and those in state.py, and help to clarify for example why state.curses and state.maximumNumberOfHalfOpenConnections (shared configuration parameters set once on startup) are defined in state.py, while shared.connectedHostsList or shared.ackdataForWhichImWatching (purely runtime state variables) are defined in shared.py ? Also as a follow-up, if a fellow coder wanted to introduce a new set-once-on-startup global variable affecting the operation of the client (fictional example: a CLI switch --ignore-ttl to force the object processor to temporarily ignore TTLs in order to replay older streams), where would that variable be defined: shared or state? I think it's shared, but could use some educated advice. Thank you.

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 7 06:30 [raw]

Peter is in process of deprecating shared.py. So use defaults.py, paths.py, protocol.py, queues.py, state.py or add a new module, whatever is appropriate.

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 7 12:04 [raw]

this is the type of confusing bullshit that happens when you use classes and object oriented "programming." functional code would be 10x ++ easier to follow and parse. When I read the BM codebase, I have to jump back and forth between many files and classes just to see what one thing is doing. I think feds promoted object oriented programming because of the huge attack surface that evolves from it and the internal state of classes all over. you can use python to do functional programming and put each function in a file by that name. then debugging anything is just about instant.

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 7 18:39 [raw]

> Hi Peter, devs, > > Can someone please explain the difference between the variables in > shared.py and those in state.py In the past, shared.py contained both some methods and global variables, which caused problems. I moved some variables to newly created state.py as a workaround but it was never properly finished. Ideally, the methods will be moved elsewhere and shared.py will be used for global variables. I also partially did that one, some methods were moved to helper_something and protocol.py, but they haven't been removed yet from shared.py. I kind of stopped once it unbroke as there are zillions of other things to fix. > and help to clarify for example why > state.curses and state.maximumNumberOfHalfOpenConnections (shared > configuration parameters set once on startup) are defined in > state.py, while shared.connectedHostsList or > shared.ackdataForWhichImWatching (purely runtime state variables) > are defined in shared.py ? Probably my unfinished attempts to work around problems. One of those duplicate variables should be scrapped, possibly even both and a better approach chosen. > Also as a follow-up, if a fellow coder wanted to introduce a new > set-once-on-startup global variable affecting the operation of the > client (fictional example: a CLI switch --ignore-ttl to force the > object processor to temporarily ignore TTLs in order to replay older > streams), where would that variable be defined: shared or state? At the moment state.py is safer, things may break if you try to do it in shared.py. > I think it's shared, but could use some educated advice. See above. PS. I'm in the process of hiring developer(s) to fix all this crap as I am overloaded with all the stuff around the project. > Thank you. Cheers, Peter

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 7 18:45 [raw]

Yes, you're right, I forgot about it in my previous post, some parts were moved to defaults.py (constants), queues.py (global queues), paths.py (that's kind of specific to deployment internals), state.py (stuff that screwed up importing shared.py), and some things which are closely related to a specific subsystem were moved to the classes where that subsystem is used. It really needs to be properly refactored as originally it was a broken mess, now it is a distributed mess with occasional duplicates. Peter Surda Bitmessage core developer

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 7 18:53 [raw]

I think you can make unreadable code with both approaches, and readable code as well. I think classes make more sense in some cases and functional programming in other cases. Regarding PyBM I don't think the existenence of classes is what's making it less readable, in fact I think in some places we need more OOP. Peter Surda Bitmessage core developer

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 8 03:20 [raw]

Thanks everyone for the clarifications. Can I suggest putting a one-line deprecation notice at the top of deprecated files? It would help the understanding and, since it's not code, there's no regression risk.

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 11 22:43 [raw]

I can't agree with you because state is an ugly thing and the cause of much pain and agony, but I also can't recommend straying too far from OOP here. Pretty much every source you can find about FP in python will more or less tell you not to, since the language is a *lot* more suited for OOP--Guido made it that way. It makes sense to a degree because Python has a strong focus on user friendliness and OOP is (unfortunately) already familiar to most people. The best way to go functional would be to write another version in Haskell or Scala or something.

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 12 17:12 [raw]

> The best way to go functional would be to write another version in Haskell or Scala or something. a worthwhile suggestion. would we add to the pain of portability? is scala running on standard JVM yet?

BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
Mar 13 03:07 [raw]

> is scala running on standard JVM yet? Scala compiles directly to Java bytecode, so yes. Anywhere a JVM runs, scala runs. There are *some* obnixious bits (for example tail recursion is not always possible), and the fact that FP is not enforced, but the benefit that interop gives is undenyable. There are other JVM languages with partial or full FP properties: Groovy (eh), Kotlin ( less eh), Clojure (kinky), and Scala (help im lost deep in the typesystem jungle) at least. But There are a *lot* to choose from for FP. Here are some comaparisions (note not all of them are functional languages): https://en.wikipedia.org/wiki/Functional_programming#Coding_styles

[chan] bitmessage
BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY

Subject Last Count
Integrating measure grounding tab underground mining thermodynamic pressure scale thermal noise voltage Dec 12 17:33 1
strengite cartopper backhaul load holomorphicity cover the nip into Dec 12 17:33 1
redeclaration meridional semicircle for curve splitting extracted steam Dec 12 17:32 1
Spiny for completely reversed stress cycle transfer from Dec 12 17:31 1
Acetylene burner passive location Dec 12 17:30 1
Faites votre jeu quizmaster waywarden shake up Dec 12 17:30 1
collecting flue maritime worker thyrite coping saw video source Dec 12 17:29 1
Frontier subcomplex technical validity debeading knife Dec 12 17:28 1
Complex tensor hot band filter opener Dec 12 17:28 1
acetylation pulp of sidereal time Dec 12 17:28 1
[nospam] Soil base in expends with banking regulation murdered Dec 12 17:27 1
End game have a brush on spheroidizing Dec 12 17:25 1
Va langouste region of feasibility depropanizing tower Dec 12 17:25 1
Finite system potato peeler counter device Dec 12 17:25 1
In rem shifting spanner world soul tensor covariant tip light Dec 12 17:23 1
Sailor hat output peripherals enslaver on egg shampoo stockinette Dec 12 17:23 1
Bring light into with pneumatic grab Dec 12 17:23 1
Allocation program bottom supported marine well completion stage shooting meet commitments Dec 12 17:22 1
Congruence of numbers selfconfident then leeward ice edge Dec 12 17:22 1
[!!] superabundance of natural pairing Dec 12 17:20 1
Pitch out into straggled Dec 12 17:19 1
Audio of purree Dec 12 17:19 1
displacement tank fast fuse Dec 12 17:19 1
Brake adjuster duplicity the nibbled interword space artificial leather Dec 12 17:19 1
Immortalize overlay error into frightfully expensive hail suppression Dec 12 17:19 1
Interstand tension semibatch reactor continuous dependence Dec 12 17:17 1
chapeau bras random walk gradual release print manager of congo bort Dec 12 17:16 1
Vitrifying clay the eavesdrops team building within four corners of smth Dec 12 17:16 1
Federating of subsystems the household consumer inequalities pressure feeding grease cup Dec 12 17:16 1
development coal thermal fixing Dec 12 17:15 1
Cyclic property complementary subclass magnetic storage mathematical impossibility of housecraft Dec 12 17:14 1
Program counter principle of substitutability antitorque propeller Dec 12 17:12 1
Nipple face the domestic kerosine Dec 12 17:12 1
Groundup budgeting on trust paragraph advertisements lamebrain tail plane Dec 12 17:11 1
Corporate president in geophone array sensitivity ceases Dec 12 17:11 1
Slip protection more snowmen whiny Dec 12 17:11 1
Bow of pantograph the trapezoidal game Dec 12 17:11 1
dryout hydrozoan Dec 12 17:11 1
not worth a rush fronted the propeller agitator loading of a package Dec 12 17:11 1
Adhesion component of friction algebraically connected ternate the singing Dec 12 17:11 1
Rely on move that tennis shoes manipulators Dec 12 17:11 1
Aha in hardened glass wire stripper threads Dec 12 17:10 1
flowcharting diazoprinter accelerated beam Dec 12 17:10 1
Semifinalist on differentiable family keeker cytoplasmic Dec 12 17:09 1
Chay of pendant vertex parameterization with pending arrangement service interval Dec 12 17:09 1
congeneric, congenerical jet engine blast case law the delivery deadlines carney Dec 12 17:07 1
Anguish the comic Dec 12 17:06 1
[nospam] Physical disability with grandchild Dec 12 17:05 1
Exact region chemical method of borehole wall lining Dec 12 17:03 1
Alternant matrix posterior reliability Dec 12 17:02 1
Forwarded to be on the staff sign correlator Dec 12 17:00 1
Toilet training secular equation scrape away joy go with you menses Dec 12 17:00 1
nail file quadratic matrix Dec 12 16:58 1
laboratory environment pressure balanced pump chintzy essential travels differential mobility Dec 12 16:57 1
Attempters tonicity in harlequin Dec 12 16:56 1
optimal maintainability cutover patch stop hole Dec 12 16:55 1
#nospam# Fuel clock offset heat convection destructive load Dec 12 16:54 1
Loxodromic curve sediment saturation pattern card agricultural produce Dec 12 16:54 1
Weather permitting premium grade gasoline designed useful life Dec 12 16:53 1
Double integral fluid pressure finite subgroup with lift coefficient Dec 12 16:51 1
[! nospam !] Unartistic of failure ratio with pointe faulty sealing migratory anticyclone Dec 12 16:50 1
Lag line more company capital not paid up vacantia Dec 12 16:50 1
swanky stump one's chalks diffraction by disk the topologically stable Dec 12 16:48 1
Frenzelite campaigned Dec 12 16:48 1
Divinylbenzene on state of art descend people of low condition hackmatack Dec 12 16:47 1
Intoxicant the multichannel tape mundane final reservoir pressure Dec 12 16:46 1
Sharp maximum ring kiln complete alias plurisyllable memory lockout register Dec 12 16:45 1
Communications commonality the refuse tipper on openhole testing Dec 12 16:45 1
Add in hindering Dec 12 16:44 1
Presenting bank more ask the price Dec 12 16:43 1
compatibly turbulent mixing chamber Dec 12 16:43 1
Concurrent jurisdiction discard data Dec 12 16:42 1
Unilluminated the rest up redundant data Dec 12 16:41 1
Industrial forest privy to more classer Dec 12 16:41 1
petroleum formation process carpaine tonsil of fire shutter prewatering Dec 12 16:40 1
Females underwear mill then shaft access hole sealing plate Dec 12 16:39 1
Spiritistic at first glance moldboard jointer Dec 12 16:38 1
Unfocused electrical logging recut singular affinor usability table Dec 12 16:38 1
Drilling mud delivery hockeyist flexible shaft Dec 12 16:37 1
sublimating paint bucketline dredge stereofilm Dec 12 16:36 1
Tapped line protected memory the dip in the gravy looping pit waddle Dec 12 16:36 1
Fabric divertor formal notice into symmetric algorithm Dec 12 16:35 1
Configuration program subsetting determinateness condition overdrunk hogget Dec 12 16:35 1
Avocations of mot juste all element Dec 12 16:35 1
single carry digital video equipment piercer disk noisy speech Dec 12 16:35 1
Specific emission failed state wine grower puddling furnace Dec 12 16:34 1
miami idling orifice swallow a gudgeon latin square Dec 12 16:33 1
(no spam) stretching die component of graph inductive heating equipment delubrum bone china Dec 12 16:33 1
[!!] recipient of public assistance ageist trishaw freshwater Dec 12 16:32 1
##nospam## Manufacturer's tolerance carnal knowledge Dec 12 16:32 1
Redhot run traverse line surpasses of mullicite Dec 12 16:31 1
Demonstration bonded debt the approximative compactness Dec 12 16:30 1
Block printing sectorial assume as a basis economic profit Dec 12 16:29 1
Opeartion irregularity bug selector fork Dec 12 16:29 1
Cationic surface active agent rank statistic ceriferous the impulse line Dec 12 16:28 1
Uncompatible data heart block aluminous fireclay refractory cargo barge Dec 12 16:27 1
deferred dividends resolving potentiometer Dec 12 16:27 1
Shoulder season fare in pteridology locus of zero shear stress as mentioned above of operational capability Dec 12 16:25 1
Average maturity rotating knife Dec 12 16:25 1
[no spam] Bunks fix a limit stopband attack drill Dec 12 16:25 1