mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-17 15:11:21 +00:00
Add .pyc to gitignore; Fix js example
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
*.swp
|
||||
*.swo
|
||||
*.pyc
|
||||
|
@ -1,5 +1,3 @@
|
||||
math = require("math")
|
||||
|
||||
module.exports = {
|
||||
decode_string: decode_string,
|
||||
decode_varint: decode_varint,
|
||||
@ -37,14 +35,14 @@ function encode_big_endian(i, size){
|
||||
if (size == 0){
|
||||
return new Buffer(0);
|
||||
}
|
||||
b = encode_big_endian(math.floor(i/256), size-1);
|
||||
b = encode_big_endian(Math.floor(i/256), size-1);
|
||||
return Buffer.concat([b, new Buffer([i%256])]);
|
||||
}
|
||||
|
||||
function decode_big_endian(reader, size){
|
||||
if (size == 0){ return 0 }
|
||||
firstByte = reader.read(1)[0];
|
||||
return firstByte*(math.pow(256, size-1)) + decode_big_endian(reader, size-1)
|
||||
return firstByte*(Math.pow(256, size-1)) + decode_big_endian(reader, size-1)
|
||||
}
|
||||
|
||||
function encode_string(s){
|
||||
@ -70,7 +68,7 @@ function encode_varint(i){
|
||||
|
||||
big_end = encode_big_endian(i, size);
|
||||
if (negate){ size += 0xF0 }
|
||||
var buf = new Buffer([1]);
|
||||
var buf = new Buffer([size]);
|
||||
return Buffer.concat([buf, big_end])
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user