Exemple #1
0
bool
Node::isVBlocking(const Hash& qSetHash, const std::vector<uint256>& nodeSet)
{
    CLOG(DEBUG, "SCP") << "Node::isVBlocking"
                       << "@" << binToHex(mNodeID).substr(0, 6)
                       << " qSet: " << binToHex(qSetHash).substr(0, 6)
                       << " nodeSet.size: " << nodeSet.size();
    // This call can throw a `QuorumSetNotFound` if the quorumSet is unknown.
    const SCPQuorumSet& qSet = retrieveQuorumSet(qSetHash);

    // There is no v-blocking set for {\empty}
    if (qSet.threshold == 0)
    {
        return false;
    }

    uint32 count = 0;
    for (auto n : qSet.validators)
    {
        auto it = std::find(nodeSet.begin(), nodeSet.end(), n);
        count += (it != nodeSet.end()) ? 1 : 0;
    }
    auto result = (qSet.validators.size() - count < qSet.threshold);
    CLOG(DEBUG, "SCP") << "Node::isVBlocking"
                       << "@" << binToHex(mNodeID).substr(0, 6) << " is "
                       << result;
    return result;
}
std::shared_ptr<Bucket>
BucketManagerImpl::getBucketByHash(uint256 const& hash)
{
    std::lock_guard<std::recursive_mutex> lock(mBucketMutex);
    if (isZero(hash))
    {
        return std::make_shared<Bucket>();
    }
    auto i = mSharedBuckets.find(hash);
    if (i != mSharedBuckets.end())
    {
        CLOG(TRACE, "Bucket")
            << "BucketManager::getBucketByHash(" << binToHex(hash)
            << ") found bucket " << i->second->getFilename();
        return i->second;
    }
    std::string canonicalName = bucketFilename(hash);
    if (fs::exists(canonicalName))
    {
        CLOG(TRACE, "Bucket")
            << "BucketManager::getBucketByHash(" << binToHex(hash)
            << ") found no bucket, making new one";
        auto p = std::make_shared<Bucket>(canonicalName, hash);
        mSharedBuckets.insert(std::make_pair(hash, p));
        mSharedBucketsSize.set_count(mSharedBuckets.size());
        return p;
    }
    return std::shared_ptr<Bucket>();
}
std::string BigInt::toHexString() const
{
	std::string response = "0x";
	std::string nStr = n.to_string<char, std::char_traits<char>, std::allocator<char> >();
	int limit = nStr.length();
	int halfword = 1;
	
	for(int i=0;i<limit;){
		if((nStr.substr(i, 16) == "0000000000000000") && (response == "0x")){
			i=i+16;
		}
		else{
			for(int j=0;j<4;j++){
				response += binToHex(nStr.substr(i, 4));
				if(halfword%4 == 0){
					response += " ";
				}
				halfword++;
				i=i+4;
			}
		}
	}//end for loop.
	
	if(response=="0x"){
		response += "00";
	}
	return response;
}
Exemple #4
0
const SCPQuorumSet&
Node::retrieveQuorumSet(const uint256& qSetHash)
{
    // Notify that we touched this node.
    mSCP->nodeTouched(mNodeID);

    assert(mCacheLRU.size() == mCache.size());
    auto it = mCache.find(qSetHash);
    if (it != mCache.end())
    {
        return it->second;
    }

    CLOG(DEBUG, "SCP") << "Node::retrieveQuorumSet"
                       << "@" << binToHex(mNodeID).substr(0, 6)
                       << " qSet: " << binToHex(qSetHash).substr(0, 6);

    throw QuorumSetNotFound(mNodeID, qSetHash);
}
void
ApplyBucketsWork::startLevel()
{
    assert(isLevelComplete());

    CLOG(DEBUG, "History") << "ApplyBuckets : starting level " << mLevel;
    auto& level = getBucketLevel(mLevel);
    HistoryStateBucket const& i = mApplyState.currentBuckets.at(mLevel);

    bool applySnap = (i.snap != binToHex(level.getSnap()->getHash()));
    bool applyCurr = (i.curr != binToHex(level.getCurr()->getHash()));
    if (!mApplying && (applySnap || applyCurr))
    {
        uint32_t oldestLedger = applySnap
                                    ? BucketList::oldestLedgerInSnap(
                                          mApplyState.currentLedger, mLevel)
                                    : BucketList::oldestLedgerInCurr(
                                          mApplyState.currentLedger, mLevel);
        auto& lsRoot = mApp.getLedgerTxnRoot();
        lsRoot.deleteObjectsModifiedOnOrAfterLedger(oldestLedger);
    }

    if (mApplying || applySnap)
    {
        mSnapBucket = getBucket(i.snap);
        mSnapApplicator = std::make_unique<BucketApplicator>(
            mApp, mMaxProtocolVersion, mSnapBucket);
        CLOG(DEBUG, "History") << "ApplyBuckets : starting level[" << mLevel
                               << "].snap = " << i.snap;
        mApplying = true;
        mBucketApplyStart.Mark();
    }
    if (mApplying || applyCurr)
    {
        mCurrBucket = getBucket(i.curr);
        mCurrApplicator = std::make_unique<BucketApplicator>(
            mApp, mMaxProtocolVersion, mCurrBucket);
        CLOG(DEBUG, "History") << "ApplyBuckets : starting level[" << mLevel
                               << "].curr = " << i.curr;
        mApplying = true;
        mBucketApplyStart.Mark();
    }
}
void
FutureBucket::setLiveOutput(std::shared_ptr<Bucket> output)
{
    mState = FB_LIVE_OUTPUT;
    mOutputBucketHash = binToHex(output->getHash());
    // Given an output bucket, fake-up a promise for it connected to
    // the future so that it can be immediately retrieved.
    std::promise<std::shared_ptr<Bucket>> promise;
    mOutputBucket = promise.get_future().share();
    promise.set_value(output);
    checkState();
}
FutureBucket::FutureBucket(Application& app,
                           std::shared_ptr<Bucket> const& curr,
                           std::shared_ptr<Bucket> const& snap,
                           std::vector<std::shared_ptr<Bucket>> const& shadows)
    : mState(FB_LIVE_INPUTS)
    , mInputCurrBucket(curr)
    , mInputSnapBucket(snap)
    , mInputShadowBuckets(shadows)
{
    // Constructed with a bunch of inputs, _immediately_ commence merging
    // them; there's no valid state for have-inputs-but-not-merging, the
    // presence of inputs implies merging, and vice-versa.
    assert(curr);
    assert(snap);
    mInputCurrBucketHash = binToHex(curr->getHash());
    mInputSnapBucketHash = binToHex(snap->getHash());
    for (auto const& b : mInputShadowBuckets)
    {
        mInputShadowBucketHashes.push_back(binToHex(b->getHash()));
    }
    startMerge(app);
}
Exemple #8
0
bool
Node::hasQuorum(const Hash& qSetHash, const std::vector<uint256>& nodeSet)
{
    CLOG(DEBUG, "SCP") << "Node::hasQuorum"
                       << "@" << binToHex(mNodeID).substr(0, 6)
                       << " qSet: " << binToHex(qSetHash).substr(0, 6)
                       << " nodeSet.size: " << nodeSet.size();
    // This call can throw a `QuorumSetNotFound` if the quorumSet is unknown.
    const SCPQuorumSet& qSet = retrieveQuorumSet(qSetHash);

    uint32 count = 0;
    for (auto n : qSet.validators)
    {
        auto it = std::find(nodeSet.begin(), nodeSet.end(), n);
        count += (it != nodeSet.end()) ? 1 : 0;
    }
    auto result = (count >= qSet.threshold);
    CLOG(DEBUG, "SCP") << "Node::hasQuorum"
                       << "@" << binToHex(mNodeID).substr(0, 6) << " is "
                       << result;
    return result;
}
Exemple #9
0
void
Node::cacheQuorumSet(const SCPQuorumSet& qSet)
{
    uint256 qSetHash = sha256(xdr::xdr_to_opaque(qSet));
    CLOG(DEBUG, "SCP") << "Node::cacheQuorumSet"
                       << "@" << binToHex(mNodeID).substr(0, 6)
                       << " qSet: " << binToHex(qSetHash).substr(0, 6);

    if (mCache.find(qSetHash) != mCache.end())
    {
        return;
    }

    while (mCacheCapacity >= 0 && mCache.size() >= (size_t)mCacheCapacity)
    {
        assert(mCacheLRU.size() == mCache.size());
        auto it = mCacheLRU.begin();
        mCache.erase(*it);
        mCacheLRU.erase(it);
    }
    mCacheLRU.push_back(qSetHash);
    mCache[qSetHash] = qSet;
}
Exemple #10
0
static std::string
randomBucketName(std::string const& tmpDir)
{
    for (;;)
    {
        std::string name =
            tmpDir + "/tmp-bucket-" + binToHex(randomBytes(8)) + ".xdr";
        std::ifstream ifile(name);
        if (!ifile)
        {
            return name;
        }
    }
}
Exemple #11
0
std::string mkContractInfoDecl(std::string input) {
    Node n = parseSerpent(input);
    std::string s = mkFullExtern(n);
    std::string c = compileLLL(rewrite(n));
    return "{\n" 
           "    \"code\": \"0x" + binToHex(c) + "\",\n" 
           "    \"info\": {\n" 
           "        \"abiDefinition\": " + indentLines(indentLines(s)).substr(8) + "\n"
           "    },\n" 
           "    \"language\": \"serpent\",\n" 
           "    \"languageVersion\": \"2\",\n" 
           "    \"source\": \""+input+"\",\n" 
           "    \"userDoc\": {}\n" 
           "}";
}
void
ArchivePublisher::enterObservedState(HistoryArchiveState const& has)
{
    assert(mState == PUBLISH_BEGIN);
    mState = PUBLISH_OBSERVED;

    mArchiveState = has;
    std::vector<std::string> bucketsToSend =
        mSnap->mLocalState.differingBuckets(mArchiveState);
    std::map<std::string, std::shared_ptr<Bucket>> bucketsByHash;
    for (auto b : mSnap->mLocalBuckets)
    {
        bucketsByHash[binToHex(b->getHash())] = b;
    }

    std::vector<std::shared_ptr<FilePublishInfo>> filePublishInfos = {
        mSnap->mLedgerSnapFile, mSnap->mTransactionSnapFile,
        mSnap->mTransactionResultSnapFile};

    for (auto const& hash : bucketsToSend)
    {
        auto b = bucketsByHash[hash];
        assert(b);
        filePublishInfos.push_back(
            std::make_shared<FilePublishInfo>(FILE_PUBLISH_NEEDED, *b));
    }

    for (auto pi : filePublishInfos)
    {
        auto name = pi->baseName_nogz();
        auto i = mFileInfos.find(name);
        if (i == mFileInfos.end() ||
            i->second->getState() == FILE_PUBLISH_FAILED)
        {
            CLOG(DEBUG, "History") << "Queueing file " << name
                                   << " to send to archive '"
                                   << mArchive->getName() << "'";
            mFileInfos[name] = pi;
        }
        else
        {
            CLOG(DEBUG, "History")
                << "Not queueing file " << name << " to send to archive '"
                << mArchive->getName() << "'; file already queued";
        }
    }
    enterSendingState();
}
string generateSHA(string& value)
{
	CSHA1 sha;

	sha.Update((UINT_8*)value.c_str(), value.length());

	sha.Final();

	UINT_8 digest[20];
	if (sha.GetHash(digest))
	{
		const int size = sizeof(digest) / sizeof(UINT_8);
		return binToHex((char*)digest, size);
	}

	return "";
}
std::shared_ptr<Bucket>
FutureBucket::resolve()
{
    checkState();
    assert(isLive());
    clearInputs();
    std::shared_ptr<Bucket> bucket = mOutputBucket.get();
    if (mOutputBucketHash.empty())
    {
        mOutputBucketHash = binToHex(bucket->getHash());
    }
    else
    {
        checkHashEq(bucket, mOutputBucketHash);
    }
    mState = FB_LIVE_OUTPUT;
    checkState();
    return bucket;
}
Exemple #15
0
/*----------------------------------------------------------------------------*/
static void printAddress(struct Interface *serial, uint64_t address)
{
  const uint8_t * const overlay = (const uint8_t *)&address;
  uint8_t serialized[25];
  uint8_t *position = serialized;

  for (unsigned int i = 0; i < 8; ++i)
  {
    if (i > 0)
      *position++ = ' ';

    *position++ = binToHex(overlay[i] >> 4);
    *position++ = binToHex(overlay[i] & 0x0F);
  }
  *position++ = '\r';
  *position = '\n';

  ifWrite(serial, serialized, sizeof(serialized));
}
Exemple #16
0
int main(int argv, char** argc) {
    if (argv == 1) {
        std::cerr << "Must provide a command and arguments! Try parse, rewrite, compile, assemble\n";
        return 0;
    }
    std::string flag = "";
    std::string command = argc[1];
    std::string input;
    std::string secondInput;
    if (std::string(argc[1]) == "-s") {
        flag = command.substr(1);
        command = argc[2];
        input = "";
        std::string line;
        while (std::getline(std::cin, line)) {
            input += line + "\n";
        }
        secondInput = argv == 3 ? "" : argc[3];
    }
    else {
        if (argv == 2) {
            std::cerr << "Not enough arguments for serpent cmdline\n";
            throw(0);
        }
        input = argc[2];
        secondInput = argv == 3 ? "" : argc[3];
    }
    bool haveSec = secondInput.length() > 0;
    if (command == "parse" || command == "parse_serpent") {
        std::cout << printAST(parseSerpent(input), haveSec) << "\n";
    }
    else if (command == "rewrite") {
        std::cout << printAST(rewrite(parseLLL(input, true)), haveSec) << "\n";
    }
    else if (command == "compile_to_lll") {
        std::cout << printAST(compileToLLL(input), haveSec) << "\n";
    }
    else if (command == "build_fragtree") {
        std::cout << printAST(buildFragmentTree(parseLLL(input, true))) << "\n";
    }
    else if (command == "compile_lll") {
        std::cout << binToHex(compileLLL(parseLLL(input, true))) << "\n";
    }
    else if (command == "dereference") {
        std::cout << printAST(dereference(parseLLL(input, true)), haveSec) <<"\n";
    }
    else if (command == "pretty_assemble") {
        std::cout << printTokens(prettyAssemble(parseLLL(input, true))) <<"\n";
    }
    else if (command == "pretty_compile_lll") {
        std::cout << printTokens(prettyCompileLLL(parseLLL(input, true))) << "\n";
    }
    else if (command == "pretty_compile") {
        std::cout << printTokens(prettyCompile(input)) << "\n";
    }
    else if (command == "assemble") {
        std::cout << assemble(parseLLL(input, true)) << "\n";
    }
    else if (command == "serialize") {
        std::cout << binToHex(serialize(tokenize(input, Metadata(), false))) << "\n";
    }
    else if (command == "flatten") {
        std::cout << printTokens(flatten(parseLLL(input, true))) << "\n";
    }
    else if (command == "deserialize") {
        std::cout << printTokens(deserialize(hexToBin(input))) << "\n";
    }
    else if (command == "compile") {
        std::cout << binToHex(compile(input)) << "\n";
    }
    else if (command == "encode_datalist") {
        std::vector<Node> tokens = tokenize(input);
        std::vector<std::string> o;
        for (int i = 0; i < (int)tokens.size(); i++) {
            o.push_back(tokens[i].val);
        }
        std::cout << binToHex(encodeDatalist(o)) << "\n";
    }
    else if (command == "decode_datalist") {
        std::vector<std::string> o = decodeDatalist(hexToBin(input));
        std::vector<Node> tokens;
        for (int i = 0; i < (int)o.size(); i++)
            tokens.push_back(token(o[i]));
        std::cout << printTokens(tokens) << "\n";
    }
    else if (command == "tokenize") {
        std::cout << printTokens(tokenize(input));
    }
    else if (command == "biject") {
        if (argv == 3)
             std::cerr << "Not enough arguments for biject\n";
        int pos = decimalToUnsigned(secondInput);
        std::vector<Node> n = prettyCompile(input);
        if (pos >= (int)n.size())
             std::cerr << "Code position too high\n";
        Metadata m = n[pos].metadata;
        std::cout << "Opcode: " << n[pos].val << ", file: " << m.file << 
             ", line: " << m.ln << ", char: " << m.ch << "\n";
    }
}
int main(int argc, char *argv[])
{
    int i;
    int digitCount = 0;
    int inputLength;
    if(argc != 4) /*If no/too few input arguments are given, OR there's more than 3 arguments passed to the program:*/
    {
        fprintf(stderr,"Error: Invalid number of arguments passed.\n"); /*Standard error is printed and help function is run.*/
        help();
    }
    else
    {
        if(strcmp(argv[1],"-b") != 0 && strcmp(argv[1],"-d") != 0 && strcmp(argv[1],"-h") != 0 && strcmp(argv[1],"-o") != 0 && strcmp(argv[3],"-b") != 0 && strcmp(argv[3],"-d") != 0 && strcmp(argv[3],"-h") != 0 && strcmp(argv[3],"-o") != 0) /*Checks that both the input and output arguments are valid ones.*/
        {
            fprintf(stderr,"Error: Invalid input or output type argument given.\n");
            help();
        }
        else
        {
            if(strcmp(argv[1],"-b") == 0) /*If the input value is -b for binary:*/
            {
                inputLength = strlen(argv[2]);
                for(i = 0; i != inputLength; i++) /*Checks the valid input of 1s and 0s are given.*/
                {
                    if (argv[2][i] != '0' && argv[2][i] != '1' && argv[2][i] != '.')
                    {
                        fprintf(stderr,"Error: Binary values can only consist of 1\'s or 0\'s.\n");
                        help();
                    }
                    if(argv[2][i] != '.') /*Counts the number of digits to ensure the input length is not more than 8 (excluding the decimal point)*/
                        digitCount++;
                }
                if(digitCount > 8)
                {
                    fprintf(stderr,"Error: Maximum number of digits exceeded.\n");
                    help();
                }
                if(strcmp(argv[3],"-b") == 0) /*If user wants to go from binary to binary, it prints the input string.*/
                    printf("%s\n",argv[2]);
                if(strcmp(argv[3],"-d") == 0)
                    printf("%G\n",binToDec(argv[2])); /*If the user wants to go from binary to decimal, it executes the correct function and prints type double with the proper number of decimal places.*/
                if(strcmp(argv[3],"-h") == 0)
                    printf("%s\n",binToHex(argv[2]));
                if(strcmp(argv[3],"-o") == 0)
                    printf("%s\n",binToOct(argv[2]));
            }
            if(strcmp(argv[1],"-d") == 0) /*If the input type is decimal, does the same checks as if the input type was binary but instead checks that each digit is a valid base 10 number.*/
            {
                inputLength = strlen(argv[2]);
                for(i = 0; i != inputLength; i++)
                {
                    if (argv[2][i] != '0' && argv[2][i] != '1' && argv[2][i] != '2' && argv[2][i] != '3' && argv[2][i] != '4' && argv[2][i] != '5' && argv[2][i] != '6' && argv[2][i] != '7' && argv[2][i] != '8' && argv[2][i] != '9' && argv[2][i] != '.')
                    {
                        fprintf(stderr,"Error: Decimal values can only consist of 0-9.\n");
                        help();
                    }
                    if(argv[2][i] != '.')
                        digitCount++;
                }
                if(digitCount > 8)
                {
                    fprintf(stderr,"Error: Maximum number of digits exceeded.\n");
                    help();
                }
                else
                {
                    if(strcmp(argv[3],"-b") == 0)
                        printf("%s\n",dectoBin(argv[2]));
                    if(strcmp(argv[3],"-d") == 0)
                        printf("%s\n",argv[2]);
                    if(strcmp(argv[3],"-h") == 0)
                        printf("%s\n",binToHex(dectoBin(argv[2])));
                    if(strcmp(argv[3],"-o") == 0)
                        printf("%s\n",binToOct(dectoBin(argv[2])));
                }
            }
            if(strcmp(argv[1],"-h") == 0) /*See above comments. Performs the same checks but for hex values.*/
            {
                inputLength = strlen(argv[2]);
                for(i = 0; i != inputLength; i++)
                {
                    if (argv[2][i] != '0' && argv[2][i] != '1' && argv[2][i] != '2' && argv[2][i] != '3' && argv[2][i] != '4' && argv[2][i] != '5' && argv[2][i] != '6' && argv[2][i] != '7' && argv[2][i] != '8' && argv[2][i] != '9' && argv[2][i] != 'a' && argv[2][i] != 'A' && argv[2][i] != 'b' && argv[2][i] != 'B' && argv[2][i] != 'c' && argv[2][i] != 'C' && argv[2][i] != 'd' && argv[2][i] != 'D' && argv[2][i] != 'e' && argv[2][i] != 'E' && argv[2][i] != 'f' && argv[2][i] != 'F' && argv[2][i] != '.')
                    {
                        fprintf(stderr,"Error: Hex values can only consist of 0-9 & A-F.\n");
                        help();
                    }
                    if(argv[2][i] != '.')
                        digitCount++;
                }
                if(digitCount > 4)
                {
                    fprintf(stderr,"Error: Maximum number of digits exceeded.\n");
                    help();
                }
                else
                {
                    if(strcmp(argv[3],"-b") == 0)
                        printf("%s\n",hextoBin(argv[2]));
                    if(strcmp(argv[3],"-d") == 0)
                        printf("%G\n",binToDec(hextoBin(argv[2])));
                    if(strcmp(argv[3],"-h") == 0)
                        printf("%s\n",argv[2]);
                    if(strcmp(argv[3],"-o") == 0)
                        printf("%s\n",binToOct(hextoBin(argv[2])));
                }
            }
            if(strcmp(argv[1],"-o") == 0) /*See above comments. Does the same checks but for octal numbers.*/
            {
                inputLength = strlen(argv[2]);
                for(i = 0; i != inputLength; i++)
                {
                    if (argv[2][i] != '0' && argv[2][i] != '1' && argv[2][i] != '2' && argv[2][i] != '3' && argv[2][i] != '4' && argv[2][i] != '5' && argv[2][i] != '6' && argv[2][i] != '7' && argv[2][i] != '.')
                    {
                        fprintf(stderr,"Error: Octal values can only consist of 0-7.\n");
                        help();
                    }
                    if(argv[2][i] != '.')
                        digitCount++;
                }
                if(digitCount > 8)
                {
                    fprintf(stderr,"Error: Maximum number of digits exceeded.\n");
                    help();
                }
                else
                {
                    if(strcmp(argv[3],"-b") == 0)
                        printf("%s\n",octtoBin(argv[2]));
                    if(strcmp(argv[3],"-d") == 0)
                        printf("%G\n",binToDec(octtoBin(argv[2])));
                    if(strcmp(argv[3],"-h") == 0)
                        printf("%s\n",binToHex(octtoBin(argv[2])));
                    if(strcmp(argv[3],"-o") == 0)
                        printf("%s\n",argv[2]);
                }
            }
        }
    }
    return 0; /*In order to meet C standards, the main function must return an int. 0 indicates successful program execution.*/
}
Exemple #18
0
// ----------------------------------------- 
// main function
// -----------------------------------------
//
// Input:
//   none
//
// Returns:
//   0/1 - success/failure
//
// Notes:
//   - character input is not handled yet.
// 
int main(void)
{
  int  idx;                      // general purpose index
  int  inputIdx;                 // index specific to stepping through user input 
  int  littleEndian = 0;         // flag for little endian: 0 = false, 1 = true
  int  jump;                     // amount to jump when parsing user input string
  int  decimalNumber;            // final integer to convert
  long long inputDecimalNumber;  // temp placeholder for value to convert 

  char ch, scrap;                // holds prompt for little endian conversion + stdin flush

  char decIntBits[INTBITS + 1];  // holds bits that describe decimal integer
  char hexBits[HEXINTBITS + 1];  // holds hex value for decIntBits[]

  char promptString[] = "Enter a number (0 to cancel): "; 

  int  maxchars = 100;           // maximum number of characters in user input
  char inputNumbers[maxchars];   // holds user input


  // Prompt for big endian or little endian output
  //
  printf("Byte ordering is set to big endian. Switch to little endian? (Y = yes): ");
  scanf(" %c", &ch);
  while ((scrap = getchar()) != '\n' && scrap != EOF);  // flush stdin
  if(tolower(ch) == 'y')
  {
      littleEndian = 1;
      printf("Byte order: little-endian\n");
  }
  else
  {
      printf("Byte order: big-endian\n");
  }


  // Prompt for a number. Loop until we get a number we can use, then
  // display the binary number and break the loop.
  //
  while(1 && (inputDecimalNumber != 0))
  {
      printf("\n%s", promptString);

      if(fgets(inputNumbers, sizeof(inputNumbers), stdin) != NULL)  // no valid characters input?
      {
          for(inputIdx = 0; (sscanf(&inputNumbers[inputIdx], "%25lld%n", &inputDecimalNumber, &jump) != EOF) && (jump <= maxchars); inputIdx += jump)
          {
              // If the number entered was outside the min/max range of regular integers...
              //
              if( inputDecimalNumber < INT_MIN || inputDecimalNumber > INT_MAX )
              {
                  printf("Number is outside of integer range (%d to %d).\n", INT_MIN, INT_MAX);
              }
              // If we get this far, we have a valid number. Convert it, then
              // display it and break from the while loop.
              //
              else if( inputDecimalNumber != 0 )
              {
                  decimalNumber = (int)inputDecimalNumber;   // convert input number to normal int
                  intToBin(decimalNumber, decIntBits);       // convert int to binary


                  // print the integer being converted
                  //
                  printf("%10d ", decimalNumber);

                  // convert to little endian byte ordering if requested
                  //
                  if(littleEndian == 1)
                  {
                      toLittleEndian(decIntBits);
                  }

          
                  // convert final bit array to hex
                  //
                  idx = 0;
                  while(idx < HEXINTBITS)
                  {
                      hexBits[idx++] = '0';                      
                  }

                  binToHex(decIntBits, hexBits);             // convert to hex
                  printf("0x");                              // start the hex string


                  // display the hex string
                  //
                  idx = 0;
                  while(idx < strlen(hexBits))
                  {
                      printf("%c", hexBits[idx]);
                      idx++;
                  }
                  printf("\n");
              }
          }
      }
      else
      {
          break;
      }
  }

  return 0;

} // end of main()
std::string
BucketManagerImpl::bucketFilename(Hash const& hash)
{
    return bucketFilename(binToHex(hash));
}