--- Day changed Tue Sep 25 2018 01:40 -!- grubles [~grubles@gateway/tor-sasl/grubles] has quit [Quit: Leaving] 03:16 -!- treyzania [~treyzania@paphos.tr3y.io] has quit [Quit: ZNC 1.6.6 - http://znc.in] 03:16 -!- treyzania [~treyzania@paphos.tr3y.io] has joined #rust-bitcoin 11:55 < dongcarl> andytoshi: 12:00 < dongcarl> andytoshi: I wanna make sure I get everything in today for https://github.com/rust-bitcoin/rust-bitcoin/pull/156, and in the way you want, so lemme make sure I got this right before I do anything crazy: 12:00 < dongcarl> 1. cccbb05, efb85a1 should be squashed into 58b6600 since they are part of the moved parts 12:00 < dongcarl> 2. ba84548 should be squashed into c56a203 since c56a203 moves things that ba84548 removes 12:00 < dongcarl> Does that look good? Anything else I need? 12:03 -!- stevenroose [~steven@vps.weuste.club] has joined #rust-bitcoin 12:03 < stevenroose> Yaaay :) 12:04 < dongcarl> Welcome Steven! 12:06 < dongcarl> stevenroose: to answer your question, I think that the "full path" thing is necessary even for unpublished macros since I want it to be very obvious why I need a certain import instead of having to dig through all the macros I've used 12:07 < dongcarl> ;;list 12:07 < gribble> Admin, Alias, Anonymous, AutoMode, BadWords, BitcoinData, Channel, ChannelLogger, ChannelStats, Conditional, Config, Debug, Dict, Dunno, Factoids, Filter, Format, GPG, Games, Gatekeeper, Google, Herald, Internet, Later, Market, Math, MessageParser, Misc, Network, OTCOrderBook, Owner, Plugin, RSS, RatingSystem, Reply, Scheduler, Seen, Services, Status, String, Time, Topic, URL, Unix, User, Utilities, and Web 12:09 < dongcarl> ;;help later 12:09 < gribble> Error: There is no command "later". 12:10 < dongcarl> ;;later tell andytoshi please see my comments above^ 12:10 < gribble> The operation succeeded. 12:12 < stevenroose> Never used gribble :p 12:12 < dongcarl> Haha yeah it's my first time trying it too... Weird it doesn't have help text for later... 12:12 < stevenroose> dongcarl: oh you mean because macros are often defined somewhere else. Yeah ok that's fine. 12:12 < dongcarl> stevenroose: :-) 12:13 < stevenroose> A quick side question, I've been googling for this, but couldn't find it. What are module paths that start with ::? 12:14 < stevenroose> dongcarl: So full paths in macros, huh :) How do you do trait implementations, then? 12:15 < dongcarl> > If that’s prefixed with ::, as in ::foo::bar(), it refers to a different foo, an absolute path from your crate root. 12:15 < dongcarl> Source: https://doc.rust-lang.org/book/first-edition/crates-and-modules.html 12:16 < dongcarl> The one I sent you before IS a trait implementation: https://github.com/rust-bitcoin/rust-bitcoin/blob/0da693f9a525fa39b14741b8d9bf74298be41f6f/src/macros.rs#L98 12:17 -!- sdaftuar_ is now known as sdaftuar 12:17 < dongcarl> I think the logic behind `::` is that for expressions that are `use bitcoin::blah`, we assume that we start at the crate root, but in all other situations, we assume that we start at the current namespace. 12:17 -!- sdaftuar [~sdaftuar@238.90.227.35.bc.googleusercontent.com] has quit [Changing host] 12:17 -!- sdaftuar [~sdaftuar@unaffiliated/sdaftuar] has joined #rust-bitcoin 12:18 < dongcarl> So, in all situations other than `use` expressions, we need a way to indicate that we're starting at the crate root, which is why we have `impl ::std::fmt::Debug for $name` instead of `impl std::fmt::Debug for $name` 12:19 < dongcarl> because `std::fmt::Debug` doesn't exist in the current namespace, but `::std::fmt::Debug` is chill as unless otherwise specified, all crates have `std` at its root 12:20 < stevenroose> You're confusing me with the reason for ::... 12:20 < stevenroose> Btw, with trait implementations I meant trait usages. 12:20 < stevenroose> How do I use a trait method on a struct that implements it? 12:21 < stevenroose> say bitcoin::blockdata::block::Block::consensus_decode(...) 12:21 < stevenroose> the trait is bitcoin::network::encodable::ConsensusDecodable 12:23 < stevenroose> dongcarl: 12:24 < dongcarl> `::bitcoin::blah` says: look for a module named `bitcoin` relative to the crate root and then a name `blah` under that 12:24 < dongcarl> `bitcoin::blah` says: look for a module named `bitcoin` relative to my current namespace and then a name `blah` under that 12:24 < stevenroose> Ok so with the former, you don't need `use bitcoin;`? 12:44 < dongcarl> stevenroose: yes 12:54 < stevenroose> dongcarl: Btw, with trait implementations I meant trait usages. 12:54 < stevenroose> How do I use a trait method on a struct that implements it? 12:54 < stevenroose> say bitcoin::blockdata::block::Block::consensus_decode(...) 12:54 < stevenroose> the trait is bitcoin::network::encodable::ConsensusDecodable 12:54 < andytoshi> you can write exactly what you wrote 12:54 < andytoshi> but you need to `use bitcoin::network::encodable::ConsensusDecodable` for it to work 12:54 < stevenroose> You have to import the trait, right? 12:54 < andytoshi> yeah 12:55 < dongcarl> andytoshi: I'm trying to show him how to make it work without an import 12:55 < stevenroose> What if two traits are implemented with the same method name :) 12:55 < stevenroose> ah andytoshi, yeah carl was saying I need to use full paths in macros to avoid making the users having to import things 12:56 < stevenroose> So I wondered how I can use a trait method without relying on a "use" statement 12:56 < dongcarl> `::bitcoin::network::encodable::ConsensusDecodable::consensus_decode(d)` 12:56 < andytoshi> there you go 12:57 < dongcarl> If the context you're in defines the type that it expects, the correct implementation of `consensus_decode` will be called 12:57 < stevenroose> What's `d` there? How does it know to use the implementatin for `Block` then? 12:57 < dongcarl> `d` is the decoder, gimme a sec to answer your second question 12:57 < stevenroose> Oh. So Block comes from type inference 12:58 < dongcarl> > Oh. So Block comes from type inference 12:58 < dongcarl> YES! 12:58 < stevenroose> And what if that's not specified? Hmm, let me see I think in my example it is specified. 12:58 < dongcarl> If there's nothing to infer, you can do a `let b: Block = ::bitcoin::network::encodable::ConsensusDecodable::consensus_decode(d)?` then do things with `b` 12:59 < stevenroose> Yeah ok, I get the point :) You forgot the full path on Block there, though ;) 12:59 < dongcarl> At least that's how I've hacked it... Keep in mind that this probably won't incur a performance hit as `rustc` is a smart fellow 12:59 < dongcarl> stevenroose: yes lol 13:00 < stevenroose> Btw, on your point that private macros should also have that, I use private types in those macros.. So it really makes no sense, I can't sensibly make full paths for private structs. 13:01 < andytoshi> btw you should start your paths with crate:: now instead of :: 13:01 < andytoshi> because :: is going away in rust 2018 13:01 < dongcarl> stevenroose: I see... 13:01 < andytoshi> oh, wait, lemme think about that.. maybe starting with :: is the only thing that works right now.. 13:02 < andytoshi> oh, no, crate:: should because external packages are imported at the crate root 13:02 < dongcarl> andytoshi: Oh? How will they differentiate between `bitcoin::` referring to the crate, and `bitcoin::` referring to a module I defined under my current namespace? 13:02 < stevenroose> Macros in question: https://github.com/stevenroose/rust-bitcoindrpc/blob/master/src/client.rs#L30-L112 13:02 < dongcarl> Or are you talking just about `use` expressions? 13:02 < stevenroose> I don't think full paths make sense on them as they are very specific to their usage in the module itself. 13:03 < dongcarl> stevenroose: Yes, you're right. 13:03 * stevenroose is going for lunch now 13:03 < andytoshi> dongcarl: you'll need to use crate::bitcoin to refer to the crate 13:04 < dongcarl> andytoshi: Oh... like... a literal `crate::`? 13:04 < andytoshi> yes 13:04 < andytoshi> https://rust-lang-nursery.github.io/edition-guide/rust-2018/module-system/path-clarity.html 13:04 < dongcarl> andytoshi: Ah, right since `crate` is already a reserved keyword I'm guessing... 13:04 < dongcarl> Yup 13:06 < dongcarl> andytoshi: lmk about #156 as I commented above, wanna get it in before having to rebase over 10 new changes lol 13:06 < andytoshi> one sec, i need to find my keys to get it from github.. 13:06 < andytoshi> because github's website is hopeless 13:07 < dongcarl> Haha I'm surprised no one's built a TUI for it yet 13:07 < andytoshi> the issue is that it orders the commits randomly 13:07 < andytoshi> you could plausibly fix it with greasemonkey 13:08 < andytoshi> or whatever the kids are using instead of greasemonkey, that feels like it was probably broken by firefox 57.. 13:08 * dongcarl having PTSD from using greasemonkey back in primary school 13:09 < dongcarl> They've updated it for >57 apparently 13:12 < andytoshi> dongcarl: yeah, that looks fine 13:12 < andytoshi> the squashes you suggested 13:12 < dongcarl> Cool, I'll rebase, fix, squash, push 13:13 < andytoshi> great thanks 13:21 < dongcarl> andytoshi: Done, Travis is travising 13:24 < andytoshi> ok, cool, thanks 13:25 < andytoshi> what other changes are you concerned about rebasing over? 13:26 < dongcarl> andytoshi: Eh, I was just concerned that people would be writing `Consensus{En,De}codable` implementations left and right and I'd have to modify my stuff 13:26 < dongcarl> Btw, can you take a look at PSBT and lmk if there are any other changes you'd like? 13:26 < dongcarl> Either to code or commit structure 13:27 < andytoshi> yeah, i'll review these things today 13:28 < dongcarl> Thank you sir 14:07 < stevenroose> Another thing: the core api uses floats (read: json numbers) for difficulty. Wha'ts the best/safest type to use for that in Rust? Plain simple f64? f64 doesn't have std::cmp::Eq though, which is a pity for unit testing.. 14:30 < andytoshi> absolutely not 14:31 < andytoshi> uint256 14:31 < andytoshi> i have no idea why core outputs that as a decimal, you'll need to write a custom parser to get an actual value out of it 15:49 < stevenroose> andytoshi: you saying the decimals can be truncated? Or does the API scale it somehow? Docs just say "difficulty" : x.xxx, (numeric) The difficulty 15:49 < stevenroose> https://github.com/bitcoin/bitcoin/blob/2848aa808fde462c27bc36de982d7ed74e882a7b/src/rpc/blockchain.cpp#L55 15:49 < stevenroose> grrr 16:06 < andytoshi> stevenroose: no, i'm sure the output is lossless, there'd be longstanding bugs if it weren't 16:06 < andytoshi> the problem is that you cannot convert a decimal number to a f64 losslessly 16:07 < andytoshi> well, it is possible, but people get this wrong a lot 16:07 < andytoshi> (it's possible specifically because difficulties are actually integers scaled by powers of 2 ... but then it's encoded in base 10 which makes it hard to get back to the base-2 representation) 16:09 < andytoshi> oh lol i'm actually pretty suspicious of that function you linked 16:10 < andytoshi> `double dDiff = (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);` looks like it'll lose information 16:10 < andytoshi> so yeah...might as well just make it an f64, to warn people that it's not a precise value 16:11 < andytoshi> and anyway they should not be doing consensus validation on blocks using jsonrpc :P 16:37 -!- grubles [~grubles@unaffiliated/grubles] has joined #rust-bitcoin 17:54 < stevenroose> Yeah the thing is that in JSON it's a JSON number not a string. So it inherently is a double precision floating point according to JSON spec. 17:54 < stevenroose> But well, it's done anyway: https://github.com/stevenroose/rust-bitcoindrpc/commit/6991303db22be3d32b3cbb31525fe520e505d372 17:55 * dongcarl facepalm 17:56 < stevenroose> dongcarl: so how is your Rust PSBT impl going? :) I'm interested 17:57 < dongcarl> stevenroose: it's done... just needs last pass review from the one and only andytoshi 17:57 < andytoshi> stevenroose: i keep nitting with "this type is ugly, can you pls overhaul this entire half of the API and rebase?" 17:57 < andytoshi> i'll try to get htrough it today though 17:58 < dongcarl> <3 17:59 < stevenroose> also, dongcarl, what's with the "Ready for Review: " instead of "WIP: "? :D Just ventilating frustration because they're not getting merged? :D 17:59 < dongcarl> I use "WIP: " for things I'm actively working on 17:59 < dongcarl> I use "Ready for Review: " for things that I am waiting for reviews on 18:00 < dongcarl> I promise it's not passive agression! :D 18:31 < dongcarl> Hallelujah!! 18:31 < dongcarl> andytoshi: lemme rebase my psbt real quick 18:34 < andytoshi> thanx 18:34 < dongcarl> rebased 18:34 < andytoshi> lol this is #103 18:34 < andytoshi> we got like 50 PRs in in front of you 18:35 * dongcarl smiles like it's all okay 18:45 < dongcarl> andytoshi: I'm gunna be up for 14 more mins, so if you got some quick comments, I'm here for you 18:45 < andytoshi> i will not have comments in 14 minutes 18:45 < andytoshi> get some sleep :P 18:45 < dongcarl> kk, gnite world! 18:54 -!- ruby32 [~ruby32@65.246.172.18] has joined #rust-bitcoin 18:54 < ruby32> Hi, how did everyone here start learning Rust? Any books or guides in particular that stand out as excellent beginner resources? 19:01 < andytoshi> ruby32: by crashing the compiler in the 0.6 days and filing bugs about it, and once writing a language RFC to ban a pile of confusing constructions, then years later have a bunch of young people contribute style cleanups to my projects, explaining how we're supposed to do things now 19:01 < andytoshi> not strongly recommended :) 19:40 -!- Tralfaz [~none@185.156.175.43] has quit [Remote host closed the connection] 19:40 -!- Tralfaz [~none@185.156.175.43] has joined #rust-bitcoin 20:03 < ruby32> That sounds fun 20:29 -!- ruby32 [~ruby32@65.246.172.18] has quit [Remote host closed the connection] 20:29 -!- ruby32 [~ruby32@65.246.172.18] has joined #rust-bitcoin 21:37 -!- ruby32 [~ruby32@65.246.172.18] has quit [Ping timeout: 240 seconds] 21:42 -!- ruby32 [~ruby32@65.246.172.18] has joined #rust-bitcoin 22:05 -!- ruby32 [~ruby32@65.246.172.18] has quit [Ping timeout: 240 seconds] 22:35 -!- ruby32 [~ruby32@2604:2000:ef1b:5e00:4887:8dbd:c50e:9c0e] has joined #rust-bitcoin 22:58 -!- ruby32 [~ruby32@2604:2000:ef1b:5e00:4887:8dbd:c50e:9c0e] has quit [Ping timeout: 250 seconds] 22:59 -!- ruby32 [~ruby32@2604:2000:e882:c800:4887:8dbd:c50e:9c0e] has joined #rust-bitcoin 23:33 -!- ruby32 [~ruby32@2604:2000:e882:c800:4887:8dbd:c50e:9c0e] has quit [Quit: Leaving]