feat: Start working on name indexing

This commit is contained in:
2025-02-09 21:33:20 +11:00
parent e30ced94c3
commit f807caee52
2 changed files with 52 additions and 9 deletions

View File

@@ -279,8 +279,21 @@ class Bid:
self.tx: Transaction = tx
self.bidHash = covenant.hash
self.bid = covenant
self.reveal = None
self.redeem = None
self.value = 0
self.blind = 0
self.txs = [tx.hash]
# TODO add blind calculation
def update(self, covenant: Covenant, tx: Transaction):
if covenant.type == 4: # REVEAL
self.reveal = covenant
self.txs.append(tx.hash)
# TODO add true bid calculation
# TODO add redeem/register covenants
@@ -335,6 +348,7 @@ class Name:
def update(self, covenant: Covenant, tx: Transaction):
self.txs.append(tx.hash)
if covenant.type == 0: # NONE
return
if covenant.type == 1: # CLAIM
@@ -342,12 +356,40 @@ class Name:
self.claimed += 1
if covenant.type == 2: # OPEN
self.state = "OPEN"
if self.height == 0:
self.height = covenant.height
self.height = covenant.height
if covenant.type == 3: # BID
bid: Bid = Bid(covenant, tx)
print(covenant.toJSON())
self.bids.append(bid)
if covenant.type == 4: # REVEAL
# Get the index of the REVEAL in the outputs
index = 0
for output in tx.outputs:
if output.covenant.hash == covenant.hash:
break
index += 1
# Get input from index
tx_input = tx.inputs[index]
# TODO get matching bid
print(tx_input)
print(covenant)
print(tx)
print(self.bids)
raise NotImplementedError
if covenant.type == 7: # UPDATE
# TODO
raise NotImplementedError
if covenant.type in [6,8]: # REGISTER, RENEW
self.lastRenewal = covenant.height
self.registered = True
if covenant.type == 6: # REGISTER
# TODO
raise NotImplementedError
if covenant.type == 9: # TRANSFER
# TODO
raise NotImplementedError
if covenant.type == 10: # FINALIZE
# TODO
raise NotImplementedError
def toJSON(self) -> dict: