Re: Recursive codec/frames in gloss? -- SOLVED

2014-10-11 Thread Ken Restivo
Solved: (g/header (g/repeated :ubyte :prefix :ubyte) (fn [h] (g/finite-block (apply + h))) (fn [b] ...)) That did it. On Fri, Oct 10, 2014 at 10:32:59AM -0700, john walker wrote: > What information do you want after this is decoded?

Re: Recursive codec/frames in gloss?

2014-10-11 Thread Ken Restivo
Correction: this actually is what I'm trying to do: (defn get-payload-from-recursive-header-frame [[hlenlen & raw-bytes]] (let [hlen (apply + (take hlenlen raw-bytes))] (take hlen (drop hlenlen raw-bytes Or with the headers preserved: (defn get-payload-from-recursive-header-f

Re: Recursive codec/frames in gloss?

2014-10-11 Thread Ken Restivo
After this is decoded, I want the the payload, and it'd be nice to have the length too but not necessary. Described in clojure instead of prose: (defn get-payload-from-recursive-header-frame [[hlenlen & raw-bytes]] (let [hlen (apply + (take hlenlen raw-bytes))] (drop hlenlen raw-bytes)))

Re: Recursive codec/frames in gloss?

2014-10-10 Thread danneu
I took a stab at it for 10 minutes, but I'm way too rusty. Last year I implemented the blockchain wire protocol with gloss that might be helpful: https://gist.github.com/danneu/7397350 Here's the spec: https://en.bitcoin.it/wiki/Protocol_specification The var-int-codec is a somewhat complex ex

Re: Recursive codec/frames in gloss?

2014-10-10 Thread john walker
What information do you want after this is decoded? Do you want the sum of byte0 ... byten, as well as the actual payload? Do you also want the header-length? On Thursday, October 9, 2014 11:34:59 PM UTC-7, Ken Restivo wrote: > > I'm playing around with Gloss, trying to decode a packet, part of

Recursive codec/frames in gloss?

2014-10-09 Thread Ken Restivo
I'm playing around with Gloss, trying to decode a packet, part of which has the following nested struture: header-length (1 byte, value n) byte0 ... byten (count defined by that header-length byte) actual payload (length of which is the sum of the values of the above bytes) S