nochowderforyou/clams — pull request #83 by dooglus (2014-12-02 14:04:17+00:00)
Title: Have 'getblock' work with 8 or more characters of a block hash prefix.

Previously it required the entire block hash.

We could always do this:

$ cc getblock ec64deeb7f1295216f20ce5dbe68b0bd28189a5a644a111e722c05451d51e66c |
grep -E '"(height|hash)"'
"hash" : "ec64deeb7f1295216f20ce5dbe68b0bd28189a5a644a111e722c05451d51e66c",
"height" : 175000,

Now we can do this too:

$ cc getblock ec64deeb |
grep -E '"(height|hash)"'
"hash" : "ec64deeb7f1295216f20ce5dbe68b0bd28189a5a644a111e722c05451d51e66c",
"height" : 175000,

I made it insist on at least 8 characters:

$ cc getblock ec64dee |
grep -E '"(height|hash)"'
error: {"code":-1,"message":"Please provide at least the first 8 digits of the block hash"}

It does a linear search through all the blocks in the map, so it's a little slow - but if you don't know the full block hash it's better than nothing.