Post
Topic
Board Announcements (Altcoins)
Re: [ANN][CLAM] CLAMs, Proof-Of-Chain, Proof-Of-Working-Stake, a.k.a. "Clamcoin"
by
Trent Russell
on 30/12/2015, 18:38:57 UTC
You could get rid of isprefix all together, and just check whether i == vchID.size() after the loop is done. Iff that's true then it's a prefix:

Code:
                unsigned char* keyidarr = (unsigned char*) &keyid;
                unsigned int i;
                for (i = 0; i < vchID.size(); i++)
                  if (vchID[i] != keyidarr[i])
                    break;
                if (i == vchID.size()) // it's a prefix ...

Edit: I meant to say that I was meaning to help you out with this about 12 hours ago, but when I went to check on my testnet instance it was dead, and crashed every time I tried to restart it, so I spent today tracking down and fixing the bugs that caused that instead.

Thanks, that code is an improvement. I'd forgotten about break.

I was originally hoping to take advantage of the representation in memory of the vchID "unsigned char vector" to avoid needing to loop at all, but it became clear that the representation isn't what I hoped it was (an array).

I'm happy with the response time I've been getting from the Clam team members, so thanks to all of you for that.

Now that I have "register pubkey" I started writing support for "register escrow agent", "create contract", "trade contract" and "settle contract" -- but found I have to rethink things again. For example, I had planned to have CLAMspeech declarations like:

register escrow agent 73 USD

in which the controller of the pubkey registered to 73 indicates his/her willingness to act as an escrow agent under the given terms until the timeout.

Obviously this tx should be signed by the corresponding private key. The easiest way to enforce this is to check that the first input to the tx with the CLAMspeech came from the corresponding address. In which case the pubkey is explicitly in the tx already, and so why did it need to be registered in advance?

In other words, it's been one of those days of taking two steps back.