예제 #1
0
def get(key, readOnly):
    if readOnly:
        if key in PersistentStorage.storage:
            return PersistentStorage.storage[key]
        value = PersistentStorage.persistent.get(RLP.encode(key))
        if value != None:
            value = RLP.decode(value)
            PersistentStorage.storage[key] = value
            return value
    else:
        value = PersistentStorage.persistent.get(RLP.encode(key))
        if value != None:
            return RLP.decode(value)
    return None
예제 #2
0
 def verifyCoinbaseWitnessLength(self, transaction):
     if transaction.isCoinbase():
         txIn = transaction.inputs[0]
         witness = txIn.witness
         witnessEncoded = RLP.encode(witness)
         if len(witnessEncoded) < 2 or len(witnessEncoded) > 100:
             return False
     return True
예제 #3
0
 def serialize(self):
     item = [
         self.host,
         self.version,
         self.lastVersionNonce,
         self.chainHeadBlockHash,
         self.lastUpdate
     ]
     return RLP.encode(item)
예제 #4
0
 def serialize(self, includeWitness=True):
     witnesses = []
     if includeWitness:
         for txIn in self.inputs:
             witnesses.append(txIn.witness)
     item = [
         self.version, self.gasLimit, self.gasPrice, self.inputs,
         self.outputs, witnesses
     ]
     return RLP.encode(item)
예제 #5
0
 def serialize(self):
     item = [
         self.type, self.version, self.timestamp, self.nonce,
         self.chainHeadBlockHash
     ]
     return RLP.encode(item)
예제 #6
0
 def serialize(self):
     item = [self.type, self.version, self.blockHashes]
     return RLP.encode(item)
예제 #7
0
 def serialize(self):
     item = [self.address, self.script, self.value, self.extraData]
     return RLP.encode(item)
예제 #8
0
 def serialize(self):
     inventory = []
     for inv in self.inventory:
         inventory.append(inv.serialize())
     item = [self.type, inventory]
     return RLP.encode(item)
예제 #9
0
 def serialize(self):
     item = [self.txId, self.outputIndex]
     return RLP.encode(item)
예제 #10
0
 def serialize(self):
     item = [self.type, self.addrList]
     return RLP.encode(item)
예제 #11
0
 def serialize(self):
     item = [self.invType, self.invHash]
     return RLP.encode(item)
예제 #12
0
def remove(key, readOnly):
    if readOnly:
        if key in PersistentStorage.storage:
            PersistentStorage.storage.pop(key)
    else:
        PersistentStorage.persistent.remove(RLP.encode(key))
예제 #13
0
def add(key, value, readOnly):
    if readOnly:
        PersistentStorage.storage[key] = value
    else:
        PersistentStorage.persistent.set(RLP.encode(key), RLP.encode(value))
예제 #14
0
 def serialize(self):
     item = [
         self.type,
         self.transaction,
     ]
     return RLP.encode(item)
예제 #15
0
 def serializeHeader(self):
     header = self.getHeader()
     return RLP.encode(header)
예제 #16
0
 def serialize(self):
     item = [self.chainWork, self.previousHash, self.gasLimit, self.height]
     return RLP.encode(item)
예제 #17
0
 def serialize(self):
     item = self.getHeader()
     item.append(self.getBody())
     return RLP.encode(item)
예제 #18
0
 def serialize(self):
     item = [self.type]
     return RLP.encode(item)
예제 #19
0
 def serialize(self):
     item = [self.outpoint]
     return RLP.encode(item)
예제 #20
0
 def serialize(self):
     item = [self.output, self.txOutputSize, self.height, self.coinbase]
     return RLP.encode(item)
예제 #21
0
 def serialize(self):
     item = [
         self.type,
         self.block,
     ]
     return RLP.encode(item)